Making WordPress.org

Changeset 7299


Ignore:
Timestamp:
06/13/2018 08:39:00 AM (7 years ago)
Author:
obenland
Message:

Themes: Update document title structure.

Also adds Open Graph tags and meta descriptions.

See #3539.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes
Files:
2 edited

Legend:

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

    r7273 r7299  
    6767            'settings' => array(
    6868                /* translators: %s: theme name */
    69                 'title'        => __( '%s — Free WordPress Themes', 'wporg-themes' ),
     69                'title'        => __( '%s | WordPress.org', 'wporg-themes' ),
    7070                'isMobile'     => wp_is_mobile(),
    7171                'postsPerPage' => 24,
     
    143143}
    144144add_filter( 'body_class', 'wporg_themes_body_class' );
     145
     146/**
     147 * Append an optimized site name.
     148 *
     149 * @param array $title {
     150 *     The document title parts.
     151 *
     152 *     @type string $title   Title of the viewed page.
     153 *     @type string $page    Optional. Page number if paginated.
     154 *     @type string $tagline Optional. Site description when on home page.
     155 *     @type string $site    Optional. Site title when not on home page.
     156 * }
     157 * @return array Filtered title parts.
     158 */
     159function wporg_themes_document_title( $title ) {
     160    if ( is_front_page() ) {
     161        $title['title']   = __( 'WordPress Themes', 'wporg-themes' );
     162        $title['tagline'] = __( 'WordPress.org', 'wporg-themes' );
     163    } else if ( is_category() || is_tag() ) {
     164        /* translators: Category or tag name */
     165        $title['title'] = sprintf( __( 'WordPress Themes: %s Free', 'wporg-themes' ), single_term_title( '', false ) );
     166    }
     167
     168    if ( ! is_front_page() ) {
     169        $title['site'] = __( 'WordPress.org', 'wporg-themes' );
     170    }
     171
     172    return $title;
     173}
     174add_filter( 'document_title_parts', 'wporg_themes_document_title' );
     175
     176/**
     177 * Set the separator for the document title.
     178 *
     179 * @return string Document title separator.
     180 */
     181add_filter( 'document_title_separator', function() {
     182    return '|';
     183} );
     184
     185/**
     186 * Adds meta description for front page.
     187 *
     188 * @param array $tags Array that consists of meta name and meta content pairs.
     189 */
     190function wporg_themes_meta_tags( $tags ) {
     191    if ( is_front_page() ) {
     192        $tags['description'] = __( 'Find the perfect theme for your WordPress website. Choose from thousands of stunning designs with a wide variety of features and customization options.', 'wporg-themes' );
     193    }
     194
     195    return $tags;
     196}
     197add_filter( 'jetpack_seo_meta_tags', 'wporg_themes_meta_tags' );
    145198
    146199/**
     
    299352add_filter( 'embed_template', 'wporg_themes_embed_template' );
    300353
     354include_once WP_CONTENT_DIR . '/plugins/jetpack/modules/seo-tools/jetpack-seo.php';
     355include_once WP_CONTENT_DIR . '/plugins/jetpack/modules/seo-tools/jetpack-seo-posts.php';
     356include_once WP_CONTENT_DIR . '/plugins/jetpack/modules/seo-tools/jetpack-seo-titles.php';
     357include_once WP_CONTENT_DIR . '/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php';
     358
     359if ( class_exists( 'Jetpack_SEO' ) ) {
     360    new Jetpack_SEO;
     361}
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/header.php

    r6347 r7299  
    66 */
    77
    8 $GLOBALS['pagetitle'] = __( 'Theme Directory — Free WordPress Themes', 'wporg-themes' );
     8$GLOBALS['pagetitle'] = wp_get_document_title();
    99
    1010require WPORGPATH . 'header.php';
Note: See TracChangeset for help on using the changeset viewer.