Code Duplication    Length = 30-31 lines in 2 locations

sync/class.jetpack-sync-client.php 2 locations

@@ 616-646 (lines=31) @@
613
		do_action( 'jetpack_full_sync_network_options', true );
614
	}
615
616
	private function maybe_sync_constants() {
617
		if ( get_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME ) ) {
618
			return;
619
		}
620
621
		$constants = $this->get_all_constants();
622
		if ( empty( $constants ) ) {
623
			return;
624
		}
625
626
		set_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_constants_wait_time );
627
628
		// only send the constants that have changed
629
		foreach ( $constants as $name => $value ) {
630
			$checksum = $this->get_check_sum( $value );
631
632
			// explicitly not using Identical comparison as get_option returns a string
633
			if ( $checksum != get_option( self::CONSTANTS_CHECKSUM_OPTION_NAME . "_$name" ) ) {
634
				/**
635
				 * Tells the client to sync a constant to the server
636
				 *
637
				 * @since 4.1
638
				 *
639
				 * @param string The name of the constant
640
				 * @param mixed The value of the constant
641
				 */
642
				do_action( 'jetpack_sync_constant', $name, $value );
643
				update_option( self::CONSTANTS_CHECKSUM_OPTION_NAME . "_$name", $checksum );
644
			}
645
		}
646
	}
647
648
	private function get_all_constants() {
649
		return array_combine(
@@ 672-701 (lines=30) @@
669
		$this->maybe_sync_callables();
670
	}
671
672
	private function maybe_sync_callables() {
673
		if ( get_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME ) ) {
674
			return;
675
		}
676
677
		$callables = $this->get_all_callables();
678
		if ( empty( $callables ) ) {
679
			return;
680
		}
681
682
		set_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_callables_wait_time );
683
684
		// only send the callables that have changed
685
		foreach ( $callables as $name => $value ) {
686
			$checksum = $this->get_check_sum( $value );
687
			// explicitly not using Identical comparison as get_option returns a string
688
			if ( $checksum != get_option( self::CALLABLES_CHECKSUM_OPTION_NAME . "_$name" ) ) {
689
				/**
690
				 * Tells the client to sync a callable (aka function) to the server
691
				 *
692
				 * @since 4.1
693
				 *
694
				 * @param string The name of the callable
695
				 * @param mixed The value of the callable
696
				 */
697
				do_action( 'jetpack_sync_callable', $name, $value );
698
				update_option( self::CALLABLES_CHECKSUM_OPTION_NAME . "_$name", $checksum );
699
			}
700
		}
701
	}
702
703
	private function get_all_callables() {
704
		return array_combine(