Plugin Directory

Changeset 1271160


Ignore:
Timestamp:
10/22/2015 03:02:53 PM (10 years ago)
Author:
GregMulhauser
Message:

obligatory message

Location:
gregs-high-performance-seo
Files:
7 edited
24 copied

Legend:

Unmodified
Added
Removed
  • gregs-high-performance-seo/tags/1.7/ghpseo-sledgehammer-mode.php

    r1106149 r1271160  
    3535    // replace the title, strip old head meta (if they exist), and add our own
    3636    $header = preg_replace( '/<title>([\w\W]*?)<\/title>/', '<title>' . $ghpseo->select_title( true, false ) . '</title>', $header );
    37     $header = preg_replace( "/<link rel ?= ?[\"']canonical[\"'] href ?= ?[\"']([\w\W]*?)[\"'] \/>/i", '', $header );
     37    $header = preg_replace( "/<link rel ?= ?[\"']canonical[\"'] href ?= ?[\"']([\w\W]*?)[\"'] ?\/>/i", '', $header );
    3838    $header = str_replace( '</title>', "</title>" . $ghpseo->canonical(), $header );
    3939    $replacements = array( 'description' => 'head_desc',
     
    4242    );
    4343    foreach ( $replacements as $tag=>$value ) {
    44         $header = preg_replace( "/<meta name ?= ?[\"']{$tag}[\"'] content ?= ?[\"']([\w\W]*?)[\"'] \/>/i", '', $header );
     44        $header = preg_replace( "/<meta name ?= ?[\"']{$tag}[\"'] content ?= ?[\"']([\w\W]*?)[\"'] ?\/>/i", '', $header );
    4545        $header = str_replace( '</title>', "</title>" . $ghpseo->$value(), $header );
    4646    } // end loop over replacements
  • gregs-high-performance-seo/tags/1.7/ghpseo.php

    r1151682 r1271160  
    44Plugin URI: http://gregsplugins.com/lib/plugin-details/gregs-high-performance-seo/
    55Description: Configure over 100 separate on-page SEO characteristics. Fewer than 700 lines of code per page view. No junk: just high performance SEO at its best.
    6 Version: 1.6.4
     6Version: 1.7
    77Author: Greg Mulhauser
    88Author URI: http://gregsplugins.com/
     
    2929class gregsHighPerformanceSEO {
    3030
    31     var $plugin_prefix;        // prefix for option names and post meta tables
    32     var $consolidate;          // whether we'll be consolidating our options into single array, or keeping discrete
     31    // identifying ourselves
     32    private $plugin_prefix;
     33
     34    // whether we'll be consolidating our options into single array, or keeping discrete
     35    private $consolidate;
     36
     37    // flag to suspend filtering of pre_get_document_title when it's our own request
     38    private $now_requesting_wp_title = false;
    3339
    3440    function __construct( $plugin_prefix='', $option_style='' ) {
     
    3844        // set up to enable dupe content handling, head description and keywords, and robots
    3945        add_filter( 'the_content', array( $this, 'paged_comments_dupefix' ), $this->opt( 'comment_page_replacement_level' ) );
     46        // tap into pre_get_document_title to enable efficient delivery of modified titles
     47        add_filter( 'pre_get_document_title', array( $this, 'tweak_wp_generated_titles'), 1, 1 );
    4048        add_action( 'wp_head', array( $this, 'head_desc' ), 2 );
    4149        add_action( 'wp_head', array( $this, 'head_keywords' ), 3 );
     
    96104        return ucfirst( join( " ", $newwords ) ); // ucfirst again in case first word was in the exception list
    97105    } // end titlecase
     106
     107    /**
     108     * We'll hook this into pre_get_document_title to provide modified titles efficiently.
     109     * @param  string $title Title passed in
     110     * @return string        Modified title, or original if we shouldn't mess with it
     111     */
     112    function tweak_wp_generated_titles( $title = '' ) {
     113        // just to be safe, if anyone else is messing with the title, don't interfere
     114        if ( !empty( $title ) )
     115            return $title;
     116        // and if this is our own request to wp_get_document_title, don't mess with it
     117        if ( $this->now_requesting_wp_title )
     118            return $title;
     119        return $this->select_title( true, false );
     120    }
     121
     122    /**
     123     * Provide a fallback for versions of WP (<4.4) before wp_title was deprecated.
     124     * @param  string  $sep         Legacy wp_title separator
     125     * @param  string  $seplocation Legacy wp_title direction to display title
     126     * @return string               Title, either from wp_title or from wp_get_document_title
     127     */
     128    function wp_title_fallback( $sep = '&raquo;', $seplocation = '' ) {
     129        if (function_exists('wp_get_document_title')) {
     130            $this->now_requesting_wp_title = true;
     131            $title = wp_get_document_title();
     132            $this->now_requesting_wp_title = false;         
     133            return $title;
     134        }
     135        /* we'll always return, never display; therefore, $display always passed as false */
     136        return wp_title( $sep, false, $seplocation );
     137    }
    98138
    99139    function id_to_check( $type = false ) { // detect special case where WP's static front page options mess up the ID we need to check for titles, descriptions, etc.
     
    215255            "frontispaged" => array ( 'home_paged', '' ),
    216256            "homestaticfront" => array ( 'home_static_front', array( "%page_title%" => single_post_title( '', false ), "%page_title_custom%" => $secondary ) ),
    217             "homestaticposts" => array ( 'home_static_posts', array( "%page_title%" => ltrim( wp_title( '', false ) ), "%page_title_custom%" => $secondary ) ),
     257            "homestaticposts" => array ( 'home_static_posts', array( "%page_title%" => ltrim( get_bloginfo( 'name' ) ), "%page_title_custom%" => $secondary ) ),
    218258            "home" => array ( 'home', '' ),
    219259            "single" => array ( 'post', array( "%post_title%" => single_post_title( '', false ), "%post_title_custom%" => $secondary, "%category_title%" => $cat_of_post ) ),
     
    222262            "search" => array ( 'search', array( "%search_terms%" => strip_tags( stripslashes( get_search_query() ) ) ) ),
    223263            "category" => array ( 'category', array( "%category_title%" => $this->titlecase( single_cat_title( '', false ) ), "%category_desc%"=>$cat_desc ) ),
    224             "page" => array ( 'page', array( "%page_title%" => ltrim( wp_title( '', false ) ), "%page_title_custom%" => $secondary ) ),
     264            "page" => array ( 'page', array( "%page_title%" => ltrim( single_post_title( '', false ) ), "%page_title_custom%" => $secondary ) ),
    225265            "year" => array ( 'year_archive', array( "%year%" => get_the_time( 'Y' ) ) ),
    226266            "month" => array ( 'month_archive', array( "%month%" => get_the_time( 'F, Y' ) ) ),
     
    350390            $title = str_replace( '%comment_page%', get_query_var( 'cpage' ), $title );
    351391        } // end handling comment pages
    352         else $title = ltrim( wp_title( '', false ) );
     392        else $title = ltrim( single_post_title( '', false ) );
    353393        return $title; // output will still need texturizing, but that's OK
    354394    } // end getting comment page title
    355395
    356     function select_title( $main=true, $echo=true ) { // root function for titles calls on other functions to produce the title, depending on type of page; $main controls whether to return main or secondary title
     396    // root function for titles calls on other functions to produce the title, depending on type of page; $main controls whether to return main or secondary title
     397    function select_title( $main = true, $echo = true ) {
    357398        global $post;
    358399        if ( is_single() || is_page() )
     
    367408    } // end select title
    368409
    369     function get_other_titles( $main=false ) { // get titles for other than paged comments; $main controls whether to return main or secondary title
     410    // get titles for other than paged comments; $main controls whether to return main or secondary title
     411    function get_other_titles( $main = false ) {
    370412        global $wp_query, $post;
     413
     414        // provide fallback if main requested but main title mods are switched off
     415        if ($main && !$this->opt('enable_main_title_modifications'))
     416            return $this->wp_title_fallback();
     417        // or if secondary requested and both main and secondary mods switched off
     418        if (!$main && !$this->opt('enable_main_title_modifications') && !$this->opt('enable_secondary_titles'))
     419            return $this->wp_title_fallback();
     420
    371421        $suffix = ( $main || !( $this->opt( 'enable_secondary_titles' ) ) ) ? '_title' : '_title_secondary';
    372422
     
    381431            if ( is_array( $titleswaps[$key]['1'] ) ) $swap = array_merge( $swap, $titleswaps[$key]['1'] );
    382432        }
    383         else $title = wp_title( '| ', false, 'right' ) . get_bloginfo( 'name' ); // if it was none of these, just get the usual
     433        else $title = get_bloginfo( 'name' ); // if it was none of these, just get the usual
    384434
    385435        if ( ( ( $key == 'single' ) || ( $key == 'page' ) ) && ( $main && $this->opt( 'legacy_title_invert' ) && $this->opt( 'enable_secondary_titles_legacy' ) ) ) { // handle legacy titles as main titles
     
    387437        } // end handling screwy legacy titles as main titles
    388438
    389         if ( $title == '' ) $title = ltrim( wp_title( '', false ) );
     439        if ( $title == '' ) $title = get_bloginfo( 'name' );
    390440        if ( is_paged() || $this->is_multipage() ) { // modify with something like a page number, if this is paged?
    391441            $modifier = $this->opt_clean( $titleswaps['paged']['0'] . $suffix ); // do some trickery to modify the title for paging
     
    399449    } // end getting other titles
    400450
    401     function paged_comments_dupefix( $content ) { // remove post content if we're on a paged comment page
     451    // remove post content if we're on a paged comment page
     452    function paged_comments_dupefix( $content ) {
    402453        if ( $this->get_comment_page() && $this->opt( 'paged_comments_dupefix' ) ) {
    403454            global $post;
     
    712763    function ghpseo_output( $type='main', $echo=true ) {
    713764        global $ghpseo;
     765        $result = '';
    714766        switch ( $type ) {
    715767        case "main": $result = $ghpseo->select_title( true, false ); break;
  • gregs-high-performance-seo/tags/1.7/options-set/ghpseo-options-instructions.ini

    r776305 r1271160  
    7272<p>Each of these template tags (i.e., <em>function calls</em>) can be used within theme files for single posts, pages, archives, etc. While they can appear either within the loop or outside the loop on individual posts and pages, they should be used only <em>outside the loop</em> on other types of pages. (Using them within the loop won't actually do any harm, but the plugin is designed to deliver output based upon what type of page is being viewed, rather than on the current state of the WordPress loop. This means, for example, that if you were to call for secondary titles of a sequence of posts using the WordPress loop, you would only get the secondary title for the page itself, repeated over and over, which is almost certainly not what you would have intended.)</p>
    7373
     74<p>As of version 4.4, WordPress added support for filtering its own internally generated title tags that were introduced more than a year earlier in version 4.1. On WordPress 4.4 and later, GHPSEO will automatically provide filtering of WordPress-generated title tags for themes which use them.</p>
     75
    7476<p>See the more detailed usage examples below for notes on safely wrapping these calls in conditionals.</p>
    7577
     
    8082<a name="obnoxious_mode" id="obnoxious_mode"></a><h4>'Sledgehammer Mode'</h4>
    8183
    82 <p>If you'd rather not draw on any of this plugin's template tags at all, you can still make use of its paged comment features and many of its <code>head meta</code> features. You can also still take full advantage of its main title functionality if you wish by enabling a special lower performance mode (also known as 'Sledgehammer Mode') via a setting on the main configuration page. This will cause Greg's High Performance SEO to behave like some other SEO plugins and force changes to the <code>head</code> section of your pages using a crude output buffering hack. By its very nature, this way of coding a WordPress plugin is fundamentally 'rude' and incompatible, in the sense that it tramples rough-shod over any modifications to the <code>head</code> section which might have been made by other plugins. It is not recommended. If Sledgehammer Mode output buffering conflicts with output buffering used by other plugins, you'll be on your own.</p>
     84<p>If you'd rather not draw on any of this plugin's template tags at all, you can still make use of its paged comment features and many of its <code>head meta</code> features. From WordPress 4.4 onwards, you can also make full use of the plugin's title modifications, provided that your theme supports the WordPress-generated title tags originally introduced in 4.1. If your theme does not support WordPress-generated title tags, or if you are using a version of WordPress prior to 4.4, you can also still take full advantage of its main title functionality if you wish by enabling a special lower performance mode (also known as 'Sledgehammer Mode') via a setting on the main configuration page. This will cause Greg's High Performance SEO to behave like some other SEO plugins and force changes to the <code>head</code> section of your pages using a crude output buffering hack. By its very nature, this way of coding a WordPress plugin is fundamentally 'rude' and incompatible, in the sense that it tramples rough-shod over any modifications to the <code>head</code> section which might have been made by other plugins. It is not recommended. If Sledgehammer Mode output buffering conflicts with output buffering used by other plugins, you'll be on your own.</p>
    8385
    8486<p>(The reason output buffering is ever used in this situation -- and the reason it qualifies as a 'hack', in my view -- is that WordPress does not offer plugins full access to the contents of the <code>head</code> section in the same way that it offers full access to, for example, the main post content. Plugins which circumvent this intentional, built-in limitation by using output buffering are essentially stepping outside the carefully designed flow of WordPress output assembly and placing themselves above the boundaries which normally protect one piece of code from trampling on another. In the 'Wild West' of multiple plugins attempting to apply their own output buffering without any way of establishing safe interactions with one another, any number of undesirable things can happen.)</p>
  • gregs-high-performance-seo/tags/1.7/options-set/ghpseo-options-maintitles.ini

    r217754 r1271160  
    11[section]
    22header[] = Enabling Main Title Modifications
    3 preface[] = "You can set a custom title structure for the main titles of each type of page. With the following box unchecked, the plugin will simply pass through the title returned by the built-in WordPress function <code>wp_title()</code>. Please see the 'Main Titles' section of the <em>Instructions</em> page for notes on implementing the <code>ghpseo_output('main_title')</code> template tag."
     3preface[] = "You can set a custom title structure for the main titles of each type of page. With the following box unchecked, the plugin will simply pass through the title returned by the built-in WordPress function <code>wp_get_document_title()</code> or, for versions of WordPress prior to 4.4, <code>wp_title()</code>. For WordPress 4.4 and later, if your theme supports automatic insertion of title tags by WordPress, this plugin will deliver its title modifications automatically. When using versions of WordPress prior to 4.4, or if your theme does not support WordPress title tag functionality, using modified titles requires either a template tag or 'Sledgehammer Mode'. Please see the 'Main Titles' section of the <em>Instructions</em> page for notes on implementing the <code>ghpseo_output('main_title')</code> template tag."
    44label[] = "Enable Main Title Modifications?"
    55type[] = checkbox,1
  • gregs-high-performance-seo/tags/1.7/options-set/ghpseo-options.ini

    r471952 r1271160  
    5252[section]
    5353header[] = "Sledgehammer Mode (Not Recommended)"
    54 preface[] = "Greg's High Performance SEO is designed for maximum performance and compatibility and can provide its full functionality <em>without</em> the wasteful use of output buffer hacks popularized by some other SEO plugins. However, due to the design of WordPress itself, the only ways to achieve direct access to certain parts of the <code>head</code> section of your pages are via calls from your theme files or via output buffer hacks. The simple theme updates are explained fully in the instructions and take no more than a couple of minutes to complete. However, if you would rather not add new template tags to your theme files, you can choose instead to enable the lower performance <em>Sledgehammer Mode</em>, in which case this plugin will use the same type of brute force output buffer hacks that other SEO plugins use to circumvent the design limitations of WordPress."
     54preface[] = "Primarily for versions of WordPress before 4.4... Greg's High Performance SEO is designed for maximum performance and compatibility and can provide its full functionality <em>without</em> the wasteful use of output buffer hacks popularized by some other SEO plugins. However, due to the design of WordPress itself prior to version 4.4, the only ways to achieve direct access to certain parts of the <code>head</code> section of your pages are via calls from your theme files or via output buffer hacks. The simple theme updates are explained fully in the instructions and take no more than a couple of minutes to complete. However, if you would rather not add new template tags to your theme files, you can choose instead to enable the lower performance <em>Sledgehammer Mode</em>, in which case this plugin will use the same type of brute force output buffer hacks that other SEO plugins use to circumvent the design limitations of WordPress."
    5555label[] = "Sledgehammer Mode?"
    5656type[] = checkbox,1
  • gregs-high-performance-seo/tags/1.7/readme.txt

    r1219865 r1271160  
    44Tags: seo, title, keywords, tags, meta, metadata, meta keywords, meta description, excerpt, paged comments, comments, duplicate content, head, canonical, google, noindex, nofollow, noodp, noydir, archives, title case, search engine optimization, WPMU, WordPress MU, WordPress Multiuser, greg mulhauser
    55Requires at least: 2.7
    6 Tested up to: 4.3
    7 Stable tag: 1.6.4
     6Tested up to: 4.4a
     7Stable tag: 1.7
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    1919= New in This Version =
    2020
    21 * Fix for default secondary title handling
     21* Added support for the wp_get_document_title() function introduced in WordPress 4.4; now that the title tag functionality first introduced in WordPress 4.1 can be filtered by plugins, GHPSEO will automatically work with themes that have enabled support for WordPress-generated title tags.
    2222
    2323= Introduction =
     
    135135== Upgrade Notice ==
    136136
    137 = 1.6.4, 2 May 2015 =
    138 * Fix for default secondary title handling
     137= 1.7, 22 October 2015 =
     138* Added support for the wp_get_document_title() function introduced in WordPress 4.4; now that the title tag functionality first introduced in WordPress 4.1 can be filtered by plugins, GHPSEO will automatically work with themes that have enabled support for WordPress-generated title tags.
    139139
    140140== Changelog ==
     141
     142= 1.7, 22 October 2015 =
     143* Added support for the wp_get_document_title() function introduced in WordPress 4.4; now that the title tag functionality first introduced in WordPress 4.1 can be filtered by plugins, GHPSEO will automatically work with themes that have enabled support for WordPress-generated title tags.
    141144
    142145= 1.6.4, 2 May 2015 =
  • gregs-high-performance-seo/trunk/ghpseo-sledgehammer-mode.php

    r1106149 r1271160  
    3535    // replace the title, strip old head meta (if they exist), and add our own
    3636    $header = preg_replace( '/<title>([\w\W]*?)<\/title>/', '<title>' . $ghpseo->select_title( true, false ) . '</title>', $header );
    37     $header = preg_replace( "/<link rel ?= ?[\"']canonical[\"'] href ?= ?[\"']([\w\W]*?)[\"'] \/>/i", '', $header );
     37    $header = preg_replace( "/<link rel ?= ?[\"']canonical[\"'] href ?= ?[\"']([\w\W]*?)[\"'] ?\/>/i", '', $header );
    3838    $header = str_replace( '</title>', "</title>" . $ghpseo->canonical(), $header );
    3939    $replacements = array( 'description' => 'head_desc',
     
    4242    );
    4343    foreach ( $replacements as $tag=>$value ) {
    44         $header = preg_replace( "/<meta name ?= ?[\"']{$tag}[\"'] content ?= ?[\"']([\w\W]*?)[\"'] \/>/i", '', $header );
     44        $header = preg_replace( "/<meta name ?= ?[\"']{$tag}[\"'] content ?= ?[\"']([\w\W]*?)[\"'] ?\/>/i", '', $header );
    4545        $header = str_replace( '</title>', "</title>" . $ghpseo->$value(), $header );
    4646    } // end loop over replacements
  • gregs-high-performance-seo/trunk/ghpseo.php

    r1151682 r1271160  
    44Plugin URI: http://gregsplugins.com/lib/plugin-details/gregs-high-performance-seo/
    55Description: Configure over 100 separate on-page SEO characteristics. Fewer than 700 lines of code per page view. No junk: just high performance SEO at its best.
    6 Version: 1.6.4
     6Version: 1.7
    77Author: Greg Mulhauser
    88Author URI: http://gregsplugins.com/
     
    2929class gregsHighPerformanceSEO {
    3030
    31     var $plugin_prefix;        // prefix for option names and post meta tables
    32     var $consolidate;          // whether we'll be consolidating our options into single array, or keeping discrete
     31    // identifying ourselves
     32    private $plugin_prefix;
     33
     34    // whether we'll be consolidating our options into single array, or keeping discrete
     35    private $consolidate;
     36
     37    // flag to suspend filtering of pre_get_document_title when it's our own request
     38    private $now_requesting_wp_title = false;
    3339
    3440    function __construct( $plugin_prefix='', $option_style='' ) {
     
    3844        // set up to enable dupe content handling, head description and keywords, and robots
    3945        add_filter( 'the_content', array( $this, 'paged_comments_dupefix' ), $this->opt( 'comment_page_replacement_level' ) );
     46        // tap into pre_get_document_title to enable efficient delivery of modified titles
     47        add_filter( 'pre_get_document_title', array( $this, 'tweak_wp_generated_titles'), 1, 1 );
    4048        add_action( 'wp_head', array( $this, 'head_desc' ), 2 );
    4149        add_action( 'wp_head', array( $this, 'head_keywords' ), 3 );
     
    96104        return ucfirst( join( " ", $newwords ) ); // ucfirst again in case first word was in the exception list
    97105    } // end titlecase
     106
     107    /**
     108     * We'll hook this into pre_get_document_title to provide modified titles efficiently.
     109     * @param  string $title Title passed in
     110     * @return string        Modified title, or original if we shouldn't mess with it
     111     */
     112    function tweak_wp_generated_titles( $title = '' ) {
     113        // just to be safe, if anyone else is messing with the title, don't interfere
     114        if ( !empty( $title ) )
     115            return $title;
     116        // and if this is our own request to wp_get_document_title, don't mess with it
     117        if ( $this->now_requesting_wp_title )
     118            return $title;
     119        return $this->select_title( true, false );
     120    }
     121
     122    /**
     123     * Provide a fallback for versions of WP (<4.4) before wp_title was deprecated.
     124     * @param  string  $sep         Legacy wp_title separator
     125     * @param  string  $seplocation Legacy wp_title direction to display title
     126     * @return string               Title, either from wp_title or from wp_get_document_title
     127     */
     128    function wp_title_fallback( $sep = '&raquo;', $seplocation = '' ) {
     129        if (function_exists('wp_get_document_title')) {
     130            $this->now_requesting_wp_title = true;
     131            $title = wp_get_document_title();
     132            $this->now_requesting_wp_title = false;         
     133            return $title;
     134        }
     135        /* we'll always return, never display; therefore, $display always passed as false */
     136        return wp_title( $sep, false, $seplocation );
     137    }
    98138
    99139    function id_to_check( $type = false ) { // detect special case where WP's static front page options mess up the ID we need to check for titles, descriptions, etc.
     
    215255            "frontispaged" => array ( 'home_paged', '' ),
    216256            "homestaticfront" => array ( 'home_static_front', array( "%page_title%" => single_post_title( '', false ), "%page_title_custom%" => $secondary ) ),
    217             "homestaticposts" => array ( 'home_static_posts', array( "%page_title%" => ltrim( wp_title( '', false ) ), "%page_title_custom%" => $secondary ) ),
     257            "homestaticposts" => array ( 'home_static_posts', array( "%page_title%" => ltrim( get_bloginfo( 'name' ) ), "%page_title_custom%" => $secondary ) ),
    218258            "home" => array ( 'home', '' ),
    219259            "single" => array ( 'post', array( "%post_title%" => single_post_title( '', false ), "%post_title_custom%" => $secondary, "%category_title%" => $cat_of_post ) ),
     
    222262            "search" => array ( 'search', array( "%search_terms%" => strip_tags( stripslashes( get_search_query() ) ) ) ),
    223263            "category" => array ( 'category', array( "%category_title%" => $this->titlecase( single_cat_title( '', false ) ), "%category_desc%"=>$cat_desc ) ),
    224             "page" => array ( 'page', array( "%page_title%" => ltrim( wp_title( '', false ) ), "%page_title_custom%" => $secondary ) ),
     264            "page" => array ( 'page', array( "%page_title%" => ltrim( single_post_title( '', false ) ), "%page_title_custom%" => $secondary ) ),
    225265            "year" => array ( 'year_archive', array( "%year%" => get_the_time( 'Y' ) ) ),
    226266            "month" => array ( 'month_archive', array( "%month%" => get_the_time( 'F, Y' ) ) ),
     
    350390            $title = str_replace( '%comment_page%', get_query_var( 'cpage' ), $title );
    351391        } // end handling comment pages
    352         else $title = ltrim( wp_title( '', false ) );
     392        else $title = ltrim( single_post_title( '', false ) );
    353393        return $title; // output will still need texturizing, but that's OK
    354394    } // end getting comment page title
    355395
    356     function select_title( $main=true, $echo=true ) { // root function for titles calls on other functions to produce the title, depending on type of page; $main controls whether to return main or secondary title
     396    // root function for titles calls on other functions to produce the title, depending on type of page; $main controls whether to return main or secondary title
     397    function select_title( $main = true, $echo = true ) {
    357398        global $post;
    358399        if ( is_single() || is_page() )
     
    367408    } // end select title
    368409
    369     function get_other_titles( $main=false ) { // get titles for other than paged comments; $main controls whether to return main or secondary title
     410    // get titles for other than paged comments; $main controls whether to return main or secondary title
     411    function get_other_titles( $main = false ) {
    370412        global $wp_query, $post;
     413
     414        // provide fallback if main requested but main title mods are switched off
     415        if ($main && !$this->opt('enable_main_title_modifications'))
     416            return $this->wp_title_fallback();
     417        // or if secondary requested and both main and secondary mods switched off
     418        if (!$main && !$this->opt('enable_main_title_modifications') && !$this->opt('enable_secondary_titles'))
     419            return $this->wp_title_fallback();
     420
    371421        $suffix = ( $main || !( $this->opt( 'enable_secondary_titles' ) ) ) ? '_title' : '_title_secondary';
    372422
     
    381431            if ( is_array( $titleswaps[$key]['1'] ) ) $swap = array_merge( $swap, $titleswaps[$key]['1'] );
    382432        }
    383         else $title = wp_title( '| ', false, 'right' ) . get_bloginfo( 'name' ); // if it was none of these, just get the usual
     433        else $title = get_bloginfo( 'name' ); // if it was none of these, just get the usual
    384434
    385435        if ( ( ( $key == 'single' ) || ( $key == 'page' ) ) && ( $main && $this->opt( 'legacy_title_invert' ) && $this->opt( 'enable_secondary_titles_legacy' ) ) ) { // handle legacy titles as main titles
     
    387437        } // end handling screwy legacy titles as main titles
    388438
    389         if ( $title == '' ) $title = ltrim( wp_title( '', false ) );
     439        if ( $title == '' ) $title = get_bloginfo( 'name' );
    390440        if ( is_paged() || $this->is_multipage() ) { // modify with something like a page number, if this is paged?
    391441            $modifier = $this->opt_clean( $titleswaps['paged']['0'] . $suffix ); // do some trickery to modify the title for paging
     
    399449    } // end getting other titles
    400450
    401     function paged_comments_dupefix( $content ) { // remove post content if we're on a paged comment page
     451    // remove post content if we're on a paged comment page
     452    function paged_comments_dupefix( $content ) {
    402453        if ( $this->get_comment_page() && $this->opt( 'paged_comments_dupefix' ) ) {
    403454            global $post;
     
    712763    function ghpseo_output( $type='main', $echo=true ) {
    713764        global $ghpseo;
     765        $result = '';
    714766        switch ( $type ) {
    715767        case "main": $result = $ghpseo->select_title( true, false ); break;
  • gregs-high-performance-seo/trunk/options-set/ghpseo-options-instructions.ini

    r776305 r1271160  
    7272<p>Each of these template tags (i.e., <em>function calls</em>) can be used within theme files for single posts, pages, archives, etc. While they can appear either within the loop or outside the loop on individual posts and pages, they should be used only <em>outside the loop</em> on other types of pages. (Using them within the loop won't actually do any harm, but the plugin is designed to deliver output based upon what type of page is being viewed, rather than on the current state of the WordPress loop. This means, for example, that if you were to call for secondary titles of a sequence of posts using the WordPress loop, you would only get the secondary title for the page itself, repeated over and over, which is almost certainly not what you would have intended.)</p>
    7373
     74<p>As of version 4.4, WordPress added support for filtering its own internally generated title tags that were introduced more than a year earlier in version 4.1. On WordPress 4.4 and later, GHPSEO will automatically provide filtering of WordPress-generated title tags for themes which use them.</p>
     75
    7476<p>See the more detailed usage examples below for notes on safely wrapping these calls in conditionals.</p>
    7577
     
    8082<a name="obnoxious_mode" id="obnoxious_mode"></a><h4>'Sledgehammer Mode'</h4>
    8183
    82 <p>If you'd rather not draw on any of this plugin's template tags at all, you can still make use of its paged comment features and many of its <code>head meta</code> features. You can also still take full advantage of its main title functionality if you wish by enabling a special lower performance mode (also known as 'Sledgehammer Mode') via a setting on the main configuration page. This will cause Greg's High Performance SEO to behave like some other SEO plugins and force changes to the <code>head</code> section of your pages using a crude output buffering hack. By its very nature, this way of coding a WordPress plugin is fundamentally 'rude' and incompatible, in the sense that it tramples rough-shod over any modifications to the <code>head</code> section which might have been made by other plugins. It is not recommended. If Sledgehammer Mode output buffering conflicts with output buffering used by other plugins, you'll be on your own.</p>
     84<p>If you'd rather not draw on any of this plugin's template tags at all, you can still make use of its paged comment features and many of its <code>head meta</code> features. From WordPress 4.4 onwards, you can also make full use of the plugin's title modifications, provided that your theme supports the WordPress-generated title tags originally introduced in 4.1. If your theme does not support WordPress-generated title tags, or if you are using a version of WordPress prior to 4.4, you can also still take full advantage of its main title functionality if you wish by enabling a special lower performance mode (also known as 'Sledgehammer Mode') via a setting on the main configuration page. This will cause Greg's High Performance SEO to behave like some other SEO plugins and force changes to the <code>head</code> section of your pages using a crude output buffering hack. By its very nature, this way of coding a WordPress plugin is fundamentally 'rude' and incompatible, in the sense that it tramples rough-shod over any modifications to the <code>head</code> section which might have been made by other plugins. It is not recommended. If Sledgehammer Mode output buffering conflicts with output buffering used by other plugins, you'll be on your own.</p>
    8385
    8486<p>(The reason output buffering is ever used in this situation -- and the reason it qualifies as a 'hack', in my view -- is that WordPress does not offer plugins full access to the contents of the <code>head</code> section in the same way that it offers full access to, for example, the main post content. Plugins which circumvent this intentional, built-in limitation by using output buffering are essentially stepping outside the carefully designed flow of WordPress output assembly and placing themselves above the boundaries which normally protect one piece of code from trampling on another. In the 'Wild West' of multiple plugins attempting to apply their own output buffering without any way of establishing safe interactions with one another, any number of undesirable things can happen.)</p>
  • gregs-high-performance-seo/trunk/options-set/ghpseo-options-maintitles.ini

    r217754 r1271160  
    11[section]
    22header[] = Enabling Main Title Modifications
    3 preface[] = "You can set a custom title structure for the main titles of each type of page. With the following box unchecked, the plugin will simply pass through the title returned by the built-in WordPress function <code>wp_title()</code>. Please see the 'Main Titles' section of the <em>Instructions</em> page for notes on implementing the <code>ghpseo_output('main_title')</code> template tag."
     3preface[] = "You can set a custom title structure for the main titles of each type of page. With the following box unchecked, the plugin will simply pass through the title returned by the built-in WordPress function <code>wp_get_document_title()</code> or, for versions of WordPress prior to 4.4, <code>wp_title()</code>. For WordPress 4.4 and later, if your theme supports automatic insertion of title tags by WordPress, this plugin will deliver its title modifications automatically. When using versions of WordPress prior to 4.4, or if your theme does not support WordPress title tag functionality, using modified titles requires either a template tag or 'Sledgehammer Mode'. Please see the 'Main Titles' section of the <em>Instructions</em> page for notes on implementing the <code>ghpseo_output('main_title')</code> template tag."
    44label[] = "Enable Main Title Modifications?"
    55type[] = checkbox,1
  • gregs-high-performance-seo/trunk/options-set/ghpseo-options.ini

    r471952 r1271160  
    5252[section]
    5353header[] = "Sledgehammer Mode (Not Recommended)"
    54 preface[] = "Greg's High Performance SEO is designed for maximum performance and compatibility and can provide its full functionality <em>without</em> the wasteful use of output buffer hacks popularized by some other SEO plugins. However, due to the design of WordPress itself, the only ways to achieve direct access to certain parts of the <code>head</code> section of your pages are via calls from your theme files or via output buffer hacks. The simple theme updates are explained fully in the instructions and take no more than a couple of minutes to complete. However, if you would rather not add new template tags to your theme files, you can choose instead to enable the lower performance <em>Sledgehammer Mode</em>, in which case this plugin will use the same type of brute force output buffer hacks that other SEO plugins use to circumvent the design limitations of WordPress."
     54preface[] = "Primarily for versions of WordPress before 4.4... Greg's High Performance SEO is designed for maximum performance and compatibility and can provide its full functionality <em>without</em> the wasteful use of output buffer hacks popularized by some other SEO plugins. However, due to the design of WordPress itself prior to version 4.4, the only ways to achieve direct access to certain parts of the <code>head</code> section of your pages are via calls from your theme files or via output buffer hacks. The simple theme updates are explained fully in the instructions and take no more than a couple of minutes to complete. However, if you would rather not add new template tags to your theme files, you can choose instead to enable the lower performance <em>Sledgehammer Mode</em>, in which case this plugin will use the same type of brute force output buffer hacks that other SEO plugins use to circumvent the design limitations of WordPress."
    5555label[] = "Sledgehammer Mode?"
    5656type[] = checkbox,1
  • gregs-high-performance-seo/trunk/readme.txt

    r1219865 r1271160  
    44Tags: seo, title, keywords, tags, meta, metadata, meta keywords, meta description, excerpt, paged comments, comments, duplicate content, head, canonical, google, noindex, nofollow, noodp, noydir, archives, title case, search engine optimization, WPMU, WordPress MU, WordPress Multiuser, greg mulhauser
    55Requires at least: 2.7
    6 Tested up to: 4.3
    7 Stable tag: 1.6.4
     6Tested up to: 4.4a
     7Stable tag: 1.7
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
     
    1919= New in This Version =
    2020
    21 * Fix for default secondary title handling
     21* Added support for the wp_get_document_title() function introduced in WordPress 4.4; now that the title tag functionality first introduced in WordPress 4.1 can be filtered by plugins, GHPSEO will automatically work with themes that have enabled support for WordPress-generated title tags.
    2222
    2323= Introduction =
     
    135135== Upgrade Notice ==
    136136
    137 = 1.6.4, 2 May 2015 =
    138 * Fix for default secondary title handling
     137= 1.7, 22 October 2015 =
     138* Added support for the wp_get_document_title() function introduced in WordPress 4.4; now that the title tag functionality first introduced in WordPress 4.1 can be filtered by plugins, GHPSEO will automatically work with themes that have enabled support for WordPress-generated title tags.
    139139
    140140== Changelog ==
     141
     142= 1.7, 22 October 2015 =
     143* Added support for the wp_get_document_title() function introduced in WordPress 4.4; now that the title tag functionality first introduced in WordPress 4.1 can be filtered by plugins, GHPSEO will automatically work with themes that have enabled support for WordPress-generated title tags.
    141144
    142145= 1.6.4, 2 May 2015 =
Note: See TracChangeset for help on using the changeset viewer.