PageRenderTime 85ms CodeModel.GetById 40ms app.highlight 12ms RepoModel.GetById 28ms app.codeStats 0ms

/wp-admin/customize.php

https://github.com/dedavidd/piratenpartij.nl
PHP | 259 lines | 168 code | 40 blank | 51 comment | 16 complexity | 5b8410933eb61f76a22c8ade7855586b MD5 | raw file
  1<?php
  2/**
  3 * Theme Customize Screen.
  4 *
  5 * @package WordPress
  6 * @subpackage Customize
  7 * @since 3.4.0
  8 */
  9
 10define( 'IFRAME_REQUEST', true );
 11
 12/** Load WordPress Administration Bootstrap */
 13require_once( dirname( __FILE__ ) . '/admin.php' );
 14
 15if ( ! current_user_can( 'edit_theme_options' ) )
 16	wp_die( __( 'Cheatin&#8217; uh?' ) );
 17
 18wp_reset_vars( array( 'url', 'return' ) );
 19$url = urldecode( $url );
 20$url = wp_validate_redirect( $url, home_url( '/' ) );
 21if ( $return )
 22	$return = wp_validate_redirect( urldecode( $return ) );
 23if ( ! $return )
 24	$return = $url;
 25
 26global $wp_scripts, $wp_customize;
 27
 28$registered = $wp_scripts->registered;
 29$wp_scripts = new WP_Scripts;
 30$wp_scripts->registered = $registered;
 31
 32add_action( 'customize_controls_print_scripts',        'print_head_scripts', 20 );
 33add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts'     );
 34add_action( 'customize_controls_print_styles',         'print_admin_styles', 20 );
 35
 36/**
 37 * Fires when Customizer controls are initialized, before scripts are enqueued.
 38 *
 39 * @since 3.4.0
 40 */
 41do_action( 'customize_controls_init' );
 42
 43wp_enqueue_script( 'customize-controls' );
 44wp_enqueue_style( 'customize-controls' );
 45
 46wp_enqueue_script( 'accordion' );
 47
 48/**
 49 * Enqueue Customizer control scripts.
 50 *
 51 * @since 3.4.0
 52 */
 53do_action( 'customize_controls_enqueue_scripts' );
 54
 55// Let's roll.
 56@header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
 57
 58wp_user_settings();
 59_wp_admin_html_begin();
 60
 61$body_class = 'wp-core-ui wp-customizer js';
 62
 63if ( wp_is_mobile() ) :
 64	$body_class .= ' mobile';
 65
 66	?><meta name="viewport" id="viewport-meta" content="width=device-width, initial-scale=0.8, minimum-scale=0.5, maximum-scale=1.2" /><?php
 67endif;
 68
 69$is_ios = wp_is_mobile() && preg_match( '/iPad|iPod|iPhone/', $_SERVER['HTTP_USER_AGENT'] );
 70
 71if ( $is_ios )
 72	$body_class .= ' ios';
 73
 74if ( is_rtl() )
 75	$body_class .=  ' rtl';
 76$body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_locale() ) ) );
 77
 78$admin_title = sprintf( __( '%1$s &#8212; WordPress' ), strip_tags( sprintf( __( 'Customize %s' ), $wp_customize->theme()->display('Name') ) ) );
 79?><title><?php echo $admin_title; ?></title>
 80
 81<script type="text/javascript">
 82var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', 'relative' ); ?>';
 83</script>
 84
 85<?php
 86/**
 87 * Fires when Customizer control styles are printed.
 88 *
 89 * @since 3.4.0
 90 */
 91do_action( 'customize_controls_print_styles' );
 92
 93/**
 94 * Fires when Customizer control scripts are printed.
 95 *
 96 * @since 3.4.0
 97 */
 98do_action( 'customize_controls_print_scripts' );
 99?>
100</head>
101<body class="<?php echo esc_attr( $body_class ); ?>">
102<div class="wp-full-overlay expanded">
103	<form id="customize-controls" class="wrap wp-full-overlay-sidebar">
104
105		<div id="customize-header-actions" class="wp-full-overlay-header">
106			<?php
107				$save_text = $wp_customize->is_theme_active() ? __( 'Save &amp; Publish' ) : __( 'Save &amp; Activate' );
108				submit_button( $save_text, 'primary save', 'save', false );
109			?>
110			<span class="spinner"></span>
111			<a class="back button" href="<?php echo esc_url( $return ? $return : admin_url( 'themes.php' ) ); ?>">
112				<?php _e( 'Cancel' ); ?>
113			</a>
114		</div>
115
116		<?php
117			$screenshot = $wp_customize->theme()->get_screenshot();
118			$cannot_expand = ! ( $screenshot || $wp_customize->theme()->get('Description') );
119		?>
120
121		<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 -->
122		<div class="wp-full-overlay-sidebar-content accordion-container" tabindex="-1">
123			<div id="customize-info" class="accordion-section <?php if ( $cannot_expand ) echo ' cannot-expand'; ?>">
124				<div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Theme Customizer Options' ); ?>" tabindex="0">
125					<span class="preview-notice"><?php
126						/* translators: %s is the theme name in the Customize/Live Preview pane */
127						echo sprintf( __( 'You are previewing %s' ), '<strong class="theme-name">' . $wp_customize->theme()->display('Name') . '</strong>' );
128					?></span>
129				</div>
130				<?php if ( ! $cannot_expand ) : ?>
131				<div class="accordion-section-content">
132					<?php if ( $screenshot ) : ?>
133						<img class="theme-screenshot" src="<?php echo esc_url( $screenshot ); ?>" />
134					<?php endif; ?>
135
136					<?php if ( $wp_customize->theme()->get('Description') ): ?>
137						<div class="theme-description"><?php echo $wp_customize->theme()->display('Description'); ?></div>
138					<?php endif; ?>
139				</div>
140				<?php endif; ?>
141			</div>
142
143			<div id="customize-theme-controls"><ul>
144				<?php
145				foreach ( $wp_customize->panels() as $panel ) {
146					$panel->maybe_render();
147				}
148				foreach ( $wp_customize->sections() as $section ) {
149					$section->maybe_render();
150				}
151				?>
152			</ul></div>
153		</div>
154		</div>
155
156		<div id="customize-footer-actions" class="wp-full-overlay-footer">
157			<a href="#" class="collapse-sidebar button-secondary" title="<?php esc_attr_e('Collapse Sidebar'); ?>">
158				<span class="collapse-sidebar-arrow"></span>
159				<span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span>
160			</a>
161		</div>
162	</form>
163	<div id="customize-preview" class="wp-full-overlay-main"></div>
164	<?php
165
166	/**
167	 * Print Customizer control scripts in the footer.
168	 *
169	 * @since 3.4.0
170	 */
171	do_action( 'customize_controls_print_footer_scripts' );
172
173	// If the frontend and the admin are served from the same domain, load the
174	// preview over ssl if the customizer is being loaded over ssl. This avoids
175	// insecure content warnings. This is not attempted if the admin and frontend
176	// are on different domains to avoid the case where the frontend doesn't have
177	// ssl certs. Domain mapping plugins can allow other urls in these conditions
178	// using the customize_allowed_urls filter.
179
180	$allowed_urls = array( home_url('/') );
181	$admin_origin = parse_url( admin_url() );
182	$home_origin  = parse_url( home_url() );
183	$cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
184
185	if ( is_ssl() && ! $cross_domain )
186		$allowed_urls[] = home_url( '/', 'https' );
187
188	/**
189	 * Filter the list of URLs allowed to be clicked and followed in the Customizer preview.
190	 *
191	 * @since 3.4.0
192	 *
193	 * @param array $allowed_urls An array of allowed URLs.
194	 */
195	$allowed_urls = array_unique( apply_filters( 'customize_allowed_urls', $allowed_urls ) );
196
197	$fallback_url = add_query_arg( array(
198		'preview'        => 1,
199		'template'       => $wp_customize->get_template(),
200		'stylesheet'     => $wp_customize->get_stylesheet(),
201		'preview_iframe' => true,
202		'TB_iframe'      => 'true'
203	), home_url( '/' ) );
204
205	$login_url = add_query_arg( array(
206		'interim-login' => 1,
207		'customize-login' => 1
208	), wp_login_url() );
209
210	// Prepare customizer settings to pass to Javascript.
211	$settings = array(
212		'theme'    => array(
213			'stylesheet' => $wp_customize->get_stylesheet(),
214			'active'     => $wp_customize->is_theme_active(),
215		),
216		'url'      => array(
217			'preview'       => esc_url_raw( $url ? $url : home_url( '/' ) ),
218			'parent'        => esc_url_raw( admin_url() ),
219			'activated'     => esc_url_raw( admin_url( 'themes.php?activated=true&previewed' ) ),
220			'ajax'          => esc_url_raw( admin_url( 'admin-ajax.php', 'relative' ) ),
221			'allowed'       => array_map( 'esc_url_raw', $allowed_urls ),
222			'isCrossDomain' => $cross_domain,
223			'fallback'      => esc_url_raw( $fallback_url ),
224			'home'          => esc_url_raw( home_url( '/' ) ),
225			'login'         => esc_url_raw( $login_url ),
226		),
227		'browser'  => array(
228			'mobile' => wp_is_mobile(),
229			'ios'    => $is_ios,
230		),
231		'settings' => array(),
232		'controls' => array(),
233		'nonce'    => array(
234			'save'    => wp_create_nonce( 'save-customize_' . $wp_customize->get_stylesheet() ),
235			'preview' => wp_create_nonce( 'preview-customize_' . $wp_customize->get_stylesheet() )
236		),
237	);
238
239	// Prepare Customize Setting objects to pass to Javascript.
240	foreach ( $wp_customize->settings() as $id => $setting ) {
241		$settings['settings'][ $id ] = array(
242			'value'     => $setting->js_value(),
243			'transport' => $setting->transport,
244		);
245	}
246
247	// Prepare Customize Control objects to pass to Javascript.
248	foreach ( $wp_customize->controls() as $id => $control ) {
249		$control->to_json();
250		$settings['controls'][ $id ] = $control->json;
251	}
252
253	?>
254	<script type="text/javascript">
255		var _wpCustomizeSettings = <?php echo json_encode( $settings ); ?>;
256	</script>
257</div>
258</body>
259</html>