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>' . __( 'Sorry, you are not allowed to customize this site.' ) . '</p>',
24 * @global WP_Scripts $wp_scripts
25 * @global WP_Customize_Manager $wp_customize
27 global $wp_scripts, $wp_customize;
29 if ( $wp_customize->changeset_post_id() ) {
30 if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->edit_post, $wp_customize->changeset_post_id() ) ) {
32 '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
33 '<p>' . __( 'Sorry, you are not allowed to edit this changeset.' ) . '</p>',
37 if ( in_array( get_post_status( $wp_customize->changeset_post_id() ), array( 'publish', 'trash' ), true ) ) {
39 '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' .
40 '<p>' . __( 'This changeset has already been published and cannot be further modified.' ) . '</p>' .
41 '<p><a href="' . esc_url( remove_query_arg( 'changeset_uuid' ) ) . '">' . __( 'Customize New Changes' ) . '</a></p>',
48 wp_reset_vars( array( 'url', 'return', 'autofocus' ) );
49 if ( ! empty( $url ) ) {
50 $wp_customize->set_preview_url( wp_unslash( $url ) );
52 if ( ! empty( $return ) ) {
53 $wp_customize->set_return_url( wp_unslash( $return ) );
55 if ( ! empty( $autofocus ) && is_array( $autofocus ) ) {
56 $wp_customize->set_autofocus( wp_unslash( $autofocus ) );
59 $registered = $wp_scripts->registered;
60 $wp_scripts = new WP_Scripts;
61 $wp_scripts->registered = $registered;
63 add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
64 add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
65 add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );
68 * Fires when Customizer controls are initialized, before scripts are enqueued.
72 do_action( 'customize_controls_init' );
74 wp_enqueue_script( 'customize-controls' );
75 wp_enqueue_style( 'customize-controls' );
78 * Enqueue Customizer control scripts.
82 do_action( 'customize_controls_enqueue_scripts' );
85 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
88 _wp_admin_html_begin();
90 $body_class = 'wp-core-ui wp-customizer js';
92 if ( wp_is_mobile() ) :
93 $body_class .= ' mobile';
95 ?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=1.2" /><?php
98 if ( $wp_customize->is_ios() ) {
99 $body_class .= ' ios';
103 $body_class .= ' rtl';
105 $body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
107 $admin_title = sprintf( $wp_customize->get_document_title_template(), __( 'Loading…' ) );
109 ?><title><?php echo $admin_title; ?></title>
111 <script type="text/javascript">
112 var ajaxurl = <?php echo wp_json_encode( admin_url( 'admin-ajax.php', 'relative' ) ); ?>;
117 * Fires when Customizer control styles are printed.
121 do_action( 'customize_controls_print_styles' );
124 * Fires when Customizer control scripts are printed.
128 do_action( 'customize_controls_print_scripts' );
131 <body class="<?php echo esc_attr( $body_class ); ?>">
132 <div class="wp-full-overlay expanded">
133 <form id="customize-controls" class="wrap wp-full-overlay-sidebar">
134 <div id="customize-header-actions" class="wp-full-overlay-header">
136 $save_text = $wp_customize->is_theme_active() ? __( 'Save & Publish' ) : __( 'Save & Activate' );
137 $save_attrs = array();
138 if ( ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->publish_posts ) ) {
139 $save_attrs['style'] = 'display: none';
141 submit_button( $save_text, 'primary save', 'save', false, $save_attrs );
143 <span class="spinner"></span>
144 <button type="button" class="customize-controls-preview-toggle">
145 <span class="controls"><?php _e( 'Customize' ); ?></span>
146 <span class="preview"><?php _e( 'Preview' ); ?></span>
148 <a class="customize-controls-close" href="<?php echo esc_url( $wp_customize->get_return_url() ); ?>">
149 <span class="screen-reader-text"><?php _e( 'Close the Customizer and go back to the previous page' ); ?></span>
153 <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 -->
154 <div class="wp-full-overlay-sidebar-content" tabindex="-1">
155 <div id="customize-info" class="accordion-section customize-info">
156 <div class="accordion-section-title">
157 <span class="preview-notice"><?php
158 echo sprintf( __( 'You are customizing %s' ), '<strong class="panel-title site-title">' . get_bloginfo( 'name' ) . '</strong>' );
160 <button type="button" class="customize-help-toggle dashicons dashicons-editor-help" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
162 <div class="customize-panel-description"><?php
163 _e( 'The Customizer allows you to preview changes to your site before publishing them. You can navigate to different pages on your site within the preview. Edit shortcuts are shown for some editable elements.' );
167 <div id="customize-theme-controls">
168 <ul class="customize-pane-parent"><?php // Panels and sections are managed here via JavaScript ?></ul>
173 <div id="customize-footer-actions" class="wp-full-overlay-footer">
174 <?php $previewable_devices = $wp_customize->get_previewable_devices(); ?>
175 <?php if ( ! empty( $previewable_devices ) ) : ?>
176 <div class="devices">
177 <?php foreach ( (array) $previewable_devices as $device => $settings ) : ?>
179 if ( empty( $settings['label'] ) ) {
182 $active = ! empty( $settings['default'] );
183 $class = 'preview-' . $device;
188 <button type="button" class="<?php echo esc_attr( $class ); ?>" aria-pressed="<?php echo esc_attr( $active ) ?>" data-device="<?php echo esc_attr( $device ); ?>">
189 <span class="screen-reader-text"><?php echo esc_html( $settings['label'] ); ?></span>
194 <button type="button" class="collapse-sidebar button" aria-expanded="true" aria-label="<?php echo esc_attr( _x( 'Hide Controls', 'label for hide controls button without length constraints' ) ); ?>">
195 <span class="collapse-sidebar-arrow"></span>
196 <span class="collapse-sidebar-label"><?php _ex( 'Hide Controls', 'short (~12 characters) label for hide controls button' ); ?></span>
200 <div id="customize-preview" class="wp-full-overlay-main"></div>
204 * Prints templates, control scripts, and settings in the footer.
208 do_action( 'customize_controls_print_footer_scripts' );