Code Duplication    Length = 30-31 lines in 2 locations

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

@@ 605-635 (lines=31) @@
602
		do_action( 'jetpack_full_sync_network_options', true );
603
	}
604
605
	private function maybe_sync_constants() {
606
		if ( get_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME ) ) {
607
			return;
608
		}
609
610
		$constants = $this->get_all_constants();
611
		if ( empty( $constants ) ) {
612
			return;
613
		}
614
615
		set_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_constants_wait_time );
616
617
		// only send the constants that have changed
618
		foreach ( $constants as $name => $value ) {
619
			$checksum = $this->get_check_sum( $value );
620
621
			// explicitly not using Identical comparison as get_option returns a string
622
			if ( $checksum != get_option( self::CONSTANTS_CHECKSUM_OPTION_NAME . "_$name" ) ) {
623
				/**
624
				 * Tells the client to sync a constant to the server
625
				 *
626
				 * @since 4.1
627
				 *
628
				 * @param string The name of the constant
629
				 * @param mixed The value of the constant
630
				 */
631
				do_action( 'jetpack_sync_constant', $name, $value );
632
				update_option( self::CONSTANTS_CHECKSUM_OPTION_NAME . "_$name", $checksum );
633
			}
634
		}
635
	}
636
637
	private function get_all_constants() {
638
		return array_combine(
@@ 661-690 (lines=30) @@
658
		$this->maybe_sync_callables();
659
	}
660
661
	private function maybe_sync_callables() {
662
		if ( get_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME ) ) {
663
			return;
664
		}
665
666
		$callables = $this->get_all_callables();
667
		if ( empty( $callables ) ) {
668
			return;
669
		}
670
671
		set_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_callables_wait_time );
672
673
		// only send the callables that have changed
674
		foreach ( $callables as $name => $value ) {
675
			$checksum = $this->get_check_sum( $value );
676
			// explicitly not using Identical comparison as get_option returns a string
677
			if ( $checksum != get_option( self::CALLABLES_CHECKSUM_OPTION_NAME . "_$name" ) ) {
678
				/**
679
				 * Tells the client to sync a callable (aka function) to the server
680
				 *
681
				 * @since 4.1
682
				 *
683
				 * @param string The name of the callable
684
				 * @param mixed The value of the callable
685
				 */
686
				do_action( 'jetpack_sync_callable', $name, $value );
687
				update_option( self::CALLABLES_CHECKSUM_OPTION_NAME . "_$name", $checksum );
688
			}
689
		}
690
	}
691
692
	private function get_all_callables() {
693
		return array_combine(