Code Duplication    Length = 30-31 lines in 2 locations

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

@@ 658-688 (lines=31) @@
655
		do_action( 'jetpack_full_sync_network_options', true );
656
	}
657
658
	private function maybe_sync_constants() {
659
		if ( get_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME ) ) {
660
			return;
661
		}
662
663
		$constants = $this->get_all_constants();
664
		if ( empty( $constants ) ) {
665
			return;
666
		}
667
668
		set_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_constants_wait_time );
669
670
		// only send the constants that have changed
671
		foreach ( $constants as $name => $value ) {
672
			$checksum = $this->get_check_sum( $value );
673
674
			// explicitly not using Identical comparison as get_option returns a string
675
			if ( $checksum != get_option( self::CONSTANTS_CHECKSUM_OPTION_NAME . "_$name" ) ) {
676
				/**
677
				 * Tells the client to sync a constant to the server
678
				 *
679
				 * @since 4.1
680
				 *
681
				 * @param string The name of the constant
682
				 * @param mixed The value of the constant
683
				 */
684
				do_action( 'jetpack_sync_constant', $name, $value );
685
				update_option( self::CONSTANTS_CHECKSUM_OPTION_NAME . "_$name", $checksum );
686
			}
687
		}
688
	}
689
690
	private function get_all_constants() {
691
		return array_combine(
@@ 714-743 (lines=30) @@
711
		$this->maybe_sync_callables();
712
	}
713
714
	private function maybe_sync_callables() {
715
		if ( get_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME ) ) {
716
			return;
717
		}
718
719
		$callables = $this->get_all_callables();
720
		if ( empty( $callables ) ) {
721
			return;
722
		}
723
724
		set_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_callables_wait_time );
725
726
		// only send the callables that have changed
727
		foreach ( $callables as $name => $value ) {
728
			$checksum = $this->get_check_sum( $value );
729
			// explicitly not using Identical comparison as get_option returns a string
730
			if ( $checksum != get_option( self::CALLABLES_CHECKSUM_OPTION_NAME . "_$name" ) ) {
731
				/**
732
				 * Tells the client to sync a callable (aka function) to the server
733
				 *
734
				 * @since 4.1
735
				 *
736
				 * @param string The name of the callable
737
				 * @param mixed The value of the callable
738
				 */
739
				do_action( 'jetpack_sync_callable', $name, $value );
740
				update_option( self::CALLABLES_CHECKSUM_OPTION_NAME . "_$name", $checksum );
741
			}
742
		}
743
	}
744
745
	private function get_all_callables() {
746
		return array_combine(