| 1 | diff --git a/src/wp-admin/css/customize-controls.css b/src/wp-admin/css/customize-controls.css |
|---|
| 2 | index 1d69609..283e68a 100644 |
|---|
| 3 | --- a/src/wp-admin/css/customize-controls.css |
|---|
| 4 | +++ b/src/wp-admin/css/customize-controls.css |
|---|
| 5 | @@ -25,12 +25,17 @@ body { |
|---|
| 6 | |
|---|
| 7 | #customize-header-actions .button-primary { |
|---|
| 8 | float: right; |
|---|
| 9 | + position: relative; |
|---|
| 10 | + top: 0; |
|---|
| 11 | margin-top: 9px; |
|---|
| 12 | + margin-right: 15px; |
|---|
| 13 | } |
|---|
| 14 | |
|---|
| 15 | #customize-header-actions .spinner { |
|---|
| 16 | margin-top: 13px; |
|---|
| 17 | margin-right: 4px; |
|---|
| 18 | + position: relative; |
|---|
| 19 | + top: -45px; |
|---|
| 20 | } |
|---|
| 21 | |
|---|
| 22 | .saving #customize-header-actions .spinner { |
|---|
| 23 | @@ -39,6 +44,16 @@ body { |
|---|
| 24 | |
|---|
| 25 | #customize-header-actions { |
|---|
| 26 | border-bottom: 1px solid #ddd; |
|---|
| 27 | + padding-top: 0; |
|---|
| 28 | +} |
|---|
| 29 | + |
|---|
| 30 | +#customize-header-actions .notice { |
|---|
| 31 | + margin-top: 46px; |
|---|
| 32 | + margin-bottom: 1px; |
|---|
| 33 | +} |
|---|
| 34 | + |
|---|
| 35 | +#customize-header-actions .notice + .notice { |
|---|
| 36 | + margin-top: 0; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | #customize-controls .wp-full-overlay-sidebar-content { |
|---|
| 40 | diff --git a/src/wp-admin/css/themes.css b/src/wp-admin/css/themes.css |
|---|
| 41 | index 988db99..6b6ef59 100644 |
|---|
| 42 | --- a/src/wp-admin/css/themes.css |
|---|
| 43 | +++ b/src/wp-admin/css/themes.css |
|---|
| 44 | @@ -1285,7 +1285,7 @@ body.full-overlay-active { |
|---|
| 45 | left: 0; |
|---|
| 46 | right: 0; |
|---|
| 47 | height: 45px; |
|---|
| 48 | - padding: 0 15px; |
|---|
| 49 | + padding: 0; |
|---|
| 50 | line-height: 45px; |
|---|
| 51 | z-index: 10; |
|---|
| 52 | margin: 0; |
|---|
| 53 | diff --git a/src/wp-admin/customize.php b/src/wp-admin/customize.php |
|---|
| 54 | index 7f667d3..0591f6b 100644 |
|---|
| 55 | --- a/src/wp-admin/customize.php |
|---|
| 56 | +++ b/src/wp-admin/customize.php |
|---|
| 57 | @@ -53,6 +53,7 @@ add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 |
|---|
| 58 | do_action( 'customize_controls_init' ); |
|---|
| 59 | |
|---|
| 60 | wp_enqueue_script( 'customize-controls' ); |
|---|
| 61 | +wp_enqueue_script( 'common' ); |
|---|
| 62 | wp_enqueue_style( 'customize-controls' ); |
|---|
| 63 | |
|---|
| 64 | /** |
|---|
| 65 | diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js |
|---|
| 66 | index a22aa76..4426be1 100644 |
|---|
| 67 | --- a/src/wp-admin/js/customize-controls.js |
|---|
| 68 | +++ b/src/wp-admin/js/customize-controls.js |
|---|
| 69 | @@ -3355,11 +3355,19 @@ |
|---|
| 70 | self.save(); |
|---|
| 71 | self.preview.iframe.show(); |
|---|
| 72 | } ); |
|---|
| 73 | + } else if( response && response.error_code != undefined ){ |
|---|
| 74 | + // inject the error notification div |
|---|
| 75 | + var template = wp.template('error-notification'); |
|---|
| 76 | + $( '#customize-header-actions' ).append( template( response ) ); |
|---|
| 77 | + |
|---|
| 78 | + // trigger the event that make notices dismissible |
|---|
| 79 | + $(document).trigger( 'wp-plugin-update-error' ); |
|---|
| 80 | } |
|---|
| 81 | api.trigger( 'error', response ); |
|---|
| 82 | } ); |
|---|
| 83 | |
|---|
| 84 | request.done( function( response ) { |
|---|
| 85 | // Clear setting dirty states |
|---|
| 86 | api.each( function ( value ) { |
|---|
| 87 | value._dirty = false; |
|---|
| 88 | diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php |
|---|
| 89 | index ea30b93..714d3cf 100644 |
|---|
| 90 | --- a/src/wp-includes/class-wp-customize-manager.php |
|---|
| 91 | +++ b/src/wp-includes/class-wp-customize-manager.php |
|---|
| 92 | @@ -301,6 +301,7 @@ final class WP_Customize_Manager { |
|---|
| 93 | add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_panel_templates' ), 1 ); |
|---|
| 94 | add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_section_templates' ), 1 ); |
|---|
| 95 | add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_control_templates' ), 1 ); |
|---|
| 96 | + add_action( 'customize_controls_print_footer_scripts', array( $this, 'render_error_notification_templates' ), 1 ); |
|---|
| 97 | |
|---|
| 98 | // Export the settings to JS via the _wpCustomizeSettings variable. |
|---|
| 99 | add_action( 'customize_controls_print_footer_scripts', array( $this, 'customize_pane_settings' ), 1000 ); |
|---|
| 100 | @@ -2181,6 +2182,32 @@ final class WP_Customize_Manager { |
|---|
| 101 | 'type' => 'dropdown-pages', |
|---|
| 102 | ) ); |
|---|
| 103 | } |
|---|
| 104 | + |
|---|
| 105 | + // This is only for demonstration purpose |
|---|
| 106 | + $this->add_section( 'test-errors', array( |
|---|
| 107 | + 'title' => __( 'Test error notification' ), |
|---|
| 108 | + 'priority' => 10, |
|---|
| 109 | + ) ); |
|---|
| 110 | + $this->add_setting( 'test_errors_trigger', array( |
|---|
| 111 | + 'type' => 'option', |
|---|
| 112 | + 'transport' => 'postMessage', |
|---|
| 113 | + ) ); |
|---|
| 114 | + $this->add_control( 'test_errors_trigger', array( |
|---|
| 115 | + 'label' => __( 'Enter a message to trigger an error' ), |
|---|
| 116 | + 'setting' => 'test_errors_trigger', |
|---|
| 117 | + 'section' => 'test-errors', |
|---|
| 118 | + ) ); |
|---|
| 119 | + |
|---|
| 120 | + add_filter( 'pre_update_option_test_errors_trigger', function($value){ |
|---|
| 121 | + // if an error message has been entered, trigger the test error |
|---|
| 122 | + if( trim($value) != '' ){ |
|---|
| 123 | + wp_send_json_error( array( |
|---|
| 124 | + 'error_code' => 'test-error-code', |
|---|
| 125 | + 'error_message' => $value, |
|---|
| 126 | + ) ); |
|---|
| 127 | + } |
|---|
| 128 | + return $value; |
|---|
| 129 | + }); |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | /** |
|---|
| 133 | @@ -2236,6 +2263,17 @@ final class WP_Customize_Manager { |
|---|
| 134 | public function _render_custom_logo_partial() { |
|---|
| 135 | return get_custom_logo(); |
|---|
| 136 | } |
|---|
| 137 | + |
|---|
| 138 | + public function render_error_notification_templates(){ |
|---|
| 139 | + ?><script type="text/html" id="tmpl-error-notification"> |
|---|
| 140 | + <div class="notice is-dismissible error {{ data.error_code }}"> |
|---|
| 141 | + <p>{{ data.error_message }}</p> |
|---|
| 142 | + <button type="button" class="notice-dismiss"> |
|---|
| 143 | + <span class="screen-reader-text"><?php _e( 'Dismiss this notice' ); ?>.</span> |
|---|
| 144 | + </button> |
|---|
| 145 | + </div> |
|---|
| 146 | + </script><?php |
|---|
| 147 | + } |
|---|
| 148 | } |
|---|
| 149 | |
|---|
| 150 | /** |
|---|
| 151 | -- |
|---|
| 152 | 2.2.2 |
|---|
| 153 | |
|---|