Changeset 1271160
- Timestamp:
- 10/22/2015 03:02:53 PM (10 years ago)
- Location:
- gregs-high-performance-seo
- Files:
-
- 7 edited
- 24 copied
-
tags/1.7 (copied) (copied from gregs-high-performance-seo/trunk)
-
tags/1.7/ghpseo-options-functions.php (copied) (copied from gregs-high-performance-seo/trunk/ghpseo-options-functions.php)
-
tags/1.7/ghpseo-options.php (copied) (copied from gregs-high-performance-seo/trunk/ghpseo-options.php)
-
tags/1.7/ghpseo-setup-functions.php (copied) (copied from gregs-high-performance-seo/trunk/ghpseo-setup-functions.php)
-
tags/1.7/ghpseo-sledgehammer-mode.php (copied) (copied from gregs-high-performance-seo/trunk/ghpseo-sledgehammer-mode.php) (2 diffs)
-
tags/1.7/ghpseo-writing-functions.php (copied) (copied from gregs-high-performance-seo/trunk/ghpseo-writing-functions.php)
-
tags/1.7/ghpseo-writing.php (copied) (copied from gregs-high-performance-seo/trunk/ghpseo-writing.php)
-
tags/1.7/ghpseo.php (copied) (copied from gregs-high-performance-seo/trunk/ghpseo.php) (12 diffs)
-
tags/1.7/options-set/extra/ghpseo-options-donating.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options-donating.txt)
-
tags/1.7/options-set/extra/ghpseo-options-headmeta.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options-headmeta.txt)
-
tags/1.7/options-set/extra/ghpseo-options-instructions.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options-instructions.txt)
-
tags/1.7/options-set/extra/ghpseo-options-legacy.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options-legacy.txt)
-
tags/1.7/options-set/extra/ghpseo-options-maintitles.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options-maintitles.txt)
-
tags/1.7/options-set/extra/ghpseo-options-pagedcomments.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options-pagedcomments.txt)
-
tags/1.7/options-set/extra/ghpseo-options-secondarydesc.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options-secondarydesc.txt)
-
tags/1.7/options-set/extra/ghpseo-options-secondarytitles.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options-secondarytitles.txt)
-
tags/1.7/options-set/extra/ghpseo-options.txt (copied) (copied from gregs-high-performance-seo/trunk/options-set/extra/ghpseo-options.txt)
-
tags/1.7/options-set/ghpseo-options-donating.ini (copied) (copied from gregs-high-performance-seo/trunk/options-set/ghpseo-options-donating.ini)
-
tags/1.7/options-set/ghpseo-options-headmeta.ini (copied) (copied from gregs-high-performance-seo/trunk/options-set/ghpseo-options-headmeta.ini)
-
tags/1.7/options-set/ghpseo-options-instructions.ini (copied) (copied from gregs-high-performance-seo/trunk/options-set/ghpseo-options-instructions.ini) (2 diffs)
-
tags/1.7/options-set/ghpseo-options-maintitles.ini (modified) (1 diff)
-
tags/1.7/options-set/ghpseo-options-secondarydesc.ini (copied) (copied from gregs-high-performance-seo/trunk/options-set/ghpseo-options-secondarydesc.ini)
-
tags/1.7/options-set/ghpseo-options.ini (copied) (copied from gregs-high-performance-seo/trunk/options-set/ghpseo-options.ini) (1 diff)
-
tags/1.7/readme.txt (copied) (copied from gregs-high-performance-seo/trunk/readme.txt) (3 diffs)
-
tags/1.7/uninstall.php (copied) (copied from gregs-high-performance-seo/trunk/uninstall.php)
-
trunk/ghpseo-sledgehammer-mode.php (modified) (2 diffs)
-
trunk/ghpseo.php (modified) (12 diffs)
-
trunk/options-set/ghpseo-options-instructions.ini (modified) (2 diffs)
-
trunk/options-set/ghpseo-options-maintitles.ini (modified) (1 diff)
-
trunk/options-set/ghpseo-options.ini (modified) (1 diff)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
gregs-high-performance-seo/tags/1.7/ghpseo-sledgehammer-mode.php
r1106149 r1271160 35 35 // replace the title, strip old head meta (if they exist), and add our own 36 36 $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 ); 38 38 $header = str_replace( '</title>', "</title>" . $ghpseo->canonical(), $header ); 39 39 $replacements = array( 'description' => 'head_desc', … … 42 42 ); 43 43 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 ); 45 45 $header = str_replace( '</title>', "</title>" . $ghpseo->$value(), $header ); 46 46 } // end loop over replacements -
gregs-high-performance-seo/tags/1.7/ghpseo.php
r1151682 r1271160 4 4 Plugin URI: http://gregsplugins.com/lib/plugin-details/gregs-high-performance-seo/ 5 5 Description: 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.46 Version: 1.7 7 7 Author: Greg Mulhauser 8 8 Author URI: http://gregsplugins.com/ … … 29 29 class gregsHighPerformanceSEO { 30 30 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; 33 39 34 40 function __construct( $plugin_prefix='', $option_style='' ) { … … 38 44 // set up to enable dupe content handling, head description and keywords, and robots 39 45 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 ); 40 48 add_action( 'wp_head', array( $this, 'head_desc' ), 2 ); 41 49 add_action( 'wp_head', array( $this, 'head_keywords' ), 3 ); … … 96 104 return ucfirst( join( " ", $newwords ) ); // ucfirst again in case first word was in the exception list 97 105 } // 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 = '»', $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 } 98 138 99 139 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. … … 215 255 "frontispaged" => array ( 'home_paged', '' ), 216 256 "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 ) ), 218 258 "home" => array ( 'home', '' ), 219 259 "single" => array ( 'post', array( "%post_title%" => single_post_title( '', false ), "%post_title_custom%" => $secondary, "%category_title%" => $cat_of_post ) ), … … 222 262 "search" => array ( 'search', array( "%search_terms%" => strip_tags( stripslashes( get_search_query() ) ) ) ), 223 263 "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 ) ), 225 265 "year" => array ( 'year_archive', array( "%year%" => get_the_time( 'Y' ) ) ), 226 266 "month" => array ( 'month_archive', array( "%month%" => get_the_time( 'F, Y' ) ) ), … … 350 390 $title = str_replace( '%comment_page%', get_query_var( 'cpage' ), $title ); 351 391 } // end handling comment pages 352 else $title = ltrim( wp_title( '', false ) );392 else $title = ltrim( single_post_title( '', false ) ); 353 393 return $title; // output will still need texturizing, but that's OK 354 394 } // end getting comment page title 355 395 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 ) { 357 398 global $post; 358 399 if ( is_single() || is_page() ) … … 367 408 } // end select title 368 409 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 ) { 370 412 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 371 421 $suffix = ( $main || !( $this->opt( 'enable_secondary_titles' ) ) ) ? '_title' : '_title_secondary'; 372 422 … … 381 431 if ( is_array( $titleswaps[$key]['1'] ) ) $swap = array_merge( $swap, $titleswaps[$key]['1'] ); 382 432 } 383 else $title = wp_title( '| ', false, 'right' ) .get_bloginfo( 'name' ); // if it was none of these, just get the usual433 else $title = get_bloginfo( 'name' ); // if it was none of these, just get the usual 384 434 385 435 if ( ( ( $key == 'single' ) || ( $key == 'page' ) ) && ( $main && $this->opt( 'legacy_title_invert' ) && $this->opt( 'enable_secondary_titles_legacy' ) ) ) { // handle legacy titles as main titles … … 387 437 } // end handling screwy legacy titles as main titles 388 438 389 if ( $title == '' ) $title = ltrim( wp_title( '', false ));439 if ( $title == '' ) $title = get_bloginfo( 'name' ); 390 440 if ( is_paged() || $this->is_multipage() ) { // modify with something like a page number, if this is paged? 391 441 $modifier = $this->opt_clean( $titleswaps['paged']['0'] . $suffix ); // do some trickery to modify the title for paging … … 399 449 } // end getting other titles 400 450 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 ) { 402 453 if ( $this->get_comment_page() && $this->opt( 'paged_comments_dupefix' ) ) { 403 454 global $post; … … 712 763 function ghpseo_output( $type='main', $echo=true ) { 713 764 global $ghpseo; 765 $result = ''; 714 766 switch ( $type ) { 715 767 case "main": $result = $ghpseo->select_title( true, false ); break; -
gregs-high-performance-seo/tags/1.7/options-set/ghpseo-options-instructions.ini
r776305 r1271160 72 72 <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> 73 73 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 74 76 <p>See the more detailed usage examples below for notes on safely wrapping these calls in conditionals.</p> 75 77 … … 80 82 <a name="obnoxious_mode" id="obnoxious_mode"></a><h4>'Sledgehammer Mode'</h4> 81 83 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> 83 85 84 86 <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 1 1 [section] 2 2 header[] = 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."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_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." 4 4 label[] = "Enable Main Title Modifications?" 5 5 type[] = checkbox,1 -
gregs-high-performance-seo/tags/1.7/options-set/ghpseo-options.ini
r471952 r1271160 52 52 [section] 53 53 header[] = "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."54 preface[] = "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." 55 55 label[] = "Sledgehammer Mode?" 56 56 type[] = checkbox,1 -
gregs-high-performance-seo/tags/1.7/readme.txt
r1219865 r1271160 4 4 Tags: 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 5 5 Requires at least: 2.7 6 Tested up to: 4. 37 Stable tag: 1. 6.46 Tested up to: 4.4a 7 Stable tag: 1.7 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 19 19 = New in This Version = 20 20 21 * Fix for default secondary title handling21 * 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. 22 22 23 23 = Introduction = … … 135 135 == Upgrade Notice == 136 136 137 = 1. 6.4, 2 May2015 =138 * Fix for default secondary title handling137 = 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. 139 139 140 140 == 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. 141 144 142 145 = 1.6.4, 2 May 2015 = -
gregs-high-performance-seo/trunk/ghpseo-sledgehammer-mode.php
r1106149 r1271160 35 35 // replace the title, strip old head meta (if they exist), and add our own 36 36 $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 ); 38 38 $header = str_replace( '</title>', "</title>" . $ghpseo->canonical(), $header ); 39 39 $replacements = array( 'description' => 'head_desc', … … 42 42 ); 43 43 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 ); 45 45 $header = str_replace( '</title>', "</title>" . $ghpseo->$value(), $header ); 46 46 } // end loop over replacements -
gregs-high-performance-seo/trunk/ghpseo.php
r1151682 r1271160 4 4 Plugin URI: http://gregsplugins.com/lib/plugin-details/gregs-high-performance-seo/ 5 5 Description: 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.46 Version: 1.7 7 7 Author: Greg Mulhauser 8 8 Author URI: http://gregsplugins.com/ … … 29 29 class gregsHighPerformanceSEO { 30 30 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; 33 39 34 40 function __construct( $plugin_prefix='', $option_style='' ) { … … 38 44 // set up to enable dupe content handling, head description and keywords, and robots 39 45 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 ); 40 48 add_action( 'wp_head', array( $this, 'head_desc' ), 2 ); 41 49 add_action( 'wp_head', array( $this, 'head_keywords' ), 3 ); … … 96 104 return ucfirst( join( " ", $newwords ) ); // ucfirst again in case first word was in the exception list 97 105 } // 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 = '»', $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 } 98 138 99 139 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. … … 215 255 "frontispaged" => array ( 'home_paged', '' ), 216 256 "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 ) ), 218 258 "home" => array ( 'home', '' ), 219 259 "single" => array ( 'post', array( "%post_title%" => single_post_title( '', false ), "%post_title_custom%" => $secondary, "%category_title%" => $cat_of_post ) ), … … 222 262 "search" => array ( 'search', array( "%search_terms%" => strip_tags( stripslashes( get_search_query() ) ) ) ), 223 263 "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 ) ), 225 265 "year" => array ( 'year_archive', array( "%year%" => get_the_time( 'Y' ) ) ), 226 266 "month" => array ( 'month_archive', array( "%month%" => get_the_time( 'F, Y' ) ) ), … … 350 390 $title = str_replace( '%comment_page%', get_query_var( 'cpage' ), $title ); 351 391 } // end handling comment pages 352 else $title = ltrim( wp_title( '', false ) );392 else $title = ltrim( single_post_title( '', false ) ); 353 393 return $title; // output will still need texturizing, but that's OK 354 394 } // end getting comment page title 355 395 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 ) { 357 398 global $post; 358 399 if ( is_single() || is_page() ) … … 367 408 } // end select title 368 409 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 ) { 370 412 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 371 421 $suffix = ( $main || !( $this->opt( 'enable_secondary_titles' ) ) ) ? '_title' : '_title_secondary'; 372 422 … … 381 431 if ( is_array( $titleswaps[$key]['1'] ) ) $swap = array_merge( $swap, $titleswaps[$key]['1'] ); 382 432 } 383 else $title = wp_title( '| ', false, 'right' ) .get_bloginfo( 'name' ); // if it was none of these, just get the usual433 else $title = get_bloginfo( 'name' ); // if it was none of these, just get the usual 384 434 385 435 if ( ( ( $key == 'single' ) || ( $key == 'page' ) ) && ( $main && $this->opt( 'legacy_title_invert' ) && $this->opt( 'enable_secondary_titles_legacy' ) ) ) { // handle legacy titles as main titles … … 387 437 } // end handling screwy legacy titles as main titles 388 438 389 if ( $title == '' ) $title = ltrim( wp_title( '', false ));439 if ( $title == '' ) $title = get_bloginfo( 'name' ); 390 440 if ( is_paged() || $this->is_multipage() ) { // modify with something like a page number, if this is paged? 391 441 $modifier = $this->opt_clean( $titleswaps['paged']['0'] . $suffix ); // do some trickery to modify the title for paging … … 399 449 } // end getting other titles 400 450 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 ) { 402 453 if ( $this->get_comment_page() && $this->opt( 'paged_comments_dupefix' ) ) { 403 454 global $post; … … 712 763 function ghpseo_output( $type='main', $echo=true ) { 713 764 global $ghpseo; 765 $result = ''; 714 766 switch ( $type ) { 715 767 case "main": $result = $ghpseo->select_title( true, false ); break; -
gregs-high-performance-seo/trunk/options-set/ghpseo-options-instructions.ini
r776305 r1271160 72 72 <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> 73 73 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 74 76 <p>See the more detailed usage examples below for notes on safely wrapping these calls in conditionals.</p> 75 77 … … 80 82 <a name="obnoxious_mode" id="obnoxious_mode"></a><h4>'Sledgehammer Mode'</h4> 81 83 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> 83 85 84 86 <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 1 1 [section] 2 2 header[] = 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."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_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." 4 4 label[] = "Enable Main Title Modifications?" 5 5 type[] = checkbox,1 -
gregs-high-performance-seo/trunk/options-set/ghpseo-options.ini
r471952 r1271160 52 52 [section] 53 53 header[] = "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."54 preface[] = "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." 55 55 label[] = "Sledgehammer Mode?" 56 56 type[] = checkbox,1 -
gregs-high-performance-seo/trunk/readme.txt
r1219865 r1271160 4 4 Tags: 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 5 5 Requires at least: 2.7 6 Tested up to: 4. 37 Stable tag: 1. 6.46 Tested up to: 4.4a 7 Stable tag: 1.7 8 8 License: GPLv3 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 19 19 = New in This Version = 20 20 21 * Fix for default secondary title handling21 * 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. 22 22 23 23 = Introduction = … … 135 135 == Upgrade Notice == 136 136 137 = 1. 6.4, 2 May2015 =138 * Fix for default secondary title handling137 = 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. 139 139 140 140 == 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. 141 144 142 145 = 1.6.4, 2 May 2015 =
Note: See TracChangeset
for help on using the changeset viewer.