The following action hooks and filters are related to location management.
slp_action_box_3_content
Type: Filter Parameters: string - the manage location screen action box #3 HTML string
Add or change the 3rd action box on the manage locations action bar.
slp_action_boxes
Type: Filter Parameters: An array of arrays. Each sub-array contains the HTML for a specified action box on the Manage Locations page.
The top of the manage locations page has an action and filter bar that consists of a series of side-by-side boxes. Each box can have action buttons or filter parameters that are execute in various ways on the manage locations form.
Each action box is represented by an array of arrays. The outer array is simply a key name that represents each box in alphabetic fashion. Box “A” is the furthest left.

Action and filter boxes can be added at any point, or existing boxes removed, by manipulating this array of arrays.
SLP 3.8.3 Code
// Basic Delete Icon
//
$actionBoxes['A'][] =
'
' .
'<a class="like-a-button" onclick="doAction(\'delete\',\''.__('Delete selected?',SLPLUS_PREFIX).'\');" href="#" name="delete_selected">'.__("Delete Selected", SLPLUS_PREFIX).
'</a>'.
'
'
;
// Loop through the action boxes content array
//
$actionBoxes = apply_filters('slp_action_boxes',$actionBoxes);
Pro Pack Example
function __construct() {
add_filter('slp_action_boxes',array($this,'manage_locations_actionbar'));
}
/**
* Add the create pages button to box "C" on the action bar
*
* @param array $actionBoxes - the existing action boxes, 'A'.. each named array element is an array of HTML strings
* @return string
*/
function manage_locations_actionbar($actionBoxes) {
if (!$this->setPlugin()) { return $actionBoxes; }
$actionBoxes['A'][] =
'
' .
'<a class="like-a-button" onclick="doAction(\'recode\',\''.__('Recode selected?',SLPLUS_PREFIX).'\');" href="#" name="recode_selected">'.__("Recode Selected", SLPLUS_PREFIX).
'</a>' .
'
'
;
$actionBoxes ['B'][] =
'</pre>
<div id="tag_actions">' .
'<a class="like-a-button" onclick="doAction(\'add_tag\',\''.__('Tag selected?',SLPLUS_PREFIX).'\');" href="#" name="tag_selected">'.
__('Tag Selected', SLPLUS_PREFIX).
'</a>'.
'<a class="like-a-button" onclick="doAction(\'remove_tag\',\''. __('Remove tag from selected?',SLPLUS_PREFIX).'\');" href="#" name="untag_selected">'.
__('Untag Selected', SLPLUS_PREFIX).
'</a>'.
'</div>
<pre>' .
'</pre>
<div id="tagentry">'.
'<label for="sl_tags">'.__('Tags', SLPLUS_PREFIX).'</label><input type="text" name="sl_tags" />'.
'</div>
<pre>'
;
return $actionBoxes;
}
Store Pages Example
function __construct() {
add_filter('slp_action_boxes',array($this,'manage_locations_actionbar'));
}
/**
* Add Pro Pack action buttons to the action bar
*
* @param array $actionBoxes - the existing action boxes, 'A'.. each named array element is an array of HTML strings
* @return string
*/
function manage_locations_actionbar($actionBoxes) {
if (!$this->setPlugin()) { return $actionBoxes; }
$actionBoxes['C'][] =
'
' .
"<a class="like-a-button" onclick="\"doAction('createpage','"" href="#" name="createpage_selected">" .
__('Create Pages', SLPLUS_PREFIX) .
'</a>' .
'
'
;
return $actionBoxes;
}
slp_add_location_form_footer
Type: filter
Params:
[0] - HTML for the additional add location form, default is blank.
Used to add HTML content with the add location form.
slp_addlocation_fieldvalue
Type: filter Default Priority: 10 Parameters: [0] – the current field value to initialize the input to (blank) [1] – the field name Available in Store Locator Plus version 3.9This filter is applied when a field is rendered for input for the add locations form. It defaults to blank. Configure your slp_addlocation_fieldvalue filter to accept TWO parameters so you can get your field name and set a different value for every form field.
slp_addlocations_with_csv
Type: action Default Priority: 10 Parameters: noneRuns whenever the add locations processor gets a CSV file input.
slp_column_data
Parameters:
the column data as a string
the name of the database field
the name of the column label
Default Priority: 10
Use this filter to tweak the data that is output on the manage locations screen.
The filter is passed three parameters representing the data that is about to be displayed, the name of the database field from which the data was obtained, and the column label. You can use these 3 elements to manipulate the data that is to be rendered.
Typically used in conjunction with the manage_location_columns filter to render new column data.
Example
This example prints out the sl_options_value contents in a formatted string, this will need further refinement for production output..
class SLPTagalong {
function __construct() {
add_filter('slp_column_data',
array($this, 'render_categories_column'),
90,
3
);
}
/**
* Render the categories column in the view locations table.
*
* @param string $theData - the option_value field data from the database
* @param string $theField - the name of the field from the database (should be sl_option_value)
* @param string $theLabel - the column label for this column (should be 'Categories')
* @return type
*/
function render_categories_column($theData,$theField,$theLabel) {
if (
($theField === 'sl_option_value') &&
($theLabel === __('Categories' ,SLPLUS_PREFIX))
) {
// No Category selected
//
if ($theData != '') {
$theData = "<pre>SL Option Value:<br/>
" . print_r($theData,true) . "</pre>";
}
}
return $theData;
}
}
slp_deletelocation_starting
Type: action
Parameters:
[0] - an array of strings that represent the integer location id to be deleted
This hook is fired when a location, or group of locations, is about to be deleted from the Store Locator Plus locations database.
slp_edit_location_data
Type: Filter Default Priority: 10 Parameters: [0] – mixed array[] $locationData – the named array representing the location data about to be edited Return: A modified $locationData array.Used to manipulate the incoming form data prior to an edit taking place. Very useful to extracting data from a serialized data string in the sl_option_value field and breaking into its parts prior to rendering the edit form.
slp_edit_location_left_column
Type: Filter Default Priority: 10 Return: An HTML string for the complete left column of the edit location form.
Extends, modifies, or replaces the edit form that is presented on the Manage Locations page when “edit locations” is selected. The form has a left and right column within a table cell. This filter receives a single parameter which represents the HTML content of the left or right table cell, depending on which filter is being hooked. The content can be modified accordingly before it is rendered in the browser window.
Example
// Search Functionality Hook
//
add_filter('slp_edit_location_right_column',
array('SLPTagalong','extend_edit_fields'),
90
);
class SLPTagalong {
function extend_edit_fields($html) {
return $html . 'New Field: <input type="text" name="slp_new_field" value="">';
}
}
slp_edit_location_right_column
Type: FilterDefault Priority: 10
Return: An HTML string for the complete right column of the edit location form.
Extends, modifies, or replaces the edit form that is presented on the Manage Locations page when “edit locations” is selected. The form has a left and right column within a table cell. This filter receives a single parameter which represents the HTML content of the left or right table cell, depending on which filter is being hooked. The content can be modified accordingly before it is rendered in the browser window.
Example
// Search Functionality Hook
//
add_filter('slp_edit_location_right_column',
array('SLPTagalong','extend_edit_fields'),
90
);
class SLPTagalong {
function extend_edit_fields($html) {
return $html . 'New Field: <input type="text" name="slp_new_field" value="" />';
}
}
slp_location_page_attributes
Type: Filter Default Priority: 10 Parameters: [0] – mixed[] $slpNewListing – a named array with custom post type attributes Return: A valid custom post type attributeModifies the store_page custom post type when it is created via the built-in SLP Admin UI getorcreate_PageID method.
Code Implementation v3.9.2
// Create a blank draft page for this location to store meta
//
$slpNewListing = array(
'ID' => '',
'post_type' => 'store_page',
'post_status' => 'draft',
'post_title' => $this->get_CurrentLocationVal('sl_store'),
'post_content' => ''
);
$slpNewListing = apply_filters('slp_location_page_attributes',$slpNewListing);
slp_location_updated
Type: Action Parameters: [0] Location ID [1] SQL string representing the update clauseThis action hook fires after the WordPress DB query is run to update the location data.
Code Implementation (v3.8.19)
$wpdb->query("UPDATE ".$wpdb->prefix."store_locator SET $field_value_str WHERE sl_id={$_REQUEST['locationID']}");
do_action('slp_location_updated',$_REQUEST['locationID'], $field_value_str);
slp_location_added
Type: Action Parameters: [0] insert ID of most recently added recordThis action hook fires after the WordPress DB query is run to insert new location data.
Code Implementation (v3.8.19)
$wpdb->query("INSERT into ". $wpdb->prefix . "store_locator ($fields) VALUES ($sl_values);");
do_action('slp_location_added',$wpdb->insert_id());
slp_locationinfoform
Type: Filter Parameters: string - the location form used on manage locations page
Use this to manipulate the location information form used to edit the location data.
slp_manage_expanded_location_columns
Type: Filter Parameters: [0] named array, key is field name, value is column label Default Priority: 10Use this filter to add columns to the Manage Locations table in expanded view only, at the end of the expanded view but before the slp_manage_location_columns is executed. See slp_manage_location_columns for examples.
slp_manage_location_columns
Type: Filter Parameters: [0] named array, key is field name, value is column label Default Priority: 10Use this filter to add columns to the Manage Locations table. The filter is passed a single parameter which is a named array that represents the existing columns. The key is the name of the Store Locator Plus field in the locations table. The value is the label to render on the top of the column.
Example
This example adds the “category ID” column to the table, which has been added to the locations table during an activation hook.
class SLPTagalong {
function __construct() {
add_filter(
'slp_manage_location_columns',
array($this,'add_catid_column'),
90
);
}
function add_catid_column($theColumns) {
return array_merge(
$theColumns,
array(
'category_id' => 'Category #'
)
);
}
}
slp_manage_priority_location_columns
Type: Filter Parameters: [0] named array, key is field name, value is column label Default Priority: 10Use this filter to add columns to the Manage Locations table in normal and expended view in a priority position, immediately after the country column output. See slp_manage_location_columns for examples.
slp_manage_locations_action
Type: Action Parameters: noneProcesses a form action from the manage locations page. Runs after the built-in SLP actions have run. Replaces the defunct “slp_managelocations_action”.
Code Implementation (v3.9)
if ($_REQUEST['act']) {
do_action('slp_manage_locations_action');
}
Example
<span style="font-size: 12px; line-height: 18px;">// Manage Locations : categorize locations in bulk // add_action('slp_managelocations_action', array($this,'categorize_locations') );</span>
/**
* Perform the manage locations action for bulk categorization.
*/
function categorize_locations() {
foreach ($_REQUEST['sl_id'] as $location) {
$this->setLocationCategory($location, $_REQUEST['tax_input']['stores']);
}
}
slp_add_manage_locations_action_box
Type: Action Default Priority: 10 Category: Admin Panel
Any output that is rendered goes inside the Location Actions and Filters div on the manage locations interface. To match the current (SLP v3.4) style you should render your output with the following div definitions.
slp_manage_locations_actionbuttons
Type: Filter
Default Priority: 10
Parameters:
[0] - the existing action buttons HTML
[1] - the current location record values in a named array
Return: An the complete action buttons HTML string
Extends, modifies, or replaces the action buttons on a per-location basis.
Code Implementation (v3.9)
$actionButtonsHTML = apply_filters('slp_manage_locations_actionbuttons',$actionButtonsHTML, $sl_value);
Example
add_filter(*'slp_manage_locations_actionbuttons',array($this,'add_manage_locations_actionbuttons),15,2);
/**
* Add a location action button.
*
* @param string $theHTML - the HTML of the original buttons in place
* @param array $locationValues
* @return string - the augmented HTML
*/
function add_manage_locations_actionbuttons($theHTML,$locationValues) {
if (!$this->setPlugin()) { return 'a' . $theHTML; }
if (!isset($locationValues['sl_id'])) { return 'c' . $theHTML; }
if ($locationValues['sl_id'] < 0) { return 'b' . $theHTML; }
// Set the URL
//
$shortSPurl = preg_replace('/^.*?store_page=/','',$locationValues['sl_pages_url']);
$locationValues['sl_pages_url'] = "<a href="$locationValues[sl_pages_url]" target="cybersprocket">$shortSPurl</a>";
$pageClass = (($locationValues['sl_linked_postid']>0)?'haspage_icon' : 'createpage_icon');
$pageURL = preg_replace(
'/&createpage=/'.(isset($_GET['createpage'])?$_GET['createpage']:''),
'',
$_SERVER['REQUEST_URI']
).
'&act=createpage'.
'&sl_id='.$locationValues['sl_id'].
'&slp_pageid='.$locationValues['sl_linked_postid'].
'#a'.$locationValues['sl_id']
;
return $theHTML .
""
;
}
