Changeset 12674 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/functions.php
- Timestamp:
- 06/22/2023 03:40:17 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/functions.php
r11448 r12674 171 171 */ 172 172 function body_class( $classes ) { 173 if ( is_page() ) {173 if ( is_page() && get_queried_object() ) { 174 174 $page = get_queried_object(); 175 175 … … 292 292 293 293 /** 294 * Disables hreflang tags on instances of this theme, unless it's a page that has localised variants. 295 * 296 * This takes the reverse approach of the function name. 297 * Instead of maybe removing it, it removes it unless a specific criteria is met. 298 * 299 * The criteria is that... 300 * - It's a page 301 * - It's not the hosting page 302 * - It's not a rosetta page owned by anyone other than wordpressdotorg (These are the globally synced pages). 303 */ 304 function maybe_remove_hreflang_tags() { 305 if ( 306 ! is_page() || 307 is_page( 'hosting' ) || 308 // Exclude custom localised pages. 309 // Only include posts authored by `wordPressdotorg` which are using a page template. 310 ( 311 defined( 'IS_ROSETTA_NETWORK' ) && IS_ROSETTA_NETWORK && 312 get_user_by( 'slug', 'wordpressdotorg' )->ID != get_post()->post_author 313 ) 314 ) { 315 remove_action( 'wp_head', 'WordPressdotorg\Theme\hreflang_link_attributes' ); 316 } 317 } 318 add_action( 'wp_head', __NAMESPACE__ . '\maybe_remove_hreflang_tags', 1 ); 319 320 /** 294 321 * Custom template tags. 295 322 */
Note: See TracChangeset
for help on using the changeset viewer.