Make WordPress Core

Changeset 31943


Ignore:
Timestamp:
03/31/2015 08:03:55 PM (10 years ago)
Author:
SergeyBiryukov
Message:

Themes: Add a filter to short-circuit wp_prepare_themes_for_js().

props mattwiebe, DrewAPicture.
fixes #31789.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/theme.php

    r31933 r31943  
    410410    $current_theme = get_stylesheet();
    411411
     412    /**
     413     * Filter theme data before it is prepared for JavaScript.
     414     *
     415     * Passing a non-empty array will result in wp_prepare_themes_for_js() returning
     416     * early with that value instead.
     417     *
     418     * @since 4.2.0
     419     *
     420     * @param array      $prepared_themes An associative array of theme data. Default empty array.
     421     * @param null|array $themes          An array of WP_Theme objects to prepare, if any.
     422     * @param string     $current_theme   The current theme slug.
     423     */
     424    $prepared_themes = (array) apply_filters( 'pre_wp_prepare_themes_for_js', array(), $themes, $current_theme );
     425
     426    if ( ! empty( $prepared_themes ) ) {
     427        return $prepared_themes;
     428    }
     429
    412430    // Make sure the current theme is listed first.
    413     $prepared_themes = array( $current_theme => array() );
     431    $prepared_themes[ $current_theme ] = array();
    414432
    415433    if ( null === $themes ) {
Note: See TracChangeset for help on using the changeset viewer.