Make WordPress Core

Ticket #35210: 35210.3.patch

File 35210.3.patch, 4.8 KB (added by Fab1en, 9 years ago)

[fix] Avoid using anonymous PHP function

  • src/wp-admin/css/customize-controls.css

    diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css
    index 36e512a..f442694 100644
    a b body { 
    2525
    2626#customize-header-actions .button-primary {
    2727        float: right;
     28        position: relative;
     29        top: 0;
    2830        margin-top: 9px;
     31        margin-right: 15px;
    2932}
    3033
    3134#customize-header-actions .spinner {
    3235        margin-top: 13px;
    3336        margin-right: 4px;
     37        position: relative;
     38        top: -45px;
    3439}
    3540
    3641.saving #customize-header-actions .spinner {
    body { 
    3944
    4045#customize-header-actions {
    4146        border-bottom: 1px solid #ddd;
     47        padding-top: 0;
     48}
     49
     50#customize-header-actions .notice {
     51        margin-top: 46px;
     52        margin-bottom: 1px;
     53}
     54
     55#customize-header-actions .notice + .notice {
     56        margin-top: 0;
    4257}
    4358
    4459#customize-controls .wp-full-overlay-sidebar-content {
  • src/wp-admin/css/themes.css

    diff --git a/src/wp-admin/css/themes.css b/src/wp-admin/css/themes.css
    index 988db99..6b6ef59 100644
    a b body.full-overlay-active { 
    12851285        left: 0;
    12861286        right: 0;
    12871287        height: 45px;
    1288         padding: 0 15px;
     1288        padding: 0;
    12891289        line-height: 45px;
    12901290        z-index: 10;
    12911291        margin: 0;
  • src/wp-admin/customize.php

    diff --git a/src/wp-admin/customize.php b/src/wp-admin/customize.php
    index 7f667d3..0591f6b 100644
    a b add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 
    5353do_action( 'customize_controls_init' );
    5454
    5555wp_enqueue_script( 'customize-controls' );
     56wp_enqueue_script( 'common' );
    5657wp_enqueue_style( 'customize-controls' );
    5758
    5859/**
  • src/wp-admin/js/customize-controls.js

    diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js
    index a22aa76..eaf1d71 100644
    a b  
    33553355                                                                self.save();
    33563356                                                                self.preview.iframe.show();
    33573357                                                        } );
     3358                                                } else if( response && response.error_code != undefined ){
     3359                                                        // inject the error notification div
     3360                                                        var template = wp.template('error-notification');
     3361                                                        $( '#customize-header-actions' ).append( template( response ) );
     3362
     3363                                                        // trigger the event that make notices dismissible
     3364                                                        $(document).trigger( 'wp-plugin-update-error' );
    33583365                                                }
    33593366                                                api.trigger( 'error', response );
    33603367                                        } );
  • src/wp-includes/class-wp-customize-manager.php

    diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php
    index 8057e57..e0ec43c 100644
    a b final class WP_Customize_Manager { 
    299299                add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_panel_templates' ), 1 );
    300300                add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_section_templates' ), 1 );
    301301                add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_control_templates' ), 1 );
     302                add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_error_notification_templates' ), 1 );
    302303
    303304                // Export the settings to JS via the _wpCustomizeSettings variable.
    304305                add_action( 'customize_controls_print_footer_scripts', array( $this, 'customize_pane_settings' ), 1000 );
    final class WP_Customize_Manager { 
    21802181                                'type'       => 'dropdown-pages',
    21812182                        ) );
    21822183                }
     2184
     2185                // This is only for demonstration purpose
     2186                $this->add_section( 'test-errors', array(
     2187                        'title'          => __( 'Test error notification' ),
     2188                        'priority'       => 10,
     2189                ) );
     2190                $this->add_setting( 'test_errors_trigger', array(
     2191                        'type'          => 'option',
     2192                        'transport'     => 'postMessage',
     2193                ) );
     2194                $this->add_control( 'test_errors_trigger', array(
     2195                        'label'    => __( 'Enter a message to trigger an error' ),
     2196                        'setting'  => 'test_errors_trigger',
     2197                        'section'  => 'test-errors',
     2198                ) );
     2199
     2200                add_filter( 'pre_update_option_test_errors_trigger', array( $this, 'send_test_error' ) );
     2201        }
     2202
     2203        public function send_test_error( $value ){
     2204                // if an error message has been entered, trigger the test error
     2205                if( trim($value) != '' ){
     2206                        wp_send_json_error( array(
     2207                                'error_code' => 'test-error-code',
     2208                                'error_message' => $value,
     2209                        ) );
     2210                }
     2211                return $value;
    21832212        }
    21842213
    21852214        /**
    final class WP_Customize_Manager { 
    22352264        public function _render_custom_logo_partial() {
    22362265                return get_custom_logo();
    22372266        }
     2267       
     2268        public function render_error_notification_templates(){
     2269                ?><script type="text/html" id="tmpl-error-notification">
     2270                        <div class="notice is-dismissible error {{ data.error_code }}">
     2271                                <p>{{ data.error_message }}</p>
     2272                                <button type="button" class="notice-dismiss">
     2273                                        <span class="screen-reader-text"><?php _e( 'Dismiss this notice' ); ?>.</span>
     2274                                </button>
     2275                        </div>
     2276                </script><?php
     2277        }
    22382278}
    22392279
    22402280/**