Code Duplication    Length = 30-31 lines in 2 locations

src/wp-includes/class-wp-customize-manager.php 2 locations

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