WordPress.org

Ready to get started?Download WordPress

Plugin Directory

!This plugin hasn't been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.

Meta SEO Pack

Fine tune your WordPress for SEO: rewrite title, add meta tags, canonical links and more. Out-of-the-box settings are a good starting point for blogs.

Integration manual for plugin developers

Filters usage in Meta SEO Pack

Meta SEO Pack internally calls many filters. Some of them are internal WordPress filters (some parts of plugin code bases on core WordPress code), but there is also a group of plugin-specific filters. You can use them to integrate your plugin with Meta SEO Pack. Full list of them you can find below.

Meta SEO Pack uses two kinds of filters to get metadata information (title, keywords, etc.): ones named msp_get_something and msp_something. The former ones are called when Meta SEO Pack does not support particular page type - you can use them to return metadata for custom page types generated by your plugin. The latter ones are called to do postprocessing of metadata. By default plugin registers three default WordPress filters (wptexturize, convert_chars and esc_html) to postprocess title, keywords and description values.

Filters for title rewriting

  • msp_get_title_format - filter called when Meta SEO Pack does not support some kind of pages internally. You can use it to return your title format (with %name% tags);
  • msp_get_title_data - filter called just after msp_get_title_format filter, to get array of values, which later are used to replace %name% tags in title. Note: keys in arrays should be added without percent (%) marks;
  • msp_title - postprocessing of title.

Filters for meta keywords

  • msp_get_keywords - filter called when Meta SEO Pack does not support some kind of pages internally. You can use it to return your meta keywords;
  • msp_keywords - postprocessing of meta keywords.

Filters for meta description

  • msp_get_description - filter called when Meta SEO Pack does not support some kind of pages internally. You can use it to return your meta description;
  • msp_description - postprocessing of meta description.

Filters for meta robots

  • msp_get_robots - filter called when Meta SEO Pack does not support some kind of pages internally. You can use it to return your meta robots;
  • msp_robots - postprocessing of meta robots.

Filters for canonical URL

  • msp_get_canonical - filter called when Meta SEO Pack does not support some kind of pages internally. You can use it to return your canonical URL;
  • msp_canonical - postprocessing of canonical URL.

Other functions

Meta SEO Pack exposes few functions too. You can use them in your plugin (or theme) too. Please use them instead of accessing class members and options directly - they may change in some version. On the other hand, functions listed here should not change.

  • msp_get_option - get value of selected Meta SEO Pack options. Functions returns option value, or false if option name is not supported. You can query values of following options:
    • rewrite_title - true if title rewriting is enabled;
    • add_keywords - true if meta keywords are enabled;
    • add_description - true if meta description is enabled;
    • add_robots - true if meta robots are enabled;
    • add_canonical - true if canonical URLs are enabled.

Examples

Integrate title generation

Meta SEO Pack calls wp_title() function, so you can use wp_title filter to provide your title. Of course you can also take advantage of Meta SEO Pack integration - here is the code:

// Check if Meta SEO Pack is present and title rewriting is enabled
if ( function_exists( 'msp_get_option' ) && msp_get_option( 'rewrite_title' ) ) {
    // Register filters for Meta SEO Pack
    add_filter( 'msp_get_title_format', 'my_title_format' );
    add_filter( 'msp_get_title_data', 'my_title_data' );
} else {
    // Register default WordPress filter
    add_filter( 'wp_title', 'my_title', 10, 3 );
}

// Return title format
function my_title_format( $format ) {
    if ( this_is_my_page() ) {
        $format = '%f1% | %f2% | %blog_name%';
    }
    return $format;
}

// Return parameters for title format
function my_title_data( $data ) {
    if ( this_is_my_page() ) {
        $data['f1'] = 'Value 1';
        $data['f2'] = 'Value 2';
    }
    return $data;
}

// Return title for wp_title() function
function wp_title( $title, $sep, $seplocation ) {
    if ( this_is_my_page() ) {
        if ( $seplocation == 'right' ) {
            $title = "Value 1 $sep Value 2 $sep ";
        } else {
            $title = " $sep Value 2 $sep Value 1";
        }
    }
    return $title;
}

Requires: 2.7 or higher
Compatible up to: 2.9.9
Last Updated: 2010-3-17
Downloads: 67,439

Ratings

4 stars
4.4 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1 100,2,2
100,1,1
67,3,2
100,3,3
0,1,0
100,1,1
100,1,1
100,2,2
100,1,1
100,4,4
100,4,4
100,2,2
100,1,1