|  | @@ 788-820 (lines=33) @@ | 
                                                            
                                    | 785 |  | 		return 1; // The number of actions enqueued | 
                                                            
                                    | 786 |  | 	} | 
                                                            
                                    | 787 |  |  | 
                                                            
                                    | 788 |  | 	private function maybe_sync_constants() { | 
                                                            
                                    | 789 |  | 		if ( get_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME ) ) { | 
                                                            
                                    | 790 |  | 			return; | 
                                                            
                                    | 791 |  | 		} | 
                                                            
                                    | 792 |  |  | 
                                                            
                                    | 793 |  | 		$constants = $this->get_all_constants(); | 
                                                            
                                    | 794 |  | 		if ( empty( $constants ) ) { | 
                                                            
                                    | 795 |  | 			return; | 
                                                            
                                    | 796 |  | 		} | 
                                                            
                                    | 797 |  |  | 
                                                            
                                    | 798 |  | 		set_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_constants_wait_time ); | 
                                                            
                                    | 799 |  | 		$constants_checksums = get_option( self::CONSTANTS_CHECKSUM_OPTION_NAME, array() ); | 
                                                            
                                    | 800 |  | 		// only send the constants that have changed | 
                                                            
                                    | 801 |  | 		foreach ( $constants as $name => $value ) { | 
                                                            
                                    | 802 |  | 			$checksum = $this->get_check_sum( $value ); | 
                                                            
                                    | 803 |  |  | 
                                                            
                                    | 804 |  | 			// explicitly not using Identical comparison as get_option returns a string | 
                                                            
                                    | 805 |  | 			if ( ! $this->still_valid_checksum( $constants_checksums, $name, $checksum ) ) { | 
                                                            
                                    | 806 |  | 				/** | 
                                                            
                                    | 807 |  | 				 * Tells the client to sync a constant to the server | 
                                                            
                                    | 808 |  | 				 * | 
                                                            
                                    | 809 |  | 				 * @since 4.2.0 | 
                                                            
                                    | 810 |  | 				 * | 
                                                            
                                    | 811 |  | 				 * @param string The name of the constant | 
                                                            
                                    | 812 |  | 				 * @param mixed The value of the constant | 
                                                            
                                    | 813 |  | 				 */ | 
                                                            
                                    | 814 |  | 				do_action( 'jetpack_sync_constant', $name, $value ); | 
                                                            
                                    | 815 |  | 				$constants_checksums[ $name ] = $checksum; | 
                                                            
                                    | 816 |  | 			} | 
                                                            
                                    | 817 |  | 		} | 
                                                            
                                    | 818 |  |  | 
                                                            
                                    | 819 |  | 		update_option( self::CONSTANTS_CHECKSUM_OPTION_NAME, $constants_checksums ); | 
                                                            
                                    | 820 |  | 	} | 
                                                            
                                    | 821 |  | 	// public so that we don't have to store an option for each constant | 
                                                            
                                    | 822 |  | 	function get_all_constants() { | 
                                                            
                                    | 823 |  | 		return array_combine( | 
                                                                                
                                |  | @@ 849-881 (lines=33) @@ | 
                                                            
                                    | 846 |  | 		$this->maybe_sync_callables(); | 
                                                            
                                    | 847 |  | 	} | 
                                                            
                                    | 848 |  |  | 
                                                            
                                    | 849 |  | 	private function maybe_sync_callables() { | 
                                                            
                                    | 850 |  | 		if ( get_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME ) ) { | 
                                                            
                                    | 851 |  | 			return; | 
                                                            
                                    | 852 |  | 		} | 
                                                            
                                    | 853 |  |  | 
                                                            
                                    | 854 |  | 		$callables = $this->get_all_callables(); | 
                                                            
                                    | 855 |  | 		if ( empty( $callables ) ) { | 
                                                            
                                    | 856 |  | 			return; | 
                                                            
                                    | 857 |  | 		} | 
                                                            
                                    | 858 |  |  | 
                                                            
                                    | 859 |  | 		set_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_callables_wait_time ); | 
                                                            
                                    | 860 |  |  | 
                                                            
                                    | 861 |  | 		$callable_checksums = get_option( self::CALLABLES_CHECKSUM_OPTION_NAME , array() ); | 
                                                            
                                    | 862 |  |  | 
                                                            
                                    | 863 |  | 		// only send the callables that have changed | 
                                                            
                                    | 864 |  | 		foreach ( $callables as $name => $value ) { | 
                                                            
                                    | 865 |  | 			$checksum = $this->get_check_sum( $value ); | 
                                                            
                                    | 866 |  | 			// explicitly not using Identical comparison as get_option returns a string | 
                                                            
                                    | 867 |  | 			if ( ! $this->still_valid_checksum( $callable_checksums, $name, $checksum ) ) { | 
                                                            
                                    | 868 |  | 				/** | 
                                                            
                                    | 869 |  | 				 * Tells the client to sync a callable (aka function) to the server | 
                                                            
                                    | 870 |  | 				 * | 
                                                            
                                    | 871 |  | 				 * @since 4.2.0 | 
                                                            
                                    | 872 |  | 				 * | 
                                                            
                                    | 873 |  | 				 * @param string The name of the callable | 
                                                            
                                    | 874 |  | 				 * @param mixed The value of the callable | 
                                                            
                                    | 875 |  | 				 */ | 
                                                            
                                    | 876 |  | 				do_action( 'jetpack_sync_callable', $name, $value ); | 
                                                            
                                    | 877 |  | 				$callable_checksums[ $name ] = $checksum; | 
                                                            
                                    | 878 |  | 			} | 
                                                            
                                    | 879 |  | 		} | 
                                                            
                                    | 880 |  | 		update_option( self::CALLABLES_CHECKSUM_OPTION_NAME , $callable_checksums ); | 
                                                            
                                    | 881 |  | 	} | 
                                                            
                                    | 882 |  |  | 
                                                            
                                    | 883 |  | 	private function still_valid_checksum( $sums_to_check, $name, $new_sum ) { | 
                                                            
                                    | 884 |  | 		if ( isset( $sums_to_check[ $name ] ) && $sums_to_check[ $name ] === $new_sum ) { |