Store Pages Hooks & Filters

The following action hooks and filters are related to store pages management.   The custom store pages page type exists “under the covers” of SLP.   Direct access to edit/create the pages via the admin UI is enabled with the Store Pages premium add-on.

slp_pages_content

Type: Filter
Default Priority: 10
Parameters:
     [0] – the HTML string representing the content
Return: the modified/augmented HTML string to create the page.
Available in Store Pages version 3.9

The incoming parameter is the HTML for the current Store Page with the default HTML rendering.

This hook is useful for augmenting or completely taking over the default Store Page format that is rendered when “Create Page” is clicked.

Code Implementation (Store Pages v3.9)

</p>
<p style="padding-left: 30px;">         function CreatePageContent($store) {
$content = '';

// Default Content
//
$content .= "<span class='storename'>".$store['sl_store']."</span>\n";
if ($store['sl_image']         !='') {
$content .= '<img title="'.$store['sl_store'].'" src="'.$store['sl_image'].'"/>'."\n";
}
if ($store['sl_address']       !='') { $content .= $store['sl_address'] . "\n"; }
if ($store['sl_address2']      !='') { $content .= $store['sl_address2'] . "\n"; }

if ($store['sl_city']          !='') {
$content .= $store['sl_city'];
if ($store['sl_state'] !='') { $content .= ', '; }
}
if ($store['sl_state']         !='') { $content .= $store['sl_state']; }
if ($store['sl_zip']           !='') { $content .= " ".$store['sl_zip']."\n"; }
if ($store['sl_country']       !='') { $content .= " ".$store['sl_country']."\n"; }
if ($store['sl_description']   !='') { $content .= "<h1>Description</h1>\n<p>". html_entity_decode($store['sl_description']) ."</p>\n"; }

$slpContactInfo = '';
if ($store['sl_phone'] !='') { $slpContactInfo .= __('Phone: ',SLPLUS_PREFIX).$store['sl_phone'] . "\n"; }
if ($store['sl_fax'] !='') { $slpContactInfo .= __('Fax: ',SLPLUS_PREFIX).$store['sl_fax'] . "\n"; }
if ($store['sl_email'] !='') { $slpContactInfo .= '<a href="mailto:'.$store['sl_email'].'">'.$store['sl_email']."</a>\n"; }
if ($store['sl_url']   !='') { $slpContactInfo .= '<a href="'.$store['sl_url'].'">'.$store['sl_url']."</a>\n"; }
if ($slpContactInfo    != '') {
$content .= "<h1>Contact Info</h1>\n<p>".$slpContactInfo."</p>\n";
}

return apply_filters('slp_pages_content',$content);
}</p>
<p style="padding-left: 30px;">

slp_pages_default_content

Type: Filter
Default Priority: 10
Parameters:
     [0] – the HTML string representing the default content
Return: the modified/augmented HTML string to be the default page content.
Available in Store Pages version 3.9

The incoming parameter is the HTML for the default Store Page content with the default HTML rendering.

This hook is useful for augmenting or completely taking over the default Store Page format that is used to be the default page content for the create page functions.  This is what the custom field “page template” will be set to when you click the reset button.

Code Implementation (Store Pages v3.9)

function create_DefaultPageTemplate() {
$content =
'<span>[storepage field="sl_store"]</span>'                           ."\n".
'<img title="[storepage field="sl_store"]" '               .
'src="[storepage field="sl_image"]"'                                                .
'/>'                                                                                   ."\n".
'[storepage field="sl_address"]'                                                        ."\n".
'[storepage field="sl_address2"]'                                                       ."\n".
'[storepage field="sl_city"] [storepage field="sl_state"] [storepage field="sl_zip"] '  ."\n".
'[storepage field="sl_country"]'                                                        ."\n".
'<h1>Description</h1>'                                                                  ."\n".
'<p>[storepage field="sl_description"]</p>'                                             ."\n".
'<h1>Contact Info</h1>'                                                                 ."\n".
'Phone: [storepage field="sl_phone"]'                                                   ."\n".
'Fax: [storepage field="sl_fax"]'                                                       ."\n".
'<a href="mailto:[storepage field="sl_email"]">[storepage field="sl_email"]</a>'        ."\n".
'<a href="[storepage field="sl_url"]">[storepage field="sl_sl_url"]</a>'                ."\n"
;

return apply_filters('slp_pages_default_content',$content);
}

slp_storepage_attributes

Type: Filter
Default Priority: 10
Parameters:
    [0] – array of page attributes (see http://codex.wordpress.org/Function_Reference/register_post_type)
Return: the modified/augmented labels array
Available in SLP version 3.9

Extends, modifies, or replaces the Store Pages page type attributes array.

Code Implementation (v3.9)

$storepage_attributes(
'slp_storepage_attributes',
array(
'labels'            => $storepage_labels,
'public'            => true,
'has_archive'       => true,
'description'       => __('Store Locator Plus location pages.','csa-slplus'),
'menu_postion'      => 20,
'menu_icon'         => SLPLUS_COREURL . 'images/icon_from_jpg_16x16.png',
'show_in_menu'      => current_user_can('manage_slp'),
'capability_type'   => 'page',
'supports'          => $storepage_features,
)
);

// Register Store Pages Custom Type
register_post_type( 'store_page',$storepage_attributes);

slp_storepage_features

Type: Filter
Default Priority: 10
Parameters:
    [0] – array of page features (see http://codex.wordpress.org/Function_Reference/register_post_type)
Return: the modified/augmented labels array
Available in SLP version 3.9

Extends, modifies, or replaces the Store Pages page type features array.

Code Implementation (v3.9)

$storepage_features =
apply_filters(
'slp_storepage_features',
array(
'title',
'editor',
'author',
'excerpt',
'trackback',
'thumbnail',
'comments',
'revisions',
'custom-fields',
'page-attributes',
'post-formats'
)
);

// Register Store Pages Custom Type
register_post_type( 'store_page',
array(
'labels'            => $storepage_labels,
'public'            => true,
'has_archive'       => true,
'description'       => __('Store Locator Plus location pages.','csa-slplus'),
'menu_postion'      => 20,
'menu_icon'         => SLPLUS_COREURL . 'images/icon_from_jpg_16x16.png',
'show_in_menu'      => current_user_can('manage_slp'),
'capability_type'   => 'page',
'supports'          => $storepage_features,
)
);

slp_storepage_labels

Type: Filter
Default Priority: 10
Parameters:
[0] – named array of label identifiers and text strings (see http://codex.wordpress.org/Function_Reference/register_taxonomy)
Return: the modified/augmented labels array
Available in SLP version 3.9

Extends, modifies, or replaces the Store Pages label array.

Code Implementation (v3.9)

// Store Page Labels
//
$storepage_labels =
apply_filters(
'slp_storepage_labels',
array(
'name'              => __( 'Store Pages','csa-slplus' ),
'singular_name'     => __( 'Store Page', 'csa-slplus' ),
'add_new'           => __('Add New Store Page', 'csa-slplus'),
)
);

// Register Store Pages Custom Type
register_post_type( 'store_page',
array(
'labels'            => $storepage_labels,
'public'            => true,
'has_archive'       => true,
'description'       => __('Store Locator Plus location pages.','csa-slplus'),
'menu_postion'      => 20,
'menu_icon'         => SLPLUS_COREURL . 'images/icon_from_jpg_16x16.png',
'show_in_menu'      => current_user_can('manage_slp'),
'capability_type'   => 'page',
'supports'          =>
array(
'title',
'editor',
'author',
'excerpt',
'trackback',
'thumbnail',
'comments',
'revisions',
'custom-fields',
'page-attributes',
'post-formats'
),
)
);