Making WordPress.org

Changeset 6869


Ignore:
Timestamp:
03/13/2018 05:00:54 AM (7 years ago)
Author:
dd32
Message:

Main: About: Centralise the custom opengraph tags content into a singular function rather than spredding the filters through page templates.
This change also makes it possible to provide the page embeds with some content, where as previously it was blank, for example: https://test.wordpress.org/about/license/embed/

See #3046.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main
Files:
1 added
15 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/functions.php

    r6797 r6869  
    167167add_filter( 'page_template_hierarchy', __NAMESPACE__ . '\child_page_templates' );
    168168
     169function use_opengraph_data_for_embed_template() {
     170    global $post;
     171    if ( 'page' != $post->post_type || ! $post->page_template || 'default' == $post->page_template ) {
     172        return;
     173    }
     174
     175    $meta = custom_open_graph_tags();
     176    if ( $meta ) {
     177        add_filter( 'the_title', function( $title ) use( $meta ) {
     178            return $meta['og:title'] ?? $title;
     179        } );
     180        add_filter( 'the_content', function( $content ) use( $meta ) {
     181            return $meta['og:description'] ?? $content;
     182        } );
     183    }
     184}
     185add_action( 'embed_head', __NAMESPACE__ . '\use_opengraph_data_for_embed_template' );
     186
    169187/**
    170188 * Custom template tags.
    171189 */
    172190require_once get_stylesheet_directory() . '/inc/template-tags.php';
     191
     192/**
     193 * Custom meta descriptions for page templates.
     194 */
     195require_once get_stylesheet_directory() . '/inc/page-meta-descriptions.php';
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-domains.php

    r6868 r6869  
    2626} );
    2727
    28 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    29     $tags['og:title']            = _esc_html__( 'WordPress Domains', 'wporg' );
    30     $tags['og:description']      = _esc_html__( 'WordPress domains and site names can be very flexible; however, top-level domains can’t use the word WordPress. Find out what is allowed and what constitutes a trademark violation, as well as policies on subdomain use. Review the list of official WordPress sites to know how to recognize and advise violators.', 'wporg' );
    31     $tags['twitter:text:title']  = $tags['og:title'];
    32     $tags['twitter:description'] = $tags['og:description'];
    33 
    34     return $tags;
    35 } );
     28// See inc/page-meta-descriptions.php for the meta description for this page.
    3629
    3730get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-etiquette.php

    r6868 r6869  
    2626} );
    2727
    28 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    29     $tags['og:title']            = _esc_html__( 'Etiquette at WordPress', 'wporg' );
    30     $tags['og:description']      = _esc_html__( 'We welcome the contributions of everyone who’s interested in joining the WordPress open source project, and every thriving, diverse community needs etiquette guidelines. Review our simple guidelines that focus on diversity, safety, and inclusion and foster a welcoming community for our contributors around the world.', 'wporg' );
    31     $tags['twitter:text:title']  = $tags['og:title'];
    32     $tags['twitter:description'] = $tags['og:description'];
    33 
    34     return $tags;
    35 } );
     28// See inc/page-meta-descriptions.php for the meta description for this page.
    3629
    3730get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-features.php

    r6868 r6869  
    2727} );
    2828
    29 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    30     $tags['og:title']            = _esc_html__( 'WordPress Features', 'wporg' );
    31     /* translators: WordPress market share: 29%; */
    32     $tags['og:description']      = sprintf( _esc_html__( 'Discover why WordPress powers more than %s of the web. WordPress is a simple, flexible, user-friendly platform, with key features that include media management, SEO, and endless options for customization. More than 50,000 plugins extend the core functionality of WordPress even more. Build your site today.', 'wporg' ), WP_MARKET_SHARE . '%' );
    33     $tags['twitter:text:title']  = $tags['og:title'];
    34     $tags['twitter:description'] = $tags['og:description'];
    35 
    36     return $tags;
    37 } );
     29// See inc/page-meta-descriptions.php for the meta description for this page.
    3830
    3931get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-history.php

    r6868 r6869  
    2727} );
    2828
    29 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    30     $tags['og:title']            = _esc_html__( 'The History of WordPress', 'wporg' );
    31     /* translators: WordPress market share: 29%; */
    32     $tags['og:description']      = sprintf( _esc_html__( 'WordPress currently powers more than %s of the web. How did it grow to become the world’s leading web publishing platform? Learn about the history of WordPress: an open source software project built by an active community of contributors who are passionate about collaboration, empowerment, and the open web.', 'wporg' ), WP_MARKET_SHARE . '%' );
    33     $tags['twitter:text:title']  = $tags['og:title'];
    34     $tags['twitter:description'] = $tags['og:description'];
    35 
    36     return $tags;
    37 } );
     29// See inc/page-meta-descriptions.php for the meta description for this page.
    3830
    3931get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-license.php

    r6868 r6869  
    2626} );
    2727
    28 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    29     $tags['og:title']            = _esc_html__( 'The GNU Public License', 'wporg' );
    30     $tags['og:description']      = _esc_html__( 'WordPress is an open source software project, and a fierce believer in the values of the open web. WordPress uses the GNU Public License, which provides a platform for technical expansion and encourages adaptation and innovation. Learn more about this license, and discover what can and cannot be done under it.', 'wporg' );
    31     $tags['twitter:text:title']  = $tags['og:title'];
    32     $tags['twitter:description'] = $tags['og:description'];
    33 
    34     return $tags;
    35 } );
     28// See inc/page-meta-descriptions.php for the meta description for this page.
    3629
    3730get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-logos.php

    r6868 r6869  
    2525    return new \WP_Error();
    2626} );
     27
     28// See inc/page-meta-descriptions.php for the meta description for this page.
    2729
    2830get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-philosophy.php

    r6868 r6869  
    2626} );
    2727
    28 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    29     $tags['og:title']            = _esc_html__( 'WordPress’ Philosophy', 'wporg' );
    30     $tags['og:description']      = _esc_html__( 'At the core of the WordPress philosophy is our commitment to the open web and to building software that works for everyone, from a new user to an advanced developer. Our philosophy pushes WordPress to remain flexible, adaptable, and easy-to-use. Learn about WordPress’s philosophy and how it shapes our community.', 'wporg' );
    31     $tags['twitter:text:title']  = $tags['og:title'];
    32     $tags['twitter:description'] = $tags['og:description'];
    33 
    34     return $tags;
    35 } );
     28// See inc/page-meta-descriptions.php for the meta description for this page.
    3629
    3730get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-privacy.php

    r6868 r6869  
    2626} );
    2727
    28 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    29     $tags['og:title']            = _esc_html__( 'WordPress Privacy Policy', 'wporg' );
    30     $tags['og:description']      = _esc_html__( 'Like other major software platforms, WordPress gathers and collects statistics and analytical data. Privacy is key in this endeavor and WordPress never discloses any personally identifiable data. Review the WordPress Privacy Policy to learn how, as a participant in this community, you’re privacy is protected.', 'wporg' );
    31     $tags['twitter:text:title']  = $tags['og:title'];
    32     $tags['twitter:description'] = $tags['og:description'];
    33 
    34     return $tags;
    35 } );
     28// See inc/page-meta-descriptions.php for the meta description for this page.
    3629
    3730get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-requirements.php

    r6868 r6869  
    2727} );
    2828
    29 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    30     $tags['og:title']            = _esc_html__( 'Hosting Requirements for WordPress', 'wporg' );
    31     $tags['og:description']      = _esc_html__( 'Running WordPress doesn’t require a lot, but your host will still need to meet a few minimum requirements. Learn about the website hosting requirements to run WordPress, including our recommendation to support PHP 7.2+ and HTTPS. Not sure how to ask your host for these details? Use the sample email we include.', 'wporg' );
    32     $tags['twitter:text:title']  = $tags['og:title'];
    33     $tags['twitter:description'] = $tags['og:description'];
    34 
    35     return $tags;
    36 } );
     29// See inc/page-meta-descriptions.php for the meta description for this page.
    3730
    3831get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-roadmap.php

    r6868 r6869  
    2727} );
    2828
    29 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    30     $tags['og:title']            = _esc_html__( 'WordPress Development Roadmap', 'wporg' );
    31     $tags['og:description']      = _esc_html__( 'The WordPress Roadmap lists major releases by date, includes details about the features of each release, and acknowledges the contributing community members. Learn about the status of upcoming releases, development cycles, issues, and milestones. Follow the progress of WordPress development week after week!', 'wporg' );
    32     $tags['twitter:text:title']  = $tags['og:title'];
    33     $tags['twitter:description'] = $tags['og:description'];
    34 
    35     return $tags;
    36 } );
     29// See inc/page-meta-descriptions.php for the meta description for this page.
    3730
    3831get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-security.php

    r6868 r6869  
    2727} );
    2828
    29 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    30     $tags['og:title']            = _esc_html__( 'WordPress is Secure', 'wporg' );
    31     /* translators: WordPress market share: 29%; */
    32     $tags['og:description']      = sprintf( _esc_html__( 'Why is WordPress recommended as a secure website-building solution? With a passionate open source community and an extensible, easy-to-use platform, WordPress provides flexible and secure options for all levels of users, from beginners to pros. Learn how WordPress guarantees the security of %s of the web.', 'wporg' ), WP_MARKET_SHARE . '%' );
    33     $tags['twitter:text:title']  = $tags['og:title'];
    34     $tags['twitter:description'] = $tags['og:description'];
    35 
    36     return $tags;
    37 } );
     29// See inc/page-meta-descriptions.php for the meta description for this page.
    3830
    3931get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-stats.php

    r6868 r6869  
    2626} );
    2727
    28 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    29     $tags['og:title']            = _esc_html__( 'Key WordPress Statistics', 'wporg' );
    30     $tags['og:description']      = _esc_html__( 'WordPress is committed to transparency, and you can get a better sense of its constant worldwide growth through the statistics we share. Review key WordPress stats including usage breakdown by WordPress versions, PHP and MySQL versions being run, and locales of use, and see how WordPress expands its global reach.', 'wporg' );
    31     $tags['twitter:text:title']  = $tags['og:title'];
    32     $tags['twitter:description'] = $tags['og:description'];
    33 
    34     return $tags;
    35 } );
     28// See inc/page-meta-descriptions.php for the meta description for this page.
    3629
    3730get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about-swag.php

    r6868 r6869  
    2626} );
    2727
    28 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    29     $tags['og:title']            = _esc_html__( 'WordPress Swag', 'wporg' );
    30     $tags['og:description']      = _esc_html__( 'Show your WordPress pride and run with the coolest swag! You’ll be surprised how widely recognized our logo is around the world, bringing people together through recognition and community. Choose your WordPress swag today (Wapuu t-shirt, anyone?) and your purchase will also support free swag at WordCamps and meetups.', 'wporg' );
    31     $tags['twitter:text:title']  = $tags['og:title'];
    32     $tags['twitter:description'] = $tags['og:description'];
    33 
    34     return $tags;
    35 } );
     28// See inc/page-meta-descriptions.php for the meta description for this page.
    3629
    3730get_header( 'child-page' );
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-main/page-about.php

    r6868 r6869  
    1919} );
    2020
    21 add_filter( 'jetpack_open_graph_tags', function( $tags ) {
    22     $tags['og:title']            = _esc_html__( 'Democratize Publishing', 'wporg' );
    23     $tags['og:description']      = _esc_html__( 'WordPress is software designed for everyone with emphasis on accessibility, performance, security, and usability.', 'wporg' );
    24     $tags['twitter:text:title']  = $tags['og:title'];
    25     $tags['twitter:description'] = $tags['og:description'];
    26 
    27     return $tags;
    28 } );
     21// See inc/page-meta-descriptions.php for the meta description for this page.
    2922
    3023get_header();
Note: See TracChangeset for help on using the changeset viewer.