WordPress.org

Make WordPress Core

Changeset 18655


Ignore:
Timestamp:
09/08/2011 08:07:15 PM (7 years ago)
Author:
azaozz
Message:

Make check_theme_switched() run an action so this enhancement is available to plugins and themes too, see #17979

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/default-filters.php

    r18630 r18655  
    220220add_action( 'wp_print_footer_scripts', '_wp_footer_scripts'                 );
    221221add_action( 'init',                'check_theme_switched',            99    );
     222add_action( 'after_theme_change',  '_wp_sidebars_changed'                   );
    222223
    223224if ( isset( $_GET['replytocom'] ) )
  • trunk/wp-includes/theme.php

    r18654 r18655  
    19941994add_action( 'delete_attachment', '_delete_attachment_theme_mod' );
    19951995
    1996 ?>
     1996/**
     1997 * Checks if a theme has been changed and runs 'after_theme_change' hook on the next WP load
     1998 *
     1999 * @since 3.3
     2000 */   
     2001function check_theme_switched() {
     2002    if ( false !== ( $old_theme = get_option( 'theme_switched' ) ) && !empty( $old_theme ) ) {
     2003        do_action( 'after_theme_change', $old_theme );     
     2004        update_option( 'theme_switched', false );
     2005    }
     2006}
  • trunk/wp-includes/widgets.php

    r18654 r18655  
    11951195}
    11961196
    1197 function check_theme_switched() {
    1198     if ( false !== ( $old_theme = get_option( 'theme_switched' ) ) && !empty( $old_theme ) ) {
    1199         global $sidebars_widgets;
    1200 
    1201         if ( ! is_array( $sidebars_widgets ) )
    1202             $sidebars_widgets = wp_get_sidebars_widgets();
    1203 
    1204         retrieve_widgets();
    1205         update_option( 'theme_switched', false );
    1206     }
     1197/**
     1198 * Handle sidebars config after theme change
     1199 *
     1200 * @access private
     1201 * @since 3.3
     1202 */ 
     1203function _wp_sidebars_changed() {
     1204    global $sidebars_widgets;
     1205
     1206    if ( ! is_array( $sidebars_widgets ) )
     1207        $sidebars_widgets = wp_get_sidebars_widgets();
     1208
     1209    retrieve_widgets();
    12071210}
    12081211
Note: See TracChangeset for help on using the changeset viewer.