Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 204 lines (169 sloc) 6.871 kB
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
1 <?php
2 /**
3 * Customize Controls
4 *
5 * @package WordPress
6 * @subpackage Customize
7 * @since 3.4.0
8 */
9
6911251 Refresh nonces in the customizer. props koopersmith. see #20876.
nacin authored
10 define( 'IFRAME_REQUEST', true );
11
95e1c32 Customize API shuffling.
nacin authored
12 require_once( './admin.php' );
13 if ( ! current_user_can( 'edit_theme_options' ) )
397fc6f Refine early bailing checks in customize.php. see #20852.
nacin authored
14 wp_die( __( 'Cheatin&#8217; uh?' ) );
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
15
69ad7a6 Customizer: Redirect back to referrer. If referrer is a front end pag…
ryan authored
16 wp_reset_vars( array( 'url', 'return' ) );
17 $url = urldecode( $url );
18 $url = wp_validate_redirect( $url, home_url( '/' ) );
19 if ( $return )
20 $return = wp_validate_redirect( urldecode( $return ) );
21 if ( ! $return )
22 $return = $url;
23
95e1c32 Customize API shuffling.
nacin authored
24 global $wp_scripts, $wp_customize;
25
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
26 $registered = $wp_scripts->registered;
27 $wp_scripts = new WP_Scripts;
28 $wp_scripts->registered = $registered;
29
30 add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
31 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
32 add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
33
34 do_action( 'customize_controls_init' );
35
36 wp_enqueue_script( 'customize-controls' );
37 wp_enqueue_style( 'customize-controls' );
38
39 do_action( 'customize_controls_enqueue_scripts' );
40
41 // Let's roll.
42 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
43
44 wp_user_settings();
45 _wp_admin_html_begin();
46
14f0413 Theme Customizer: Fix scrolling on iOS and Kindle Fire. props azaozz,…
koopersmith authored
47 $body_class = '';
48
49 if ( wp_is_mobile() ) :
50 $body_class .= ' mobile';
51
52 ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=0.8, minimum-scale=0.5, maximum-scale=1.2"><?php
53 endif;
54
55 $is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
56
57 if ( $is_ios )
58 $body_class .= ' ios';
59
95e1c32 Customize API shuffling.
nacin authored
60 $admin_title = sprintf( __( '%1$s &#8212; WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
61 ?><title><?php echo $admin_title; ?></title><?php
62
63 do_action( 'customize_controls_print_styles' );
64 do_action( 'customize_controls_print_scripts' );
65 ?>
66 </head>
14f0413 Theme Customizer: Fix scrolling on iOS and Kindle Fire. props azaozz,…
koopersmith authored
67 <body class="<?php echo esc_attr( $body_class ); ?>">
68 <div class="wp-full-overlay expanded">
2f2cb09 Theme Customizer: Migrate to an ajax-based solution for refreshing th…
koopersmith authored
69 <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
70 <div id="customize-header-actions" class="wp-full-overlay-header">
4973f92 Theme Customizer: Change 'Return to...' link to 'Cancel' and move 'Sa…
koopersmith authored
71 <?php
35d5894 "Save & Activate", "Save & Publish" for customizer save button. Props…
ryan authored
72 $save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
4973f92 Theme Customizer: Change 'Return to...' link to 'Cancel' and move 'Sa…
koopersmith authored
73 submit_button( $save_text, 'primary', 'save', false );
74 ?>
1acd8b5 @nacin New HiDPI spinner. Uses clean <span class="spinner"></span> markup.
nacin authored
75 <span class="spinner"></span>
69ad7a6 Customizer: Redirect back to referrer. If referrer is a front end pag…
ryan authored
76 <a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
4973f92 Theme Customizer: Change 'Return to...' link to 'Cancel' and move 'Sa…
koopersmith authored
77 <?php _e( 'Cancel' ); ?>
a5dacf7 Theme Customizer: Allow the customize iframe to be accessed directly …
koopersmith authored
78 </a>
79 </div>
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
80
c2c3f2b Theme Customizer: Don't expand theme title if there are no details to…
koopersmith authored
81 <?php
82 $screenshot = $wp_customize->theme()->get_screenshot();
83 $cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
84 ?>
85
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
86 <div class="wp-full-overlay-sidebar-content">
c2c3f2b Theme Customizer: Don't expand theme title if there are no details to…
koopersmith authored
87 <div id="customize-info" class="customize-section<?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
88 <div class="customize-section-title">
df1a904 Theme Customizer: Add the theme name to the 'You are previewing' stri…
nacin authored
89 <span class="preview-notice"><?php
90 /* translators: %s is the theme name in the Customize/Live Preview pane */
91 echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
92 ?></span>
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
93 </div>
c2c3f2b Theme Customizer: Don't expand theme title if there are no details to…
koopersmith authored
94 <?php if ( ! $cannot_expand ) : ?>
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
95 <div class="customize-section-content">
c2c3f2b Theme Customizer: Don't expand theme title if there are no details to…
koopersmith authored
96 <?php if ( $screenshot ) : ?>
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
97 <img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
98 <?php endif; ?>
99
95e1c32 Customize API shuffling.
nacin authored
100 <?php if ( $wp_customize->theme()->get('Description') ): ?>
101 <div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
102 <?php endif; ?>
103 </div>
c2c3f2b Theme Customizer: Don't expand theme title if there are no details to…
koopersmith authored
104 <?php endif; ?>
9523a90 Theme Customizer: Improve form markup. Make the theme title/author a …
koopersmith authored
105 </div>
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
106
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
107 <div id="customize-theme-controls"><ul>
108 <?php
95e1c32 Customize API shuffling.
nacin authored
109 foreach ( $wp_customize->sections() as $section )
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
110 $section->maybe_render();
111 ?>
112 </ul></div>
113 </div>
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
114
ae14873 Theme Customizer: Prevent sidebar scrollbar from overlapping sidebar …
koopersmith authored
115 <div id="customize-footer-actions" class="wp-full-overlay-footer">
a5dacf7 Theme Customizer: Allow the customize iframe to be accessed directly …
koopersmith authored
116 <a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
117 <span class="collapse-sidebar-arrow"></span>
729e723 Darken the hover/on states for the customizer section titles. Switch …
nacin authored
118 <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
a5dacf7 Theme Customizer: Allow the customize iframe to be accessed directly …
koopersmith authored
119 </a>
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
120 </div>
121 </form>
2f2cb09 Theme Customizer: Migrate to an ajax-based solution for refreshing th…
koopersmith authored
122 <div id="customize-preview" class="wp-full-overlay-main"></div>
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
123 <?php
124
125 do_action( 'customize_controls_print_footer_scripts' );
126
103fba7 Load the customize preview over ssl if the customize admin page is lo…
ryan authored
127 // If the frontend and the admin are served from the same domain, load the
128 // preview over ssl if the customizer is being loaded over ssl. This avoids
129 // insecure content warnings. This is not attempted if the admin and frontend
130 // are on different domains to avoid the case where the frontend doesn't have
84cc00a Theme Customizer: Improve accuracy of identifying internal urls. see …
koopersmith authored
131 // ssl certs. Domain mapping plugins can allow other urls in these conditions
132 // using the customize_allowed_urls filter.
133
134 $allowed_urls = array( home_url('/') );
103fba7 Load the customize preview over ssl if the customize admin page is lo…
ryan authored
135 $admin_origin = parse_url( admin_url() );
84cc00a Theme Customizer: Improve accuracy of identifying internal urls. see …
koopersmith authored
136 $home_origin = parse_url( home_url() );
c3e7ce5 Theme Customizer: Check for CORS support when the preview and admin u…
koopersmith authored
137 $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
84cc00a Theme Customizer: Improve accuracy of identifying internal urls. see …
koopersmith authored
138
c3e7ce5 Theme Customizer: Check for CORS support when the preview and admin u…
koopersmith authored
139 if ( is_ssl() && ! $cross_domain )
84cc00a Theme Customizer: Improve accuracy of identifying internal urls. see …
koopersmith authored
140 $allowed_urls[] = home_url( '/', 'https' );
103fba7 Load the customize preview over ssl if the customize admin page is lo…
ryan authored
141
84cc00a Theme Customizer: Improve accuracy of identifying internal urls. see …
koopersmith authored
142 $allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
103fba7 Load the customize preview over ssl if the customize admin page is lo…
ryan authored
143
c3e7ce5 Theme Customizer: Check for CORS support when the preview and admin u…
koopersmith authored
144 $fallback_url = add_query_arg( array(
145 'preview' => 1,
146 'template' => $wp_customize->get_template(),
147 'stylesheet' => $wp_customize->get_stylesheet(),
148 'preview_iframe' => true,
149 'TB_iframe' => 'true'
150 ), home_url( '/' ) );
151
9115435 Customizer: Gravefully handle cookie expipration. Prompt for log in i…
ryan authored
152 $login_url = add_query_arg( array(
153 'interim-login' => 1,
154 'customize-login' => 1
155 ), wp_login_url() );
156
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
157 $settings = array(
bc99ad3 Theme Customizer: Properly change state when theme is switched. fixes…
koopersmith authored
158 'theme' => array(
95e1c32 Customize API shuffling.
nacin authored
159 'stylesheet' => $wp_customize->get_stylesheet(),
160 'active' => $wp_customize->is_theme_active(),
bc99ad3 Theme Customizer: Properly change state when theme is switched. fixes…
koopersmith authored
161 ),
162 'url' => array(
69ad7a6 Customizer: Redirect back to referrer. If referrer is a front end pag…
ryan authored
163 'preview' => esc_url( $url ? $url : home_url( '/' ) ),
c3e7ce5 Theme Customizer: Check for CORS support when the preview and admin u…
koopersmith authored
164 'parent' => esc_url( admin_url() ),
2abd3ad Theme Customizer: Validate themes with more than just an existence ch…
nacin authored
165 'activated' => admin_url( 'themes.php?activated=true&previewed' ),
c3e7ce5 Theme Customizer: Check for CORS support when the preview and admin u…
koopersmith authored
166 'ajax' => esc_url( admin_url( 'admin-ajax.php', 'relative' ) ),
167 'allowed' => array_map( 'esc_url', $allowed_urls ),
168 'isCrossDomain' => $cross_domain,
169 'fallback' => $fallback_url,
69ad7a6 Customizer: Redirect back to referrer. If referrer is a front end pag…
ryan authored
170 'home' => esc_url( home_url( '/' ) ),
9115435 Customizer: Gravefully handle cookie expipration. Prompt for log in i…
ryan authored
171 'login' => $login_url,
bc99ad3 Theme Customizer: Properly change state when theme is switched. fixes…
koopersmith authored
172 ),
14f0413 Theme Customizer: Fix scrolling on iOS and Kindle Fire. props azaozz,…
koopersmith authored
173 'browser' => array(
174 'mobile' => wp_is_mobile(),
175 'ios' => $is_ios,
176 ),
30d798e Create WP_Customize_Control to separate the process of rendering a co…
koopersmith authored
177 'settings' => array(),
e9652cf Theme Customizer: Add a Control object to better encapsulate differen…
koopersmith authored
178 'controls' => array(),
6911251 Refresh nonces in the customizer. props koopersmith. see #20876.
nacin authored
179 'nonce' => array(
180 'save' => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),
181 'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )
182 ),
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
183 );
184
95e1c32 Customize API shuffling.
nacin authored
185 foreach ( $wp_customize->settings() as $id => $setting ) {
30d798e Create WP_Customize_Control to separate the process of rendering a co…
koopersmith authored
186 $settings['settings'][ $id ] = array(
507f3b2 Theme Customizer: Properly escape customize settings when sending val…
koopersmith authored
187 'value' => $setting->js_value(),
863a458 Theme Customizer: For clarity, wp.customize.Setting.method to wp.cust…
koopersmith authored
188 'transport' => $setting->transport,
e9652cf Theme Customizer: Add a Control object to better encapsulate differen…
koopersmith authored
189 );
30d798e Create WP_Customize_Control to separate the process of rendering a co…
koopersmith authored
190 }
191
95e1c32 Customize API shuffling.
nacin authored
192 foreach ( $wp_customize->controls() as $id => $control ) {
79f8b89 Theme Customizer: Move upload and image controls to subclasses. see #…
koopersmith authored
193 $control->to_json();
194 $settings['controls'][ $id ] = $control->json;
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
195 }
196
197 ?>
198 <script type="text/javascript">
13628d9 Theme Customizer: Use a internal global _wpCustomizeSettings object f…
koopersmith authored
199 var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
200 </script>
14f0413 Theme Customizer: Fix scrolling on iOS and Kindle Fire. props azaozz,…
koopersmith authored
201 </div>
c832f90 Introduce new theme customizer to replace theme preview. Rough first …
koopersmith authored
202 </body>
203 </html>
Something went wrong with that request. Please try again.