WordPress.org

Making WordPress.org

Changeset 7348


Ignore:
Timestamp:
06/29/2018 02:10:40 PM (2 years ago)
Author:
obenland
Message:

Main: Filter Rosetta-dependent templates.

Makes sure templates that depend on $rosetta being available can't be selected if it's not.

See #3673.

File:
1 edited

Legend:

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

    r7336 r7348  
    170170add_filter( 'page_template_hierarchy', __NAMESPACE__ . '\child_page_templates' );
    171171
     172/**
     173 * Filter page templates that require `$rosetta` to be available.
     174 *
     175 * @global Rosetta_Sites $rosetta
     176 *
     177 * @param array $post_templates Array of page templates. Keys are filenames,
     178 *                              values are translated names.
     179 */
     180function rosetta_page_templates( $post_templates ) {
     181    if ( empty( $GLOBALS['rosetta'] ) ) {
     182        unset( $post_templates['page-releases.php'] );
     183    }
     184
     185    return $post_templates;
     186}
     187add_filter( 'theme_page_templates', __NAMESPACE__ . '\rosetta_page_templates' );
     188
    172189function use_opengraph_data_for_embed_template() {
    173190    global $post;
Note: See TracChangeset for help on using the changeset viewer.