Changeset 41797
- Timestamp:
- 10/09/2017 04:03:35 PM (7 years ago)
- Location:
- trunk/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/themes.css
r41667 r41797 7 7 16.1 - Manage Themes 8 8 ------------------------------------------------------------------------------*/ 9 10 body.js .theme-browser.search-loading { 11 display: none; 12 } 9 13 10 14 .theme-browser .themes { -
trunk/src/wp-admin/includes/class-theme-installer-skin.php
r41161 r41797 65 65 66 66 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 67 $install_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; 67 $customize_url = add_query_arg( 68 array( 69 'theme' => urlencode( $stylesheet ), 70 'return' => urlencode( admin_url( 'web' === $this->type ? 'theme-install.php' : 'themes.php' ) ), 71 ), 72 admin_url( 'customize.php' ) 73 ); 74 $install_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; 68 75 } 69 76 $install_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; -
trunk/src/wp-admin/includes/class-theme-upgrader-skin.php
r41161 r41797 50 50 $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); 51 51 52 $customize_url = add_query_arg( 53 array( 54 'theme' => urlencode( $stylesheet ), 55 'return' => urlencode( admin_url( 'themes.php' ) ), 56 ), 57 admin_url( 'customize.php' ) 58 ); 52 59 if ( get_stylesheet() == $stylesheet ) { 53 60 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 54 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>';61 $update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Customize' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Customize “%s”' ), $name ) . '</span></a>'; 55 62 } 56 63 } elseif ( current_user_can( 'switch_themes' ) ) { 57 64 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { 58 $update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>';65 $update_actions['preview'] = '<a href="' . esc_url( $customize_url ) . '" class="hide-if-no-customize load-customize"><span aria-hidden="true">' . __( 'Live Preview' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Live Preview “%s”' ), $name ) . '</span></a>'; 59 66 } 60 67 $update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink"><span aria-hidden="true">' . __( 'Activate' ) . '</span><span class="screen-reader-text">' . sprintf( __( 'Activate “%s”' ), $name ) . '</span></a>'; -
trunk/src/wp-admin/index.php
r40776 r41797 17 17 wp_enqueue_script( 'dashboard' ); 18 18 19 if ( current_user_can( 'edit_theme_options' ) )20 wp_enqueue_script( 'customize-loader' );21 19 if ( current_user_can( 'install_plugins' ) ) { 22 20 wp_enqueue_script( 'plugin-install' ); -
trunk/src/wp-admin/js/customize-controls.js
r41788 r41797 107 107 * @since 4.9.0 108 108 * 109 * @param {string|wp.customize.Notification} - Notification object to add. Alternatively code may be supplied, and in that case the second notificationObject argument must be supplied.109 * @param {string|wp.customize.Notification} notification - Notification object to add. Alternatively code may be supplied, and in that case the second notificationObject argument must be supplied. 110 110 * @param {wp.customize.Notification} [notificationObject] - Notification to add when first argument is the code string. 111 111 * @returns {wp.customize.Notification} Added notification (or existing instance if it was already added). … … 3015 3015 { 3016 3016 theme: themeId, 3017 changeset_uuid: api.settings.changeset.uuid 3017 changeset_uuid: api.settings.changeset.uuid, 3018 'return': api.settings.url['return'] 3018 3019 } 3019 3020 ); … … 3045 3046 deferred.resolve(); 3046 3047 $( window ).off( 'beforeunload.customize-confirm' ); 3047 window.location.href = urlParser.href; // @todo Use location.replace()?3048 location.replace( urlParser.href ); 3048 3049 } ); 3049 3050 request.fail( function() { … … 6959 6960 api.settings.changeset.uuid = response.next_changeset_uuid; 6960 6961 api.state( 'changesetStatus' ).set( '' ); 6961 parent.send( 'changeset-uuid', api.settings.changeset.uuid ); 6962 if ( api.settings.changeset.branching ) { 6963 parent.send( 'changeset-uuid', api.settings.changeset.uuid ); 6964 } 6962 6965 api.previewer.send( 'changeset-uuid', api.settings.changeset.uuid ); 6963 6966 } … … 6990 6993 api.state( 'changesetStatus' ).set( '' ); 6991 6994 api.settings.changeset.uuid = response.next_changeset_uuid; 6992 parent.send( 'changeset-uuid', api.settings.changeset.uuid ); 6995 if ( api.settings.changeset.branching ) { 6996 parent.send( 'changeset-uuid', api.settings.changeset.uuid ); 6997 } 6993 6998 } 6994 6999 … … 7066 7071 queryParams = api.utils.parseQueryString( urlParser.search.substr( 1 ) ); 7067 7072 delete queryParams.changeset_uuid; 7073 queryParams['return'] = api.settings.url['return']; 7068 7074 urlParser.search = $.param( queryParams ); 7069 7075 location.replace( urlParser.href ); … … 7419 7425 queryParams.customize_autosaved = 'on'; 7420 7426 } 7427 queryParams['return'] = api.settings.url['return']; 7421 7428 urlParser.search = $.param( queryParams ); 7422 7429 return urlParser.href; … … 7916 7923 api.bind( 'change', startPromptingBeforeUnload ); 7917 7924 7918 closeBtn.on( 'click.customize-controls-close', function( event) {7925 function requestClose() { 7919 7926 var clearedToClose = $.Deferred(); 7920 event.preventDefault(); 7921 7922 /* 7923 * The isInsideIframe condition is because Customizer is not able to use a confirm() 7924 * since customize-loader.js will also use one. So autosave restorations are disabled 7925 * when customize-loader.js is used. 7926 */ 7927 if ( isInsideIframe || isCleanState() ) { 7927 if ( isCleanState() ) { 7928 7928 clearedToClose.resolve(); 7929 7929 } else if ( confirm( api.l10n.saveAlert ) ) { … … 7955 7955 clearedToClose.reject(); 7956 7956 } 7957 7958 clearedToClose.done( function() { 7959 $( window ).off( 'beforeunload.customize-confirm' ); 7960 if ( isInsideIframe ) { 7961 parent.send( 'close' ); 7962 } else { 7957 return clearedToClose.promise(); 7958 } 7959 7960 parent.bind( 'confirm-close', function() { 7961 requestClose().done( function() { 7962 parent.send( 'confirmed-close', true ); 7963 } ).fail( function() { 7964 parent.send( 'confirmed-close', false ); 7965 } ); 7966 } ); 7967 7968 closeBtn.on( 'click.customize-controls-close', function( event ) { 7969 event.preventDefault(); 7970 if ( isInsideIframe ) { 7971 parent.send( 'close' ); // See confirm-close logic above. 7972 } else { 7973 requestClose().done( function() { 7974 $( window ).off( 'beforeunload.customize-confirm' ); 7963 7975 window.location.href = closeBtn.prop( 'href' ); 7964 } 7965 } );7976 } ); 7977 } 7966 7978 }); 7967 7979 })(); … … 7979 7991 }); 7980 7992 7981 parent.send( 'changeset-uuid', api.settings.changeset.uuid ); 7993 if ( api.settings.changeset.branching ) { 7994 parent.send( 'changeset-uuid', api.settings.changeset.uuid ); 7995 } 7982 7996 7983 7997 // Initialize the connection with the parent frame. -
trunk/src/wp-admin/js/theme.js
r41683 r41797 77 77 // Render search form. 78 78 this.search(); 79 80 this.$el.removeClass( 'search-loading' ); 79 81 80 82 // Render and append … … 1346 1348 } 1347 1349 1348 /** 1349 * Since doSearch is debounced, it will only run when user input comes to a rest 1350 */ 1350 // Note that doSearch is throttled. 1351 1351 this.doSearch( event ); 1352 1352 }, 1353 1353 1354 1354 // Runs a search on the theme collection. 1355 doSearch: _. debounce( function( event ) {1355 doSearch: _.throttle( function( event ) { 1356 1356 var options = {}; 1357 1357 1358 this.collection.doSearch( event.target.value );1358 this.collection.doSearch( event.target.value.replace( /\+/g, ' ' ) ); 1359 1359 1360 1360 // if search is initiated and key is not return … … 1377 1377 1378 1378 if ( event.target.value ) { 1379 url = themes.router.baseUrl( themes.router.searchPath + e vent.target.value);1379 url = themes.router.baseUrl( themes.router.searchPath + encodeURIComponent( event.target.value ) ); 1380 1380 } 1381 1381 … … 1385 1385 } 1386 1386 }); 1387 1388 /** 1389 * Navigate router. 1390 * 1391 * @since 4.9.0 1392 * 1393 * @param {string} url - URL to navigate to. 1394 * @param {object} state - State. 1395 * @returns {void} 1396 */ 1397 function navigateRouter( url, state ) { 1398 var router = this; 1399 if ( Backbone.history._hasPushState ) { 1400 Backbone.Router.prototype.navigate.call( router, url, state ); 1401 } 1402 } 1387 1403 1388 1404 // Sets up the routes events for relevant url queries … … 1406 1422 1407 1423 search: function( query ) { 1408 $( '.wp-filter-search' ).val( query );1424 $( '.wp-filter-search' ).val( query.replace( /\+/g, ' ' ) ); 1409 1425 }, 1410 1426 … … 1413 1429 }, 1414 1430 1415 navigate: function() { 1416 if ( Backbone.history._hasPushState ) { 1417 Backbone.Router.prototype.navigate.apply( this, arguments ); 1418 } 1419 } 1431 navigate: navigateRouter 1420 1432 1421 1433 }); … … 1509 1521 }, 1510 1522 1511 doSearch: _. debounce( function( value ) {1523 doSearch: _.throttle( function( value ) { 1512 1524 var request = {}; 1513 1525 … … 1552 1564 1553 1565 // Set route 1554 themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + value), { replace: true } );1566 themes.router.navigate( themes.router.baseUrl( themes.router.searchPath + encodeURIComponent( value ) ), { replace: true } ); 1555 1567 }, 500 ) 1556 1568 }); … … 1888 1900 1889 1901 search: function( query ) { 1890 $( '.wp-filter-search' ).val( query ); 1891 }, 1892 1893 navigate: function() { 1894 if ( Backbone.history._hasPushState ) { 1895 Backbone.Router.prototype.navigate.apply( this, arguments ); 1896 } 1897 } 1902 $( '.wp-filter-search' ).val( query.replace( /\+/g, ' ' ) ); 1903 }, 1904 1905 navigate: navigateRouter 1898 1906 }); 1899 1907 … … 2003 2011 themes.Run.init(); 2004 2012 } 2013 2014 // Update the return param just in time. 2015 $( document.body ).on( 'click', '.load-customize', function() { 2016 var link = $( this ), urlParser = document.createElement( 'a' ); 2017 urlParser.href = link.prop( 'href' ); 2018 urlParser.search = $.param( _.extend( 2019 wp.customize.utils.parseQueryString( urlParser.search.substr( 1 ) ), 2020 { 2021 'return': window.location.href 2022 } 2023 ) ); 2024 link.prop( 'href', urlParser.href ); 2025 }); 2005 2026 2006 2027 $( '.broken-themes .delete-theme' ).on( 'click', function() { -
trunk/src/wp-admin/themes.php
r41658 r41797 147 147 wp_enqueue_script( 'theme' ); 148 148 wp_enqueue_script( 'updates' ); 149 wp_enqueue_script( 'customize-loader' );150 149 151 150 require_once( ABSPATH . 'wp-admin/admin-header.php' ); … … 154 153 <div class="wrap"> 155 154 <h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?> 156 <span class="title-count theme-count"><?php echo count( $themes ); ?></span>155 <span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '…' ) : count( $themes ); ?></span> 157 156 </h1> 158 157 … … 235 234 ?> 236 235 237 <div class="theme-browser"> 236 <?php 237 $class_name = 'theme-browser'; 238 if ( ! empty( $_GET['search'] ) ) { 239 $class_name .= ' search-loading'; 240 } 241 ?> 242 <div class="<?php echo esc_attr( $class_name ); ?>"> 238 243 <div class="themes wp-clearfix"> 239 244 -
trunk/src/wp-admin/update.php
r41289 r41797 174 174 check_admin_referer('upgrade-theme_' . $theme); 175 175 176 wp_enqueue_script( 'customize-loader' );177 176 wp_enqueue_script( 'updates' ); 178 177 … … 224 223 $api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth. 225 224 226 if ( is_wp_error($api) ) 227 wp_die($api); 228 229 wp_enqueue_script( 'customize-loader' ); 225 if ( is_wp_error( $api ) ) { 226 wp_die( $api ); 227 } 230 228 231 229 $title = __('Install Themes'); … … 253 251 254 252 $file_upload = new File_Upload_Upgrader('themezip', 'package'); 255 256 wp_enqueue_script( 'customize-loader' );257 253 258 254 $title = __('Upload Theme'); -
trunk/src/wp-includes/class-wp-customize-manager.php
r41793 r41797 4237 4237 'url' => array( 4238 4238 'preview' => esc_url_raw( $this->get_preview_url() ), 4239 'return' => esc_url_raw( $this->get_return_url() ), 4239 4240 'parent' => esc_url_raw( admin_url() ), 4240 4241 'activated' => esc_url_raw( home_url( '/' ) ), -
trunk/src/wp-includes/js/customize-loader.js
r41351 r41797 1 /* global _wpCustomizeLoaderSettings , confirm*/1 /* global _wpCustomizeLoaderSettings */ 2 2 /** 3 3 * Expose a public API that allows the customizer to be … … 209 209 */ 210 210 close: function() { 211 if ( ! this.active ) { 211 var self = this, onConfirmClose; 212 if ( ! self.active ) { 212 213 return; 213 214 } 214 215 215 // Display AYS dialog if Customizer is dirty 216 if ( ! this.saved() && ! confirm( Loader.settings.l10n.saveAlert ) ) { 217 // Go forward since Customizer is exited by history.back() 218 history.forward(); 219 return; 220 } 221 222 this.active = false; 223 224 this.trigger( 'close' ); 225 226 // Restore document title prior to opening the Live Preview 227 if ( this.originalDocumentTitle ) { 228 document.title = this.originalDocumentTitle; 229 } 216 onConfirmClose = function( confirmed ) { 217 if ( confirmed ) { 218 self.active = false; 219 self.trigger( 'close' ); 220 221 // Restore document title prior to opening the Live Preview 222 if ( self.originalDocumentTitle ) { 223 document.title = self.originalDocumentTitle; 224 } 225 } else { 226 227 // Go forward since Customizer is exited by history.back() 228 history.forward(); 229 } 230 self.messenger.unbind( 'confirmed-close', onConfirmClose ); 231 }; 232 self.messenger.bind( 'confirmed-close', onConfirmClose ); 233 234 Loader.messenger.send( 'confirm-close' ); 230 235 }, 231 236 -
trunk/src/wp-includes/script-loader.php
r41791 r41797 726 726 $scripts->add( 'custom-html-widgets', "/wp-admin/js/widgets/custom-html-widgets$suffix.js", array( 'code-editor', 'jquery', 'backbone', 'wp-util', 'jquery-ui-core', 'wp-a11y' ) ); 727 727 728 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 );728 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y', 'customize-base' ), false, 1 ); 729 729 730 730 $scripts->add( 'inline-edit-post', "/wp-admin/js/inline-edit-post$suffix.js", array( 'jquery', 'tags-suggest', 'wp-a11y' ), false, 1 );
Note: See TracChangeset
for help on using the changeset viewer.