PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 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 All 507 releases
← All changes | _inc/lib/class.core-rest-api-endpoints.php +411 -862 13.6.2 → 16.3-beta View file →
@@ -8,10 +8,10 @@
8 8 use Automattic\Jetpack\Connection\Client;
9 9 use Automattic\Jetpack\Connection\Manager as Connection_Manager;
10 10 use Automattic\Jetpack\Connection\Rest_Authentication;
11 11 use Automattic\Jetpack\Connection\REST_Connector;
12 +use Automattic\Jetpack\Connection\REST_Jetpack_AI_JWT;
12 13 use Automattic\Jetpack\Connection\SSO;
13 -use Automattic\Jetpack\Current_Plan as Jetpack_Plan;
14 14 use Automattic\Jetpack\Jetpack_CRM_Data;
15 15 use Automattic\Jetpack\Plugins_Installer;
16 16 use Automattic\Jetpack\Stats\Options as Stats_Options;
17 17 use Automattic\Jetpack\Status\Host;
@@ -20,9 +20,9 @@
20 20 use Automattic\Jetpack\Waf\Waf_Compatibility;
21 21
22 22 // Disable direct access.
23 23 if ( ! defined( 'ABSPATH' ) ) {
24 - exit;
24 + exit( 0 );
25 25 }
26 26
27 27 // Load WP_Error for error messages.
28 28 require_once ABSPATH . '/wp-includes/class-wp-error.php';
@@ -32,8 +32,10 @@
32 32 // Load API endpoints that are synced with WP.com
33 33 // Each of these is a class that will register its own routes on 'rest_api_init'.
34 34 require_once JETPACK__PLUGIN_DIR . '_inc/lib/core-api/load-wpcom-endpoints.php';
35 35
36 +require_once JETPACK__PLUGIN_DIR . 'modules/subscriptions/class-settings.php';
37 +
36 38 /**
37 39 * Class Jetpack_Core_Json_Api_Endpoints
38 40 *
39 41 * @since 4.3.0
@@ -70,23 +72,10 @@
70 72 $module_toggle_endpoint = new Jetpack_Core_API_Module_Toggle_Endpoint( new Jetpack_IXR_Client() );
71 73 $site_endpoint = new Jetpack_Core_API_Site_Endpoint();
72 74 $widget_endpoint = new Jetpack_Core_API_Widget_Endpoint();
73 75
74 - /**
75 - * TODO: Move me somewhere that makes more sense.
76 - * Also give me permissions that aren't awful.
77 - */
78 - register_rest_route(
79 - 'jetpack/v4',
80 - 'jetpack-ai-jwt',
81 - array(
82 - 'methods' => WP_REST_Server::EDITABLE,
83 - 'callback' => __CLASS__ . '::get_openai_jwt',
84 - 'permission_callback' => function () {
85 - return ( new Connection_Manager( 'jetpack' ) )->is_user_connected() && current_user_can( 'edit_posts' );
86 - },
87 - )
88 - );
76 + // My Jetpack and Agents Manager register the same controller; its guard keeps the route registered once.
77 + ( new REST_Jetpack_AI_JWT() )->register_rest_route();
89 78
90 79 register_rest_route(
91 80 'jetpack/v4',
92 81 'plans',
@@ -116,32 +105,10 @@
116 105 'permission_callback' => __CLASS__ . '::disconnect_site_permission_callback',
117 106 )
118 107 );
119 108
120 - // Test current connection status of Jetpack.
121 109 register_rest_route(
122 110 'jetpack/v4',
123 - '/connection/test',
124 - array(
125 - 'methods' => WP_REST_Server::READABLE,
126 - 'callback' => __CLASS__ . '::jetpack_connection_test',
127 - 'permission_callback' => __CLASS__ . '::manage_modules_permission_check',
128 - )
129 - );
130 -
131 - // Endpoint specific for privileged servers to request detailed debug information.
132 - register_rest_route(
133 - 'jetpack/v4',
134 - '/connection/test-wpcom/',
135 - array(
136 - 'methods' => WP_REST_Server::READABLE,
137 - 'callback' => __CLASS__ . '::jetpack_connection_test_for_external',
138 - 'permission_callback' => __CLASS__ . '::view_jetpack_connection_test_check',
139 - )
140 - );
141 -
142 - register_rest_route(
143 - 'jetpack/v4',
144 111 '/rewind',
145 112 array(
146 113 'methods' => WP_REST_Server::READABLE,
147 114 'callback' => __CLASS__ . '::get_rewind_data',
@@ -194,33 +161,11 @@
194 161 ),
195 162 )
196 163 );
197 164
198 - // Disconnect/unlink user from WordPress.com servers.
165 + // Get current site features.
199 166 register_rest_route(
200 167 'jetpack/v4',
201 - '/connection/user',
202 - array(
203 - 'methods' => WP_REST_Server::EDITABLE,
204 - 'callback' => __CLASS__ . '::unlink_user',
205 - 'permission_callback' => __CLASS__ . '::unlink_user_permission_callback',
206 - )
207 - );
208 -
209 - // Get current site data.
210 - register_rest_route(
211 - 'jetpack/v4',
212 - '/site',
213 - array(
214 - 'methods' => WP_REST_Server::READABLE,
215 - 'callback' => __CLASS__ . '::get_site_data',
216 - 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check',
217 - )
218 - );
219 -
220 - // Get current site data.
221 - register_rest_route(
222 - 'jetpack/v4',
223 168 '/site/features',
224 169 array(
225 170 'methods' => WP_REST_Server::READABLE,
226 171 'callback' => array( $site_endpoint, 'get_features' ),
@@ -604,103 +549,8 @@
604 549 ),
605 550 )
606 551 );
607 552
608 - register_rest_route(
609 - 'jetpack/v4',
610 - '/recommendations/data',
611 - array(
612 - array(
613 - 'methods' => WP_REST_Server::READABLE,
614 - 'callback' => __CLASS__ . '::get_recommendations_data',
615 - 'permission_callback' => __CLASS__ . '::update_settings_permission_check',
616 - ),
617 - array(
618 - 'methods' => WP_REST_Server::EDITABLE,
619 - 'callback' => __CLASS__ . '::update_recommendations_data',
620 - 'permission_callback' => __CLASS__ . '::update_settings_permission_check',
621 - 'args' => array(
622 - 'data' => array(
623 - 'required' => true,
624 - 'type' => 'object',
625 - 'validate_callback' => __CLASS__ . '::validate_recommendations_data',
626 - ),
627 - ),
628 - ),
629 - )
630 - );
631 -
632 - register_rest_route(
633 - 'jetpack/v4',
634 - '/recommendations/step',
635 - array(
636 - array(
637 - 'methods' => WP_REST_Server::READABLE,
638 - 'callback' => __CLASS__ . '::get_recommendations_step',
639 - 'permission_callback' => __CLASS__ . '::update_settings_permission_check',
640 - ),
641 - array(
642 - 'methods' => WP_REST_Server::EDITABLE,
643 - 'callback' => __CLASS__ . '::update_recommendations_step',
644 - 'permission_callback' => __CLASS__ . '::update_settings_permission_check',
645 - 'args' => array(
646 - 'step' => array(
647 - 'required' => true,
648 - 'type' => 'string',
649 - 'validate_callback' => __CLASS__ . '::validate_string',
650 - ),
651 - ),
652 - ),
653 - )
654 - );
655 -
656 - register_rest_route(
657 - 'jetpack/v4',
658 - '/recommendations/product-suggestions',
659 - array(
660 - array(
661 - 'methods' => WP_REST_Server::READABLE,
662 - 'callback' => __CLASS__ . '::get_recommendations_product_suggestions',
663 - 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check',
664 - ),
665 - )
666 - );
667 -
668 - register_rest_route(
669 - 'jetpack/v4',
670 - '/recommendations/upsell',
671 - array(
672 - array(
673 - 'methods' => WP_REST_Server::READABLE,
674 - 'callback' => __CLASS__ . '::get_recommendations_upsell',
675 - 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check',
676 - ),
677 - )
678 - );
679 -
680 - register_rest_route(
681 - 'jetpack/v4',
682 - '/recommendations/conditional',
683 - array(
684 - array(
685 - 'methods' => WP_REST_Server::READABLE,
686 - 'callback' => __CLASS__ . '::get_conditional_recommendations',
687 - 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check',
688 - ),
689 - )
690 - );
691 -
692 - // Get site discount.
693 - register_rest_route(
694 - 'jetpack/v4',
695 - '/site/discount',
696 - array(
697 - 'methods' => WP_REST_Server::READABLE,
698 - 'callback' => __CLASS__ . '::get_site_discount',
699 - 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check',
700 - )
701 - );
702 -
703 553 /*
704 554 * Manage the Jetpack CRM plugin's integration with Jetpack contact forms.
705 555 */
706 556 register_rest_route(
@@ -755,19 +605,8 @@
755 605 'permission_callback' => __CLASS__ . '::manage_modules_permission_check',
756 606 )
757 607 );
758 608
759 - // Get Jetpack introduction offers
760 - register_rest_route(
761 - 'jetpack/v4',
762 - '/intro-offers',
763 - array(
764 - 'methods' => WP_REST_Server::READABLE,
765 - 'callback' => __CLASS__ . '::get_intro_offers',
766 - 'permission_callback' => __CLASS__ . '::view_admin_page_permission_check',
767 - )
768 - );
769 -
770 609 // Save subscriber token and redirect
771 610 register_rest_route(
772 611 'jetpack/v4',
773 612 '/subscribers/auth',
@@ -786,42 +625,59 @@
786 625 ),
787 626 ),
788 627 )
789 628 );
629 +
630 + /**
631 + * Get the list of available Jetpack features.
632 + *
633 + * @since 13.9
634 + */
635 + register_rest_route(
636 + 'jetpack/v4',
637 + '/features/available',
638 + array(
639 + 'methods' => WP_REST_Server::READABLE,
640 + 'callback' => array( static::class, 'get_features_available' ),
641 + 'permission_callback' => array( static::class, 'get_features_permission_check' ),
642 + )
643 + );
644 +
645 + /**
646 + * Get the list of enabled Jetpack features.
647 + *
648 + * @since 13.9
649 + */
650 + register_rest_route(
651 + 'jetpack/v4',
652 + '/features/enabled',
653 + array(
654 + 'methods' => WP_REST_Server::READABLE,
655 + 'callback' => array( static::class, 'get_features_enabled' ),
656 + 'permission_callback' => array( static::class, 'get_features_permission_check' ),
657 + )
658 + );
790 659 }
791 660
792 661 /**
793 662 * Ask WPCOM for a JWT token to use for OpenAI conversations.
794 - * TODO: Clean me up. This is ugly hack code.
663 + *
664 + * @deprecated since 16.2
665 + * @see Automattic\Jetpack\Connection\REST_Jetpack_AI_JWT::get_jwt()
666 + *
667 + * @return array|WP_Error The token and blog ID, or the error from WPCOM.
795 668 */
796 669 public static function get_openai_jwt() {
797 - $blog_id = \Jetpack_Options::get_option( 'id' );
670 + _deprecated_function( __METHOD__, 'jetpack-16.2', '\Automattic\Jetpack\Connection\REST_Jetpack_AI_JWT::get_jwt' );
798 671
799 - $response = \Automattic\Jetpack\Connection\Client::wpcom_json_api_request_as_user(
800 - "/sites/$blog_id/jetpack-openai-query/jwt",
801 - '2',
802 - array(
803 - 'method' => 'POST',
804 - 'headers' => array( 'Content-Type' => 'application/json; charset=utf-8' ),
805 - ),
806 - wp_json_encode( array() ),
807 - 'wpcom'
808 - );
672 + $response = ( new REST_Jetpack_AI_JWT() )->get_jwt();
809 673
810 674 if ( is_wp_error( $response ) ) {
811 675 return $response;
812 676 }
813 677
814 - $json = json_decode( wp_remote_retrieve_body( $response ) );
815 -
816 - if ( ! isset( $json->token ) ) {
817 - return new WP_Error( 'no-token', 'No token returned from WPCOM' );
818 - }
819 -
820 - return array(
821 - 'token' => $json->token,
822 - 'blog_id' => $blog_id,
823 - );
678 + // Pre-deprecation callers expect the raw array, not a WP_REST_Response.
679 + return $response->get_data();
824 680 }
825 681
826 682 /**
827 683 * Set subscriber cookie and redirect
@@ -832,191 +688,27 @@
832 688 */
833 689 public static function set_subscriber_cookie_and_redirect( $request ) {
834 690 require_once JETPACK__PLUGIN_DIR . 'extensions/blocks/premium-content/_inc/subscription-service/include.php';
835 691 $subscription_service = \Automattic\Jetpack\Extensions\Premium_Content\subscription_service();
836 - $token = $subscription_service->get_and_set_token_from_request();
837 - $payload = $subscription_service->decode_token( $token );
838 - $is_valid_token = ! empty( $payload );
839 - if ( $is_valid_token ) {
840 - return new WP_REST_Response( null, 302, array( 'location' => $request['redirect_url'] ) );
692 + // Note: get_and_set_token_from_request() sets the subscriber cookie as a side effect.
693 + // The cookie is set regardless of the redirect target below; only the redirect is gated.
694 + $token = $subscription_service->get_and_set_token_from_request();
695 + $payload = $subscription_service->decode_token( $token );
696 + $is_valid_token = ! empty( $payload );
697 + if ( ! $is_valid_token ) {
698 + return new WP_Error( 'invalid-token', 'Invalid Token', array( 'status' => 403 ) );
841 699 }
842 - return new WP_Error( 'invalid-token', 'Invalid Token' );
843 - }
844 700
845 - /**
846 - * Get the data for the recommendations
847 - *
848 - * @return array Recommendations data
849 - */
850 - public static function get_recommendations_data() {
851 - return Jetpack_Recommendations::get_recommendations_data();
852 - }
853 -
854 - /**
855 - * Update the data for the recommendations
856 - *
857 - * @param WP_REST_Request $request The request.
858 - *
859 - * @return bool true
860 - */
861 - public static function update_recommendations_data( $request ) {
862 - $data = $request['data'];
863 - Jetpack_Recommendations::update_recommendations_data( $data );
864 -
865 - return true;
866 - }
867 -
868 - /**
869 - * Get the data for the recommendations
870 - *
871 - * @return array Recommendations data
872 - */
873 - public static function get_recommendations_step() {
874 - return Jetpack_Recommendations::get_recommendations_step();
875 - }
876 -
877 - /**
878 - * Update the step for the recommendations
879 - *
880 - * @param WP_REST_Request $request The request.
881 - *
882 - * @return bool true
883 - */
884 - public static function update_recommendations_step( $request ) {
885 - $step = $request['step'];
886 - Jetpack_Recommendations::update_recommendations_step( $step );
887 -
888 - return true;
889 - }
890 -
891 - /**
892 - * Get product suggestions for the recommendations
893 - *
894 - * @return string|WP_Error The response from the wpcom product suggestions endpoint as a JSON object.
895 - */
896 - public static function get_recommendations_product_suggestions() {
897 - $blog_id = Jetpack_Options::get_option( 'id' );
898 - if ( ! $blog_id ) {
899 - return new WP_Error( 'site_not_registered', esc_html__( 'Site not registered.', 'jetpack' ) );
701 + // Only redirect to the current site, not to an arbitrary host.
702 + $redirect_url = wp_validate_redirect( $request['redirect_url'], '' );
703 + if ( ! $redirect_url ) {
704 + return new WP_Error( 'invalid-redirect', 'Invalid Redirect URL', array( 'status' => 400 ) );
900 705 }
901 706
902 - $user_connected = ( new Connection_Manager( 'jetpack' ) )->is_user_connected( get_current_user_id() );
903 - if ( ! $user_connected ) {
904 - return wp_json_encode( array() );
905 - }
906 -
907 - $request_path = sprintf( '/sites/%s/jetpack-recommendations/product-suggestions?locale=' . get_user_locale(), $blog_id );
908 - $wpcom_request = Client::wpcom_json_api_request_as_user(
909 - $request_path,
910 - '2',
911 - array(
912 - 'method' => 'GET',
913 - 'headers' => array(
914 - 'X-Forwarded-For' => ( new Visitor() )->get_ip( true ),
915 - ),
916 - )
917 - );
918 -
919 - $response_code = wp_remote_retrieve_response_code( $wpcom_request );
920 - if ( 200 === $response_code ) {
921 - return json_decode( wp_remote_retrieve_body( $wpcom_request ) );
922 - } else {
923 - return new WP_Error(
924 - 'failed_to_fetch_data',
925 - esc_html__( 'Unable to fetch the requested data.', 'jetpack' ),
926 - array( 'status' => $response_code )
927 - );
928 - }
707 + return new WP_REST_Response( null, 302, array( 'location' => $redirect_url ) );
929 708 }
930 709
931 710 /**
932 - * Get the upsell for the recommendations
933 - *
934 - * @return string The response from the wpcom upsell endpoint as a JSON object
935 - */
936 - public static function get_recommendations_upsell() {
937 - $blog_id = Jetpack_Options::get_option( 'id' );
938 - if ( ! $blog_id ) {
939 - return new WP_Error( 'site_not_registered', esc_html__( 'Site not registered.', 'jetpack' ) );
940 - }
941 -
942 - $user_connected = ( new Connection_Manager( 'jetpack' ) )->is_user_connected( get_current_user_id() );
943 - if ( ! $user_connected ) {
944 - $response = array(
945 - 'hide_upsell' => true,
946 - );
947 -
948 - return $response;
949 - }
950 -
951 - $request_path = sprintf( '/sites/%s/jetpack-recommendations/upsell?locale=' . get_user_locale(), $blog_id );
952 - $wpcom_request = Client::wpcom_json_api_request_as_user(
953 - $request_path,
954 - '2',
955 - array(
956 - 'method' => 'GET',
957 - 'headers' => array(
958 - 'X-Forwarded-For' => ( new Visitor() )->get_ip( true ),
959 - ),
960 - )
961 - );
962 -
963 - $response_code = wp_remote_retrieve_response_code( $wpcom_request );
964 - if ( 200 === $response_code ) {
965 - return json_decode( wp_remote_retrieve_body( $wpcom_request ) );
966 - } else {
967 - return new WP_Error(
968 - 'failed_to_fetch_data',
969 - esc_html__( 'Unable to fetch the requested data.', 'jetpack' ),
970 - array( 'status' => $response_code )
971 - );
972 - }
973 - }
974 -
975 - /**
976 - * Get conditional recommendations data.
977 - *
978 - * @return array Conditional recommendations data.
979 - */
980 - public static function get_conditional_recommendations() {
981 - return Jetpack_Recommendations::get_conditional_recommendations();
982 - }
983 -
984 - /**
985 - * Validate the recommendations data
986 - *
987 - * @param array $value Value to check received by request.
988 - * @param WP_REST_Request $request The request sent to the WP REST API.
989 - * @param string $param Name of the parameter passed to endpoint holding $value.
990 - *
991 - * @return bool|WP_Error
992 - */
993 - public static function validate_recommendations_data( $value, $request, $param ) {
994 - if ( ! is_array( $value ) ) {
995 - /* translators: Name of a parameter that must be an object */
996 - return new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an object.', 'jetpack' ), $param ) );
997 - }
998 -
999 - foreach ( $value as $answer ) {
1000 - if ( is_array( $answer ) ) {
1001 - $validate = self::validate_array_of_strings( $answer, $request, $param );
1002 - } elseif ( is_string( $answer ) ) {
1003 - $validate = self::validate_string( $answer, $request, $param );
1004 - } elseif ( $answer === null ) {
1005 - $validate = true;
1006 - } else {
1007 - $validate = self::validate_boolean( $answer, $request, $param );
1008 - }
1009 -
1010 - if ( is_wp_error( $validate ) ) {
1011 - return $validate;
1012 - }
1013 - }
1014 -
1015 - return true;
1016 - }
1017 -
1018 - /**
1019 711 * Return a purchase token used for site-connected (non user-authenticated) checkout.
1020 712 *
1021 713 * @return string|WP_Error The current purchase token or WP_Error with error details.
1022 714 */
@@ -1171,8 +863,9 @@
1171 863 || Jetpack::is_plugin_active( 'mojo-under-construction/mojo-contruction.php' ) && 1 == $under_construction_activation_status // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
1172 864 || ( Jetpack::is_plugin_active( 'under-construction-page/under-construction.php' ) && isset( $ucp_options['status'] ) && 1 == $ucp_options['status'] ) // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
1173 865 || ( Jetpack::is_plugin_active( 'ultimate-under-construction/ultimate-under-construction.php' ) && isset( $uuc_settings['enable'] ) && 1 == $uuc_settings['enable'] ) // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
1174 866 || ( Jetpack::is_plugin_active( 'coming-soon/coming-soon.php' ) && isset( $csp4['status'] ) && ( 1 == $csp4['status'] || 2 == $csp4['status'] ) ) // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual
867 + ||
1175 868 /**
1176 869 * Allow plugins to mark a site as "under construction".
1177 870 *
1178 871 * @since 6.7.0
@@ -1178,9 +871,9 @@
1178 871 * @since 6.7.0
1179 872 *
1180 873 * @param false bool Is the site under construction? Default to false.
1181 874 */
1182 - || true === apply_filters( 'jetpack_is_under_construction_plugin', false )
875 + true === apply_filters( 'jetpack_is_under_construction_plugin', false )
1183 876 ) {
1184 877 return new WP_Error( 'forbidden', __( 'Site is under construction and cannot be verified', 'jetpack' ) );
1185 878 }
1186 879
@@ -1319,24 +1012,20 @@
1319 1012
1320 1013 /**
1321 1014 * Verify that a user can use the /connection/user endpoint. Has to be a registered user and be currently linked.
1322 1015 *
1016 + * @uses Automattic\Jetpack\Connection\Manager::is_user_connected();)
1017 + *
1018 + * @deprecated since Jetpack 14.4.0
1019 + * @see Automattic\Jetpack\Connection\REST_Connector::unlink_user_permission_callback()
1020 + *
1323 1021 * @since 4.3.0
1324 1022 *
1325 - * @uses Automattic\Jetpack\Connection\Manager::is_user_connected();)
1326 - *
1327 1023 * @return bool|WP_Error True if user is able to unlink.
1328 1024 */
1329 1025 public static function unlink_user_permission_callback() {
1330 - if ( current_user_can( 'jetpack_connect_user' ) && ( new Connection_Manager( 'jetpack' ) )->is_user_connected( get_current_user_id() ) ) {
1331 - return true;
1332 - }
1333 -
1334 - return new WP_Error(
1335 - 'invalid_user_permission_unlink_user',
1336 - REST_Connector::get_user_permissions_error_msg(),
1337 - array( 'status' => rest_authorization_required_code() )
1338 - );
1026 + _deprecated_function( __METHOD__, 'jetpack-14.4.0', 'Automattic\Jetpack\Connection\REST_Connector::unlink_user_permission_callback()' );
1027 + return REST_Connector::unlink_user_permission_callback();
1339 1028 }
1340 1029
1341 1030 /**
1342 1031 * Verify that user can manage Jetpack modules.
@@ -1471,139 +1160,8 @@
1471 1160 );
1472 1161 }
1473 1162
1474 1163 /**
1475 - * Test connection status for this Jetpack site.
1476 - *
1477 - * @since 6.8.0
1478 - *
1479 - * @return array|WP_Error WP_Error returned if connection test does not succeed.
1480 - */
1481 - public static function jetpack_connection_test() {
1482 - require_once JETPACK__PLUGIN_DIR . '_inc/lib/debugger.php';
1483 - $cxntests = new Jetpack_Cxn_Tests();
1484 -
1485 - if ( $cxntests->pass() ) {
1486 - return rest_ensure_response(
1487 - array(
1488 - 'code' => 'success',
1489 - 'message' => __( 'All connection tests passed.', 'jetpack' ),
1490 - )
1491 - );
1492 - } else {
1493 - return $cxntests->output_fails_as_wp_error();
1494 - }
1495 - }
1496 -
1497 - /**
1498 - * Test connection permission check method.
1499 - *
1500 - * @since 7.1.0
1501 - *
1502 - * @return bool
1503 - */
1504 - public static function view_jetpack_connection_test_check() {
1505 - // phpcs:disable WordPress.Security.NonceVerification.Recommended -- This is verifying the trusted caller via a shared private key and timestamp.
1506 - if ( ! isset( $_GET['signature'] ) || ! isset( $_GET['timestamp'] ) || ! isset( $_GET['url'] ) ) {
1507 - return false;
1508 - }
1509 - $signature = base64_decode( wp_unslash( $_GET['signature'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_decode, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1510 -
1511 - $signature_data = wp_json_encode(
1512 - array(
1513 - 'rest_route' => isset( $_GET['rest_route'] ) ? filter_var( wp_unslash( $_GET['rest_route'] ) ) : null,
1514 - 'timestamp' => (int) $_GET['timestamp'],
1515 - 'url' => esc_url_raw( wp_unslash( $_GET['url'] ) ),
1516 - )
1517 - );
1518 -
1519 - if (
1520 - ! function_exists( 'openssl_verify' )
1521 - || 1 !== openssl_verify(
1522 - $signature_data,
1523 - $signature,
1524 - JETPACK__DEBUGGER_PUBLIC_KEY
1525 - )
1526 - ) {
1527 - return false;
1528 - }
1529 -
1530 - // signature timestamp must be within 5min of current time.
1531 - if ( abs( time() - (int) $_GET['timestamp'] ) > 300 ) {
1532 - return false;
1533 - }
1534 -
1535 - // phpcs:enable WordPress.Security.NonceVerification.Recommended
1536 -
1537 - return true;
1538 - }
1539 -
1540 - /**
1541 - * Test connection status for this Jetpack site, encrypt the results for decryption by a third-party.
1542 - *
1543 - * @since 7.1.0
1544 - *
1545 - * @return array|mixed|object|WP_Error
1546 - */
1547 - public static function jetpack_connection_test_for_external() {
1548 - // Since we are running this test for inclusion in the WP.com testing suite, let's not try to run them as part of these results.
1549 - add_filter( 'jetpack_debugger_run_self_test', '__return_false' );
1550 - require_once JETPACK__PLUGIN_DIR . '_inc/lib/debugger.php';
1551 - $cxntests = new Jetpack_Cxn_Tests();
1552 -
1553 - if ( $cxntests->pass() ) {
1554 - $result = array(
1555 - 'code' => 'success',
1556 - 'message' => __( 'All connection tests passed.', 'jetpack' ),
1557 - );
1558 - } else {
1559 - $error = $cxntests->output_fails_as_wp_error(); // Using this so the output is similar both ways.
1560 - $errors = array();
1561 -
1562 - // Borrowed from WP_REST_Server::error_to_response().
1563 - foreach ( (array) $error->errors as $code => $messages ) {
1564 - foreach ( (array) $messages as $message ) {
1565 - $errors[] = array(
1566 - 'code' => $code,
1567 - 'message' => $message,
1568 - 'data' => $error->get_error_data( $code ),
1569 - );
1570 - }
1571 - }
1572 -
1573 - $result = ( ! empty( $errors ) ) ? $errors[0] : null;
1574 - if ( count( $errors ) > 1 ) {
1575 - // Remove the primary error.
1576 - array_shift( $errors );
1577 - $result['additional_errors'] = $errors;
1578 - }
1579 - }
1580 -
1581 - $result = wp_json_encode( $result );
1582 -
1583 - $encrypted = $cxntests->encrypt_string_for_wpcom( $result );
1584 -
1585 - if ( ! $encrypted || ! is_array( $encrypted ) ) {
1586 - return rest_ensure_response(
1587 - array(
1588 - 'code' => 'action_required',
1589 - 'message' => 'Please request results from the in-plugin debugger',
1590 - )
1591 - );
1592 - }
1593 -
1594 - return rest_ensure_response(
1595 - array(
1596 - 'code' => 'response',
1597 - 'debug' => array(
1598 - 'data' => $encrypted['data'],
1599 - 'key' => $encrypted['key'],
1600 - ),
1601 - )
1602 - );
1603 - }
1604 -
1605 - /**
1606 1164 * Fetch information about the Rewind status of the site.
1607 1165 */
1608 1166 public static function rewind_data() {
1609 1167 $site_id = Jetpack_Options::get_option( 'id' );
@@ -1646,9 +1204,9 @@
1646 1204 return rest_ensure_response(
1647 1205 array(
1648 1206 'code' => 'success',
1649 1207 'message' => esc_html__( 'Backup & Scan data correctly received.', 'jetpack' ),
1650 - 'data' => wp_json_encode( $rewind_data ),
1208 + 'data' => wp_json_encode( $rewind_data, JSON_UNESCAPED_SLASHES ),
1651 1209 )
1652 1210 );
1653 1211 }
1654 1212
@@ -1729,9 +1287,9 @@
1729 1287 return rest_ensure_response(
1730 1288 array(
1731 1289 'code' => 'success',
1732 1290 'message' => esc_html__( 'Scan state correctly received.', 'jetpack' ),
1733 - 'data' => wp_json_encode( $scan_state ),
1291 + 'data' => wp_json_encode( $scan_state, JSON_UNESCAPED_SLASHES ),
1734 1292 )
1735 1293 );
1736 1294 }
1737 1295
@@ -1788,10 +1346,10 @@
1788 1346 *
1789 1347 * @return string|WP_Error A raw URL if the connection URL could be built; error message otherwise.
1790 1348 */
1791 1349 public static function build_connect_url( $request = array() ) {
1792 - $from = isset( $request['from'] ) ? $request['from'] : false;
1793 - $redirect = isset( $request['redirect'] ) ? $request['redirect'] : false;
1350 + $from = $request['from'] ?? false;
1351 + $redirect = $request['redirect'] ?? false;
1794 1352
1795 1353 $url = Jetpack::init()->build_connect_url( true, $redirect, $from );
1796 1354 if ( $url ) {
1797 1355 return rest_ensure_response( $url );
@@ -1814,9 +1372,9 @@
1814 1372 */
1815 1373 public static function get_user_connection_data() {
1816 1374 _deprecated_function( __METHOD__, 'jetpack-10.0.0', '\Automattic\Jetpack\Connection\REST_Connector::get_user_connection_data' );
1817 1375
1818 - require_once JETPACK__PLUGIN_DIR . '_inc/lib/admin-pages/class.jetpack-react-page.php';
1376 + require_once JETPACK__PLUGIN_DIR . '_inc/lib/admin-pages/class-jetpack-redux-state-helper.php';
1819 1377
1820 1378 $connection_owner = ( new Connection_Manager() )->get_connection_owner();
1821 1379 $owner_display_name = false === $connection_owner ? null : $connection_owner->data->display_name;
1822 1380
@@ -1829,30 +1387,21 @@
1829 1387
1830 1388 /**
1831 1389 * Unlinks current user from the WordPress.com Servers.
1832 1390 *
1833 - * @since 4.3.0
1391 + * @param WP_REST_Request $request The request sent to the WP REST API.
1834 1392 * @uses Automattic\Jetpack\Connection\Manager->disconnect_user
1835 1393 *
1836 - * @param WP_REST_Request $request The request sent to the WP REST API.
1394 + * @deprecated since Jetpack 14.4.0
1395 + * @see Automattic\Jetpack\Connection\REST_Connector::unlink_user()
1837 1396 *
1397 + * @since 4.3.0
1398 + *
1838 1399 * @return bool|WP_Error True if user successfully unlinked.
1839 1400 */
1840 1401 public static function unlink_user( $request ) {
1841 -
1842 - if ( ! isset( $request['linked'] ) || false !== $request['linked'] ) {
1843 - return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) );
1844 - }
1845 -
1846 - if ( ( new Connection_Manager( 'jetpack' ) )->disconnect_user() ) {
1847 - return rest_ensure_response(
1848 - array(
1849 - 'code' => 'success',
1850 - )
1851 - );
1852 - }
1853 -
1854 - return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) );
1402 + _deprecated_function( __METHOD__, 'jetpack-14.4.0', 'Automattic\Jetpack\Connection\REST_Connector::unlink_user()' );
1403 + return REST_Connector::unlink_user( $request );
1855 1404 }
1856 1405
1857 1406 /**
1858 1407 * Gets current user's tracking settings.
@@ -1911,9 +1460,9 @@
1911 1460 'Content-Type' => 'application/json',
1912 1461 'X-Forwarded-For' => ( new Visitor() )->get_ip( true ),
1913 1462 ),
1914 1463 ),
1915 - wp_json_encode( $request->get_params() )
1464 + wp_json_encode( $request->get_params(), JSON_UNESCAPED_SLASHES )
1916 1465 );
1917 1466 if ( ! is_wp_error( $response ) ) {
1918 1467 $response = json_decode( wp_remote_retrieve_body( $response ), true );
1919 1468 }
@@ -1925,93 +1474,30 @@
1925 1474 /**
1926 1475 * Fetch site data from .com including the site's current plan and the site's products.
1927 1476 *
1928 1477 * @since 5.5.0
1478 + * @deprecated 16.2 Use Automattic\Jetpack\Connection\Manager::get_connected_site_data().
1929 1479 *
1930 1480 * @return stdClass|WP_Error
1931 1481 */
1932 1482 public static function site_data() {
1933 - $site_id = Jetpack_Options::get_option( 'id' );
1483 + _deprecated_function( __METHOD__, 'jetpack-16.2', 'Automattic\Jetpack\Connection\Manager::get_connected_site_data' );
1934 1484
1935 - if ( ! $site_id ) {
1936 - return new WP_Error( 'site_id_missing', '', array( 'api_error_code' => __( 'site_id_missing', 'jetpack' ) ) );
1937 - }
1485 + return ( new Connection_Manager() )->get_connected_site_data();
1486 + }
1938 1487
1939 - $args = array( 'headers' => array() );
1940 -
1941 - // Allow use a store sandbox. Internal ref: PCYsg-IA-p2.
1942 - if ( isset( $_COOKIE ) && isset( $_COOKIE['store_sandbox'] ) ) {
1943 - $secret = filter_var( wp_unslash( $_COOKIE['store_sandbox'] ) );
1944 - $args['headers']['Cookie'] = "store_sandbox=$secret;";
1945 - }
1946 -
1947 - $response = Client::wpcom_json_api_request_as_blog( sprintf( '/sites/%d', $site_id ) . '?force=wpcom', '1.1', $args );
1948 - $body = wp_remote_retrieve_body( $response );
1949 - $data = $body ? json_decode( $body ) : null;
1950 -
1951 - if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
1952 - $error_info = array(
1953 - 'api_error_code' => null,
1954 - 'api_http_code' => wp_remote_retrieve_response_code( $response ),
1955 - );
1956 -
1957 - if ( is_wp_error( $response ) ) {
1958 - $error_info['api_error_code'] = $response->get_error_code() ? wp_strip_all_tags( $response->get_error_code() ) : null;
1959 - } elseif ( $data && ! empty( $data->error ) ) {
1960 - $error_info['api_error_code'] = $data->error;
1961 - }
1962 -
1963 - return new WP_Error( 'site_data_fetch_failed', '', $error_info );
1964 - }
1965 -
1966 - Jetpack_Plan::update_from_sites_response( $response );
1967 -
1968 - return $data;
1969 - }
1970 1488 /**
1971 1489 * Get site data, including for example, the site's current plan.
1972 1490 *
1491 + * @since 4.3.0
1492 + * @deprecated 16.2 Use Automattic\Jetpack\Connection\REST_Connector::site_data_response().
1493 + *
1973 1494 * @return WP_Error|WP_HTTP_Response|WP_REST_Response
1974 - * @since 4.3.0
1975 1495 */
1976 1496 public static function get_site_data() {
1977 - $site_data = self::site_data();
1497 + _deprecated_function( __METHOD__, 'jetpack-16.2', 'Automattic\Jetpack\Connection\REST_Connector::site_data_response' );
1978 1498
1979 - if ( ! is_wp_error( $site_data ) ) {
1980 -
1981 - /**
1982 - * Fires when the site data was successfully returned from the /sites/%d wpcom endpoint.
1983 - *
1984 - * @since 8.7.0
1985 - */
1986 - do_action( 'jetpack_get_site_data_success' );
1987 - return rest_ensure_response(
1988 - array(
1989 - 'code' => 'success',
1990 - 'message' => esc_html__( 'Site data correctly received.', 'jetpack' ),
1991 - 'data' => wp_json_encode( $site_data ),
1992 - )
1993 - );
1994 - }
1995 -
1996 - $error_data = $site_data->get_error_data();
1997 -
1998 - if ( empty( $error_data['api_error_code'] ) ) {
1999 - $error_message = esc_html__( 'Failed fetching site data from WordPress.com. If the problem persists, try reconnecting Jetpack.', 'jetpack' );
2000 - } else {
2001 - /* translators: %s is an error code (e.g. `token_mismatch`) */
2002 - $error_message = sprintf( esc_html__( 'Failed fetching site data from WordPress.com (%s). If the problem persists, try reconnecting Jetpack.', 'jetpack' ), $error_data['api_error_code'] );
2003 - }
2004 -
2005 - return new WP_Error(
2006 - $site_data->get_error_code(),
2007 - $error_message,
2008 - array(
2009 - 'status' => 400,
2010 - 'api_error_code' => empty( $error_data['api_error_code'] ) ? null : $error_data['api_error_code'],
2011 - 'api_http_code' => empty( $error_data['api_http_code'] ) ? null : $error_data['api_http_code'],
2012 - )
2013 - );
1499 + return REST_Connector::site_data_response();
2014 1500 }
2015 1501
2016 1502 /**
2017 1503 * Fetch AL data for this site and return it.
@@ -2071,64 +1557,8 @@
2071 1557 );
2072 1558 }
2073 1559
2074 1560 /**
2075 - * Fetch the discount for this site and return it.
2076 - *
2077 - * @since 10.8
2078 - *
2079 - * @return array|WP_Error
2080 - */
2081 - public static function get_site_discount() {
2082 - $site_id = Jetpack_Options::get_option( 'id' );
2083 -
2084 - if ( ! $site_id ) {
2085 - return new WP_Error(
2086 - 'site_id_missing',
2087 - esc_html__( 'Site ID is missing.', 'jetpack' ),
2088 - array( 'status' => 400 )
2089 - );
2090 - }
2091 -
2092 - $response = Client::wpcom_json_api_request_as_user(
2093 - "/sites/$site_id/discount",
2094 - '2',
2095 - array(
2096 - 'method' => 'GET',
2097 - 'headers' => array(
2098 - 'X-Forwarded-For' => ( new Visitor() )->get_ip( true ),
2099 - ),
2100 - )
2101 - );
2102 -
2103 - $response_code = wp_remote_retrieve_response_code( $response );
2104 - $data = json_decode( wp_remote_retrieve_body( $response ) );
2105 -
2106 - if ( 200 !== $response_code ) {
2107 - return new WP_Error(
2108 - 'discount_fetch_failed',
2109 - is_object( $data ) && property_exists( $data, 'error' ) ? $data->error : esc_html__( 'Could not retrieve site discount.', 'jetpack' ),
2110 - array( 'status' => $response_code )
2111 - );
2112 - }
2113 -
2114 - if ( ! isset( $data ) ) {
2115 - return new WP_Error(
2116 - 'discount_parse_error',
2117 - esc_html__( 'Could not parse discount', 'jetpack' ),
2118 - array( 'status' => 204 ) // no content.
2119 - );
2120 - }
2121 -
2122 - return rest_ensure_response(
2123 - array(
2124 - 'code' => 'success',
2125 - 'data' => $data,
2126 - )
2127 - );
2128 - }
2129 -
2130 - /**
2131 1561 * Reset Jetpack options
2132 1562 *
2133 1563 * @since 4.3.0
2134 1564 *
@@ -2226,9 +1656,9 @@
2226 1656 public static function get_updateable_data_list( $selector = '' ) {
2227 1657
2228 1658 $options = array(
2229 1659 // Blocks.
2230 - 'jetpack_blocks_disabled' => array(
1660 + 'jetpack_blocks_disabled' => array(
2231 1661 'description' => esc_html__( 'Jetpack Blocks disabled.', 'jetpack' ),
2232 1662 'type' => 'boolean',
2233 1663 'default' => false,
2234 1664 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2235,9 +1665,9 @@
2235 1665 'jp_group' => 'settings',
2236 1666 ),
2237 1667
2238 1668 // Carousel
2239 - 'carousel_background_color' => array(
1669 + 'carousel_background_color' => array(
2240 1670 'description' => esc_html__( 'Color scheme.', 'jetpack' ),
2241 1671 'type' => 'string',
2242 1672 'default' => 'black',
2243 1673 'enum' => array(
@@ -2250,9 +1680,9 @@
2250 1680 ),
2251 1681 'validate_callback' => __CLASS__ . '::validate_list_item',
2252 1682 'jp_group' => 'carousel',
2253 1683 ),
2254 - 'carousel_display_exif' => array(
1684 + 'carousel_display_exif' => array(
2255 1685 'description' => wp_kses(
2256 1686 sprintf( __( 'Show photo metadata (<a href="https://en.wikipedia.org/wiki/Exchangeable_image_file_format" target="_blank">Exif</a>) in carousel, when available.', 'jetpack' ) ),
2257 1687 array(
2258 1688 'a' => array(
@@ -2265,9 +1695,9 @@
2265 1695 'default' => 0,
2266 1696 'validate_callback' => __CLASS__ . '::validate_boolean',
2267 1697 'jp_group' => 'carousel',
2268 1698 ),
2269 - 'carousel_display_comments' => array(
1699 + 'carousel_display_comments' => array(
2270 1700 'description' => esc_html__( 'Show comments area in carousel', 'jetpack' ),
2271 1701 'type' => 'boolean',
2272 1702 'default' => 1,
2273 1703 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2274,9 +1704,9 @@
2274 1704 'jp_group' => 'carousel',
2275 1705 ),
2276 1706
2277 1707 // Comments.
2278 - 'highlander_comment_form_prompt' => array(
1708 + 'highlander_comment_form_prompt' => array(
2279 1709 'description' => esc_html__( 'Greeting Text', 'jetpack' ),
2280 1710 'type' => 'string',
2281 1711 'default' => esc_html__( 'Leave a Reply', 'jetpack' ),
2282 1712 'sanitize_callback' => 'sanitize_text_field',
@@ -2281,9 +1711,9 @@
2281 1711 'default' => esc_html__( 'Leave a Reply', 'jetpack' ),
2282 1712 'sanitize_callback' => 'sanitize_text_field',
2283 1713 'jp_group' => 'comments',
2284 1714 ),
2285 - 'jetpack_comment_form_color_scheme' => array(
1715 + 'jetpack_comment_form_color_scheme' => array(
2286 1716 'description' => esc_html__( 'Color scheme', 'jetpack' ),
2287 1717 'type' => 'string',
2288 1718 'default' => 'light',
2289 1719 'enum' => array(
@@ -2298,41 +1728,47 @@
2298 1728 ),
2299 1729 'validate_callback' => __CLASS__ . '::validate_list_item',
2300 1730 'jp_group' => 'comments',
2301 1731 ),
1732 + 'enable_blocks_comments' => array(
1733 + 'description' => esc_html__( 'Enable blocks in comments', 'jetpack' ),
1734 + 'type' => 'boolean',
1735 + 'default' => 1,
1736 + 'validate_callback' => __CLASS__ . '::validate_boolean',
1737 + 'jp_group' => 'comments',
1738 + ),
2302 1739
2303 1740 // Custom Content Types.
2304 - 'jetpack_portfolio' => array(
1741 + 'jetpack_portfolio' => array(
2305 1742 'description' => esc_html__( 'Enable or disable Jetpack portfolio post type.', 'jetpack' ),
2306 1743 'type' => 'boolean',
2307 1744 'default' => 0,
2308 1745 'validate_callback' => __CLASS__ . '::validate_boolean',
2309 - 'jp_group' => 'custom-content-types',
1746 + 'jp_group' => 'settings',
2310 1747 ),
2311 - 'jetpack_portfolio_posts_per_page' => array(
1748 + 'jetpack_portfolio_posts_per_page' => array(
2312 1749 'description' => esc_html__( 'Number of entries to show at most in Portfolio pages.', 'jetpack' ),
2313 1750 'type' => 'integer',
2314 1751 'default' => 10,
2315 1752 'validate_callback' => __CLASS__ . '::validate_posint',
2316 - 'jp_group' => 'custom-content-types',
1753 + 'jp_group' => 'settings',
2317 1754 ),
2318 - 'jetpack_testimonial' => array(
1755 + 'jetpack_testimonial' => array(
2319 1756 'description' => esc_html__( 'Enable or disable Jetpack testimonial post type.', 'jetpack' ),
2320 1757 'type' => 'boolean',
2321 1758 'default' => 0,
2322 1759 'validate_callback' => __CLASS__ . '::validate_boolean',
2323 - 'jp_group' => 'custom-content-types',
1760 + 'jp_group' => 'settings',
2324 1761 ),
2325 - 'jetpack_testimonial_posts_per_page' => array(
1762 + 'jetpack_testimonial_posts_per_page' => array(
2326 1763 'description' => esc_html__( 'Number of entries to show at most in Testimonial pages.', 'jetpack' ),
2327 1764 'type' => 'integer',
2328 1765 'default' => 10,
2329 1766 'validate_callback' => __CLASS__ . '::validate_posint',
2330 - 'jp_group' => 'custom-content-types',
1767 + 'jp_group' => 'settings',
2331 1768 ),
2332 -
2333 1769 // WAF.
2334 - 'jetpack_waf_automatic_rules' => array(
1770 + 'jetpack_waf_automatic_rules' => array(
2335 1771 'description' => esc_html__( 'Enable automatic rules - Protect your site against untrusted traffic sources with automatic security rules.', 'jetpack' ),
2336 1772 'type' => 'boolean',
2337 1773 'default' => Waf_Compatibility::get_default_automatic_rules_option(),
2338 1774 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2337,16 +1773,16 @@
2337 1773 'default' => Waf_Compatibility::get_default_automatic_rules_option(),
2338 1774 'validate_callback' => __CLASS__ . '::validate_boolean',
2339 1775 'jp_group' => 'waf',
2340 1776 ),
2341 - 'jetpack_waf_ip_list' => array(
2342 - 'description' => esc_html__( 'Allow / Block list - Block or allow a specific request IP.', 'jetpack' ),
1777 + 'jetpack_waf_ip_block_list_enabled' => array(
1778 + 'description' => esc_html__( 'Block list - Block a specific request IP.', 'jetpack' ),
2343 1779 'type' => 'boolean',
2344 1780 'default' => 0,
2345 1781 'validate_callback' => __CLASS__ . '::validate_boolean',
2346 1782 'jp_group' => 'waf',
2347 1783 ),
2348 - 'jetpack_waf_ip_block_list' => array(
1784 + 'jetpack_waf_ip_block_list' => array(
2349 1785 'description' => esc_html__( 'Blocked IP addresses', 'jetpack' ),
2350 1786 'type' => 'string',
2351 1787 'default' => '',
2352 1788 'validate_callback' => __CLASS__ . '::validate_string',
@@ -2352,9 +1788,16 @@
2352 1788 'validate_callback' => __CLASS__ . '::validate_string',
2353 1789 'sanitize_callback' => 'esc_textarea',
2354 1790 'jp_group' => 'waf',
2355 1791 ),
2356 - 'jetpack_waf_ip_allow_list' => array(
1792 + 'jetpack_waf_ip_allow_list_enabled' => array(
1793 + 'description' => esc_html__( 'Allow list - Allow a specific request IP.', 'jetpack' ),
1794 + 'type' => 'boolean',
1795 + 'default' => 0,
1796 + 'validate_callback' => __CLASS__ . '::validate_boolean',
1797 + 'jp_group' => 'settings',
1798 + ),
1799 + 'jetpack_waf_ip_allow_list' => array(
2357 1800 'description' => esc_html__( 'Always allowed IP addresses', 'jetpack' ),
2358 1801 'type' => 'string',
2359 1802 'default' => '',
2360 1803 'validate_callback' => __CLASS__ . '::validate_string',
@@ -2360,9 +1803,9 @@
2360 1803 'validate_callback' => __CLASS__ . '::validate_string',
2361 1804 'sanitize_callback' => 'esc_textarea',
2362 1805 'jp_group' => 'settings',
2363 1806 ),
2364 - 'jetpack_waf_share_data' => array(
1807 + 'jetpack_waf_share_data' => array(
2365 1808 'description' => esc_html__( 'Share basic data with Jetpack.', 'jetpack' ),
2366 1809 'type' => 'boolean',
2367 1810 'default' => 0,
2368 1811 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2367,9 +1810,9 @@
2367 1810 'default' => 0,
2368 1811 'validate_callback' => __CLASS__ . '::validate_boolean',
2369 1812 'jp_group' => 'waf',
2370 1813 ),
2371 - 'jetpack_waf_share_debug_data' => array(
1814 + 'jetpack_waf_share_debug_data' => array(
2372 1815 'description' => esc_html__( 'Share detailed data with Jetpack.', 'jetpack' ),
2373 1816 'type' => 'boolean',
2374 1817 'default' => 0,
2375 1818 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2375,9 +1818,9 @@
2375 1818 'validate_callback' => __CLASS__ . '::validate_boolean',
2376 1819 'jp_group' => 'waf',
2377 1820 ),
2378 1821 // Galleries.
2379 - 'tiled_galleries' => array(
1822 + 'tiled_galleries' => array(
2380 1823 'description' => esc_html__( 'Display all your gallery pictures in a cool mosaic.', 'jetpack' ),
2381 1824 'type' => 'boolean',
2382 1825 'default' => 0,
2383 1826 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2383,9 +1826,9 @@
2383 1826 'validate_callback' => __CLASS__ . '::validate_boolean',
2384 1827 'jp_group' => 'tiled-gallery',
2385 1828 ),
2386 1829
2387 - 'gravatar_disable_hovercards' => array(
1830 + 'gravatar_disable_hovercards' => array(
2388 1831 'description' => esc_html__( "View people's profiles when you mouse over their Gravatars", 'jetpack' ),
2389 1832 'type' => 'string',
2390 1833 'default' => 'enabled',
2391 1834 // Not visible. This is used as the checkbox value.
@@ -2401,9 +1844,9 @@
2401 1844 'jp_group' => 'gravatar-hovercards',
2402 1845 ),
2403 1846
2404 1847 // Infinite Scroll.
2405 - 'infinite_scroll' => array(
1848 + 'infinite_scroll' => array(
2406 1849 'description' => esc_html__( 'To infinity and beyond', 'jetpack' ),
2407 1850 'type' => 'boolean',
2408 1851 'default' => 1,
2409 1852 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2408,9 +1851,9 @@
2408 1851 'default' => 1,
2409 1852 'validate_callback' => __CLASS__ . '::validate_boolean',
2410 1853 'jp_group' => 'infinite-scroll',
2411 1854 ),
2412 - 'infinite_scroll_google_analytics' => array(
1855 + 'infinite_scroll_google_analytics' => array(
2413 1856 'description' => esc_html__( 'Use Google Analytics with Infinite Scroll', 'jetpack' ),
2414 1857 'type' => 'boolean',
2415 1858 'default' => 0,
2416 1859 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2417,9 +1860,9 @@
2417 1860 'jp_group' => 'infinite-scroll',
2418 1861 ),
2419 1862
2420 1863 // Likes.
2421 - 'wpl_default' => array(
1864 + 'wpl_default' => array(
2422 1865 'description' => esc_html__( 'WordPress.com Likes are', 'jetpack' ),
2423 1866 'type' => 'string',
2424 1867 'default' => 'on',
2425 1868 'enum' => array(
@@ -2432,9 +1875,9 @@
2432 1875 ),
2433 1876 'validate_callback' => __CLASS__ . '::validate_list_item',
2434 1877 'jp_group' => 'likes',
2435 1878 ),
2436 - 'social_notifications_like' => array(
1879 + 'social_notifications_like' => array(
2437 1880 'description' => esc_html__( 'Send email notification when someone likes a post', 'jetpack' ),
2438 1881 'type' => 'boolean',
2439 1882 'default' => 1,
2440 1883 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2441,9 +1884,9 @@
2441 1884 'jp_group' => 'likes',
2442 1885 ),
2443 1886
2444 1887 // Markdown.
2445 - 'wpcom_publish_comments_with_markdown' => array(
1888 + 'wpcom_publish_comments_with_markdown' => array(
2446 1889 'description' => esc_html__( 'Use Markdown for comments.', 'jetpack' ),
2447 1890 'type' => 'boolean',
2448 1891 'default' => 0,
2449 1892 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2448,9 +1891,9 @@
2448 1891 'default' => 0,
2449 1892 'validate_callback' => __CLASS__ . '::validate_boolean',
2450 1893 'jp_group' => 'markdown',
2451 1894 ),
2452 - 'wpcom_publish_posts_with_markdown' => array(
1895 + 'wpcom_publish_posts_with_markdown' => array(
2453 1896 'description' => esc_html__( 'Use Markdown for posts.', 'jetpack' ),
2454 1897 'type' => 'boolean',
2455 1898 'default' => 0,
2456 1899 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2457,9 +1900,9 @@
2457 1900 'jp_group' => 'markdown',
2458 1901 ),
2459 1902
2460 1903 // Monitor.
2461 - 'monitor_receive_notifications' => array(
1904 + 'monitor_receive_notifications' => array(
2462 1905 'description' => esc_html__( 'Receive Monitor Email Notifications.', 'jetpack' ),
2463 1906 'type' => 'boolean',
2464 1907 'default' => 0,
2465 1908 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2466,9 +1909,9 @@
2466 1909 'jp_group' => 'monitor',
2467 1910 ),
2468 1911
2469 1912 // Post by Email.
2470 - 'post_by_email_address' => array(
1913 + 'post_by_email_address' => array(
2471 1914 'description' => esc_html__( 'Email Address', 'jetpack' ),
2472 1915 'type' => 'string',
2473 1916 'default' => 'noop',
2474 1917 'enum' => array(
@@ -2487,9 +1930,9 @@
2487 1930 'jp_group' => 'post-by-email',
2488 1931 ),
2489 1932
2490 1933 // Protect.
2491 - 'jetpack_protect_key' => array(
1934 + 'jetpack_protect_key' => array(
2492 1935 'description' => esc_html__( 'Protect API key', 'jetpack' ),
2493 1936 'type' => 'string',
2494 1937 'default' => '',
2495 1938 'validate_callback' => __CLASS__ . '::validate_alphanum',
@@ -2494,9 +1937,9 @@
2494 1937 'default' => '',
2495 1938 'validate_callback' => __CLASS__ . '::validate_alphanum',
2496 1939 'jp_group' => 'protect',
2497 1940 ),
2498 - 'jetpack_protect_global_whitelist' => array(
1941 + 'jetpack_protect_global_whitelist' => array(
2499 1942 'description' => esc_html__( 'Protect global IP allow list', 'jetpack' ),
2500 1943 'type' => 'string',
2501 1944 'default' => '',
2502 1945 'validate_callback' => __CLASS__ . '::validate_string',
@@ -2504,9 +1947,9 @@
2504 1947 'jp_group' => 'protect',
2505 1948 ),
2506 1949
2507 1950 // Sharing.
2508 - 'sharing_services' => array(
1951 + 'sharing_services' => array(
2509 1952 'description' => esc_html__( 'Enabled Services and those hidden behind a button', 'jetpack' ),
2510 1953 'type' => 'object',
2511 1954 'default' => array(
2512 1955 'visible' => array( 'facebook', 'x' ),
@@ -2514,9 +1957,9 @@
2514 1957 ),
2515 1958 'validate_callback' => __CLASS__ . '::validate_services',
2516 1959 'jp_group' => 'sharedaddy',
2517 1960 ),
2518 - 'button_style' => array(
1961 + 'button_style' => array(
2519 1962 'description' => esc_html__( 'Button Style', 'jetpack' ),
2520 1963 'type' => 'string',
2521 1964 'default' => 'icon',
2522 1965 'enum' => array(
@@ -2533,9 +1976,9 @@
2533 1976 ),
2534 1977 'validate_callback' => __CLASS__ . '::validate_list_item',
2535 1978 'jp_group' => 'sharedaddy',
2536 1979 ),
2537 - 'sharing_label' => array(
1980 + 'sharing_label' => array(
2538 1981 'description' => esc_html__( 'Sharing Label', 'jetpack' ),
2539 1982 'type' => 'string',
2540 1983 'default' => '',
2541 1984 'validate_callback' => __CLASS__ . '::validate_string',
@@ -2541,9 +1984,9 @@
2541 1984 'validate_callback' => __CLASS__ . '::validate_string',
2542 1985 'sanitize_callback' => 'esc_html',
2543 1986 'jp_group' => 'sharedaddy',
2544 1987 ),
2545 - 'show' => array(
1988 + 'show' => array(
2546 1989 'description' => esc_html__( 'Views where buttons are shown', 'jetpack' ),
2547 1990 'type' => 'array',
2548 1991 'items' => array(
2549 1992 'type' => 'string',
@@ -2551,9 +1994,9 @@
2551 1994 'default' => array( 'post' ),
2552 1995 'validate_callback' => __CLASS__ . '::validate_sharing_show',
2553 1996 'jp_group' => 'sharedaddy',
2554 1997 ),
2555 - 'jetpack-twitter-cards-site-tag' => array(
1998 + 'jetpack-twitter-cards-site-tag' => array(
2556 1999 'description' => esc_html__( "The Twitter username of the owner of this site's domain.", 'jetpack' ),
2557 2000 'type' => 'string',
2558 2001 'default' => '',
2559 2002 'validate_callback' => __CLASS__ . '::validate_twitter_username',
@@ -2559,9 +2002,9 @@
2559 2002 'validate_callback' => __CLASS__ . '::validate_twitter_username',
2560 2003 'sanitize_callback' => 'esc_html',
2561 2004 'jp_group' => 'sharedaddy',
2562 2005 ),
2563 - 'sharedaddy_disable_resources' => array(
2006 + 'sharedaddy_disable_resources' => array(
2564 2007 'description' => esc_html__( 'Disable CSS and JS', 'jetpack' ),
2565 2008 'type' => 'boolean',
2566 2009 'default' => 0,
2567 2010 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2566,9 +2009,9 @@
2566 2009 'default' => 0,
2567 2010 'validate_callback' => __CLASS__ . '::validate_boolean',
2568 2011 'jp_group' => 'sharedaddy',
2569 2012 ),
2570 - 'custom' => array(
2013 + 'custom' => array(
2571 2014 'description' => esc_html__( 'Custom sharing services added by user.', 'jetpack' ),
2572 2015 'type' => 'object',
2573 2016 'default' => array(
2574 2017 'sharing_name' => '',
@@ -2578,9 +2021,9 @@
2578 2021 'validate_callback' => __CLASS__ . '::validate_custom_service',
2579 2022 'jp_group' => 'sharedaddy',
2580 2023 ),
2581 2024 // Not an option, but an action that can be performed on the list of custom services passing the service ID.
2582 - 'sharing_delete_service' => array(
2025 + 'sharing_delete_service' => array(
2583 2026 'description' => esc_html__( 'Delete custom sharing service.', 'jetpack' ),
2584 2027 'type' => 'string',
2585 2028 'default' => '',
2586 2029 'validate_callback' => __CLASS__ . '::validate_custom_service_id',
@@ -2587,9 +2030,9 @@
2587 2030 'jp_group' => 'sharedaddy',
2588 2031 ),
2589 2032
2590 2033 // SSO.
2591 - 'jetpack_sso_require_two_step' => array(
2034 + 'jetpack_sso_require_two_step' => array(
2592 2035 'description' => esc_html__( 'Require Two-Step Authentication', 'jetpack' ),
2593 2036 'type' => 'boolean',
2594 2037 'default' => SSO\Helpers::is_require_two_step_checkbox_disabled(),
2595 2038 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2594,9 +2037,9 @@
2594 2037 'default' => SSO\Helpers::is_require_two_step_checkbox_disabled(),
2595 2038 'validate_callback' => __CLASS__ . '::validate_boolean',
2596 2039 'jp_group' => 'sso',
2597 2040 ),
2598 - 'jetpack_sso_match_by_email' => array(
2041 + 'jetpack_sso_match_by_email' => array(
2599 2042 'description' => esc_html__( 'Match by Email', 'jetpack' ),
2600 2043 'type' => 'boolean',
2601 2044 'default' => 1,
2602 2045 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2603,9 +2046,9 @@
2603 2046 'jp_group' => 'sso',
2604 2047 ),
2605 2048
2606 2049 // Subscriptions.
2607 - 'stb_enabled' => array(
2050 + 'stb_enabled' => array(
2608 2051 'description' => esc_html__( "Show a <em>'follow blog'</em> option in the comment form", 'jetpack' ),
2609 2052 'type' => 'boolean',
2610 2053 'default' => 1,
2611 2054 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2610,9 +2053,9 @@
2610 2053 'default' => 1,
2611 2054 'validate_callback' => __CLASS__ . '::validate_boolean',
2612 2055 'jp_group' => 'subscriptions',
2613 2056 ),
2614 - 'stc_enabled' => array(
2057 + 'stc_enabled' => array(
2615 2058 'description' => esc_html__( "Show a <em>'follow comments'</em> option in the comment form", 'jetpack' ),
2616 2059 'type' => 'boolean',
2617 2060 'default' => 1,
2618 2061 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2617,9 +2060,9 @@
2617 2060 'default' => 1,
2618 2061 'validate_callback' => __CLASS__ . '::validate_boolean',
2619 2062 'jp_group' => 'subscriptions',
2620 2063 ),
2621 - 'wpcom_newsletter_categories' => array(
2064 + 'wpcom_newsletter_categories' => array(
2622 2065 'description' => esc_html__( 'Array of post category ids that are marked as newsletter categories', 'jetpack' ),
2623 2066 'type' => 'array',
2624 2067 'default' => array(),
2625 2068 'validate_callback' => __CLASS__ . '::validate_array',
@@ -2624,9 +2067,9 @@
2624 2067 'default' => array(),
2625 2068 'validate_callback' => __CLASS__ . '::validate_array',
2626 2069 'jp_group' => 'subscriptions',
2627 2070 ),
2628 - 'wpcom_newsletter_categories_enabled' => array(
2071 + 'wpcom_newsletter_categories_enabled' => array(
2629 2072 'description' => esc_html__( 'Whether the newsletter categories are enabled or not', 'jetpack' ),
2630 2073 'type' => 'boolean',
2631 2074 'default' => 0,
2632 2075 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2631,16 +2074,23 @@
2631 2074 'default' => 0,
2632 2075 'validate_callback' => __CLASS__ . '::validate_boolean',
2633 2076 'jp_group' => 'subscriptions',
2634 2077 ),
2635 - 'wpcom_featured_image_in_email' => array(
2078 + 'wpcom_newsletter_send_default' => array(
2079 + 'description' => esc_html__( 'Whether to send newsletter emails by default when publishing a post', 'jetpack' ),
2080 + 'type' => 'boolean',
2081 + 'default' => 1,
2082 + 'validate_callback' => __CLASS__ . '::validate_boolean',
2083 + 'jp_group' => 'subscriptions',
2084 + ),
2085 + 'wpcom_featured_image_in_email' => array(
2636 2086 'description' => esc_html__( 'Whether to include the featured image in the email or not', 'jetpack' ),
2637 2087 'type' => 'boolean',
2638 - 'default' => 1,
2088 + 'default' => 0,
2639 2089 'validate_callback' => __CLASS__ . '::validate_boolean',
2640 2090 'jp_group' => 'subscriptions',
2641 2091 ),
2642 - 'jetpack_gravatar_in_email' => array(
2092 + 'jetpack_gravatar_in_email' => array(
2643 2093 'description' => esc_html__( 'Whether to show author avatar in the email byline', 'jetpack' ),
2644 2094 'type' => 'boolean',
2645 2095 'default' => 1,
2646 2096 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2645,9 +2095,9 @@
2645 2095 'default' => 1,
2646 2096 'validate_callback' => __CLASS__ . '::validate_boolean',
2647 2097 'jp_group' => 'subscriptions',
2648 2098 ),
2649 - 'jetpack_author_in_email' => array(
2099 + 'jetpack_author_in_email' => array(
2650 2100 'description' => esc_html__( 'Whether to show author display name in the email byline', 'jetpack' ),
2651 2101 'type' => 'boolean',
2652 2102 'default' => 1,
2653 2103 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2652,9 +2102,9 @@
2652 2102 'default' => 1,
2653 2103 'validate_callback' => __CLASS__ . '::validate_boolean',
2654 2104 'jp_group' => 'subscriptions',
2655 2105 ),
2656 - 'jetpack_post_date_in_email' => array(
2106 + 'jetpack_post_date_in_email' => array(
2657 2107 'description' => esc_html__( 'Whether to show date in the email byline', 'jetpack' ),
2658 2108 'type' => 'boolean',
2659 2109 'default' => 1,
2660 2110 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2659,23 +2109,23 @@
2659 2109 'default' => 1,
2660 2110 'validate_callback' => __CLASS__ . '::validate_boolean',
2661 2111 'jp_group' => 'subscriptions',
2662 2112 ),
2663 - 'wpcom_subscription_emails_use_excerpt' => array(
2113 + 'wpcom_subscription_emails_use_excerpt' => array(
2664 2114 'description' => esc_html__( 'Whether to use the excerpt in the email or not', 'jetpack' ),
2665 2115 'type' => 'boolean',
2666 - 'default' => 1,
2116 + 'default' => 0,
2667 2117 'validate_callback' => __CLASS__ . '::validate_boolean',
2668 2118 'jp_group' => 'subscriptions',
2669 2119 ),
2670 - 'jetpack_subscriptions_reply_to' => array(
2120 + 'jetpack_subscriptions_reply_to' => array(
2671 2121 'description' => esc_html__( 'Reply to email behaviour for newsletters emails', 'jetpack' ),
2672 2122 'type' => 'string',
2673 - 'default' => 'no-reply',
2123 + 'default' => Automattic\Jetpack\Modules\Subscriptions\Settings::$default_reply_to,
2674 2124 'validate_callback' => __CLASS__ . '::validate_subscriptions_reply_to',
2675 2125 'jp_group' => 'subscriptions',
2676 2126 ),
2677 - 'jetpack_subscriptions_from_name' => array(
2127 + 'jetpack_subscriptions_from_name' => array(
2678 2128 'description' => esc_html__( 'From name for newsletters emails', 'jetpack' ),
2679 2129 'type' => 'string',
2680 2130 'default' => '',
2681 2131 'validate_callback' => __CLASS__ . '::validate_subscriptions_reply_to_name',
@@ -2680,9 +2130,9 @@
2680 2130 'default' => '',
2681 2131 'validate_callback' => __CLASS__ . '::validate_subscriptions_reply_to_name',
2682 2132 'jp_group' => 'subscriptions',
2683 2133 ),
2684 - 'sm_enabled' => array(
2134 + 'sm_enabled' => array(
2685 2135 'description' => esc_html__( 'Show popup Subscribe modal to readers.', 'jetpack' ),
2686 2136 'type' => 'boolean',
2687 2137 'default' => 0,
2688 2138 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2687,9 +2137,9 @@
2687 2137 'default' => 0,
2688 2138 'validate_callback' => __CLASS__ . '::validate_boolean',
2689 2139 'jp_group' => 'subscriptions',
2690 2140 ),
2691 - 'jetpack_subscribe_overlay_enabled' => array(
2141 + 'jetpack_subscribe_overlay_enabled' => array(
2692 2142 'description' => esc_html__( 'Show subscribe overlay on homepage.', 'jetpack' ),
2693 2143 'type' => 'boolean',
2694 2144 'default' => 0,
2695 2145 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2694,8 +2144,15 @@
2694 2144 'default' => 0,
2695 2145 'validate_callback' => __CLASS__ . '::validate_boolean',
2696 2146 'jp_group' => 'subscriptions',
2697 2147 ),
2148 + 'jetpack_subscribe_floating_button_enabled' => array(
2149 + 'description' => esc_html__( 'Show a floating subscribe button.', 'jetpack' ),
2150 + 'type' => 'boolean',
2151 + 'default' => 0,
2152 + 'validate_callback' => __CLASS__ . '::validate_boolean',
2153 + 'jp_group' => 'subscriptions',
2154 + ),
2698 2155 'jetpack_subscriptions_subscribe_post_end_enabled' => array(
2699 2156 'description' => esc_html__( 'Add Subscribe block at the end of each post.', 'jetpack' ),
2700 2157 'type' => 'boolean',
2701 2158 'default' => 0,
@@ -2715,9 +2172,9 @@
2715 2172 'default' => 0,
2716 2173 'validate_callback' => __CLASS__ . '::validate_boolean',
2717 2174 'jp_group' => 'subscriptions',
2718 2175 ),
2719 - 'social_notifications_subscribe' => array(
2176 + 'social_notifications_subscribe' => array(
2720 2177 'description' => esc_html__( 'Send email notification when someone subscribes to my blog', 'jetpack' ),
2721 2178 'type' => 'boolean',
2722 2179 'default' => 0,
2723 2180 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2722,15 +2179,18 @@
2722 2179 'default' => 0,
2723 2180 'validate_callback' => __CLASS__ . '::validate_boolean',
2724 2181 'jp_group' => 'subscriptions',
2725 2182 ),
2726 - 'subscription_options' => array(
2727 - 'description' => esc_html__( 'Three options used in subscription email templates: \'invitation\', \'welcome\' and \'comment_follow\'.', 'jetpack' ),
2183 + 'subscription_options' => array(
2184 + 'description' => esc_html__( 'Options used in subscription email templates and the Subscribe block: \'invitation\', \'welcome\', \'comment_follow\', \'subscribe_modal_heading\', \'free_tier_description\' and \'hide_free_tier\'.', 'jetpack' ),
2728 2185 'type' => 'object',
2729 2186 'default' => array(
2730 - 'invitation' => '',
2731 - 'welcome' => '',
2732 - 'comment_follow' => '',
2187 + 'invitation' => '',
2188 + 'welcome' => '',
2189 + 'comment_follow' => '',
2190 + 'subscribe_modal_heading' => '',
2191 + 'free_tier_description' => '',
2192 + 'hide_free_tier' => false,
2733 2193 ),
2734 2194 'validate_callback' => __CLASS__ . '::validate_subscription_options',
2735 2195 'jp_group' => 'subscriptions',
2736 2196 ),
@@ -2735,9 +2195,9 @@
2735 2195 'jp_group' => 'subscriptions',
2736 2196 ),
2737 2197
2738 2198 // Related Posts.
2739 - 'show_headline' => array(
2199 + 'show_headline' => array(
2740 2200 'description' => esc_html__( 'Highlight related content with a heading', 'jetpack' ),
2741 2201 'type' => 'boolean',
2742 2202 'default' => 1,
2743 2203 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2742,9 +2202,9 @@
2742 2202 'default' => 1,
2743 2203 'validate_callback' => __CLASS__ . '::validate_boolean',
2744 2204 'jp_group' => 'related-posts',
2745 2205 ),
2746 - 'show_thumbnails' => array(
2206 + 'show_thumbnails' => array(
2747 2207 'description' => esc_html__( 'Show a thumbnail image where available', 'jetpack' ),
2748 2208 'type' => 'boolean',
2749 2209 'default' => 0,
2750 2210 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2751,9 +2211,9 @@
2751 2211 'jp_group' => 'related-posts',
2752 2212 ),
2753 2213
2754 2214 // Search.
2755 - 'instant_search_enabled' => array(
2215 + 'instant_search_enabled' => array(
2756 2216 'description' => esc_html__( 'Enable Instant Search', 'jetpack' ),
2757 2217 'type' => 'boolean',
2758 2218 'default' => 0,
2759 2219 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2759,9 +2219,9 @@
2759 2219 'validate_callback' => __CLASS__ . '::validate_boolean',
2760 2220 'jp_group' => 'search',
2761 2221 ),
2762 2222
2763 - 'has_jetpack_search_product' => array(
2223 + 'has_jetpack_search_product' => array(
2764 2224 'description' => esc_html__( 'Has an active Jetpack Search product purchase', 'jetpack' ),
2765 2225 'type' => 'boolean',
2766 2226 'default' => 0,
2767 2227 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2767,9 +2227,9 @@
2767 2227 'validate_callback' => __CLASS__ . '::validate_boolean',
2768 2228 'jp_group' => 'settings',
2769 2229 ),
2770 2230
2771 - 'search_auto_config' => array(
2231 + 'search_auto_config' => array(
2772 2232 'description' => esc_html__( 'Trigger an auto config of instant search', 'jetpack' ),
2773 2233 'type' => 'boolean',
2774 2234 'default' => 0,
2775 2235 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2776,9 +2236,9 @@
2776 2236 'jp_group' => 'search',
2777 2237 ),
2778 2238
2779 2239 // Verification Tools.
2780 - 'google' => array(
2240 + 'google' => array(
2781 2241 'description' => esc_html__( 'Google Search Console', 'jetpack' ),
2782 2242 'type' => 'string',
2783 2243 'default' => '',
2784 2244 'validate_callback' => __CLASS__ . '::validate_verification_service',
@@ -2783,9 +2243,9 @@
2783 2243 'default' => '',
2784 2244 'validate_callback' => __CLASS__ . '::validate_verification_service',
2785 2245 'jp_group' => 'verification-tools',
2786 2246 ),
2787 - 'bing' => array(
2247 + 'bing' => array(
2788 2248 'description' => esc_html__( 'Bing Webmaster Center', 'jetpack' ),
2789 2249 'type' => 'string',
2790 2250 'default' => '',
2791 2251 'validate_callback' => __CLASS__ . '::validate_verification_service',
@@ -2790,9 +2250,9 @@
2790 2250 'default' => '',
2791 2251 'validate_callback' => __CLASS__ . '::validate_verification_service',
2792 2252 'jp_group' => 'verification-tools',
2793 2253 ),
2794 - 'pinterest' => array(
2254 + 'pinterest' => array(
2795 2255 'description' => esc_html__( 'Pinterest Site Verification', 'jetpack' ),
2796 2256 'type' => 'string',
2797 2257 'default' => '',
2798 2258 'validate_callback' => __CLASS__ . '::validate_verification_service',
@@ -2797,9 +2257,9 @@
2797 2257 'default' => '',
2798 2258 'validate_callback' => __CLASS__ . '::validate_verification_service',
2799 2259 'jp_group' => 'verification-tools',
2800 2260 ),
2801 - 'yandex' => array(
2261 + 'yandex' => array(
2802 2262 'description' => esc_html__( 'Yandex Site Verification', 'jetpack' ),
2803 2263 'type' => 'string',
2804 2264 'default' => '',
2805 2265 'validate_callback' => __CLASS__ . '::validate_verification_service',
@@ -2804,9 +2264,9 @@
2804 2264 'default' => '',
2805 2265 'validate_callback' => __CLASS__ . '::validate_verification_service',
2806 2266 'jp_group' => 'verification-tools',
2807 2267 ),
2808 - 'facebook' => array(
2268 + 'facebook' => array(
2809 2269 'description' => esc_html__( 'Facebook Domain Verification', 'jetpack' ),
2810 2270 'type' => 'string',
2811 2271 'default' => '',
2812 2272 'validate_callback' => __CLASS__ . '::validate_verification_service',
@@ -2813,9 +2273,9 @@
2813 2273 'jp_group' => 'verification-tools',
2814 2274 ),
2815 2275
2816 2276 // WordAds.
2817 - 'enable_header_ad' => array(
2277 + 'enable_header_ad' => array(
2818 2278 'description' => esc_html__( 'Display an ad unit at the top of each page.', 'jetpack' ),
2819 2279 'type' => 'boolean',
2820 2280 'default' => 1,
2821 2281 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2820,9 +2280,9 @@
2820 2280 'default' => 1,
2821 2281 'validate_callback' => __CLASS__ . '::validate_boolean',
2822 2282 'jp_group' => 'wordads',
2823 2283 ),
2824 - 'wordads_approved' => array(
2284 + 'wordads_approved' => array(
2825 2285 'description' => esc_html__( 'Is site approved for WordAds?', 'jetpack' ),
2826 2286 'type' => 'boolean',
2827 2287 'default' => 0,
2828 2288 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2827,9 +2287,9 @@
2827 2287 'default' => 0,
2828 2288 'validate_callback' => __CLASS__ . '::validate_boolean',
2829 2289 'jp_group' => 'wordads',
2830 2290 ),
2831 - 'wordads_second_belowpost' => array(
2291 + 'wordads_second_belowpost' => array(
2832 2292 'description' => esc_html__( 'Display second ad below post?', 'jetpack' ),
2833 2293 'type' => 'boolean',
2834 2294 'default' => 1,
2835 2295 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2834,9 +2294,9 @@
2834 2294 'default' => 1,
2835 2295 'validate_callback' => __CLASS__ . '::validate_boolean',
2836 2296 'jp_group' => 'wordads',
2837 2297 ),
2838 - 'wordads_inline_enabled' => array(
2298 + 'wordads_inline_enabled' => array(
2839 2299 'description' => esc_html__( 'Display inline ad within post content?', 'jetpack' ),
2840 2300 'type' => 'boolean',
2841 2301 'default' => 1,
2842 2302 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2841,9 +2301,9 @@
2841 2301 'default' => 1,
2842 2302 'validate_callback' => __CLASS__ . '::validate_boolean',
2843 2303 'jp_group' => 'wordads',
2844 2304 ),
2845 - 'wordads_display_front_page' => array(
2305 + 'wordads_display_front_page' => array(
2846 2306 'description' => esc_html__( 'Display ads on the front page?', 'jetpack' ),
2847 2307 'type' => 'boolean',
2848 2308 'default' => 1,
2849 2309 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2848,9 +2308,9 @@
2848 2308 'default' => 1,
2849 2309 'validate_callback' => __CLASS__ . '::validate_boolean',
2850 2310 'jp_group' => 'wordads',
2851 2311 ),
2852 - 'wordads_display_post' => array(
2312 + 'wordads_display_post' => array(
2853 2313 'description' => esc_html__( 'Display ads on posts?', 'jetpack' ),
2854 2314 'type' => 'boolean',
2855 2315 'default' => 1,
2856 2316 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2855,9 +2315,9 @@
2855 2315 'default' => 1,
2856 2316 'validate_callback' => __CLASS__ . '::validate_boolean',
2857 2317 'jp_group' => 'wordads',
2858 2318 ),
2859 - 'wordads_display_page' => array(
2319 + 'wordads_display_page' => array(
2860 2320 'description' => esc_html__( 'Display ads on pages?', 'jetpack' ),
2861 2321 'type' => 'boolean',
2862 2322 'default' => 1,
2863 2323 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2862,9 +2322,9 @@
2862 2322 'default' => 1,
2863 2323 'validate_callback' => __CLASS__ . '::validate_boolean',
2864 2324 'jp_group' => 'wordads',
2865 2325 ),
2866 - 'wordads_display_archive' => array(
2326 + 'wordads_display_archive' => array(
2867 2327 'description' => esc_html__( 'Display ads on archive pages?', 'jetpack' ),
2868 2328 'type' => 'boolean',
2869 2329 'default' => 1,
2870 2330 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2869,9 +2329,9 @@
2869 2329 'default' => 1,
2870 2330 'validate_callback' => __CLASS__ . '::validate_boolean',
2871 2331 'jp_group' => 'wordads',
2872 2332 ),
2873 - 'wordads_custom_adstxt_enabled' => array(
2333 + 'wordads_custom_adstxt_enabled' => array(
2874 2334 'description' => esc_html__( 'Custom ads.txt', 'jetpack' ),
2875 2335 'type' => 'boolean',
2876 2336 'default' => 0,
2877 2337 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2876,9 +2336,9 @@
2876 2336 'default' => 0,
2877 2337 'validate_callback' => __CLASS__ . '::validate_boolean',
2878 2338 'jp_group' => 'wordads',
2879 2339 ),
2880 - 'wordads_custom_adstxt' => array(
2340 + 'wordads_custom_adstxt' => array(
2881 2341 'description' => esc_html__( 'Custom ads.txt entries', 'jetpack' ),
2882 2342 'type' => 'string',
2883 2343 'default' => '',
2884 2344 'validate_callback' => __CLASS__ . '::validate_string',
@@ -2884,9 +2344,9 @@
2884 2344 'validate_callback' => __CLASS__ . '::validate_string',
2885 2345 'sanitize_callback' => 'sanitize_textarea_field',
2886 2346 'jp_group' => 'wordads',
2887 2347 ),
2888 - 'wordads_ccpa_enabled' => array(
2348 + 'wordads_ccpa_enabled' => array(
2889 2349 'description' => esc_html__( 'Enable support for California Consumer Privacy Act', 'jetpack' ),
2890 2350 'type' => 'boolean',
2891 2351 'default' => 0,
2892 2352 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2891,9 +2351,9 @@
2891 2351 'default' => 0,
2892 2352 'validate_callback' => __CLASS__ . '::validate_boolean',
2893 2353 'jp_group' => 'wordads',
2894 2354 ),
2895 - 'wordads_ccpa_privacy_policy_url' => array(
2355 + 'wordads_ccpa_privacy_policy_url' => array(
2896 2356 'description' => esc_html__( 'Privacy Policy URL', 'jetpack' ),
2897 2357 'type' => 'string',
2898 2358 'default' => '',
2899 2359 'validate_callback' => __CLASS__ . '::validate_string',
@@ -2899,9 +2359,9 @@
2899 2359 'validate_callback' => __CLASS__ . '::validate_string',
2900 2360 'sanitize_callback' => 'sanitize_text_field',
2901 2361 'jp_group' => 'wordads',
2902 2362 ),
2903 - 'wordads_cmp_enabled' => array(
2363 + 'wordads_cmp_enabled' => array(
2904 2364 'description' => esc_html__( 'Enable GDPR Consent Management Banner for WordAds', 'jetpack' ),
2905 2365 'type' => 'boolean',
2906 2366 'default' => 0,
2907 2367 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2908,9 +2368,9 @@
2908 2368 'jp_group' => 'wordads',
2909 2369 ),
2910 2370
2911 2371 // Google Analytics.
2912 - 'google_analytics_tracking_id' => array(
2372 + 'google_analytics_tracking_id' => array(
2913 2373 'description' => esc_html__( 'Google Analytics', 'jetpack' ),
2914 2374 'type' => 'string',
2915 2375 'default' => '',
2916 2376 'validate_callback' => __CLASS__ . '::validate_alphanum',
@@ -2915,11 +2375,16 @@
2915 2375 'default' => '',
2916 2376 'validate_callback' => __CLASS__ . '::validate_alphanum',
2917 2377 'jp_group' => 'google-analytics',
2918 2378 ),
2379 + 'jetpack_wga' => array(
2380 + 'description' => esc_html__( 'Google Analytics', 'jetpack' ),
2381 + 'type' => 'object',
2382 + 'jp_group' => 'settings',
2383 + ),
2919 2384
2920 2385 // Stats.
2921 - 'admin_bar' => array(
2386 + 'admin_bar' => array(
2922 2387 'description' => esc_html__( 'Include a small chart in your admin bar with a 48-hour traffic snapshot.', 'jetpack' ),
2923 2388 'type' => 'boolean',
2924 2389 'default' => 1,
2925 2390 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2924,9 +2389,9 @@
2924 2389 'default' => 1,
2925 2390 'validate_callback' => __CLASS__ . '::validate_boolean',
2926 2391 'jp_group' => 'stats',
2927 2392 ),
2928 - 'enable_odyssey_stats' => array(
2393 + 'enable_odyssey_stats' => array(
2929 2394 'description' => esc_html__( 'Preview the new Jetpack Stats experience (Experimental).', 'jetpack' ),
2930 2395 'type' => 'boolean',
2931 2396 'default' => 1,
2932 2397 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2931,9 +2396,9 @@
2931 2396 'default' => 1,
2932 2397 'validate_callback' => __CLASS__ . '::validate_boolean',
2933 2398 'jp_group' => 'stats',
2934 2399 ),
2935 - 'roles' => array(
2400 + 'roles' => array(
2936 2401 'description' => esc_html__( 'Select the roles that will be able to view stats reports.', 'jetpack' ),
2937 2402 'type' => 'array',
2938 2403 'items' => array(
2939 2404 'type' => 'string',
@@ -2942,9 +2407,9 @@
2942 2407 'validate_callback' => __CLASS__ . '::validate_stats_roles',
2943 2408 'sanitize_callback' => __CLASS__ . '::sanitize_stats_allowed_roles',
2944 2409 'jp_group' => 'stats',
2945 2410 ),
2946 - 'count_roles' => array(
2411 + 'count_roles' => array(
2947 2412 'description' => esc_html__( 'Count the page views of registered users who are logged in.', 'jetpack' ),
2948 2413 'type' => 'array',
2949 2414 'items' => array(
2950 2415 'type' => 'string',
@@ -2952,9 +2417,9 @@
2952 2417 'default' => array( 'administrator' ),
2953 2418 'validate_callback' => __CLASS__ . '::validate_stats_roles',
2954 2419 'jp_group' => 'stats',
2955 2420 ),
2956 - 'blog_id' => array(
2421 + 'blog_id' => array(
2957 2422 'description' => esc_html__( 'Blog ID.', 'jetpack' ),
2958 2423 'type' => 'boolean',
2959 2424 'default' => 0,
2960 2425 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2959,9 +2424,9 @@
2959 2424 'default' => 0,
2960 2425 'validate_callback' => __CLASS__ . '::validate_boolean',
2961 2426 'jp_group' => 'stats',
2962 2427 ),
2963 - 'do_not_track' => array(
2428 + 'do_not_track' => array(
2964 2429 'description' => esc_html__( 'Do not track.', 'jetpack' ),
2965 2430 'type' => 'boolean',
2966 2431 'default' => 1,
2967 2432 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2966,9 +2431,9 @@
2966 2431 'default' => 1,
2967 2432 'validate_callback' => __CLASS__ . '::validate_boolean',
2968 2433 'jp_group' => 'stats',
2969 2434 ),
2970 - 'version' => array(
2435 + 'version' => array(
2971 2436 'description' => esc_html__( 'Version.', 'jetpack' ),
2972 2437 'type' => 'integer',
2973 2438 'default' => 9,
2974 2439 'validate_callback' => __CLASS__ . '::validate_posint',
@@ -2973,9 +2438,9 @@
2973 2438 'default' => 9,
2974 2439 'validate_callback' => __CLASS__ . '::validate_posint',
2975 2440 'jp_group' => 'stats',
2976 2441 ),
2977 - 'collapse_nudges' => array(
2442 + 'collapse_nudges' => array(
2978 2443 'description' => esc_html__( 'Collapse upgrade nudges', 'jetpack' ),
2979 2444 'type' => 'boolean',
2980 2445 'default' => 0,
2981 2446 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2982,9 +2447,9 @@
2982 2447 'jp_group' => 'stats',
2983 2448 ),
2984 2449
2985 2450 // Whether to share stats views with WordPress.com Reader.
2986 - 'wpcom_reader_views_enabled' => array(
2451 + 'wpcom_reader_views_enabled' => array(
2987 2452 'description' => esc_html__( 'Show post views in the WordPress.com Reader.', 'jetpack' ),
2988 2453 'type' => 'boolean',
2989 2454 'default' => 1,
2990 2455 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2991,9 +2456,9 @@
2991 2456 'jp_group' => 'settings',
2992 2457 ),
2993 2458
2994 2459 // Akismet - Not a module, but a plugin. The options can be passed and handled differently.
2995 - 'akismet_show_user_comments_approved' => array(
2460 + 'akismet_show_user_comments_approved' => array(
2996 2461 'description' => '',
2997 2462 'type' => 'boolean',
2998 2463 'default' => 0,
2999 2464 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -2999,9 +2464,9 @@
2999 2464 'validate_callback' => __CLASS__ . '::validate_boolean',
3000 2465 'jp_group' => 'settings',
3001 2466 ),
3002 2467
3003 - 'wordpress_api_key' => array(
2468 + 'wordpress_api_key' => array(
3004 2469 'description' => '',
3005 2470 'type' => 'string',
3006 2471 'default' => '',
3007 2472 'validate_callback' => __CLASS__ . '::validate_alphanum',
@@ -3008,9 +2473,9 @@
3008 2473 'jp_group' => 'settings',
3009 2474 ),
3010 2475
3011 2476 // Empty stats card dismiss.
3012 - 'dismiss_empty_stats_card' => array(
2477 + 'dismiss_empty_stats_card' => array(
3013 2478 'description' => '',
3014 2479 'type' => 'boolean',
3015 2480 'default' => 0,
3016 2481 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -3017,9 +2482,9 @@
3017 2482 'jp_group' => 'settings',
3018 2483 ),
3019 2484
3020 2485 // Backup Getting Started card on dashboard.
3021 - 'dismiss_dash_backup_getting_started' => array(
2486 + 'dismiss_dash_backup_getting_started' => array(
3022 2487 'description' => '',
3023 2488 'type' => 'boolean',
3024 2489 'default' => 0,
3025 2490 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -3026,9 +2491,9 @@
3026 2491 'jp_group' => 'settings',
3027 2492 ),
3028 2493
3029 2494 // Agencies Learn More card on dashboard.
3030 - 'dismiss_dash_agencies_learn_more' => array(
2495 + 'dismiss_dash_agencies_learn_more' => array(
3031 2496 'description' => '',
3032 2497 'type' => 'boolean',
3033 2498 'default' => 0,
3034 2499 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -3034,9 +2499,9 @@
3034 2499 'validate_callback' => __CLASS__ . '::validate_boolean',
3035 2500 'jp_group' => 'settings',
3036 2501 ),
3037 2502
3038 - 'lang_id' => array(
2503 + 'lang_id' => array(
3039 2504 'description' => esc_html__( 'Primary language for the site.', 'jetpack' ),
3040 2505 'type' => 'string',
3041 2506 'default' => 'en_US',
3042 2507 'jp_group' => 'settings',
@@ -3041,32 +2506,10 @@
3041 2506 'default' => 'en_US',
3042 2507 'jp_group' => 'settings',
3043 2508 ),
3044 2509
3045 - 'onboarding' => array(
3046 - 'description' => '',
3047 - 'type' => 'object',
3048 - 'default' => array(
3049 - 'siteTitle' => '',
3050 - 'siteDescription' => '',
3051 - 'siteType' => 'personal',
3052 - 'homepageFormat' => 'posts',
3053 - 'addContactForm' => 0,
3054 - 'businessAddress' => array(
3055 - 'name' => '',
3056 - 'street' => '',
3057 - 'city' => '',
3058 - 'state' => '',
3059 - 'zip' => '',
3060 - ),
3061 - 'installWooCommerce' => false,
3062 - ),
3063 - 'validate_callback' => __CLASS__ . '::validate_onboarding',
3064 - 'jp_group' => 'settings',
3065 - ),
3066 -
3067 2510 // SEO Tools.
3068 - 'advanced_seo_front_page_description' => array(
2511 + 'advanced_seo_front_page_description' => array(
3069 2512 'description' => esc_html__( 'Front page meta description.', 'jetpack' ),
3070 2513 'type' => 'string',
3071 2514 'default' => '',
3072 2515 'sanitize_callback' => 'Jetpack_SEO_Utils::sanitize_front_page_meta_description',
@@ -3072,9 +2515,9 @@
3072 2515 'sanitize_callback' => 'Jetpack_SEO_Utils::sanitize_front_page_meta_description',
3073 2516 'jp_group' => 'seo-tools',
3074 2517 ),
3075 2518
3076 - 'advanced_seo_title_formats' => array(
2519 + 'advanced_seo_title_formats' => array(
3077 2520 'description' => esc_html__( 'SEO page title structures.', 'jetpack' ),
3078 2521 'type' => 'object',
3079 2522 'default' => array(
3080 2523 'archives' => array(),
@@ -3087,10 +2530,34 @@
3087 2530 'validate_callback' => 'Jetpack_SEO_Titles::are_valid_title_formats',
3088 2531 'sanitize_callback' => 'Jetpack_SEO_Titles::sanitize_title_formats',
3089 2532 ),
3090 2533
2534 + // AI tab (Jetpack > SEO). Plain option the SEO package reads to serve
2535 + // /llms.txt. The front-end behavior is gated inside the package; this
2536 + // only round-trips the persisted state alongside the other seo-tools
2537 + // settings.
2538 + 'jetpack_seo_llms_txt_enabled' => array(
2539 + 'description' => esc_html__( 'Generate an llms.txt file to guide AI assistants around your content.', 'jetpack' ),
2540 + 'type' => 'boolean',
2541 + 'default' => 0,
2542 + 'validate_callback' => __CLASS__ . '::validate_boolean',
2543 + 'jp_group' => 'seo-tools',
2544 + ),
2545 +
2546 + // AI tab (Jetpack > SEO). Sparse per-crawler override map the SEO
2547 + // package reads to emit robots.txt directives for blocked AI crawlers.
2548 + // Stored as `slug => bool` (true = blocked); catalog validation and
2549 + // default-pruning happen in `Ai_Crawlers::get_overrides()`.
2550 + 'jetpack_seo_ai_crawler_overrides' => array(
2551 + 'description' => esc_html__( 'AI crawler allow/block overrides.', 'jetpack' ),
2552 + 'type' => 'object',
2553 + 'default' => array(),
2554 + 'jp_group' => 'seo-tools',
2555 + 'sanitize_callback' => __CLASS__ . '::sanitize_ai_crawler_overrides',
2556 + ),
2557 +
3091 2558 // VideoPress.
3092 - 'videopress_private_enabled_for_site' => array(
2559 + 'videopress_private_enabled_for_site' => array(
3093 2560 'description' => esc_html__( 'Video Privacy: Restrict views to members of this site', 'jetpack' ),
3094 2561 'type' => 'boolean',
3095 2562 'default' => 0,
3096 2563 'validate_callback' => __CLASS__ . '::validate_boolean',
@@ -3095,10 +2562,30 @@
3095 2562 'default' => 0,
3096 2563 'validate_callback' => __CLASS__ . '::validate_boolean',
3097 2564 'jp_group' => 'videopress',
3098 2565 ),
2566 + 'videopress_share_menu_disabled' => array(
2567 + 'description' => esc_html__( 'Hide the share menu on every video, overriding each video’s own setting', 'jetpack' ),
2568 + 'type' => 'boolean',
2569 + 'default' => 0,
2570 + 'validate_callback' => __CLASS__ . '::validate_boolean',
2571 + 'jp_group' => 'videopress',
2572 + ),
3099 2573 );
3100 2574
2575 + // SEO Tools - SEO Enhancer.
2576 + // TODO: move this to the main options array? The filter was there while developing the feature.
2577 + // It might come in handy to hold its availability behind the filter since it still depends on AI to be available.
2578 + if ( apply_filters( 'ai_seo_enhancer_enabled', true ) ) {
2579 + $options['ai_seo_enhancer_enabled'] = array(
2580 + 'description' => esc_html__( 'Automatically generate SEO title, SEO description, and image alt text for new posts.', 'jetpack' ),
2581 + 'type' => 'boolean',
2582 + 'default' => 0,
2583 + 'validate_callback' => __CLASS__ . '::validate_boolean',
2584 + 'jp_group' => 'seo-tools',
2585 + );
2586 + }
2587 +
3101 2588 // Add modules to list so they can be toggled.
3102 2589 $modules = Jetpack::get_available_modules();
3103 2590 if ( is_array( $modules ) && ! empty( $modules ) ) {
3104 2591 $module_args = array(
@@ -3144,8 +2631,10 @@
3144 2631 * Validates that the parameters are proper values that can be set during Jetpack onboarding.
3145 2632 *
3146 2633 * @since 5.4.0
3147 2634 *
2635 + * @deprecated since 13.9
2636 + *
3148 2637 * @param array $onboarding_data Values to check.
3149 2638 * @param WP_REST_Request $request The request sent to the WP REST API.
3150 2639 * @param string $param Name of the parameter passed to endpoint holding $value.
3151 2640 *
@@ -3150,24 +2639,10 @@
3150 2639 * @param string $param Name of the parameter passed to endpoint holding $value.
3151 2640 *
3152 2641 * @return bool|WP_Error
3153 2642 */
3154 - public static function validate_onboarding( $onboarding_data, $request, $param ) {
3155 - if ( ! is_array( $onboarding_data ) ) {
3156 - return new WP_Error( 'invalid_param', esc_html__( 'Not valid onboarding data.', 'jetpack' ) );
3157 - }
3158 - foreach ( $onboarding_data as $value ) {
3159 - if ( is_string( $value ) ) {
3160 - $onboarding_choice = self::validate_string( $value, $request, $param );
3161 - } elseif ( is_array( $value ) ) {
3162 - $onboarding_choice = self::validate_onboarding( $value, $request, $param );
3163 - } else {
3164 - $onboarding_choice = self::validate_boolean( $value, $request, $param );
3165 - }
3166 - if ( is_wp_error( $onboarding_choice ) ) {
3167 - return $onboarding_choice;
3168 - }
3169 - }
2643 + public static function validate_onboarding( $onboarding_data, $request, $param ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
2644 + _deprecated_function( __METHOD__, '13.9' );
3170 2645 return true;
3171 2646 }
3172 2647
3173 2648 /**
@@ -3363,14 +2838,14 @@
3363 2838 *
3364 2839 * @return bool|WP_Error
3365 2840 */
3366 2841 public static function validate_verification_service( $value, $request, $param ) {
3367 - if ( ! empty( $value ) && ! ( is_string( $value ) && ( preg_match( '/^[a-z0-9_-]+$/i', $value ) || jetpack_verification_get_code( $value ) !== false ) ) ) {
2842 + if ( ! empty( $value ) && ( ! is_string( $value ) || false === jetpack_verification_validate_code( $value ) ) ) {
3368 2843 return new WP_Error(
3369 2844 'invalid_param',
3370 2845 sprintf(
3371 2846 /* Translators: Placeholder is a verification string used to verify a service like Google Webmaster Console. */
3372 - esc_html__( '%s must be an alphanumeric string or a verification tag.', 'jetpack' ),
2847 + esc_html__( '%s must be a valid verification code or verification tag.', 'jetpack' ),
3373 2848 $param
3374 2849 )
3375 2850 );
3376 2851 }
@@ -3381,9 +2856,9 @@
3381 2856 * Validates that the parameter is among the roles allowed for Stats.
3382 2857 *
3383 2858 * @since 4.3.0
3384 2859 *
3385 - * @param string|bool $value Value to check.
2860 + * @param mixed $value Value to check.
3386 2861 * @param WP_REST_Request $request The request sent to the WP REST API.
3387 2862 * @param string $param Name of the parameter passed to endpoint holding $value.
3388 2863 *
3389 2864 * @return bool|WP_Error
@@ -3388,16 +2863,37 @@
3388 2863 *
3389 2864 * @return bool|WP_Error
3390 2865 */
3391 2866 public static function validate_stats_roles( $value, $request, $param ) {
3392 - if ( ! empty( $value ) && ! array_intersect( self::$stats_roles, $value ) ) {
2867 + // An empty value clears the setting; sanitize_stats_allowed_roles() falls back to 'administrator'.
2868 + if ( empty( $value ) ) {
2869 + return true;
2870 + }
2871 +
2872 + // Enforce the schema's list-of-strings contract before array_intersect() below sees the value.
2873 + if ( ! is_array( $value ) || count( array_filter( $value, 'is_string' ) ) !== count( $value ) ) {
3393 2874 return new WP_Error(
3394 2875 'invalid_param',
3395 2876 sprintf(
2877 + /* Translators: Placeholder is a parameter name. */
2878 + esc_html__( '%s must be an array of user roles.', 'jetpack' ),
2879 + $param
2880 + )
2881 + );
2882 + }
2883 +
2884 + if ( ! function_exists( 'get_editable_roles' ) ) {
2885 + require_once ABSPATH . 'wp-admin/includes/user.php';
2886 + }
2887 + $editable_roles = array_keys( get_editable_roles() );
2888 + if ( ! array_intersect( $editable_roles, $value ) ) {
2889 + return new WP_Error(
2890 + 'invalid_param',
2891 + sprintf(
3396 2892 /* Translators: first variable is the name of a parameter passed to endpoint holding the role that will be checked, the second is a list of roles allowed to see stats. The parameter is checked against this list. */
3397 2893 esc_html__( '%1$s must be %2$s.', 'jetpack' ),
3398 2894 $param,
3399 - implode( ', ', self::$stats_roles )
2895 + implode( ', ', $editable_roles )
3400 2896 )
3401 2897 );
3402 2898 }
3403 2899 return true;
@@ -3714,9 +3210,12 @@
3714 3210 *
3715 3211 * @return bool|WP_Error
3716 3212 */
3717 3213 public static function validate_subscription_options( $values ) {
3718 - if ( is_object( $values ) ) {
3214 + // A REST "object" decodes to a PHP associative array. Reject any other
3215 + // type (object, string, int, null, ...) up front so the array_keys()
3216 + // loop below never runs against a non-array and triggers a PHP warning.
3217 + if ( ! is_array( $values ) ) {
3719 3218 return new WP_Error(
3720 3219 'invalid_param',
3721 3220 /* Translators: subscription_options is a variable name, and shouldn't be translated. */
3722 3221 esc_html__( 'subscription_options must be an object.', 'jetpack' )
@@ -3722,9 +3221,9 @@
3722 3221 esc_html__( 'subscription_options must be an object.', 'jetpack' )
3723 3222 );
3724 3223 }
3725 3224 foreach ( array_keys( $values ) as $key ) {
3726 - if ( ! in_array( $key, array( 'welcome', 'invitation', 'comment_follow' ), true ) ) {
3225 + if ( ! in_array( $key, array( 'welcome', 'invitation', 'comment_follow', 'subscribe_modal_heading', 'free_tier_description', 'hide_free_tier' ), true ) ) {
3727 3226 return new WP_Error(
3728 3227 'invalid_param',
3729 3228 sprintf(
3730 3229 /* Translators: Placeholder is the invalid param being sent. */
@@ -3765,11 +3264,11 @@
3765 3264 * return an array with only 'administrator' as the allowed role and save it for 'roles' option.
3766 3265 *
3767 3266 * @since 4.3.0
3768 3267 *
3769 - * @param string|bool $value Value to check.
3268 + * @param mixed $value Value to check.
3770 3269 *
3771 - * @return bool|array
3270 + * @return mixed The value as submitted, or an array holding only 'administrator' when it is empty.
3772 3271 */
3773 3272 public static function sanitize_stats_allowed_roles( $value ) {
3774 3273 if ( empty( $value ) ) {
3775 3274 return array( 'administrator' );
@@ -3777,8 +3276,31 @@
3777 3276 return $value;
3778 3277 }
3779 3278
3780 3279 /**
3280 + * Sanitize the AI crawler override map.
3281 + *
3282 + * Keeps the value package-agnostic: each key is normalized with sanitize_key()
3283 + * and each value cast to bool. Catalog validation and default-pruning happen in
3284 + * `Automattic\Jetpack\SEO\Ai_Crawlers::get_overrides()`.
3285 + *
3286 + * @param mixed $value The submitted override map.
3287 + *
3288 + * @return array<string, bool> Sanitized `slug => bool` map.
3289 + */
3290 + public static function sanitize_ai_crawler_overrides( $value ) {
3291 + if ( ! is_array( $value ) ) {
3292 + return array();
3293 + }
3294 +
3295 + $sanitized = array();
3296 + foreach ( $value as $k => $v ) {
3297 + $sanitized[ sanitize_key( $k ) ] = (bool) $v;
3298 + }
3299 + return $sanitized;
3300 + }
3301 +
3302 + /**
3781 3303 * Get the currently accessed route and return the module slug in it.
3782 3304 *
3783 3305 * @since 4.3.0
3784 3306 *
@@ -3787,9 +3309,9 @@
3787 3309 * @return array|string
3788 3310 */
3789 3311 public static function get_module_requested( $route = '/module/(?P<slug>[a-z\-]+)' ) {
3790 3312
3791 - if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
3313 + if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) || ! is_string( $GLOBALS['wp']->query_vars['rest_route'] ) ) {
3792 3314 return '';
3793 3315 }
3794 3316
3795 3317 preg_match( "#$route#", $GLOBALS['wp']->query_vars['rest_route'], $module );
@@ -3840,8 +3362,40 @@
3840 3362 return $modules;
3841 3363 }
3842 3364
3843 3365 /**
3366 + * Remove options the current user cannot read.
3367 + *
3368 + * Covers every `jetpack_waf_*` option, plus the two Protect options that expose the
3369 + * same data under a different name: `jetpack_protect_global_whitelist` is populated
3370 + * from `jetpack_waf_ip_allow_list`, and `jetpack_protect_key` is a shared secret.
3371 + *
3372 + * @since 16.2
3373 + *
3374 + * @param array $options Option definitions keyed by option name.
3375 + * @return array
3376 + */
3377 + public static function filter_options_for_response( $options ) {
3378 + if ( current_user_can( 'manage_options' ) ) {
3379 + return $options;
3380 + }
3381 +
3382 + $restricted = array(
3383 + 'jetpack_protect_key',
3384 + 'jetpack_protect_global_whitelist',
3385 + );
3386 +
3387 + return array_filter(
3388 + $options,
3389 + static function ( $option_name ) use ( $restricted ) {
3390 + return 0 !== strpos( $option_name, 'jetpack_waf_' )
3391 + && ! in_array( $option_name, $restricted, true );
3392 + },
3393 + ARRAY_FILTER_USE_KEY
3394 + );
3395 + }
3396 +
3397 + /**
3844 3398 * Remove 'validate_callback' item from options available for module.
3845 3399 * Fetch current option value and add to array of module options.
3846 3400 * Prepare values of module options that need special handling, like those saved in wpcom.
3847 3401 *
@@ -3904,9 +3458,9 @@
3904 3458 $options = self::split_options( $options, $sharer->get_global_options() );
3905 3459 $options['sharing_services']['current_value'] = $sharer->get_blog_services();
3906 3460 $other_sharedaddy_options = array( 'jetpack-twitter-cards-site-tag', 'sharedaddy_disable_resources', 'sharing_delete_service' );
3907 3461 foreach ( $other_sharedaddy_options as $key ) {
3908 - $default_value = isset( $options[ $key ]['default'] ) ? $options[ $key ]['default'] : '';
3462 + $default_value = $options[ $key ]['default'] ?? '';
3909 3463 $current_value = get_option( $key, $default_value );
3910 3464 $options[ $key ]['current_value'] = self::cast_value( $current_value, $options[ $key ] );
3911 3465 }
3912 3466 break;
@@ -3917,9 +3471,9 @@
3917 3471 break;
3918 3472 default:
3919 3473 // These option are just stored as plain WordPress options.
3920 3474 foreach ( $options as $key => $value ) {
3921 - $default_value = isset( $options[ $key ]['default'] ) ? $options[ $key ]['default'] : '';
3475 + $default_value = $options[ $key ]['default'] ?? '';
3922 3476 $current_value = get_option( $key, $default_value );
3923 3477 $options[ $key ]['current_value'] = self::cast_value( $current_value, $options[ $key ] );
3924 3478 }
3925 3479 }
@@ -3929,14 +3483,17 @@
3929 3483 // We don't need validate_callback in the response.
3930 3484 if ( isset( $options[ $key ]['validate_callback'] ) ) {
3931 3485 unset( $options[ $key ]['validate_callback'] );
3932 3486 }
3933 - $default_value = isset( $options[ $key ]['default'] ) ? $options[ $key ]['default'] : '';
3487 + $default_value = $options[ $key ]['default'] ?? '';
3934 3488 if ( ! array_key_exists( 'current_value', $options[ $key ] ) ) {
3935 3489 $options[ $key ]['current_value'] = self::cast_value( $default_value, $options[ $key ] );
3936 3490 }
3937 3491 }
3938 - return $options;
3492 +
3493 + // Filter last: the switch above assigns current_value by key without isset(),
3494 + // so filtering earlier would let those assignments re-add a removed option.
3495 + return self::filter_options_for_response( $options );
3939 3496 }
3940 3497
3941 3498 /**
3942 3499 * Splits module options saved as arrays like relatedposts or verification_services_codes into separate options to be returned in the response.
@@ -4441,60 +3998,52 @@
4441 3998 return rest_ensure_response( array( 'success' => $updated_option ) );
4442 3999 }
4443 4000
4444 4001 /**
4445 - * Fetch introdution offers.
4002 + * Return the list of available features.
4446 4003 *
4447 - * @since 10.9
4448 - *
4449 - * @return array|WP_Error
4004 + * @return array
4450 4005 */
4451 - public static function get_intro_offers() {
4452 - $site_id = Jetpack_Options::get_option( 'id' );
4453 -
4454 - if ( ! $site_id ) {
4455 - return new WP_Error(
4456 - 'site_id_missing',
4457 - esc_html__( 'Site ID is missing.', 'jetpack' ),
4458 - array( 'status' => 400 )
4459 - );
4006 + public static function get_features_available() {
4007 + $raw_modules = Jetpack::get_available_modules();
4008 + $modules = array();
4009 + foreach ( $raw_modules as $module ) {
4010 + $modules[] = Jetpack::get_module_slug( $module );
4460 4011 }
4461 4012
4462 - $response = Client::wpcom_json_api_request_as_user(
4463 - '/introductory-offers',
4464 - '2',
4465 - array(
4466 - 'method' => 'GET',
4467 - 'headers' => array(
4468 - 'X-Forwarded-For' => ( new Visitor() )->get_ip( true ),
4469 - ),
4470 - )
4471 - );
4013 + return $modules;
4014 + }
4472 4015
4473 - $response_code = wp_remote_retrieve_response_code( $response );
4474 -
4475 - if ( 200 !== $response_code ) {
4476 - return new WP_Error(
4477 - 'intro_offers_fetch_failed',
4478 - esc_html__( 'Could not retrieve intro offers.', 'jetpack' ),
4479 - array( 'status' => $response_code )
4480 - );
4016 + /**
4017 + * Returns what features are enabled. Uses the slug of the modules files.
4018 + *
4019 + * @return array
4020 + */
4021 + public static function get_features_enabled() {
4022 + $raw_modules = Jetpack::get_active_modules();
4023 + $modules = array();
4024 + foreach ( $raw_modules as $module ) {
4025 + $modules[] = Jetpack::get_module_slug( $module );
4481 4026 }
4482 4027
4483 - $data = json_decode( wp_remote_retrieve_body( $response ) );
4028 + return $modules;
4029 + }
4484 4030
4485 - if ( ! isset( $data ) ) {
4486 - return new WP_Error(
4487 - 'intro_offers_error',
4488 - esc_html__( 'Could not parse intro offers.', 'jetpack' ),
4489 - array( 'status' => 204 ) // no content.
4031 + /**
4032 + * Verify that the API client is allowed to replace user token.
4033 + *
4034 + * @since 1.29.0
4035 + *
4036 + * @return bool|WP_Error
4037 + */
4038 + public static function get_features_permission_check() {
4039 + if ( ! Rest_Authentication::is_signed_with_blog_token() ) {
4040 + $message = esc_html__(
4041 + 'You do not have the correct user permissions to perform this action. Please contact your site admin if you think this is a mistake.',
4042 + 'jetpack'
4490 4043 );
4044 + return new WP_Error( 'invalid_permission_fetch_features', $message, array( 'status' => rest_authorization_required_code() ) );
4491 4045 }
4492 4046
4493 - return rest_ensure_response(
4494 - array(
4495 - 'code' => 'success',
4496 - 'data' => $data,
4497 - )
4498 - );
4047 + return true;
4499 4048 }
4500 4049 } // class end