Ticket #30677: 30677.3.diff
| File 30677.3.diff, 4.0 KB (added by , 11 years ago) |
|---|
-
src/wp-admin/js/customize-controls.js
diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js index 1a088ca..ecc1167 100644
3219 3219 topFocus.focus(); 3220 3220 }, 200); 3221 3221 3222 // Change the preview URL for static pages 3223 $.each( [ 'page_on_front', 'page_for_posts' ], function ( i, controlId ) { 3224 api( controlId, function( control ) { 3225 control.bind( function( to ) { 3226 if ( isNaN( to ) ) { 3227 return false; 3228 } 3229 var x = parseFloat( to ); 3230 if ( (x | 0) === x && 0 < to ) { 3231 var request = wp.ajax.post( 'customize_' + controlId, { 3232 nonce: window._wpCustomizeControls.getPreviewUrlNonce, 3233 wp_customize: 'on', 3234 url: api.previewer.previewUrl(), 3235 id: to 3236 } ); 3237 request.done( function( data ) { 3238 api.previewer.previewUrl( data.url ); 3239 }); 3240 } 3241 }); 3242 }); 3243 }); 3244 3222 3245 }); 3223 3246 3224 3247 })( wp, jQuery ); -
src/wp-includes/class-wp-customize-manager.php
diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php index 7f778eb..1ba324f 100644
final class WP_Customize_Manager { 134 134 135 135 add_action( 'wp_ajax_customize_save', array( $this, 'save' ) ); 136 136 add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); 137 add_action( 'wp_ajax_customize_page_on_front', array( $this, 'page_on_front' ) ); 138 add_action( 'wp_ajax_customize_page_for_posts', array( $this, 'page_for_posts' ) ); 137 139 138 140 add_action( 'customize_register', array( $this, 'register_controls' ) ); 139 141 add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first … … final class WP_Customize_Manager { 852 854 } 853 855 854 856 /** 857 * Customizer AJAX response for page_on_front. 858 * 859 * @since 4.3.0 860 */ 861 public function page_on_front() { 862 $this->_send_preview_url( true ); 863 } 864 865 /** 866 * Customizer AJAX response for page_for_posts. 867 * 868 * @since 4.3.0 869 */ 870 public function page_for_posts() { 871 $this->_send_preview_url( false ); 872 } 873 874 /** 875 * Sends a JSON object back to the Customizer. 876 * 877 * Contains a success message with a preview URL, or an error message when it fails. 878 * 879 * @since 4.3.0 880 * 881 * @param bool $front True for the front page, false otherwise. 882 */ 883 protected function _send_preview_url( $front = true ) { 884 if ( ! $this->is_preview() ) { 885 wp_send_json_error( 'not_preview' ); 886 } 887 888 if ( ! check_ajax_referer( 'get-preview-url', 'nonce', false ) ) { 889 wp_send_json_error( 'invalid_nonce' ); 890 } 891 892 $id = absint( $_POST['id'] ); 893 if ( 1 > $id ) { 894 wp_send_json_error( 'invalid_id' ); 895 } 896 897 $current_url = esc_url( $_POST[ 'url' ] ); 898 $preview_url = esc_url( true === $front ? home_url( '/' ) : get_permalink( $id ) ); 899 900 if ( $current_url === $preview_url ) { 901 wp_send_json_error( 'same_url' ); 902 } 903 904 wp_send_json_success( array( 'url' => $preview_url ) ); 905 } 906 907 /** 855 908 * Add a customize setting. 856 909 * 857 910 * @since 3.4.0 -
src/wp-includes/script-loader.php
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php index 71e07f5..27d4816 100644
function wp_default_scripts( &$scripts ) { 402 402 // Used for overriding the file types allowed in plupload. 403 403 'allowedFiles' => __( 'Allowed Files' ), 404 404 ) ); 405 did_action( 'init' ) && $scripts->localize( 'customize-controls', '_wpCustomizeControls', array( 406 'getPreviewUrlNonce' => wp_create_nonce( 'get-preview-url' ), 407 ) ); 405 408 406 409 $scripts->add( 'customize-widgets', "/wp-admin/js/customize-widgets$suffix.js", array( 'jquery', 'jquery-ui-sortable', 'jquery-ui-droppable', 'wp-backbone', 'customize-controls' ), false, 1 ); 407 410 $scripts->add( 'customize-preview-widgets', "/wp-includes/js/customize-preview-widgets$suffix.js", array( 'jquery', 'wp-util', 'customize-preview' ), false, 1 );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)