I suggest you use the hooks & filters that do just this, available since version 3.5. This way you can create your own plugin in a separate directory that will not be overwritten when upgrading and still interacts with SLP. Enhanced Search is a small version of a plugin that does just this. Tagalong is a more extensive plugin that uses a lot of the tricks you will want to mimic. It should be out later this month.
https://www.charlestonsw.com/support/documentation/technical-documentation/store-locator-plus/add-on-packs-roll-your-own/
Store the data in a serialized named array in sl_option_value (a new field since 3.5) using the data filter and setting the sl_option_value similar to this:
// Manage Locations Interface
//
add_filter('slp_manage_location_columns',
array($this, 'add_categories_column')
);
add_filter('slp_column_data',
array($this, 'render_categories_column'),
90,
3
);
add_filter('slp_edit_location_right_column',
array($this,'location_edit_category')
);
add_filter('slp_update_location_data',
array($this,'location_update_data'),
90,
2
);
/**
* Attach our category data to the update string.
*
* Put it in the sl_option_value field as a seralized string.
*
* @param string $sqlSetStr - the original SQL set syntax
* @return string - the modified SQL set syntax
*/
function location_update_data($sqlSetStr,$locationID) {
if (isset($_POST['tax_input'])) {
$originalOptionArray = slp_deserialize_to_array($_POST['option_value-'.$locationID]);
$newOptionArray =
array_merge($originalOptionArray,
array(
'store_categories' => $_POST['tax_input']
)
);
}
$sqlSetStr = preg_replace("/, sl_option_value='(.*?)'/",'',$sqlSetStr);
return $sqlSetStr.", sl_option_value='".maybe_serialize($newOptionArray)."'" ;
}
/**
* Add the category editor/selector on the manage/edit location form.
*
* @param string $theForm - the original HTML form for the manage locations edit (right side)
* @return string - the modified HTML form
*/
function location_edit_category($theForm) {
ob_start();
wp_terms_checklist(
0,
array(
'checked_ontop' => false,
'taxonomy' => 'stores',
)
);
$checkList = ob_get_contents();
ob_end_clean();
$theForm .= '<div id="slp_tagalong_categories"><strong>Tagalong</strong>'.
$checkList .
'</div>';
return $theForm;
}
/**
* Add the categories column to the manage locations table.
*
* @param named array $currentCols - column name + column label for existing items
* @return named array - column name + column labels, extended with our categories data
*/
function add_categories_column($currentCols) {
return array_merge($currentCols,
array(
'sl_option_value' => __('Categories' ,SLPLUS_PREFIX)
)
);
}
/**
* 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 != '') {
$OptionArray = slp_deserialize_to_array($theData);
if (isset($OptionArray['store_categories']['stores'])){
$theData = '';
foreach ($OptionArray['store_categories']['stores'] as $optVal) {
$theCat = get_term($optVal,'stores');
$tagalongData = get_option(SLPLUS_PREFIX.'-TAGALONG-category_'.$theCat->term_id);
$theData .= '<div class="tagalong_entry">'.$theCat->name;
if (isset($tagalongData['map-marker']) && ($tagalongData['map-marker']!='')) {
$theData .=
'<img src="'.$tagalongData['map-marker'].'" '.
'id="slp_map_marker_'.$theCat->slug.'" '.
'class="slp_map_marker" '.
'alt="'.$theCat->slug.'" '.
'title="'.$theCat->slug.'"/>'
;
}
$theData .= '</div>';
//$theData .= '<pre>'.print_r($theCat,true).'</pre>';
//$theData .= '<pre>'.print_r($tagalongData,true).'</pre>';
}
}
}
}
return $theData;
}