PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/customize.php

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