@@ 577-607 (lines=31) @@ | ||
574 | * |
|
575 | * @since 3.4.0 |
|
576 | */ |
|
577 | public function start_previewing_theme() { |
|
578 | // Bail if we're already previewing. |
|
579 | if ( $this->is_preview() ) { |
|
580 | return; |
|
581 | } |
|
582 | ||
583 | $this->previewing = true; |
|
584 | ||
585 | if ( ! $this->is_theme_active() ) { |
|
586 | add_filter( 'template', array( $this, 'get_template' ) ); |
|
587 | add_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); |
|
588 | add_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); |
|
589 | ||
590 | // @link: https://core.trac.wordpress.org/ticket/20027 |
|
591 | add_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); |
|
592 | add_filter( 'pre_option_template', array( $this, 'get_template' ) ); |
|
593 | ||
594 | // Handle custom theme roots. |
|
595 | add_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); |
|
596 | add_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); |
|
597 | } |
|
598 | ||
599 | /** |
|
600 | * Fires once the Customizer theme preview has started. |
|
601 | * |
|
602 | * @since 3.4.0 |
|
603 | * |
|
604 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
|
605 | */ |
|
606 | do_action( 'start_previewing_theme', $this ); |
|
607 | } |
|
608 | ||
609 | /** |
|
610 | * Stop previewing the selected theme. |
|
@@ 616-645 (lines=30) @@ | ||
613 | * |
|
614 | * @since 3.4.0 |
|
615 | */ |
|
616 | public function stop_previewing_theme() { |
|
617 | if ( ! $this->is_preview() ) { |
|
618 | return; |
|
619 | } |
|
620 | ||
621 | $this->previewing = false; |
|
622 | ||
623 | if ( ! $this->is_theme_active() ) { |
|
624 | remove_filter( 'template', array( $this, 'get_template' ) ); |
|
625 | remove_filter( 'stylesheet', array( $this, 'get_stylesheet' ) ); |
|
626 | remove_filter( 'pre_option_current_theme', array( $this, 'current_theme' ) ); |
|
627 | ||
628 | // @link: https://core.trac.wordpress.org/ticket/20027 |
|
629 | remove_filter( 'pre_option_stylesheet', array( $this, 'get_stylesheet' ) ); |
|
630 | remove_filter( 'pre_option_template', array( $this, 'get_template' ) ); |
|
631 | ||
632 | // Handle custom theme roots. |
|
633 | remove_filter( 'pre_option_stylesheet_root', array( $this, 'get_stylesheet_root' ) ); |
|
634 | remove_filter( 'pre_option_template_root', array( $this, 'get_template_root' ) ); |
|
635 | } |
|
636 | ||
637 | /** |
|
638 | * Fires once the Customizer theme preview has stopped. |
|
639 | * |
|
640 | * @since 3.4.0 |
|
641 | * |
|
642 | * @param WP_Customize_Manager $this WP_Customize_Manager instance. |
|
643 | */ |
|
644 | do_action( 'stop_previewing_theme', $this ); |
|
645 | } |
|
646 | ||
647 | /** |
|
648 | * Get the changeset UUID. |