@@ 440-470 (lines=31) @@ | ||
437 | * |
|
438 | * @since 3.4.0 |
|
439 | */ |
|
440 | public function start_previewing_theme() { |
|
441 | // Bail if we're already previewing. |
|
442 | if ( $this->is_preview() ) { |
|
443 | return; |
|
444 | } |
|
445 | ||
446 | $this->previewing = true; |
|
447 | ||
448 | if ( ! $this->is_theme_active() ) { |
|
449 | add_filter( 'template', array( $this, 'get_template' ) ); |
|
450 | add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); |
|
451 | add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); |
|
452 | ||
453 | // @link: https://core.trac.wordpress.org/ticket/20027 |
|
454 | add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); |
|
455 | add_filter( 'pre_option_template', array( $this, 'get_template' ) ); |
|
456 | ||
457 | // Handle custom theme roots. |
|
458 | add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); |
|
459 | add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); |
|
460 | } |
|
461 | ||
462 | /** |
|
463 | * Fires once the Customizer theme preview has started. |
|
464 | * |
|
465 | * @since 3.4.0 |
|
466 | * |
|
467 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
|
468 | */ |
|
469 | do_action( 'start_previewing_theme', $this ); |
|
470 | } |
|
471 | ||
472 | /** |
|
473 | * Stop previewing the selected theme. |
|
@@ 479-508 (lines=30) @@ | ||
476 | * |
|
477 | * @since 3.4.0 |
|
478 | */ |
|
479 | public function stop_previewing_theme() { |
|
480 | if ( ! $this->is_preview() ) { |
|
481 | return; |
|
482 | } |
|
483 | ||
484 | $this->previewing = false; |
|
485 | ||
486 | if ( ! $this->is_theme_active() ) { |
|
487 | remove_filter( 'template', array( $this, 'get_template' ) ); |
|
488 | remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); |
|
489 | remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); |
|
490 | ||
491 | // @link: https://core.trac.wordpress.org/ticket/20027 |
|
492 | remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); |
|
493 | remove_filter( 'pre_option_template', array( $this, 'get_template' ) ); |
|
494 | ||
495 | // Handle custom theme roots. |
|
496 | remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); |
|
497 | remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); |
|
498 | } |
|
499 | ||
500 | /** |
|
501 | * Fires once the Customizer theme preview has stopped. |
|
502 | * |
|
503 | * @since 3.4.0 |
|
504 | * |
|
505 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
|
506 | */ |
|
507 | do_action( 'stop_previewing_theme', $this ); |
|
508 | } |
|
509 | ||
510 | /** |
|
511 | * Get the theme being customized. |