Changeset 34269 for trunk/src/wp-admin/customize.php
- Timestamp:
- 09/17/2015 07:41:35 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/customize.php
r34093 r34269 21 21 } 22 22 23 wp_reset_vars( array( 'url', 'return' ) ); 24 $url = wp_unslash( $url ); 25 $url = wp_validate_redirect( $url, home_url( '/' ) ); 26 if ( $return ) { 27 $return = wp_unslash( $return ); 28 $return = remove_query_arg( wp_removable_query_args(), $return ); 29 $return = wp_validate_redirect( $return ); 23 wp_reset_vars( array( 'url', 'return', 'autofocus' ) ); 24 if ( ! empty( $url ) ) { 25 $wp_customize->set_preview_url( wp_unslash( $url ) ); 30 26 } 31 if ( ! $return ) { 32 if ( $url ) { 33 $return = $url; 34 } elseif ( current_user_can( 'edit_theme_options' ) || current_user_can( 'switch_themes' ) ) { 35 $return = admin_url( 'themes.php' ); 36 } else { 37 $return = admin_url(); 38 } 27 if ( ! empty( $return ) ) { 28 $wp_customize->set_return_url( wp_unslash( $return ) ); 29 } 30 if ( ! empty( $autofocus ) && is_array( $autofocus ) ) { 31 $wp_customize->set_autofocus( wp_unslash( $autofocus ) ); 39 32 } 40 33 … … 84 77 endif; 85 78 86 $is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] ); 87 88 if ( $is_ios ) { 79 if ( $wp_customize->is_ios() ) { 89 80 $body_class .= ' ios'; 90 81 } … … 95 86 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) ); 96 87 97 if ( $wp_customize->is_theme_active() ) { 98 $document_title_tmpl = _x( 'Customize: %s', 'Placeholder is the document title from the preview' ); 99 } else { 100 $document_title_tmpl = _x( 'Live Preview: %s', 'Placeholder is the document title from the preview' ); 101 } 102 $document_title_tmpl = html_entity_decode( $document_title_tmpl, ENT_QUOTES, 'UTF-8' ); // because exported to JS and assigned to document.title 103 $admin_title = sprintf( $document_title_tmpl, __( 'Loading…' ) ); 88 $admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading…' ) ); 104 89 105 90 ?><title><?php echo $admin_title; ?></title> 106 91 107 92 <script type="text/javascript"> 108 var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>';93 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>; 109 94 </script> 110 95 … … 138 123 <span class="preview"><?php _e( 'Preview' ); ?></span> 139 124 </a> 140 <a class="customize-controls-close" href="<?php echo esc_url( $ return); ?>">125 <a class="customize-controls-close" href="<?php echo esc_url( $wp_customize->get_return_url() ); ?>"> 141 126 <span class="screen-reader-text"><?php _e( 'Cancel' ); ?></span> 142 127 </a> … … 173 158 <?php 174 159 175 // Render Panel, Section, and Control templates.176 $wp_customize->render_panel_templates();177 $wp_customize->render_section_templates();178 $wp_customize->render_control_templates();179 180 160 /** 181 * Print Customizer control scripts in the footer.161 * Print templates, control scripts, and settings in the footer. 182 162 * 183 163 * @since 3.4.0 184 164 */ 185 165 do_action( 'customize_controls_print_footer_scripts' ); 186 187 /*188 * If the frontend and the admin are served from the same domain, load the189 * preview over ssl if the Customizer is being loaded over ssl. This avoids190 * insecure content warnings. This is not attempted if the admin and frontend191 * are on different domains to avoid the case where the frontend doesn't have192 * ssl certs. Domain mapping plugins can allow other urls in these conditions193 * using the customize_allowed_urls filter.194 */195 196 $allowed_urls = array( home_url('/') );197 $admin_origin = parse_url( admin_url() );198 $home_origin = parse_url( home_url() );199 $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );200 201 if ( is_ssl() && ! $cross_domain )202 $allowed_urls[] = home_url( '/', 'https' );203 204 /**205 * Filter the list of URLs allowed to be clicked and followed in the Customizer preview.206 *207 * @since 3.4.0208 *209 * @param array $allowed_urls An array of allowed URLs.210 */211 $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );212 213 $login_url = add_query_arg( array(214 'interim-login' => 1,215 'customize-login' => 1216 ), wp_login_url() );217 218 // Prepare Customizer settings to pass to JavaScript.219 $settings = array(220 'theme' => array(221 'stylesheet' => $wp_customize->get_stylesheet(),222 'active' => $wp_customize->is_theme_active(),223 ),224 'url' => array(225 'preview' => esc_url_raw( $url ? $url : home_url( '/' ) ),226 'parent' => esc_url_raw( admin_url() ),227 'activated' => esc_url_raw( home_url( '/' ) ),228 'ajax' => esc_url_raw( admin_url( 'admin-ajax.php', 'relative' ) ),229 'allowed' => array_map( 'esc_url_raw', $allowed_urls ),230 'isCrossDomain' => $cross_domain,231 'home' => esc_url_raw( home_url( '/' ) ),232 'login' => esc_url_raw( $login_url ),233 ),234 'browser' => array(235 'mobile' => wp_is_mobile(),236 'ios' => $is_ios,237 ),238 'settings' => array(),239 'controls' => array(),240 'panels' => array(),241 'sections' => array(),242 'nonce' => array(243 'save' => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),244 'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )245 ),246 'autofocus' => array(),247 'documentTitleTmpl' => $document_title_tmpl,248 );249 250 // Prepare Customize Setting objects to pass to JavaScript.251 foreach ( $wp_customize->settings() as $id => $setting ) {252 if ( $setting->check_capabilities() ) {253 $settings['settings'][ $id ] = array(254 'value' => $setting->js_value(),255 'transport' => $setting->transport,256 'dirty' => $setting->dirty,257 );258 }259 }260 261 // Prepare Customize Control objects to pass to JavaScript.262 foreach ( $wp_customize->controls() as $id => $control ) {263 if ( $control->check_capabilities() ) {264 $settings['controls'][ $id ] = $control->json();265 }266 }267 268 // Prepare Customize Section objects to pass to JavaScript.269 foreach ( $wp_customize->sections() as $id => $section ) {270 if ( $section->check_capabilities() ) {271 $settings['sections'][ $id ] = $section->json();272 }273 }274 275 // Prepare Customize Panel objects to pass to JavaScript.276 foreach ( $wp_customize->panels() as $panel_id => $panel ) {277 if ( $panel->check_capabilities() ) {278 $settings['panels'][ $panel_id ] = $panel->json();279 foreach ( $panel->sections as $section_id => $section ) {280 if ( $section->check_capabilities() ) {281 $settings['sections'][ $section_id ] = $section->json();282 }283 }284 }285 }286 287 // Pass to frontend the Customizer construct being deeplinked288 if ( isset( $_GET['autofocus'] ) ) {289 $autofocus = wp_unslash( $_GET['autofocus'] );290 if ( is_array( $autofocus ) ) {291 foreach ( $autofocus as $type => $id ) {292 if ( isset( $settings[ $type . 's' ][ $id ] ) ) {293 $settings['autofocus'][ $type ] = $id;294 }295 }296 }297 }298 299 166 ?> 300 <script type="text/javascript">301 var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;302 </script>303 167 </div> 304 168 </body>
Note: See TracChangeset
for help on using the changeset viewer.