Making WordPress.org


Ignore:
Timestamp:
03/13/2018 05:00:54 AM (8 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.

File:
1 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';
Note: See TracChangeset for help on using the changeset viewer.