Changeset 8215 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
- Timestamp:
- 02/08/2019 03:59:08 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php
r8202 r8215 20 20 add_action( 'wp_print_footer_scripts', array( $this, 'replace_quicktags_blockquote_button' ) ); 21 21 22 // Output rel="canonical" meta tag. 23 add_action( 'wp_head', array( $this, 'rel_canonical' ) );22 // Output rel="canonical" meta tag. Runs before WP's rel_canonical to unhook that if needed. 23 add_action( 'wp_head', array( $this, 'rel_canonical' ), 9 ); 24 24 25 25 // Link to create new topics atop topic list. … … 273 273 274 274 /** 275 * Outputs rel="canonical" for topic tags and views.275 * Outputs <link rel="canonical"> tags for various pages. 276 276 */ 277 277 public function rel_canonical() { 278 if ( ! bbp_is_topic_tag() && ! bbp_is_single_view() ) { 279 return; 280 } 281 278 $canonical_url = false; 282 279 if ( bbp_is_topic_tag() ) { 283 280 $canonical_url = bbp_get_topic_tag_link(); 284 } else {281 } elseif ( bbp_is_single_view() ) { 285 282 $canonical_url = bbp_get_view_url(); 283 } elseif ( bbp_is_forum_archive() ) { 284 $canonical_url = get_post_type_archive_link( 'forum' ); 285 } elseif ( bbp_is_single_topic() ) { 286 remove_action( 'wp_head', 'rel_canonical' ); // Doesn't handle pagination. 287 $canonical_url = bbp_get_topic_permalink(); 288 } elseif ( bbp_is_single_forum() ) { 289 remove_action( 'wp_head', 'rel_canonical' ); // Doesn't handle pagination. 290 $canonical_url = bbp_get_forum_permalink(); 286 291 } 287 292 288 293 // Make sure canonical has pagination if needed. 289 294 $page = get_query_var( 'paged', 0 ); 290 if ( $ page >= 2 ) {295 if ( $canonical_url && $page >= 2 ) { 291 296 $canonical_url .= 'page/' . absint( $page ) . '/'; 292 297 }
Note: See TracChangeset
for help on using the changeset viewer.