3 * Theme Customize Screen.
6 * @subpackage Customize
10 define( 'IFRAME_REQUEST', true );
12 /** Load WordPress Administration Bootstrap */
13 require_once( dirname( __FILE__ ) . '/admin.php' );
15 if ( ! current_user_can( 'customize' ) ) {
17 '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
18 '<p>' . __( 'You are not allowed to customize the appearance of this site.' ) . '</p>',
23 wp_reset_vars( array( 'url', 'return', 'autofocus' ) );
24 if ( ! empty( $url ) ) {
25 $wp_customize->set_preview_url( wp_unslash( $url ) );
27 if ( ! empty( $return ) ) {
28 $wp_customize->set_return_url( wp_unslash( $return ) );
30 if ( ! empty( $autofocus ) && is_array( $autofocus ) ) {
31 $wp_customize->set_autofocus( wp_unslash( $autofocus ) );
35 * @global WP_Scripts $wp_scripts
36 * @global WP_Customize_Manager $wp_customize
38 global $wp_scripts, $wp_customize;
40 $registered = $wp_scripts->registered;
41 $wp_scripts = new WP_Scripts;
42 $wp_scripts->registered = $registered;
44 add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
45 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
46 add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
49 * Fires when Customizer controls are initialized, before scripts are enqueued.
53 do_action( 'customize_controls_init' );
55 wp_enqueue_script( 'customize-controls' );
56 wp_enqueue_style( 'customize-controls' );
59 * Enqueue Customizer control scripts.
63 do_action( 'customize_controls_enqueue_scripts' );
66 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
69 _wp_admin_html_begin();
71 $body_class = 'wp-core-ui wp-customizer js';
73 if ( wp_is_mobile() ) :
74 $body_class .= ' mobile';
76 ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" /><?php
79 if ( $wp_customize->is_ios() ) {
80 $body_class .= ' ios';
84 $body_class .= ' rtl';
86 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
88 $admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading…' ) );
90 ?><title><?php echo $admin_title; ?></title>
92 <script type="text/javascript">
93 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>;
98 * Fires when Customizer control styles are printed.
102 do_action( 'customize_controls_print_styles' );
105 * Fires when Customizer control scripts are printed.
109 do_action( 'customize_controls_print_scripts' );
112 <body class="<?php echo esc_attr( $body_class ); ?>">
113 <div class="wp-full-overlay expanded">
114 <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
115 <div id="customize-header-actions" class="wp-full-overlay-header">
117 $save_text = $wp_customize->is_theme_active() ? __( 'Save & Publish' ) : __( 'Save & Activate' );
118 submit_button( $save_text, 'primary save', 'save', false );
120 <span class="spinner"></span>
121 <a class="customize-controls-preview-toggle" href="#">
122 <span class="controls"><?php _e( 'Customize' ); ?></span>
123 <span class="preview"><?php _e( 'Preview' ); ?></span>
125 <a class="customize-controls-close" href="<?php echo esc_url( $wp_customize->get_return_url() ); ?>">
126 <span class="screen-reader-text"><?php _e( 'Cancel' ); ?></span>
130 <div id="widgets-right" class="wp-clearfix"><!-- 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 -->
131 <div class="wp-full-overlay-sidebar-content" tabindex="-1">
132 <div id="customize-info" class="accordion-section customize-info">
133 <div class="accordion-section-title">
134 <span class="preview-notice"><?php
135 echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name' ) . '</strong>' );
137 <button class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
139 <div class="customize-panel-description"><?php
140 _e( 'The Customizer allows you to preview changes to your site before publishing them. You can also navigate to different pages on your site to preview them.' );
144 <div id="customize-theme-controls">
145 <ul><?php // Panels and sections are managed here via JavaScript ?></ul>
150 <div id="customize-footer-actions" class="wp-full-overlay-footer">
151 <?php $previewable_devices = $wp_customize->get_previewable_devices(); ?>
152 <?php if ( ! empty( $previewable_devices ) ) : ?>
153 <div class="devices">
154 <?php foreach ( (array) $previewable_devices as $device => $settings ) : ?>
156 if ( empty( $settings['label'] ) ) {
159 $active = ! empty( $settings['default'] );
160 $class = 'preview-' . $device;
165 <button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ) ?>" data-device="<?php echo esc_attr( $device ); ?>">
166 <span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span>
171 <button type="button" class="collapse-sidebar button-secondary" aria-expanded="true" aria-label="<?php esc_attr_e( 'Collapse Sidebar' ); ?>">
172 <span class="collapse-sidebar-arrow"></span>
173 <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span>
177 <div id="customize-preview" class="wp-full-overlay-main"></div>
181 * Print templates, control scripts, and settings in the footer.
185 do_action( 'customize_controls_print_footer_scripts' );