WordPress.org

Make WordPress Core

Ticket #22856: 22856.3.diff

File 22856.3.diff, 1.5 KB (added by nacin, 6 months ago)
  • trunk/hotfix.php

     
    157157 
    158158function wp_hotfix_350_twentytwelve() { 
    159159        add_action( 'pre_http_request', 'wp_hotfix_350_twentytwelve_pre_http_request', 10, 3 ); 
     160        add_action( 'load-themes.php', 'wp_hotfix_350_twentytwelve_themes_php' ); 
     161        add_action( 'load-update-core.php', 'wp_hotfix_350_twentytwelve_update_core_php', 9 ); 
    160162} 
    161163 
     164function wp_hotfix_350_twentytwelve_update_core_php() { 
     165        if ( ! empty( $_GET['action'] ) ) 
     166                return; 
     167 
     168        $theme = wp_get_theme('twentytwelve'); 
     169        if ( ! $theme->exists() || ! $theme->errors() ) 
     170                return; 
     171 
     172        delete_site_transient( 'update_themes' ); 
     173} 
     174 
     175function wp_hotfix_350_twentytwelve_themes_php() { 
     176        $theme = wp_get_theme('twentytwelve'); 
     177        if ( ! $theme->exists() || ! $theme->errors() ) 
     178                return; 
     179 
     180        // Non-English installs weren't affected. Saves us the need to translate! 
     181        if ( 'en_US' != get_locale() ) 
     182                return; 
     183 
     184        if ( current_user_can( 'update_themes' ) ) 
     185                add_action( 'admin_notices', 'wp_hotfix_350_twentytwelve_notice' ); 
     186} 
     187 
     188function wp_hotfix_350_twentytwelve_notice() { 
     189        printf( '<div class="error"><p><strong>Looking for Twenty Twelve?</strong> You will need to first update it at <a href="%s">Dashboard &rarr; Updates</a>.</p></div>', 
     190                self_admin_url( 'update-core.php' ) ); 
     191} 
     192 
    162193function wp_hotfix_350_twentytwelve_pre_http_request( $return, $args, $url ) { 
    163194        if ( $url != 'http://api.wordpress.org/themes/update-check/1.0/' ) 
    164195                return $return;