PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | jetpack_vendor/automattic/jetpack-sync/src/class-functions.php +82 -12 12.4.2 → 16.3-a.5 View file →
@@ -6,11 +6,13 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Sync;
9 9
10 +use Automattic\Jetpack\Connection\Manager;
10 11 use Automattic\Jetpack\Connection\Urls;
11 12 use Automattic\Jetpack\Constants;
12 13 use Automattic\Jetpack\Modules as Jetpack_Modules;
14 +use Automattic\Jetpack\Status;
13 15
14 16 /**
15 17 * Utility functions to generate data synced to wpcom
16 18 */
@@ -69,9 +71,9 @@
69 71 */
70 72 public static function sanitize_taxonomy( $taxonomy ) {
71 73
72 74 // Lets clone the taxonomy object instead of modifing the global one.
73 - $cloned_taxonomy = json_decode( wp_json_encode( $taxonomy ) );
75 + $cloned_taxonomy = json_decode( wp_json_encode( $taxonomy, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ) );
74 76
75 77 // recursive taxonomies are no fun.
76 78 if ( $cloned_taxonomy === null ) {
77 79 return null;
@@ -144,9 +146,9 @@
144 146 $post_type_object->add_supports();
145 147 $post_type_object->add_rewrite_rules();
146 148 $post_type_object->add_hooks();
147 149 $post_type_object->register_taxonomies();
148 - return (object) $post_type_object;
150 + return $post_type_object;
149 151 }
150 152
151 153 /**
152 154 * Returns site's post_type_features.
@@ -390,9 +392,9 @@
390 392 /**
391 393 * Return the main network site WPCOM ID for multi-site installs
392 394 */
393 395 $current_network = get_network();
394 - switch_to_blog( $current_network->blog_id );
396 + switch_to_blog( (int) $current_network->blog_id );
395 397 $wpcom_blog_id = \Jetpack_Options::get_option( 'id' );
396 398 restore_current_blog();
397 399 return $wpcom_blog_id;
398 400 }
@@ -401,10 +403,10 @@
401 403 * Return URL with a normalized protocol.
402 404 *
403 405 * @deprecated 1.23.1
404 406 *
405 - * @param callable $callable Function to retrieve URL option.
406 - * @param string $new_value URL Protocol to set URLs to.
407 + * @param string $callable Function name that was used to retrieve URL option.
408 + * @param string $new_value URL Protocol to set URLs to.
407 409 * @return string Normalized URL.
408 410 */
409 411 public static function get_protocol_normalized_url( $callable, $new_value ) {
410 412 _deprecated_function( __METHOD__, '1.23.1', '\\Automattic\\Jetpack\\Connection\\Urls::get_protocol_normalized_url' );
@@ -469,9 +471,9 @@
469 471 if ( ! empty( $plugins_action_links ) ) {
470 472 if ( $plugin_file_singular === null ) {
471 473 return $plugins_action_links;
472 474 }
473 - return ( isset( $plugins_action_links[ $plugin_file_singular ] ) ? $plugins_action_links[ $plugin_file_singular ] : null );
475 + return ( $plugins_action_links[ $plugin_file_singular ] ?? null );
474 476 }
475 477 return array();
476 478 }
477 479
@@ -532,9 +534,9 @@
532 534
533 535 $formatted_gmt_offset = str_replace(
534 536 array( '.25', '.5', '.75' ),
535 537 array( ':15', ':30', ':45' ),
536 - (string) $formatted_gmt_offset
538 + $formatted_gmt_offset
537 539 );
538 540
539 541 /* translators: %s is UTC offset, e.g. "+1" */
540 542 return sprintf( __( 'UTC%s', 'jetpack-sync' ), $formatted_gmt_offset );
@@ -591,20 +593,50 @@
591 593 return wp_is_block_theme();
592 594 }
593 595
594 596 /**
597 + * Returns the site's visibility as a `blog_public` value, or -1 when Jetpack considers the site private.
598 + *
599 + * Lets `jetpack_is_private_site` report the site as private to WordPress.com without changing
600 + * the `blog_public` option itself, since core and other plugins do not expect a -1 there.
601 + *
602 + * @since 5.2.0
603 + *
604 + * @return int -1 when private, otherwise the stored `blog_public` value.
605 + */
606 + public static function get_site_visibility() {
607 + if ( ( new Status() )->is_private_site() ) {
608 + return -1;
609 + }
610 +
611 + return (int) get_option( 'blog_public', 1 );
612 + }
613 +
614 + /**
595 615 * Wraps data in a way so that we can distinguish between objects and array and also prevent object recursion.
596 616 *
597 617 * @since 1.21.0
598 618 *
599 - * @param array|obj $any Source data to be cleaned up.
600 - * @param array $seen_nodes Built array of nodes.
619 + * @param mixed $any Source data to be cleaned up.
620 + * @param array $seen_nodes Built array of nodes.
601 621 *
602 622 * @return array
603 623 */
604 624 public static function json_wrap( &$any, $seen_nodes = array() ) {
605 625 if ( is_object( $any ) ) {
606 - $input = get_object_vars( $any );
626 + $input = get_object_vars( $any );
627 +
628 + // WordPress 6.9 introduced lazy-loading of WP_User `roles`, `caps`, and `allcaps` properties.
629 + // It also made said properties protected, so we need to access them and set them as keys manually.
630 + if ( $any instanceof \WP_User ) {
631 + $roles = $any->roles;
632 + $caps = $any->caps;
633 + $allcaps = $any->allcaps;
634 + $input['roles'] = $roles;
635 + $input['caps'] = $caps;
636 + $input['allcaps'] = $allcaps;
637 + }
638 +
607 639 $input['__o'] = 1;
608 640 } else {
609 641 $input = &$any;
610 642 }
@@ -665,9 +697,9 @@
665 697
666 698 /**
667 699 * Return the list of active Jetpack modules.
668 700 *
669 - * @since $$next_version$$
701 + * @since 1.34.0
670 702 *
671 703 * @return array
672 704 */
673 705 public static function get_active_modules() {
@@ -676,9 +708,9 @@
676 708
677 709 /**
678 710 * Return a list of PHP modules that we want to track.
679 711 *
680 - * @since $$next_version$$
712 + * @since 1.50.0
681 713 *
682 714 * @return array
683 715 */
684 716 public static function get_loaded_extensions() {
@@ -707,6 +739,44 @@
707 739 }
708 740 }
709 741
710 742 return $enabled_extensions;
743 + }
744 +
745 + /**
746 + * Return the list of active connected Jetpack plugins.
747 + *
748 + * @since 3.2.0
749 + *
750 + * @return array
751 + */
752 + public static function get_jetpack_connection_active_plugins() {
753 + return ( new Manager() )->get_connected_plugins();
754 + }
755 +
756 + /**
757 + * Return the list of active sync modules.
758 + *
759 + * @since 3.6.0
760 + *
761 + * @return array
762 + */
763 + public static function get_jetpack_sync_active_modules() {
764 +
765 + /** This filter is documented in projects/packages/sync/src/class-modules.php */
766 + $modules = apply_filters( 'jetpack_sync_modules', Modules::DEFAULT_SYNC_MODULES );
767 + $modules = array_unique( $modules );
768 + $modules = array_map( 'wp_normalize_path', $modules );
769 + return $modules;
770 + }
771 +
772 + /**
773 + * Return the list of Jetpack package versions.
774 + *
775 + * @since 4.11.1
776 + *
777 + * @return array
778 + */
779 + public static function get_jetpack_package_versions() {
780 + return apply_filters( 'jetpack_package_versions', array() );
711 781 }
712 782 }