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