Changeset 21031
- Timestamp:
- 06/08/2012 07:22:11 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/customize-controls.dev.css
r21014 r21031 515 515 } 516 516 517 /** 518 * Handle cheaters. 519 */ 520 body.cheatin { 521 min-width: 0; 522 background: #f9f9f9; 523 padding: 50px; 524 } 525 526 body.cheatin p { 527 max-width: 700px; 528 margin: 0 auto; 529 padding: 2em; 530 font-size: 14px; 531 532 background: #fff; 533 border: 1px solid #dfdfdf; 534 535 -webkit-border-radius: 3px; 536 border-radius: 3px; 537 } -
trunk/wp-admin/customize.php
r21028 r21031 149 149 ), home_url( '/' ) ); 150 150 151 $login_url = add_query_arg( array( 152 'interim-login' => 1, 153 'customize-login' => 1 154 ), wp_login_url() ); 155 151 156 $settings = array( 152 157 'theme' => array( … … 163 168 'fallback' => $fallback_url, 164 169 'home' => esc_url( home_url( '/' ) ), 170 'login' => $login_url, 165 171 ), 166 172 'browser' => array( -
trunk/wp-admin/js/customize-controls.dev.js
r21029 r21031 332 332 if ( location && location != self.url() ) { 333 333 deferred.rejectWith( self, [ 'redirect', location ] ); 334 return; 335 } 336 337 // Check if the user is not logged in. 338 if ( '0' === response ) { 339 deferred.rejectWith( self, [ 'logged out' ] ); 340 return; 341 } 342 343 // Check for cheaters. 344 if ( '-1' === response ) { 345 deferred.rejectWith( self, [ 'cheatin' ] ); 334 346 return; 335 347 } … … 549 561 if ( 'redirect' === reason && location ) 550 562 self.url( location ); 551 }); 563 564 if ( 'logged out' === reason ) { 565 if ( self.iframe ) { 566 self.iframe.destroy(); 567 delete self.iframe; 568 } 569 570 self.login().done( self.refresh ); 571 } 572 573 if ( 'cheatin' === reason ) 574 self.cheatin(); 575 }); 576 }, 577 578 login: function() { 579 var previewer = this, 580 deferred, messenger, iframe; 581 582 if ( this._login ) 583 return this._login; 584 585 deferred = $.Deferred(); 586 this._login = deferred.promise(); 587 588 messenger = new api.Messenger({ 589 channel: 'login', 590 url: api.settings.url.login 591 }); 592 593 iframe = $('<iframe src="' + api.settings.url.login + '" />').appendTo( this.container ); 594 595 messenger.targetWindow( iframe[0].contentWindow ); 596 597 messenger.bind( 'login', function() { 598 iframe.remove(); 599 messenger.destroy(); 600 delete previewer._login; 601 deferred.resolve(); 602 }); 603 604 return this._login; 605 }, 606 607 cheatin: function() { 608 $( document.body ).empty().addClass('cheatin').append( '<p>' + api.l10n.cheatin + '</p>' ); 552 609 } 553 610 }); … … 606 663 607 664 save: function() { 608 var query = $.extend( this.query(), { 665 var self = this, 666 query = $.extend( this.query(), { 609 667 action: 'customize_save', 610 668 nonce: this.nonce … … 620 678 }); 621 679 622 request.done( function() { 680 request.done( function( response ) { 681 // Check if the user is logged out. 682 if ( '0' === response ) { 683 self.iframe.iframe.hide(); 684 self.login().done( function() { 685 self.save(); 686 self.iframe.iframe.show(); 687 }); 688 return; 689 } 690 691 // Check for cheaters. 692 if ( '-1' === response ) { 693 self.cheatin(); 694 return; 695 } 696 623 697 api.trigger( 'saved' ); 624 698 }); -
trunk/wp-includes/class-wp-customize-manager.php
r21027 r21031 32 32 require( ABSPATH . WPINC . '/class-wp-customize-control.php' ); 33 33 34 add_filter( 'wp_die_handler', array( $this, 'wp_die_handler' ) ); 35 34 36 add_action( 'setup_theme', array( $this, 'setup_theme' ) ); 35 37 add_action( 'wp_loaded', array( $this, 'wp_loaded' ) ); … … 53 55 } 54 56 55 /** 56 * Start preview and customize theme. 57 * 58 * Check if customize query variable exist. Init filters to filter the current theme. 57 /** 58 * Return true if it's an AJAX request. 59 * 60 * @since 3.4.0 61 */ 62 public function doing_ajax() { 63 return isset( $_POST['customized'] ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ); 64 } 65 66 /** 67 * Custom wp_die wrapper. Returns either the standard message for UI 68 * or the AJAX message. 69 * 70 * @param mixed $ajax_message AJAX return 71 * @param mixed $message UI message 72 * 73 * @since 3.4.0 74 */ 75 private function wp_die( $ajax_message, $message ) { 76 if ( $this->doing_ajax() ) 77 wp_die( $ajax_message ); 78 79 wp_die( $message ); 80 } 81 82 /** 83 * Return the AJAX wp_die() handler if it's a customized request. 84 * 85 * @since 3.4.0 86 */ 87 public function wp_die_handler() { 88 if ( $this->doing_ajax() ) 89 return '_ajax_wp_die_handler'; 90 91 return '_default_wp_die_handler'; 92 } 93 /** 94 * Start preview and customize theme. 95 * 96 * Check if customize query variable exist. Init filters to filter the current theme. 59 97 * 60 98 * @since 3.4.0 61 99 */ 62 100 public function setup_theme() { 63 if ( is_admin() && ! defined( 'DOING_AJAX' ) ) 64 auth_redirect(); 101 if ( is_admin() && ! $this->doing_ajax() ) 102 auth_redirect(); 103 elseif ( $this->doing_ajax() && ! is_user_logged_in()) 104 wp_die( 0 ); 65 105 66 106 send_origin_headers(); … … 72 112 // You can't preview a theme if it doesn't exist, or if it is not allowed (unless active). 73 113 if ( ! $this->theme->exists() ) 74 wp_die(__( 'Cheatin’ uh?' ) );114 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 75 115 76 116 if ( $this->theme->get_stylesheet() != get_stylesheet() && ( ! $this->theme()->is_allowed() || ! current_user_can( 'switch_themes' ) ) ) 77 wp_die(__( 'Cheatin’ uh?' ) );117 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 78 118 79 119 if ( ! current_user_can( 'edit_theme_options' ) ) 80 wp_die(__( 'Cheatin’ uh?' ) );120 $this->wp_die( -1, __( 'Cheatin’ uh?' ) ); 81 121 82 122 $this->start_previewing_theme(); -
trunk/wp-includes/script-loader.php
r21003 r21031 306 306 'cancel' => __( 'Cancel' ), 307 307 'close' => __( 'Close' ), 308 'cheatin' => __( 'Cheatin’ uh?' ), 308 309 ) ); 309 310 -
trunk/wp-login.php
r20887 r21031 40 40 */ 41 41 function login_header($title = 'Log In', $message = '', $wp_error = '') { 42 global $error, $interim_login, $current_site ;42 global $error, $interim_login, $current_site, $customize_login; 43 43 44 44 // Don't index any of these forms … … 69 69 } 70 70 71 if ( $customize_login ) 72 wp_enqueue_script( 'customize-base' ); 73 71 74 do_action( 'login_enqueue_scripts' ); 72 75 do_action( 'login_head' ); … … 82 85 $login_header_url = apply_filters( 'login_headerurl', $login_header_url ); 83 86 $login_header_title = apply_filters( 'login_headertitle', $login_header_title ); 87 88 // Don't allow interim logins to navigate away from the page. 89 if ( $interim_login ) 90 $login_header_url = '#'; 84 91 85 92 ?> … … 127 134 */ 128 135 function login_footer($input_id = '') { 129 ?> 136 global $interim_login; 137 138 // Don't allow interim logins to navigate away from the page. 139 if ( ! $interim_login ): ?> 130 140 <p id="backtoblog"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php esc_attr_e( 'Are you lost?' ); ?>"><?php printf( __( '← Back to %s' ), get_bloginfo( 'title', 'display' ) ); ?></a></p> 141 <?php endif; ?> 142 131 143 </div> 132 144 … … 556 568 $secure_cookie = ''; 557 569 $interim_login = isset($_REQUEST['interim-login']); 570 $customize_login = isset( $_REQUEST['customize-login'] ); 558 571 559 572 // If the user wants ssl but the session is not ssl, force a secure cookie. … … 592 605 if ( $interim_login ) { 593 606 $message = '<p class="message">' . __('You have logged in successfully.') . '</p>'; 594 login_header( '', $message ); ?> 595 <script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script> 596 <p class="alignright"> 597 <input type="button" class="button-primary" value="<?php esc_attr_e('Close'); ?>" onclick="window.close()" /></p> 598 </div></body></html> 607 login_header( '', $message ); 608 609 if ( ! $customize_login ) : ?> 610 <script type="text/javascript">setTimeout( function(){window.close()}, 8000);</script> 611 <p class="alignright"> 612 <input type="button" class="button-primary" value="<?php esc_attr_e('Close'); ?>" onclick="window.close()" /></p> 613 <?php endif; 614 615 ?></div><?php 616 617 do_action('login_footer'); 618 619 if ( $customize_login ) : ?> 620 <script type="text/javascript">setTimeout( function(){ new wp.customize.Messenger({ url: '<?php echo wp_customize_url(); ?>', channel: 'login' }).send('login') }, 1000 );</script> 621 <?php endif; ?> 622 </body></html> 599 623 <?php exit; 600 624 } … … 667 691 <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" /> 668 692 <?php } ?> 693 <?php if ( $customize_login ) : ?> 694 <input type="hidden" name="customize-login" value="1" /> 695 <?php endif; ?> 669 696 <input type="hidden" name="testcookie" value="1" /> 670 697 </p>
Note: See TracChangeset
for help on using the changeset viewer.