[ Index ]

WordPress Cross Reference

title

Body

[close]

/wp-admin/ -> customize.php (source)

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


Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu