|
@@ 641-671 (lines=31) @@
|
| 638 |
|
do_action( 'jetpack_full_sync_network_options', true ); |
| 639 |
|
} |
| 640 |
|
|
| 641 |
|
private function maybe_sync_constants() { |
| 642 |
|
if ( get_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME ) ) { |
| 643 |
|
return; |
| 644 |
|
} |
| 645 |
|
|
| 646 |
|
$constants = $this->get_all_constants(); |
| 647 |
|
if ( empty( $constants ) ) { |
| 648 |
|
return; |
| 649 |
|
} |
| 650 |
|
|
| 651 |
|
set_transient( self::CONSTANTS_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_constants_wait_time ); |
| 652 |
|
|
| 653 |
|
// only send the constants that have changed |
| 654 |
|
foreach ( $constants as $name => $value ) { |
| 655 |
|
$checksum = $this->get_check_sum( $value ); |
| 656 |
|
|
| 657 |
|
// explicitly not using Identical comparison as get_option returns a string |
| 658 |
|
if ( $checksum != get_option( self::CONSTANTS_CHECKSUM_OPTION_NAME . "_$name" ) ) { |
| 659 |
|
/** |
| 660 |
|
* Tells the client to sync a constant to the server |
| 661 |
|
* |
| 662 |
|
* @since 4.1 |
| 663 |
|
* |
| 664 |
|
* @param string The name of the constant |
| 665 |
|
* @param mixed The value of the constant |
| 666 |
|
*/ |
| 667 |
|
do_action( 'jetpack_sync_constant', $name, $value ); |
| 668 |
|
update_option( self::CONSTANTS_CHECKSUM_OPTION_NAME . "_$name", $checksum ); |
| 669 |
|
} |
| 670 |
|
} |
| 671 |
|
} |
| 672 |
|
|
| 673 |
|
private function get_all_constants() { |
| 674 |
|
return array_combine( |
|
@@ 697-726 (lines=30) @@
|
| 694 |
|
$this->maybe_sync_callables(); |
| 695 |
|
} |
| 696 |
|
|
| 697 |
|
private function maybe_sync_callables() { |
| 698 |
|
if ( get_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME ) ) { |
| 699 |
|
return; |
| 700 |
|
} |
| 701 |
|
|
| 702 |
|
$callables = $this->get_all_callables(); |
| 703 |
|
if ( empty( $callables ) ) { |
| 704 |
|
return; |
| 705 |
|
} |
| 706 |
|
|
| 707 |
|
set_transient( self::CALLABLES_AWAIT_TRANSIENT_NAME, microtime( true ), Jetpack_Sync_Defaults::$default_sync_callables_wait_time ); |
| 708 |
|
|
| 709 |
|
// only send the callables that have changed |
| 710 |
|
foreach ( $callables as $name => $value ) { |
| 711 |
|
$checksum = $this->get_check_sum( $value ); |
| 712 |
|
// explicitly not using Identical comparison as get_option returns a string |
| 713 |
|
if ( $checksum != get_option( self::CALLABLES_CHECKSUM_OPTION_NAME . "_$name" ) ) { |
| 714 |
|
/** |
| 715 |
|
* Tells the client to sync a callable (aka function) to the server |
| 716 |
|
* |
| 717 |
|
* @since 4.1 |
| 718 |
|
* |
| 719 |
|
* @param string The name of the callable |
| 720 |
|
* @param mixed The value of the callable |
| 721 |
|
*/ |
| 722 |
|
do_action( 'jetpack_sync_callable', $name, $value ); |
| 723 |
|
update_option( self::CALLABLES_CHECKSUM_OPTION_NAME . "_$name", $checksum ); |
| 724 |
|
} |
| 725 |
|
} |
| 726 |
|
} |
| 727 |
|
|
| 728 |
|
private function get_all_callables() { |
| 729 |
|
return array_combine( |