Changeset 11451
- Timestamp:
- 01/17/2022 06:48:02 AM (3 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/mu-plugins/pub/site-branding.php
r11450 r11451 1 1 <?php 2 namespace WordPressdotorg\MU_Plugins\Site_Branding;3 2 /** 4 3 * Plugin Name: WordPress.org Site Branding … … 6 5 */ 7 6 8 add_filter( 'document_title_parts', __NAMESPACE__ . '\document_title_parts', 100 ); 9 function document_title_parts( $parts ) { 10 global $rosetta; 7 namespace WordPressdotorg\MU_Plugins\Site_Branding { 11 8 12 // In some places on WordPress.org the document title is used within the theme, don't affect title calls after the </head>. 13 if ( did_action( 'wp_body_open' ) ) { 9 /** 10 * Filter the document title parts to ensure that WordPress is replaced into it consistently. 11 */ 12 function document_title_parts( $parts ) { 13 global $rosetta; 14 15 // In some places on WordPress.org the document title is used within the theme, don't affect title calls after the </head>. 16 if ( did_action( 'wp_body_open' ) ) { 17 return $parts; 18 } 19 20 $combined = implode( ' ', $parts ); 21 22 // Ensure that 'WordPress' is present in the title of the URL 23 if ( false === strpos( $combined, 'WordPress' ) ) { 24 $parts['wporg-suffix'] = get_wordpress_brand(); 25 } 26 27 // Override anything that set part of the title directly to WordPress.org on rosetta sites. 28 if ( isset( $rosetta ) ) { 29 foreach ( [ 'site', 'tagline' ] as $field ) { 30 if ( ! empty( $parts[ $field ] ) && 'WordPress.org' === $parts[ $field ] ) { 31 $parts[ $field ] = get_wordpress_brand(); 32 } 33 } 34 } 35 14 36 return $parts; 15 37 } 38 add_filter( 'document_title_parts', __NAMESPACE__ . '\document_title_parts', 100 ); 16 39 17 $combined = implode( ' ', $parts ); 40 /** 41 * Always suffix the WordPress brand to bbPress titles. 42 */ 43 function bbp_title( $title ) { 44 return $title . get_wordpress_brand(); 45 } 46 add_filter( 'bbp_title', __NAMESPACE__ . '\bbp_title', 100 ); 18 47 19 // Ensure that 'WordPress' is present in the title of the URL 20 if ( false === strpos( $combined, 'WordPress' ) ) { 21 $parts['wporg-suffix'] = get_wordpress_brand(); 48 /** 49 * Filter Jetpack opengraph tags to reference the localised WordPress.org site. 50 */ 51 function jetpack_opengraph( $fields ) { 52 if ( isset( $fields['og:site_name'] ) && 'WordPress.org' === $fields['og:site_name'] ) { 53 $fields['og:site_name'] = get_wordpress_brand(); 54 } 55 56 return $fields; 57 } 58 add_filter( 'jetpack_open_graph_tags', __NAMESPACE__ . '\jetpack_opengraph', 100 ); 59 60 /** 61 * Return the 'Brand' of the WordPress.org site. 62 * 63 * This is "WordPress.org" or a localised variant such as "WordPress Deutch". 64 */ 65 function get_wordpress_brand() { 66 global $rosetta; 67 68 if ( ! isset( $rosetta ) ) { 69 return 'WordPress.org'; 70 } 71 72 $root_id = $rosetta->get_root_site_id(); 73 $name = get_blog_option( $root_id, 'blogname' ); 74 75 if ( false !== strpos( $name, 'WordPress' ) ) { 76 return $name; 77 } 78 79 return "WordPress.org $name"; 22 80 } 23 81 24 // Override anything that set part of the title directly to WordPress.org on rosetta sites. 25 if ( isset( $rosetta ) ) { 26 foreach ( [ 'site', 'tagline' ] as $field ) { 27 if ( ! empty( $parts[ $field ] ) && 'WordPress.org' === $parts[ $field ] ) { 28 $parts[ $field ] = get_wordpress_brand(); 29 } 30 } 82 /** 83 * Output the WordPress favicon on all WordPress.org themes. 84 */ 85 function favicon_icon() { 86 echo '<link rel="icon" href="https://s.w.org/favicon.ico?2" type="image/x-icon" />', "\n"; 31 87 } 88 add_action( 'wp_head', __NAMESPACE__ . '\favicon_icon', 1 ); 32 89 33 return $parts;34 90 } 35 91 36 add_filter( 'bbp_title', __NAMESPACE__ . '\bbp_title', 100 ); 37 function bbp_title( $title ) { 38 return $title . get_wordpress_brand(); 92 namespace WordPressdotorg { 93 /** 94 * Function to call as `\WordPressdotorg\site_brand()` in other plugins. 95 */ 96 function site_brand() { 97 return \WordPressdotorg\MU_Plugins\Site_Branding\get_wordpress_brand(); 98 } 39 99 } 40 41 /**42 * Return the 'Brand' of the WordPress.org site.43 *44 * This is "WordPress.org" or a localised variant such as "WordPress Deutch".45 */46 function get_wordpress_brand() {47 global $rosetta;48 49 if ( ! isset( $rosetta ) ) {50 return 'WordPress.org';51 }52 53 $root_id = $rosetta->get_root_site_id();54 $name = get_blog_option( $root_id, 'blogname' );55 56 if ( false !== strpos( $name, 'WordPress' ) ) {57 return $name;58 }59 60 return "WordPress.org $name";61 }62 63 /**64 * Output the WordPress favicon on all WordPress.org themes.65 */66 function favicon_icon() {67 echo '<link rel="icon" href="https://s.w.org/favicon.ico?2" type="image/x-icon" />', "\n";68 }69 add_action( 'wp_head', __NAMESPACE__ . '\favicon_icon', 1 ); -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/inc/page-meta-descriptions.php
r11427 r11451 18 18 */ 19 19 function custom_open_graph_tags( $tags = [] ) { 20 global $wporg_global_header_options;21 22 20 // Use `name=""` for description. 23 21 // See Jetpacks Twitter Card for where it happens for the twitter:* fields. … … 28 26 // Override the Front-page tags. 29 27 if ( is_front_page() ) { 30 $site_title = ! empty( $wporg_global_header_options['rosetta_title'] ) ? $wporg_global_header_options['rosetta_title'] : 'WordPress';31 28 return array( 32 29 'og:type' => 'website', … … 35 32 'description' => __( 'Open source software which you can use to easily create a beautiful website, blog, or app.', 'wporg' ), 36 33 'og:url' => home_url( '/' ), 37 'og:site_name' => $site_title,34 'og:site_name' => 'WordPress.org', // Rosetta title will automatically be inserted. 38 35 'og:image' => 'https://s.w.org/images/home/screen-themes.png?3', 39 36 'og:locale' => get_locale(), -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-patterns/functions.php
r11215 r11451 284 284 */ 285 285 function add_social_meta_tags() { 286 global $wporg_global_header_options;286 $og_fields = []; 287 287 $default_image = get_stylesheet_directory_uri() . '/images/social-image.png'; 288 $ og_fields = [];288 $site_title = function_exists( '\WordPressdotorg\site_brand' ) ? \WordPressdotorg\site_brand() : 'WordPress.org'; 289 289 290 290 if ( is_front_page() || is_home() ) { … … 292 292 'og:title' => __( 'Block Pattern Directory', 'wporg-patterns' ), 293 293 'og:description' => __( 'Add a beautifully designed, ready to go layout to any WordPress site with a simple copy/paste.', 'wporg-patterns' ), 294 'og:site_name' => $ wporg_global_header_options['rosetta_title'] ?? 'WordPress.org',294 'og:site_name' => $site_title, 295 295 'og:type' => 'website', 296 296 'og:url' => home_url(), … … 301 301 'og:title' => sprintf( __( 'Block Patterns: %s', 'wporg-patterns' ), esc_attr( single_term_title( '', false ) ) ), 302 302 'og:description' => __( 'Add a beautifully designed, ready to go layout to any WordPress site with a simple copy/paste.', 'wporg-patterns' ), 303 'og:site_name' => esc_attr( $wporg_global_header_options['rosetta_title'] ?? 'WordPress.org' ),303 'og:site_name' => $site_title, 304 304 'og:type' => 'website', 305 305 'og:url' => esc_url( get_term_link( get_queried_object_id() ) ), … … 309 309 $og_fields = [ 310 310 'og:title' => the_title_attribute( array( 'echo' => false ) ), 311 'og:description' => esc_attr( strip_tags( get_post_meta( get_the_ID(), 'wpop_description', true )) ),312 'og:site_name' => esc_attr( $wporg_global_header_options['rosetta_title'] ?? 'WordPress.org' ),311 'og:description' => strip_tags( get_post_meta( get_the_ID(), 'wpop_description', true ) ), 312 'og:site_name' => $site_title, 313 313 'og:type' => 'website', 314 314 'og:url' => esc_url( get_permalink() ), -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/functions.php
r11449 r11451 331 331 */ 332 332 function social_meta_data() { 333 global $wporg_global_header_options; 333 $site_title = function_exists( '\WordPressdotorg\site_brand' ) ? \WordPressdotorg\site_brand() : 'WordPress.org'; 334 334 335 if ( is_front_page() ) { 335 336 $og_fields = [ 336 337 'og:title' => __( 'WordPress Plugins', 'wporg-plugins' ), 337 338 'og:description' => __( 'Choose from thousands of free plugins to build, customize, and enhance your WordPress website.', 'wporg-plugins' ), 338 'og:site_name' => $ wporg_global_header_options['rosetta_title'] ?? 'WordPress.org',339 'og:site_name' => $site_title, 339 340 'og:type' => 'website', 340 341 'og:url' => home_url(), … … 367 368 printf( '<meta property="og:description" content="%s" />' . "\n", esc_attr( strip_tags( get_the_excerpt() ) ) ); 368 369 printf( '<meta name="description" content="%s" />' . "\n", esc_attr( strip_tags( get_the_excerpt() ) ) ); 369 printf( '<meta property="og:site_name" content="%s" />' . "\n", esc_attr( $ wporg_global_header_options['rosetta_title'] ?? 'WordPress.org') );370 printf( '<meta property="og:site_name" content="%s" />' . "\n", esc_attr( $site_title ) ); 370 371 printf( '<meta property="og:type" content="website" />' . "\n" ); 371 372 printf( '<meta property="og:url" content="%s" />' . "\n", esc_url( get_permalink() ) );
Note: See TracChangeset
for help on using the changeset viewer.