~canonical-sysadmins/wordpress/4.2.4

« back to all changes in this revision

Viewing changes to wp-admin/customize.php

  • Committer: Nick Moffitt
  • Date: 2015-01-15 11:05:37 UTC
  • mfrom: (1.1.1 wp4-upstream)
  • Revision ID: nick.moffitt@canonical.com-20150115110537-8bp1y42eyg0jsa7c
Tags: 4.1
MergeĀ upstreamĀ versionĀ 4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
require_once( dirname( __FILE__ ) . '/admin.php' );
14
14
 
15
15
if ( ! current_user_can( 'customize' ) ) {
16
 
        wp_die( __( 'Cheatin’ uh?' ) );
 
16
        wp_die( __( 'Cheatin’ uh?' ), 403 );
17
17
}
18
18
 
19
19
wp_reset_vars( array( 'url', 'return' ) );
53
53
wp_enqueue_script( 'customize-controls' );
54
54
wp_enqueue_style( 'customize-controls' );
55
55
 
56
 
wp_enqueue_script( 'accordion' );
57
 
 
58
56
/**
59
57
 * Enqueue Customizer control scripts.
60
58
 *
78
76
 
79
77
$is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
80
78
 
81
 
if ( $is_ios )
 
79
if ( $is_ios ) {
82
80
        $body_class .= ' ios';
 
81
}
83
82
 
84
 
if ( is_rtl() )
85
 
        $body_class .=  ' rtl';
 
83
if ( is_rtl() ) {
 
84
        $body_class .= ' rtl';
 
85
}
86
86
$body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
87
87
 
88
 
$admin_title = sprintf( __( '%1$s — WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
 
88
if ( $wp_customize->is_theme_active() ) {
 
89
        $document_title_tmpl = _x( 'Customize: %s', 'Placeholder is the document title from the preview' );
 
90
} else {
 
91
        $document_title_tmpl = _x( 'Live Preview: %s', 'Placeholder is the document title from the preview' );
 
92
}
 
93
$document_title_tmpl = html_entity_decode( $document_title_tmpl, ENT_QUOTES, 'UTF-8' ); // because exported to JS and assigned to document.title
 
94
$admin_title = sprintf( $document_title_tmpl, __( 'Loading…' ) );
 
95
 
89
96
?><title><?php echo $admin_title; ?></title>
90
97
 
91
98
<script type="text/javascript">
111
118
<body class="<?php echo esc_attr( $body_class ); ?>">
112
119
<div class="wp-full-overlay expanded">
113
120
        <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
 
121
                <div id="screen-reader-messages" aria-live="polite" aria-relevant="all" aria-role="status" aria-atomic="true" class="screen-reader-text"></div>
114
122
 
115
123
                <div id="customize-header-actions" class="wp-full-overlay-header">
116
124
                        <?php
129
137
                        $cannot_expand = ! ( $wp_customize->is_theme_active() || $screenshot || $wp_customize->theme()->get('Description') );
130
138
                ?>
131
139
 
132
 
                <div id="widgets-right"><!-- For Widget Customizer, many widgets try to look for instances under div#widgets-right, so we have to add that ID to a container div in the customizer for compat -->
133
 
                <div class="wp-full-overlay-sidebar-content accordion-container" tabindex="-1">
 
140
                <div id="widgets-right"><!-- For Widget Customizer, many widgets try to look for instances under div#widgets-right, so we have to add that ID to a container div in the Customizer for compat -->
 
141
                <div class="wp-full-overlay-sidebar-content" tabindex="-1">
134
142
                        <div id="customize-info" class="accordion-section <?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
135
 
                                <div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Theme Customizer Options' ); ?>" tabindex="0">
 
143
                                <div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Customizer Options' ); ?>" tabindex="0">
136
144
                                        <span class="preview-notice"><?php
137
145
                                                if ( ! $wp_customize->is_theme_active() ) {
138
146
                                                        /* translators: %s is the theme name in the Customize/Live Preview pane */
160
168
                                <?php endif; ?>
161
169
                        </div>
162
170
 
163
 
                        <div id="customize-theme-controls"><ul>
164
 
                                <?php
165
 
                                foreach ( $wp_customize->containers() as $container ) {
166
 
                                        $container->maybe_render();
167
 
                                }
168
 
                                ?>
169
 
                        </ul></div>
 
171
                        <div id="customize-theme-controls">
 
172
                                <ul><?php // Panels and sections are managed here via JavaScript ?></ul>
 
173
                        </div>
170
174
                </div>
171
175
                </div>
172
176
 
180
184
        <div id="customize-preview" class="wp-full-overlay-main"></div>
181
185
        <?php
182
186
 
 
187
        // Render control templates.
 
188
        $wp_customize->render_control_templates();
 
189
 
183
190
        /**
184
191
         * Print Customizer control scripts in the footer.
185
192
         *
189
196
 
190
197
        /*
191
198
         * If the frontend and the admin are served from the same domain, load the
192
 
         * preview over ssl if the customizer is being loaded over ssl. This avoids
 
199
         * preview over ssl if the Customizer is being loaded over ssl. This avoids
193
200
         * insecure content warnings. This is not attempted if the admin and frontend
194
201
         * are on different domains to avoid the case where the frontend doesn't have
195
202
         * ssl certs. Domain mapping plugins can allow other urls in these conditions
226
233
                'customize-login' => 1
227
234
        ), wp_login_url() );
228
235
 
229
 
        // Prepare customizer settings to pass to Javascript.
 
236
        // Prepare Customizer settings to pass to JavaScript.
230
237
        $settings = array(
231
238
                'theme'    => array(
232
239
                        'stylesheet' => $wp_customize->get_stylesheet(),
249
256
                ),
250
257
                'settings' => array(),
251
258
                'controls' => array(),
 
259
                'panels'   => array(),
 
260
                'sections' => array(),
252
261
                'nonce'    => array(
253
262
                        'save'    => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),
254
263
                        'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )
255
264
                ),
 
265
                'autofocus' => array(),
 
266
                'documentTitleTmpl' => $document_title_tmpl,
256
267
        );
257
268
 
258
 
        // Prepare Customize Setting objects to pass to Javascript.
 
269
        // Prepare Customize Setting objects to pass to JavaScript.
259
270
        foreach ( $wp_customize->settings() as $id => $setting ) {
260
271
                $settings['settings'][ $id ] = array(
261
272
                        'value'     => $setting->js_value(),
263
274
                );
264
275
        }
265
276
 
266
 
        // Prepare Customize Control objects to pass to Javascript.
 
277
        // Prepare Customize Control objects to pass to JavaScript.
267
278
        foreach ( $wp_customize->controls() as $id => $control ) {
268
 
                $control->to_json();
269
 
                $settings['controls'][ $id ] = $control->json;
 
279
                $settings['controls'][ $id ] = $control->json();
 
280
        }
 
281
 
 
282
        // Prepare Customize Section objects to pass to JavaScript.
 
283
        foreach ( $wp_customize->sections() as $id => $section ) {
 
284
                $settings['sections'][ $id ] = $section->json();
 
285
        }
 
286
 
 
287
        // Prepare Customize Panel objects to pass to JavaScript.
 
288
        foreach ( $wp_customize->panels() as $id => $panel ) {
 
289
                $settings['panels'][ $id ] = $panel->json();
 
290
                foreach ( $panel->sections as $section_id => $section ) {
 
291
                        $settings['sections'][ $section_id ] = $section->json();
 
292
                }
 
293
        }
 
294
 
 
295
        // Pass to frontend the Customizer construct being deeplinked
 
296
        if ( isset( $_GET['autofocus'] ) ) {
 
297
                $autofocus = wp_unslash( $_GET['autofocus'] );
 
298
                if ( is_array( $autofocus ) ) {
 
299
                        foreach ( $autofocus as $type => $id ) {
 
300
                                if ( isset( $settings[ $type . 's' ][ $id ] ) ) {
 
301
                                        $settings['autofocus'][ $type ] = $id;
 
302
                                }
 
303
                        }
 
304
                }
270
305
        }
271
306
 
272
307
        ?>
273
308
        <script type="text/javascript">
274
 
                var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
 
309
                var _wpCustomizeSettings = <?php echo wp_json_encode( $settings ); ?>;
275
310
        </script>
276
311
</div>
277
312
</body>