| @@ 176-193 (lines=18) @@ | ||
| 173 | ||
| 174 | $constants_checksums = (array) get_option( self::CONSTANTS_CHECKSUM_OPTION_NAME, array() ); |
|
| 175 | ||
| 176 | foreach ( $constants as $name => $value ) { |
|
| 177 | $checksum = $this->get_check_sum( $value ); |
|
| 178 | // Explicitly not using Identical comparison as get_option returns a string. |
|
| 179 | if ( ! $this->still_valid_checksum( $constants_checksums, $name, $checksum ) && ! is_null( $value ) ) { |
|
| 180 | /** |
|
| 181 | * Tells the client to sync a constant to the server |
|
| 182 | * |
|
| 183 | * @since 4.2.0 |
|
| 184 | * |
|
| 185 | * @param string The name of the constant |
|
| 186 | * @param mixed The value of the constant |
|
| 187 | */ |
|
| 188 | do_action( 'jetpack_sync_constant', $name, $value ); |
|
| 189 | $constants_checksums[ $name ] = $checksum; |
|
| 190 | } else { |
|
| 191 | $constants_checksums[ $name ] = $checksum; |
|
| 192 | } |
|
| 193 | } |
|
| 194 | update_option( self::CONSTANTS_CHECKSUM_OPTION_NAME, $constants_checksums ); |
|
| 195 | } |
|
| 196 | ||
| @@ 419-437 (lines=19) @@ | ||
| 416 | $callable_checksums = (array) \Jetpack_Options::get_raw_option( self::CALLABLES_CHECKSUM_OPTION_NAME, array() ); |
|
| 417 | $has_changed = false; |
|
| 418 | // Only send the callables that have changed. |
|
| 419 | foreach ( $callables as $name => $value ) { |
|
| 420 | $checksum = $this->get_check_sum( $value ); |
|
| 421 | // Explicitly not using Identical comparison as get_option returns a string. |
|
| 422 | if ( ! is_null( $value ) && $this->should_send_callable( $callable_checksums, $name, $checksum ) ) { |
|
| 423 | /** |
|
| 424 | * Tells the client to sync a callable (aka function) to the server |
|
| 425 | * |
|
| 426 | * @since 4.2.0 |
|
| 427 | * |
|
| 428 | * @param string The name of the callable |
|
| 429 | * @param mixed The value of the callable |
|
| 430 | */ |
|
| 431 | do_action( 'jetpack_sync_callable', $name, $value ); |
|
| 432 | $callable_checksums[ $name ] = $checksum; |
|
| 433 | $has_changed = true; |
|
| 434 | } else { |
|
| 435 | $callable_checksums[ $name ] = $checksum; |
|
| 436 | } |
|
| 437 | } |
|
| 438 | if ( $has_changed ) { |
|
| 439 | \Jetpack_Options::update_raw_option( self::CALLABLES_CHECKSUM_OPTION_NAME, $callable_checksums ); |
|
| 440 | } |
|