| @@ -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' ), |
| @@ -786,42 +731,59 @@ | ||
| 786 | 731 | ), |
| 787 | 732 | ), |
| 788 | 733 | ) |
| 789 | 734 | ); |
| 735 | + | |
| 736 | + /** | |
| 737 | + * Get the list of available Jetpack features. | |
| 738 | + * | |
| 739 | + * @since 13.9 | |
| 740 | + */ | |
| 741 | + register_rest_route( | |
| 742 | + 'jetpack/v4', | |
| 743 | + '/features/available', | |
| 744 | + array( | |
| 745 | + 'methods' => WP_REST_Server::READABLE, | |
| 746 | + 'callback' => array( static::class, 'get_features_available' ), | |
| 747 | + 'permission_callback' => array( static::class, 'get_features_permission_check' ), | |
| 748 | + ) | |
| 749 | + ); | |
| 750 | + | |
| 751 | + /** | |
| 752 | + * Get the list of enabled Jetpack features. | |
| 753 | + * | |
| 754 | + * @since 13.9 | |
| 755 | + */ | |
| 756 | + register_rest_route( | |
| 757 | + 'jetpack/v4', | |
| 758 | + '/features/enabled', | |
| 759 | + array( | |
| 760 | + 'methods' => WP_REST_Server::READABLE, | |
| 761 | + 'callback' => array( static::class, 'get_features_enabled' ), | |
| 762 | + 'permission_callback' => array( static::class, 'get_features_permission_check' ), | |
| 763 | + ) | |
| 764 | + ); | |
| 790 | 765 | } |
| 791 | 766 | |
| 792 | 767 | /** |
| 793 | 768 | * Ask WPCOM for a JWT token to use for OpenAI conversations. |
| 794 | - * TODO: Clean me up. This is ugly hack code. | |
| 769 | + * | |
| 770 | + * @deprecated since 16.2 | |
| 771 | + * @see Automattic\Jetpack\Connection\REST_Jetpack_AI_JWT::get_jwt() | |
| 772 | + * | |
| 773 | + * @return array|WP_Error The token and blog ID, or the error from WPCOM. | |
| 795 | 774 | */ |
| 796 | 775 | public static function get_openai_jwt() { |
| 797 | - $blog_id = \Jetpack_Options::get_option( 'id' ); | |
| 776 | + _deprecated_function( __METHOD__, 'jetpack-16.2', '\Automattic\Jetpack\Connection\REST_Jetpack_AI_JWT::get_jwt' ); | |
| 798 | 777 | |
| 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 | - ); | |
| 778 | + $response = ( new REST_Jetpack_AI_JWT() )->get_jwt(); | |
| 809 | 779 | |
| 810 | 780 | if ( is_wp_error( $response ) ) { |
| 811 | 781 | return $response; |
| 812 | 782 | } |
| 813 | 783 | |
| 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 | - ); | |
| 784 | + // Pre-deprecation callers expect the raw array, not a WP_REST_Response. | |
| 785 | + return $response->get_data(); | |
| 824 | 786 | } |
| 825 | 787 | |
| 826 | 788 | /** |
| 827 | 789 | * Set subscriber cookie and redirect |
| @@ -832,15 +794,24 @@ | ||
| 832 | 794 | */ |
| 833 | 795 | public static function set_subscriber_cookie_and_redirect( $request ) { |
| 834 | 796 | require_once JETPACK__PLUGIN_DIR . 'extensions/blocks/premium-content/_inc/subscription-service/include.php'; |
| 835 | 797 | $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'] ) ); | |
| 798 | + // Note: get_and_set_token_from_request() sets the subscriber cookie as a side effect. | |
| 799 | + // The cookie is set regardless of the redirect target below; only the redirect is gated. | |
| 800 | + $token = $subscription_service->get_and_set_token_from_request(); | |
| 801 | + $payload = $subscription_service->decode_token( $token ); | |
| 802 | + $is_valid_token = ! empty( $payload ); | |
| 803 | + if ( ! $is_valid_token ) { | |
| 804 | + return new WP_Error( 'invalid-token', 'Invalid Token', array( 'status' => 403 ) ); | |
| 841 | 805 | } |
| 842 | - return new WP_Error( 'invalid-token', 'Invalid Token' ); | |
| 806 | + | |
| 807 | + // Only redirect to the current site, not to an arbitrary host. | |
| 808 | + $redirect_url = wp_validate_redirect( $request['redirect_url'], '' ); | |
| 809 | + if ( ! $redirect_url ) { | |
| 810 | + return new WP_Error( 'invalid-redirect', 'Invalid Redirect URL', array( 'status' => 400 ) ); | |
| 811 | + } | |
| 812 | + | |
| 813 | + return new WP_REST_Response( null, 302, array( 'location' => $redirect_url ) ); | |
| 843 | 814 | } |
| 844 | 815 | |
| 845 | 816 | /** |
| 846 | 817 | * Get the data for the recommendations |
| @@ -900,9 +871,9 @@ | ||
| 900 | 871 | } |
| 901 | 872 | |
| 902 | 873 | $user_connected = ( new Connection_Manager( 'jetpack' ) )->is_user_connected( get_current_user_id() ); |
| 903 | 874 | if ( ! $user_connected ) { |
| 904 | - return wp_json_encode( array() ); | |
| 875 | + return wp_json_encode( array(), JSON_UNESCAPED_SLASHES ); | |
| 905 | 876 | } |
| 906 | 877 | |
| 907 | 878 | $request_path = sprintf( '/sites/%s/jetpack-recommendations/product-suggestions?locale=' . get_user_locale(), $blog_id ); |
| 908 | 879 | $wpcom_request = Client::wpcom_json_api_request_as_user( |
| @@ -1171,8 +1142,9 @@ | ||
| 1171 | 1142 | || Jetpack::is_plugin_active( 'mojo-under-construction/mojo-contruction.php' ) && 1 == $under_construction_activation_status // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual |
| 1172 | 1143 | || ( 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 | 1144 | || ( 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 | 1145 | || ( Jetpack::is_plugin_active( 'coming-soon/coming-soon.php' ) && isset( $csp4['status'] ) && ( 1 == $csp4['status'] || 2 == $csp4['status'] ) ) // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual |
| 1146 | + || | |
| 1175 | 1147 | /** |
| 1176 | 1148 | * Allow plugins to mark a site as "under construction". |
| 1177 | 1149 | * |
| 1178 | 1150 | * @since 6.7.0 |
| @@ -1178,9 +1150,9 @@ | ||
| 1178 | 1150 | * @since 6.7.0 |
| 1179 | 1151 | * |
| 1180 | 1152 | * @param false bool Is the site under construction? Default to false. |
| 1181 | 1153 | */ |
| 1182 | - || true === apply_filters( 'jetpack_is_under_construction_plugin', false ) | |
| 1154 | + true === apply_filters( 'jetpack_is_under_construction_plugin', false ) | |
| 1183 | 1155 | ) { |
| 1184 | 1156 | return new WP_Error( 'forbidden', __( 'Site is under construction and cannot be verified', 'jetpack' ) ); |
| 1185 | 1157 | } |
| 1186 | 1158 | |
| @@ -1319,24 +1291,20 @@ | ||
| 1319 | 1291 | |
| 1320 | 1292 | /** |
| 1321 | 1293 | * Verify that a user can use the /connection/user endpoint. Has to be a registered user and be currently linked. |
| 1322 | 1294 | * |
| 1295 | + * @uses Automattic\Jetpack\Connection\Manager::is_user_connected();) | |
| 1296 | + * | |
| 1297 | + * @deprecated since Jetpack 14.4.0 | |
| 1298 | + * @see Automattic\Jetpack\Connection\REST_Connector::unlink_user_permission_callback() | |
| 1299 | + * | |
| 1323 | 1300 | * @since 4.3.0 |
| 1324 | 1301 | * |
| 1325 | - * @uses Automattic\Jetpack\Connection\Manager::is_user_connected();) | |
| 1326 | - * | |
| 1327 | 1302 | * @return bool|WP_Error True if user is able to unlink. |
| 1328 | 1303 | */ |
| 1329 | 1304 | 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 | - ); | |
| 1305 | + _deprecated_function( __METHOD__, 'jetpack-14.4.0', 'Automattic\Jetpack\Connection\REST_Connector::unlink_user_permission_callback()' ); | |
| 1306 | + return REST_Connector::unlink_user_permission_callback(); | |
| 1339 | 1307 | } |
| 1340 | 1308 | |
| 1341 | 1309 | /** |
| 1342 | 1310 | * Verify that user can manage Jetpack modules. |
| @@ -1471,136 +1439,8 @@ | ||
| 1471 | 1439 | ); |
| 1472 | 1440 | } |
| 1473 | 1441 | |
| 1474 | 1442 | /** |
| 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' => $encrypted, | |
| 1598 | - ) | |
| 1599 | - ); | |
| 1600 | - } | |
| 1601 | - | |
| 1602 | - /** | |
| 1603 | 1443 | * Fetch information about the Rewind status of the site. |
| 1604 | 1444 | */ |
| 1605 | 1445 | public static function rewind_data() { |
| 1606 | 1446 | $site_id = Jetpack_Options::get_option( 'id' ); |
| @@ -1643,9 +1483,9 @@ | ||
| 1643 | 1483 | return rest_ensure_response( |
| 1644 | 1484 | array( |
| 1645 | 1485 | 'code' => 'success', |
| 1646 | 1486 | 'message' => esc_html__( 'Backup & Scan data correctly received.', 'jetpack' ), |
| 1647 | - 'data' => wp_json_encode( $rewind_data ), | |
| 1487 | + 'data' => wp_json_encode( $rewind_data, JSON_UNESCAPED_SLASHES ), | |
| 1648 | 1488 | ) |
| 1649 | 1489 | ); |
| 1650 | 1490 | } |
| 1651 | 1491 | |
| @@ -1726,9 +1566,9 @@ | ||
| 1726 | 1566 | return rest_ensure_response( |
| 1727 | 1567 | array( |
| 1728 | 1568 | 'code' => 'success', |
| 1729 | 1569 | 'message' => esc_html__( 'Scan state correctly received.', 'jetpack' ), |
| 1730 | - 'data' => wp_json_encode( $scan_state ), | |
| 1570 | + 'data' => wp_json_encode( $scan_state, JSON_UNESCAPED_SLASHES ), | |
| 1731 | 1571 | ) |
| 1732 | 1572 | ); |
| 1733 | 1573 | } |
| 1734 | 1574 | |
| @@ -1785,10 +1625,10 @@ | ||
| 1785 | 1625 | * |
| 1786 | 1626 | * @return string|WP_Error A raw URL if the connection URL could be built; error message otherwise. |
| 1787 | 1627 | */ |
| 1788 | 1628 | public static function build_connect_url( $request = array() ) { |
| 1789 | - $from = isset( $request['from'] ) ? $request['from'] : false; | |
| 1790 | - $redirect = isset( $request['redirect'] ) ? $request['redirect'] : false; | |
| 1629 | + $from = $request['from'] ?? false; | |
| 1630 | + $redirect = $request['redirect'] ?? false; | |
| 1791 | 1631 | |
| 1792 | 1632 | $url = Jetpack::init()->build_connect_url( true, $redirect, $from ); |
| 1793 | 1633 | if ( $url ) { |
| 1794 | 1634 | return rest_ensure_response( $url ); |
| @@ -1826,30 +1666,21 @@ | ||
| 1826 | 1666 | |
| 1827 | 1667 | /** |
| 1828 | 1668 | * Unlinks current user from the WordPress.com Servers. |
| 1829 | 1669 | * |
| 1830 | - * @since 4.3.0 | |
| 1670 | + * @param WP_REST_Request $request The request sent to the WP REST API. | |
| 1831 | 1671 | * @uses Automattic\Jetpack\Connection\Manager->disconnect_user |
| 1832 | 1672 | * |
| 1833 | - * @param WP_REST_Request $request The request sent to the WP REST API. | |
| 1673 | + * @deprecated since Jetpack 14.4.0 | |
| 1674 | + * @see Automattic\Jetpack\Connection\REST_Connector::unlink_user() | |
| 1834 | 1675 | * |
| 1676 | + * @since 4.3.0 | |
| 1677 | + * | |
| 1835 | 1678 | * @return bool|WP_Error True if user successfully unlinked. |
| 1836 | 1679 | */ |
| 1837 | 1680 | public static function unlink_user( $request ) { |
| 1838 | - | |
| 1839 | - if ( ! isset( $request['linked'] ) || false !== $request['linked'] ) { | |
| 1840 | - return new WP_Error( 'invalid_param', esc_html__( 'Invalid Parameter', 'jetpack' ), array( 'status' => 404 ) ); | |
| 1841 | - } | |
| 1842 | - | |
| 1843 | - if ( ( new Connection_Manager( 'jetpack' ) )->disconnect_user() ) { | |
| 1844 | - return rest_ensure_response( | |
| 1845 | - array( | |
| 1846 | - 'code' => 'success', | |
| 1847 | - ) | |
| 1848 | - ); | |
| 1849 | - } | |
| 1850 | - | |
| 1851 | - return new WP_Error( 'unlink_user_failed', esc_html__( 'Was not able to unlink the user. Please try again.', 'jetpack' ), array( 'status' => 400 ) ); | |
| 1681 | + _deprecated_function( __METHOD__, 'jetpack-14.4.0', 'Automattic\Jetpack\Connection\REST_Connector::unlink_user()' ); | |
| 1682 | + return REST_Connector::unlink_user( $request ); | |
| 1852 | 1683 | } |
| 1853 | 1684 | |
| 1854 | 1685 | /** |
| 1855 | 1686 | * Gets current user's tracking settings. |
| @@ -1908,9 +1739,9 @@ | ||
| 1908 | 1739 | 'Content-Type' => 'application/json', |
| 1909 | 1740 | 'X-Forwarded-For' => ( new Visitor() )->get_ip( true ), |
| 1910 | 1741 | ), |
| 1911 | 1742 | ), |
| 1912 | - wp_json_encode( $request->get_params() ) | |
| 1743 | + wp_json_encode( $request->get_params(), JSON_UNESCAPED_SLASHES ) | |
| 1913 | 1744 | ); |
| 1914 | 1745 | if ( ! is_wp_error( $response ) ) { |
| 1915 | 1746 | $response = json_decode( wp_remote_retrieve_body( $response ), true ); |
| 1916 | 1747 | } |
| @@ -1922,93 +1753,30 @@ | ||
| 1922 | 1753 | /** |
| 1923 | 1754 | * Fetch site data from .com including the site's current plan and the site's products. |
| 1924 | 1755 | * |
| 1925 | 1756 | * @since 5.5.0 |
| 1757 | + * @deprecated 16.2 Use Automattic\Jetpack\Connection\Manager::get_connected_site_data(). | |
| 1926 | 1758 | * |
| 1927 | 1759 | * @return stdClass|WP_Error |
| 1928 | 1760 | */ |
| 1929 | 1761 | public static function site_data() { |
| 1930 | - $site_id = Jetpack_Options::get_option( 'id' ); | |
| 1762 | + _deprecated_function( __METHOD__, 'jetpack-16.2', 'Automattic\Jetpack\Connection\Manager::get_connected_site_data' ); | |
| 1931 | 1763 | |
| 1932 | - if ( ! $site_id ) { | |
| 1933 | - return new WP_Error( 'site_id_missing', '', array( 'api_error_code' => __( 'site_id_missing', 'jetpack' ) ) ); | |
| 1934 | - } | |
| 1764 | + return ( new Connection_Manager() )->get_connected_site_data(); | |
| 1765 | + } | |
| 1935 | 1766 | |
| 1936 | - $args = array( 'headers' => array() ); | |
| 1937 | - | |
| 1938 | - // Allow use a store sandbox. Internal ref: PCYsg-IA-p2. | |
| 1939 | - if ( isset( $_COOKIE ) && isset( $_COOKIE['store_sandbox'] ) ) { | |
| 1940 | - $secret = filter_var( wp_unslash( $_COOKIE['store_sandbox'] ) ); | |
| 1941 | - $args['headers']['Cookie'] = "store_sandbox=$secret;"; | |
| 1942 | - } | |
| 1943 | - | |
| 1944 | - $response = Client::wpcom_json_api_request_as_blog( sprintf( '/sites/%d', $site_id ) . '?force=wpcom', '1.1', $args ); | |
| 1945 | - $body = wp_remote_retrieve_body( $response ); | |
| 1946 | - $data = $body ? json_decode( $body ) : null; | |
| 1947 | - | |
| 1948 | - if ( 200 !== wp_remote_retrieve_response_code( $response ) ) { | |
| 1949 | - $error_info = array( | |
| 1950 | - 'api_error_code' => null, | |
| 1951 | - 'api_http_code' => wp_remote_retrieve_response_code( $response ), | |
| 1952 | - ); | |
| 1953 | - | |
| 1954 | - if ( is_wp_error( $response ) ) { | |
| 1955 | - $error_info['api_error_code'] = $response->get_error_code() ? wp_strip_all_tags( $response->get_error_code() ) : null; | |
| 1956 | - } elseif ( $data && ! empty( $data->error ) ) { | |
| 1957 | - $error_info['api_error_code'] = $data->error; | |
| 1958 | - } | |
| 1959 | - | |
| 1960 | - return new WP_Error( 'site_data_fetch_failed', '', $error_info ); | |
| 1961 | - } | |
| 1962 | - | |
| 1963 | - Jetpack_Plan::update_from_sites_response( $response ); | |
| 1964 | - | |
| 1965 | - return $data; | |
| 1966 | - } | |
| 1967 | 1767 | /** |
| 1968 | 1768 | * Get site data, including for example, the site's current plan. |
| 1969 | 1769 | * |
| 1770 | + * @since 4.3.0 | |
| 1771 | + * @deprecated 16.2 Use Automattic\Jetpack\Connection\REST_Connector::site_data_response(). | |
| 1772 | + * | |
| 1970 | 1773 | * @return WP_Error|WP_HTTP_Response|WP_REST_Response |
| 1971 | - * @since 4.3.0 | |
| 1972 | 1774 | */ |
| 1973 | 1775 | public static function get_site_data() { |
| 1974 | - $site_data = self::site_data(); | |
| 1776 | + _deprecated_function( __METHOD__, 'jetpack-16.2', 'Automattic\Jetpack\Connection\REST_Connector::site_data_response' ); | |
| 1975 | 1777 | |
| 1976 | - if ( ! is_wp_error( $site_data ) ) { | |
| 1977 | - | |
| 1978 | - /** | |
| 1979 | - * Fires when the site data was successfully returned from the /sites/%d wpcom endpoint. | |
| 1980 | - * | |
| 1981 | - * @since 8.7.0 | |
| 1982 | - */ | |
| 1983 | - do_action( 'jetpack_get_site_data_success' ); | |
| 1984 | - return rest_ensure_response( | |
| 1985 | - array( | |
| 1986 | - 'code' => 'success', | |
| 1987 | - 'message' => esc_html__( 'Site data correctly received.', 'jetpack' ), | |
| 1988 | - 'data' => wp_json_encode( $site_data ), | |
| 1989 | - ) | |
| 1990 | - ); | |
| 1991 | - } | |
| 1992 | - | |
| 1993 | - $error_data = $site_data->get_error_data(); | |
| 1994 | - | |
| 1995 | - if ( empty( $error_data['api_error_code'] ) ) { | |
| 1996 | - $error_message = esc_html__( 'Failed fetching site data from WordPress.com. If the problem persists, try reconnecting Jetpack.', 'jetpack' ); | |
| 1997 | - } else { | |
| 1998 | - /* translators: %s is an error code (e.g. `token_mismatch`) */ | |
| 1999 | - $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'] ); | |
| 2000 | - } | |
| 2001 | - | |
| 2002 | - return new WP_Error( | |
| 2003 | - $site_data->get_error_code(), | |
| 2004 | - $error_message, | |
| 2005 | - array( | |
| 2006 | - 'status' => 400, | |
| 2007 | - 'api_error_code' => empty( $error_data['api_error_code'] ) ? null : $error_data['api_error_code'], | |
| 2008 | - 'api_http_code' => empty( $error_data['api_http_code'] ) ? null : $error_data['api_http_code'], | |
| 2009 | - ) | |
| 2010 | - ); | |
| 1778 | + return REST_Connector::site_data_response(); | |
| 2011 | 1779 | } |
| 2012 | 1780 | |
| 2013 | 1781 | /** |
| 2014 | 1782 | * Fetch AL data for this site and return it. |
| @@ -2223,9 +1991,9 @@ | ||
| 2223 | 1991 | public static function get_updateable_data_list( $selector = '' ) { |
| 2224 | 1992 | |
| 2225 | 1993 | $options = array( |
| 2226 | 1994 | // Blocks. |
| 2227 | - 'jetpack_blocks_disabled' => array( | |
| 1995 | + 'jetpack_blocks_disabled' => array( | |
| 2228 | 1996 | 'description' => esc_html__( 'Jetpack Blocks disabled.', 'jetpack' ), |
| 2229 | 1997 | 'type' => 'boolean', |
| 2230 | 1998 | 'default' => false, |
| 2231 | 1999 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2232,9 +2000,9 @@ | ||
| 2232 | 2000 | 'jp_group' => 'settings', |
| 2233 | 2001 | ), |
| 2234 | 2002 | |
| 2235 | 2003 | // Carousel |
| 2236 | - 'carousel_background_color' => array( | |
| 2004 | + 'carousel_background_color' => array( | |
| 2237 | 2005 | 'description' => esc_html__( 'Color scheme.', 'jetpack' ), |
| 2238 | 2006 | 'type' => 'string', |
| 2239 | 2007 | 'default' => 'black', |
| 2240 | 2008 | 'enum' => array( |
| @@ -2247,9 +2015,9 @@ | ||
| 2247 | 2015 | ), |
| 2248 | 2016 | 'validate_callback' => __CLASS__ . '::validate_list_item', |
| 2249 | 2017 | 'jp_group' => 'carousel', |
| 2250 | 2018 | ), |
| 2251 | - 'carousel_display_exif' => array( | |
| 2019 | + 'carousel_display_exif' => array( | |
| 2252 | 2020 | 'description' => wp_kses( |
| 2253 | 2021 | sprintf( __( 'Show photo metadata (<a href="https://en.wikipedia.org/wiki/Exchangeable_image_file_format" target="_blank">Exif</a>) in carousel, when available.', 'jetpack' ) ), |
| 2254 | 2022 | array( |
| 2255 | 2023 | 'a' => array( |
| @@ -2262,9 +2030,9 @@ | ||
| 2262 | 2030 | 'default' => 0, |
| 2263 | 2031 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2264 | 2032 | 'jp_group' => 'carousel', |
| 2265 | 2033 | ), |
| 2266 | - 'carousel_display_comments' => array( | |
| 2034 | + 'carousel_display_comments' => array( | |
| 2267 | 2035 | 'description' => esc_html__( 'Show comments area in carousel', 'jetpack' ), |
| 2268 | 2036 | 'type' => 'boolean', |
| 2269 | 2037 | 'default' => 1, |
| 2270 | 2038 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2271,9 +2039,9 @@ | ||
| 2271 | 2039 | 'jp_group' => 'carousel', |
| 2272 | 2040 | ), |
| 2273 | 2041 | |
| 2274 | 2042 | // Comments. |
| 2275 | - 'highlander_comment_form_prompt' => array( | |
| 2043 | + 'highlander_comment_form_prompt' => array( | |
| 2276 | 2044 | 'description' => esc_html__( 'Greeting Text', 'jetpack' ), |
| 2277 | 2045 | 'type' => 'string', |
| 2278 | 2046 | 'default' => esc_html__( 'Leave a Reply', 'jetpack' ), |
| 2279 | 2047 | 'sanitize_callback' => 'sanitize_text_field', |
| @@ -2278,9 +2046,9 @@ | ||
| 2278 | 2046 | 'default' => esc_html__( 'Leave a Reply', 'jetpack' ), |
| 2279 | 2047 | 'sanitize_callback' => 'sanitize_text_field', |
| 2280 | 2048 | 'jp_group' => 'comments', |
| 2281 | 2049 | ), |
| 2282 | - 'jetpack_comment_form_color_scheme' => array( | |
| 2050 | + 'jetpack_comment_form_color_scheme' => array( | |
| 2283 | 2051 | 'description' => esc_html__( 'Color scheme', 'jetpack' ), |
| 2284 | 2052 | 'type' => 'string', |
| 2285 | 2053 | 'default' => 'light', |
| 2286 | 2054 | 'enum' => array( |
| @@ -2297,39 +2065,38 @@ | ||
| 2297 | 2065 | 'jp_group' => 'comments', |
| 2298 | 2066 | ), |
| 2299 | 2067 | |
| 2300 | 2068 | // Custom Content Types. |
| 2301 | - 'jetpack_portfolio' => array( | |
| 2069 | + 'jetpack_portfolio' => array( | |
| 2302 | 2070 | 'description' => esc_html__( 'Enable or disable Jetpack portfolio post type.', 'jetpack' ), |
| 2303 | 2071 | 'type' => 'boolean', |
| 2304 | 2072 | 'default' => 0, |
| 2305 | 2073 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2306 | - 'jp_group' => 'custom-content-types', | |
| 2074 | + 'jp_group' => 'settings', | |
| 2307 | 2075 | ), |
| 2308 | - 'jetpack_portfolio_posts_per_page' => array( | |
| 2076 | + 'jetpack_portfolio_posts_per_page' => array( | |
| 2309 | 2077 | 'description' => esc_html__( 'Number of entries to show at most in Portfolio pages.', 'jetpack' ), |
| 2310 | 2078 | 'type' => 'integer', |
| 2311 | 2079 | 'default' => 10, |
| 2312 | 2080 | 'validate_callback' => __CLASS__ . '::validate_posint', |
| 2313 | - 'jp_group' => 'custom-content-types', | |
| 2081 | + 'jp_group' => 'settings', | |
| 2314 | 2082 | ), |
| 2315 | - 'jetpack_testimonial' => array( | |
| 2083 | + 'jetpack_testimonial' => array( | |
| 2316 | 2084 | 'description' => esc_html__( 'Enable or disable Jetpack testimonial post type.', 'jetpack' ), |
| 2317 | 2085 | 'type' => 'boolean', |
| 2318 | 2086 | 'default' => 0, |
| 2319 | 2087 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2320 | - 'jp_group' => 'custom-content-types', | |
| 2088 | + 'jp_group' => 'settings', | |
| 2321 | 2089 | ), |
| 2322 | - 'jetpack_testimonial_posts_per_page' => array( | |
| 2090 | + 'jetpack_testimonial_posts_per_page' => array( | |
| 2323 | 2091 | 'description' => esc_html__( 'Number of entries to show at most in Testimonial pages.', 'jetpack' ), |
| 2324 | 2092 | 'type' => 'integer', |
| 2325 | 2093 | 'default' => 10, |
| 2326 | 2094 | 'validate_callback' => __CLASS__ . '::validate_posint', |
| 2327 | - 'jp_group' => 'custom-content-types', | |
| 2095 | + 'jp_group' => 'settings', | |
| 2328 | 2096 | ), |
| 2329 | - | |
| 2330 | 2097 | // WAF. |
| 2331 | - 'jetpack_waf_automatic_rules' => array( | |
| 2098 | + 'jetpack_waf_automatic_rules' => array( | |
| 2332 | 2099 | 'description' => esc_html__( 'Enable automatic rules - Protect your site against untrusted traffic sources with automatic security rules.', 'jetpack' ), |
| 2333 | 2100 | 'type' => 'boolean', |
| 2334 | 2101 | 'default' => Waf_Compatibility::get_default_automatic_rules_option(), |
| 2335 | 2102 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2334,9 +2101,9 @@ | ||
| 2334 | 2101 | 'default' => Waf_Compatibility::get_default_automatic_rules_option(), |
| 2335 | 2102 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2336 | 2103 | 'jp_group' => 'waf', |
| 2337 | 2104 | ), |
| 2338 | - 'jetpack_waf_ip_block_list_enabled' => array( | |
| 2105 | + 'jetpack_waf_ip_block_list_enabled' => array( | |
| 2339 | 2106 | 'description' => esc_html__( 'Block list - Block a specific request IP.', 'jetpack' ), |
| 2340 | 2107 | 'type' => 'boolean', |
| 2341 | 2108 | 'default' => 0, |
| 2342 | 2109 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2341,9 +2108,9 @@ | ||
| 2341 | 2108 | 'default' => 0, |
| 2342 | 2109 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2343 | 2110 | 'jp_group' => 'waf', |
| 2344 | 2111 | ), |
| 2345 | - 'jetpack_waf_ip_block_list' => array( | |
| 2112 | + 'jetpack_waf_ip_block_list' => array( | |
| 2346 | 2113 | 'description' => esc_html__( 'Blocked IP addresses', 'jetpack' ), |
| 2347 | 2114 | 'type' => 'string', |
| 2348 | 2115 | 'default' => '', |
| 2349 | 2116 | 'validate_callback' => __CLASS__ . '::validate_string', |
| @@ -2349,9 +2116,9 @@ | ||
| 2349 | 2116 | 'validate_callback' => __CLASS__ . '::validate_string', |
| 2350 | 2117 | 'sanitize_callback' => 'esc_textarea', |
| 2351 | 2118 | 'jp_group' => 'waf', |
| 2352 | 2119 | ), |
| 2353 | - 'jetpack_waf_ip_allow_list_enabled' => array( | |
| 2120 | + 'jetpack_waf_ip_allow_list_enabled' => array( | |
| 2354 | 2121 | 'description' => esc_html__( 'Allow list - Allow a specific request IP.', 'jetpack' ), |
| 2355 | 2122 | 'type' => 'boolean', |
| 2356 | 2123 | 'default' => 0, |
| 2357 | 2124 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2356,9 +2123,9 @@ | ||
| 2356 | 2123 | 'default' => 0, |
| 2357 | 2124 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2358 | 2125 | 'jp_group' => 'settings', |
| 2359 | 2126 | ), |
| 2360 | - 'jetpack_waf_ip_allow_list' => array( | |
| 2127 | + 'jetpack_waf_ip_allow_list' => array( | |
| 2361 | 2128 | 'description' => esc_html__( 'Always allowed IP addresses', 'jetpack' ), |
| 2362 | 2129 | 'type' => 'string', |
| 2363 | 2130 | 'default' => '', |
| 2364 | 2131 | 'validate_callback' => __CLASS__ . '::validate_string', |
| @@ -2364,9 +2131,9 @@ | ||
| 2364 | 2131 | 'validate_callback' => __CLASS__ . '::validate_string', |
| 2365 | 2132 | 'sanitize_callback' => 'esc_textarea', |
| 2366 | 2133 | 'jp_group' => 'settings', |
| 2367 | 2134 | ), |
| 2368 | - 'jetpack_waf_share_data' => array( | |
| 2135 | + 'jetpack_waf_share_data' => array( | |
| 2369 | 2136 | 'description' => esc_html__( 'Share basic data with Jetpack.', 'jetpack' ), |
| 2370 | 2137 | 'type' => 'boolean', |
| 2371 | 2138 | 'default' => 0, |
| 2372 | 2139 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2371,9 +2138,9 @@ | ||
| 2371 | 2138 | 'default' => 0, |
| 2372 | 2139 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2373 | 2140 | 'jp_group' => 'waf', |
| 2374 | 2141 | ), |
| 2375 | - 'jetpack_waf_share_debug_data' => array( | |
| 2142 | + 'jetpack_waf_share_debug_data' => array( | |
| 2376 | 2143 | 'description' => esc_html__( 'Share detailed data with Jetpack.', 'jetpack' ), |
| 2377 | 2144 | 'type' => 'boolean', |
| 2378 | 2145 | 'default' => 0, |
| 2379 | 2146 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2379,9 +2146,9 @@ | ||
| 2379 | 2146 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2380 | 2147 | 'jp_group' => 'waf', |
| 2381 | 2148 | ), |
| 2382 | 2149 | // Galleries. |
| 2383 | - 'tiled_galleries' => array( | |
| 2150 | + 'tiled_galleries' => array( | |
| 2384 | 2151 | 'description' => esc_html__( 'Display all your gallery pictures in a cool mosaic.', 'jetpack' ), |
| 2385 | 2152 | 'type' => 'boolean', |
| 2386 | 2153 | 'default' => 0, |
| 2387 | 2154 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2387,9 +2154,9 @@ | ||
| 2387 | 2154 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2388 | 2155 | 'jp_group' => 'tiled-gallery', |
| 2389 | 2156 | ), |
| 2390 | 2157 | |
| 2391 | - 'gravatar_disable_hovercards' => array( | |
| 2158 | + 'gravatar_disable_hovercards' => array( | |
| 2392 | 2159 | 'description' => esc_html__( "View people's profiles when you mouse over their Gravatars", 'jetpack' ), |
| 2393 | 2160 | 'type' => 'string', |
| 2394 | 2161 | 'default' => 'enabled', |
| 2395 | 2162 | // Not visible. This is used as the checkbox value. |
| @@ -2405,9 +2172,9 @@ | ||
| 2405 | 2172 | 'jp_group' => 'gravatar-hovercards', |
| 2406 | 2173 | ), |
| 2407 | 2174 | |
| 2408 | 2175 | // Infinite Scroll. |
| 2409 | - 'infinite_scroll' => array( | |
| 2176 | + 'infinite_scroll' => array( | |
| 2410 | 2177 | 'description' => esc_html__( 'To infinity and beyond', 'jetpack' ), |
| 2411 | 2178 | 'type' => 'boolean', |
| 2412 | 2179 | 'default' => 1, |
| 2413 | 2180 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2412,9 +2179,9 @@ | ||
| 2412 | 2179 | 'default' => 1, |
| 2413 | 2180 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2414 | 2181 | 'jp_group' => 'infinite-scroll', |
| 2415 | 2182 | ), |
| 2416 | - 'infinite_scroll_google_analytics' => array( | |
| 2183 | + 'infinite_scroll_google_analytics' => array( | |
| 2417 | 2184 | 'description' => esc_html__( 'Use Google Analytics with Infinite Scroll', 'jetpack' ), |
| 2418 | 2185 | 'type' => 'boolean', |
| 2419 | 2186 | 'default' => 0, |
| 2420 | 2187 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2421,9 +2188,9 @@ | ||
| 2421 | 2188 | 'jp_group' => 'infinite-scroll', |
| 2422 | 2189 | ), |
| 2423 | 2190 | |
| 2424 | 2191 | // Likes. |
| 2425 | - 'wpl_default' => array( | |
| 2192 | + 'wpl_default' => array( | |
| 2426 | 2193 | 'description' => esc_html__( 'WordPress.com Likes are', 'jetpack' ), |
| 2427 | 2194 | 'type' => 'string', |
| 2428 | 2195 | 'default' => 'on', |
| 2429 | 2196 | 'enum' => array( |
| @@ -2436,9 +2203,9 @@ | ||
| 2436 | 2203 | ), |
| 2437 | 2204 | 'validate_callback' => __CLASS__ . '::validate_list_item', |
| 2438 | 2205 | 'jp_group' => 'likes', |
| 2439 | 2206 | ), |
| 2440 | - 'social_notifications_like' => array( | |
| 2207 | + 'social_notifications_like' => array( | |
| 2441 | 2208 | 'description' => esc_html__( 'Send email notification when someone likes a post', 'jetpack' ), |
| 2442 | 2209 | 'type' => 'boolean', |
| 2443 | 2210 | 'default' => 1, |
| 2444 | 2211 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2445,9 +2212,9 @@ | ||
| 2445 | 2212 | 'jp_group' => 'likes', |
| 2446 | 2213 | ), |
| 2447 | 2214 | |
| 2448 | 2215 | // Markdown. |
| 2449 | - 'wpcom_publish_comments_with_markdown' => array( | |
| 2216 | + 'wpcom_publish_comments_with_markdown' => array( | |
| 2450 | 2217 | 'description' => esc_html__( 'Use Markdown for comments.', 'jetpack' ), |
| 2451 | 2218 | 'type' => 'boolean', |
| 2452 | 2219 | 'default' => 0, |
| 2453 | 2220 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2452,9 +2219,9 @@ | ||
| 2452 | 2219 | 'default' => 0, |
| 2453 | 2220 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2454 | 2221 | 'jp_group' => 'markdown', |
| 2455 | 2222 | ), |
| 2456 | - 'wpcom_publish_posts_with_markdown' => array( | |
| 2223 | + 'wpcom_publish_posts_with_markdown' => array( | |
| 2457 | 2224 | 'description' => esc_html__( 'Use Markdown for posts.', 'jetpack' ), |
| 2458 | 2225 | 'type' => 'boolean', |
| 2459 | 2226 | 'default' => 0, |
| 2460 | 2227 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2461,9 +2228,9 @@ | ||
| 2461 | 2228 | 'jp_group' => 'markdown', |
| 2462 | 2229 | ), |
| 2463 | 2230 | |
| 2464 | 2231 | // Monitor. |
| 2465 | - 'monitor_receive_notifications' => array( | |
| 2232 | + 'monitor_receive_notifications' => array( | |
| 2466 | 2233 | 'description' => esc_html__( 'Receive Monitor Email Notifications.', 'jetpack' ), |
| 2467 | 2234 | 'type' => 'boolean', |
| 2468 | 2235 | 'default' => 0, |
| 2469 | 2236 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2470,9 +2237,9 @@ | ||
| 2470 | 2237 | 'jp_group' => 'monitor', |
| 2471 | 2238 | ), |
| 2472 | 2239 | |
| 2473 | 2240 | // Post by Email. |
| 2474 | - 'post_by_email_address' => array( | |
| 2241 | + 'post_by_email_address' => array( | |
| 2475 | 2242 | 'description' => esc_html__( 'Email Address', 'jetpack' ), |
| 2476 | 2243 | 'type' => 'string', |
| 2477 | 2244 | 'default' => 'noop', |
| 2478 | 2245 | 'enum' => array( |
| @@ -2491,9 +2258,9 @@ | ||
| 2491 | 2258 | 'jp_group' => 'post-by-email', |
| 2492 | 2259 | ), |
| 2493 | 2260 | |
| 2494 | 2261 | // Protect. |
| 2495 | - 'jetpack_protect_key' => array( | |
| 2262 | + 'jetpack_protect_key' => array( | |
| 2496 | 2263 | 'description' => esc_html__( 'Protect API key', 'jetpack' ), |
| 2497 | 2264 | 'type' => 'string', |
| 2498 | 2265 | 'default' => '', |
| 2499 | 2266 | 'validate_callback' => __CLASS__ . '::validate_alphanum', |
| @@ -2498,9 +2265,9 @@ | ||
| 2498 | 2265 | 'default' => '', |
| 2499 | 2266 | 'validate_callback' => __CLASS__ . '::validate_alphanum', |
| 2500 | 2267 | 'jp_group' => 'protect', |
| 2501 | 2268 | ), |
| 2502 | - 'jetpack_protect_global_whitelist' => array( | |
| 2269 | + 'jetpack_protect_global_whitelist' => array( | |
| 2503 | 2270 | 'description' => esc_html__( 'Protect global IP allow list', 'jetpack' ), |
| 2504 | 2271 | 'type' => 'string', |
| 2505 | 2272 | 'default' => '', |
| 2506 | 2273 | 'validate_callback' => __CLASS__ . '::validate_string', |
| @@ -2508,9 +2275,9 @@ | ||
| 2508 | 2275 | 'jp_group' => 'protect', |
| 2509 | 2276 | ), |
| 2510 | 2277 | |
| 2511 | 2278 | // Sharing. |
| 2512 | - 'sharing_services' => array( | |
| 2279 | + 'sharing_services' => array( | |
| 2513 | 2280 | 'description' => esc_html__( 'Enabled Services and those hidden behind a button', 'jetpack' ), |
| 2514 | 2281 | 'type' => 'object', |
| 2515 | 2282 | 'default' => array( |
| 2516 | 2283 | 'visible' => array( 'facebook', 'x' ), |
| @@ -2518,9 +2285,9 @@ | ||
| 2518 | 2285 | ), |
| 2519 | 2286 | 'validate_callback' => __CLASS__ . '::validate_services', |
| 2520 | 2287 | 'jp_group' => 'sharedaddy', |
| 2521 | 2288 | ), |
| 2522 | - 'button_style' => array( | |
| 2289 | + 'button_style' => array( | |
| 2523 | 2290 | 'description' => esc_html__( 'Button Style', 'jetpack' ), |
| 2524 | 2291 | 'type' => 'string', |
| 2525 | 2292 | 'default' => 'icon', |
| 2526 | 2293 | 'enum' => array( |
| @@ -2537,9 +2304,9 @@ | ||
| 2537 | 2304 | ), |
| 2538 | 2305 | 'validate_callback' => __CLASS__ . '::validate_list_item', |
| 2539 | 2306 | 'jp_group' => 'sharedaddy', |
| 2540 | 2307 | ), |
| 2541 | - 'sharing_label' => array( | |
| 2308 | + 'sharing_label' => array( | |
| 2542 | 2309 | 'description' => esc_html__( 'Sharing Label', 'jetpack' ), |
| 2543 | 2310 | 'type' => 'string', |
| 2544 | 2311 | 'default' => '', |
| 2545 | 2312 | 'validate_callback' => __CLASS__ . '::validate_string', |
| @@ -2545,9 +2312,9 @@ | ||
| 2545 | 2312 | 'validate_callback' => __CLASS__ . '::validate_string', |
| 2546 | 2313 | 'sanitize_callback' => 'esc_html', |
| 2547 | 2314 | 'jp_group' => 'sharedaddy', |
| 2548 | 2315 | ), |
| 2549 | - 'show' => array( | |
| 2316 | + 'show' => array( | |
| 2550 | 2317 | 'description' => esc_html__( 'Views where buttons are shown', 'jetpack' ), |
| 2551 | 2318 | 'type' => 'array', |
| 2552 | 2319 | 'items' => array( |
| 2553 | 2320 | 'type' => 'string', |
| @@ -2555,9 +2322,9 @@ | ||
| 2555 | 2322 | 'default' => array( 'post' ), |
| 2556 | 2323 | 'validate_callback' => __CLASS__ . '::validate_sharing_show', |
| 2557 | 2324 | 'jp_group' => 'sharedaddy', |
| 2558 | 2325 | ), |
| 2559 | - 'jetpack-twitter-cards-site-tag' => array( | |
| 2326 | + 'jetpack-twitter-cards-site-tag' => array( | |
| 2560 | 2327 | 'description' => esc_html__( "The Twitter username of the owner of this site's domain.", 'jetpack' ), |
| 2561 | 2328 | 'type' => 'string', |
| 2562 | 2329 | 'default' => '', |
| 2563 | 2330 | 'validate_callback' => __CLASS__ . '::validate_twitter_username', |
| @@ -2563,9 +2330,9 @@ | ||
| 2563 | 2330 | 'validate_callback' => __CLASS__ . '::validate_twitter_username', |
| 2564 | 2331 | 'sanitize_callback' => 'esc_html', |
| 2565 | 2332 | 'jp_group' => 'sharedaddy', |
| 2566 | 2333 | ), |
| 2567 | - 'sharedaddy_disable_resources' => array( | |
| 2334 | + 'sharedaddy_disable_resources' => array( | |
| 2568 | 2335 | 'description' => esc_html__( 'Disable CSS and JS', 'jetpack' ), |
| 2569 | 2336 | 'type' => 'boolean', |
| 2570 | 2337 | 'default' => 0, |
| 2571 | 2338 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2570,9 +2337,9 @@ | ||
| 2570 | 2337 | 'default' => 0, |
| 2571 | 2338 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2572 | 2339 | 'jp_group' => 'sharedaddy', |
| 2573 | 2340 | ), |
| 2574 | - 'custom' => array( | |
| 2341 | + 'custom' => array( | |
| 2575 | 2342 | 'description' => esc_html__( 'Custom sharing services added by user.', 'jetpack' ), |
| 2576 | 2343 | 'type' => 'object', |
| 2577 | 2344 | 'default' => array( |
| 2578 | 2345 | 'sharing_name' => '', |
| @@ -2582,9 +2349,9 @@ | ||
| 2582 | 2349 | 'validate_callback' => __CLASS__ . '::validate_custom_service', |
| 2583 | 2350 | 'jp_group' => 'sharedaddy', |
| 2584 | 2351 | ), |
| 2585 | 2352 | // Not an option, but an action that can be performed on the list of custom services passing the service ID. |
| 2586 | - 'sharing_delete_service' => array( | |
| 2353 | + 'sharing_delete_service' => array( | |
| 2587 | 2354 | 'description' => esc_html__( 'Delete custom sharing service.', 'jetpack' ), |
| 2588 | 2355 | 'type' => 'string', |
| 2589 | 2356 | 'default' => '', |
| 2590 | 2357 | 'validate_callback' => __CLASS__ . '::validate_custom_service_id', |
| @@ -2591,9 +2358,9 @@ | ||
| 2591 | 2358 | 'jp_group' => 'sharedaddy', |
| 2592 | 2359 | ), |
| 2593 | 2360 | |
| 2594 | 2361 | // SSO. |
| 2595 | - 'jetpack_sso_require_two_step' => array( | |
| 2362 | + 'jetpack_sso_require_two_step' => array( | |
| 2596 | 2363 | 'description' => esc_html__( 'Require Two-Step Authentication', 'jetpack' ), |
| 2597 | 2364 | 'type' => 'boolean', |
| 2598 | 2365 | 'default' => SSO\Helpers::is_require_two_step_checkbox_disabled(), |
| 2599 | 2366 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2598,9 +2365,9 @@ | ||
| 2598 | 2365 | 'default' => SSO\Helpers::is_require_two_step_checkbox_disabled(), |
| 2599 | 2366 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2600 | 2367 | 'jp_group' => 'sso', |
| 2601 | 2368 | ), |
| 2602 | - 'jetpack_sso_match_by_email' => array( | |
| 2369 | + 'jetpack_sso_match_by_email' => array( | |
| 2603 | 2370 | 'description' => esc_html__( 'Match by Email', 'jetpack' ), |
| 2604 | 2371 | 'type' => 'boolean', |
| 2605 | 2372 | 'default' => 1, |
| 2606 | 2373 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2607,9 +2374,9 @@ | ||
| 2607 | 2374 | 'jp_group' => 'sso', |
| 2608 | 2375 | ), |
| 2609 | 2376 | |
| 2610 | 2377 | // Subscriptions. |
| 2611 | - 'stb_enabled' => array( | |
| 2378 | + 'stb_enabled' => array( | |
| 2612 | 2379 | 'description' => esc_html__( "Show a <em>'follow blog'</em> option in the comment form", 'jetpack' ), |
| 2613 | 2380 | 'type' => 'boolean', |
| 2614 | 2381 | 'default' => 1, |
| 2615 | 2382 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2614,9 +2381,9 @@ | ||
| 2614 | 2381 | 'default' => 1, |
| 2615 | 2382 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2616 | 2383 | 'jp_group' => 'subscriptions', |
| 2617 | 2384 | ), |
| 2618 | - 'stc_enabled' => array( | |
| 2385 | + 'stc_enabled' => array( | |
| 2619 | 2386 | 'description' => esc_html__( "Show a <em>'follow comments'</em> option in the comment form", 'jetpack' ), |
| 2620 | 2387 | 'type' => 'boolean', |
| 2621 | 2388 | 'default' => 1, |
| 2622 | 2389 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2621,9 +2388,9 @@ | ||
| 2621 | 2388 | 'default' => 1, |
| 2622 | 2389 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2623 | 2390 | 'jp_group' => 'subscriptions', |
| 2624 | 2391 | ), |
| 2625 | - 'wpcom_newsletter_categories' => array( | |
| 2392 | + 'wpcom_newsletter_categories' => array( | |
| 2626 | 2393 | 'description' => esc_html__( 'Array of post category ids that are marked as newsletter categories', 'jetpack' ), |
| 2627 | 2394 | 'type' => 'array', |
| 2628 | 2395 | 'default' => array(), |
| 2629 | 2396 | 'validate_callback' => __CLASS__ . '::validate_array', |
| @@ -2628,9 +2395,9 @@ | ||
| 2628 | 2395 | 'default' => array(), |
| 2629 | 2396 | 'validate_callback' => __CLASS__ . '::validate_array', |
| 2630 | 2397 | 'jp_group' => 'subscriptions', |
| 2631 | 2398 | ), |
| 2632 | - 'wpcom_newsletter_categories_enabled' => array( | |
| 2399 | + 'wpcom_newsletter_categories_enabled' => array( | |
| 2633 | 2400 | 'description' => esc_html__( 'Whether the newsletter categories are enabled or not', 'jetpack' ), |
| 2634 | 2401 | 'type' => 'boolean', |
| 2635 | 2402 | 'default' => 0, |
| 2636 | 2403 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2635,16 +2402,23 @@ | ||
| 2635 | 2402 | 'default' => 0, |
| 2636 | 2403 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2637 | 2404 | 'jp_group' => 'subscriptions', |
| 2638 | 2405 | ), |
| 2639 | - 'wpcom_featured_image_in_email' => array( | |
| 2406 | + 'wpcom_newsletter_send_default' => array( | |
| 2407 | + 'description' => esc_html__( 'Whether to send newsletter emails by default when publishing a post', 'jetpack' ), | |
| 2408 | + 'type' => 'boolean', | |
| 2409 | + 'default' => 1, | |
| 2410 | + 'validate_callback' => __CLASS__ . '::validate_boolean', | |
| 2411 | + 'jp_group' => 'subscriptions', | |
| 2412 | + ), | |
| 2413 | + 'wpcom_featured_image_in_email' => array( | |
| 2640 | 2414 | 'description' => esc_html__( 'Whether to include the featured image in the email or not', 'jetpack' ), |
| 2641 | 2415 | 'type' => 'boolean', |
| 2642 | - 'default' => 1, | |
| 2416 | + 'default' => 0, | |
| 2643 | 2417 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2644 | 2418 | 'jp_group' => 'subscriptions', |
| 2645 | 2419 | ), |
| 2646 | - 'jetpack_gravatar_in_email' => array( | |
| 2420 | + 'jetpack_gravatar_in_email' => array( | |
| 2647 | 2421 | 'description' => esc_html__( 'Whether to show author avatar in the email byline', 'jetpack' ), |
| 2648 | 2422 | 'type' => 'boolean', |
| 2649 | 2423 | 'default' => 1, |
| 2650 | 2424 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2649,9 +2423,9 @@ | ||
| 2649 | 2423 | 'default' => 1, |
| 2650 | 2424 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2651 | 2425 | 'jp_group' => 'subscriptions', |
| 2652 | 2426 | ), |
| 2653 | - 'jetpack_author_in_email' => array( | |
| 2427 | + 'jetpack_author_in_email' => array( | |
| 2654 | 2428 | 'description' => esc_html__( 'Whether to show author display name in the email byline', 'jetpack' ), |
| 2655 | 2429 | 'type' => 'boolean', |
| 2656 | 2430 | 'default' => 1, |
| 2657 | 2431 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2656,9 +2430,9 @@ | ||
| 2656 | 2430 | 'default' => 1, |
| 2657 | 2431 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2658 | 2432 | 'jp_group' => 'subscriptions', |
| 2659 | 2433 | ), |
| 2660 | - 'jetpack_post_date_in_email' => array( | |
| 2434 | + 'jetpack_post_date_in_email' => array( | |
| 2661 | 2435 | 'description' => esc_html__( 'Whether to show date in the email byline', 'jetpack' ), |
| 2662 | 2436 | 'type' => 'boolean', |
| 2663 | 2437 | 'default' => 1, |
| 2664 | 2438 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2663,9 +2437,9 @@ | ||
| 2663 | 2437 | 'default' => 1, |
| 2664 | 2438 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2665 | 2439 | 'jp_group' => 'subscriptions', |
| 2666 | 2440 | ), |
| 2667 | - 'wpcom_subscription_emails_use_excerpt' => array( | |
| 2441 | + 'wpcom_subscription_emails_use_excerpt' => array( | |
| 2668 | 2442 | 'description' => esc_html__( 'Whether to use the excerpt in the email or not', 'jetpack' ), |
| 2669 | 2443 | 'type' => 'boolean', |
| 2670 | 2444 | 'default' => 0, |
| 2671 | 2445 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2670,16 +2444,16 @@ | ||
| 2670 | 2444 | 'default' => 0, |
| 2671 | 2445 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2672 | 2446 | 'jp_group' => 'subscriptions', |
| 2673 | 2447 | ), |
| 2674 | - 'jetpack_subscriptions_reply_to' => array( | |
| 2448 | + 'jetpack_subscriptions_reply_to' => array( | |
| 2675 | 2449 | 'description' => esc_html__( 'Reply to email behaviour for newsletters emails', 'jetpack' ), |
| 2676 | 2450 | 'type' => 'string', |
| 2677 | - 'default' => 'no-reply', | |
| 2451 | + 'default' => Automattic\Jetpack\Modules\Subscriptions\Settings::$default_reply_to, | |
| 2678 | 2452 | 'validate_callback' => __CLASS__ . '::validate_subscriptions_reply_to', |
| 2679 | 2453 | 'jp_group' => 'subscriptions', |
| 2680 | 2454 | ), |
| 2681 | - 'jetpack_subscriptions_from_name' => array( | |
| 2455 | + 'jetpack_subscriptions_from_name' => array( | |
| 2682 | 2456 | 'description' => esc_html__( 'From name for newsletters emails', 'jetpack' ), |
| 2683 | 2457 | 'type' => 'string', |
| 2684 | 2458 | 'default' => '', |
| 2685 | 2459 | 'validate_callback' => __CLASS__ . '::validate_subscriptions_reply_to_name', |
| @@ -2684,9 +2458,9 @@ | ||
| 2684 | 2458 | 'default' => '', |
| 2685 | 2459 | 'validate_callback' => __CLASS__ . '::validate_subscriptions_reply_to_name', |
| 2686 | 2460 | 'jp_group' => 'subscriptions', |
| 2687 | 2461 | ), |
| 2688 | - 'sm_enabled' => array( | |
| 2462 | + 'sm_enabled' => array( | |
| 2689 | 2463 | 'description' => esc_html__( 'Show popup Subscribe modal to readers.', 'jetpack' ), |
| 2690 | 2464 | 'type' => 'boolean', |
| 2691 | 2465 | 'default' => 0, |
| 2692 | 2466 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2691,9 +2465,9 @@ | ||
| 2691 | 2465 | 'default' => 0, |
| 2692 | 2466 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2693 | 2467 | 'jp_group' => 'subscriptions', |
| 2694 | 2468 | ), |
| 2695 | - 'jetpack_subscribe_overlay_enabled' => array( | |
| 2469 | + 'jetpack_subscribe_overlay_enabled' => array( | |
| 2696 | 2470 | 'description' => esc_html__( 'Show subscribe overlay on homepage.', 'jetpack' ), |
| 2697 | 2471 | 'type' => 'boolean', |
| 2698 | 2472 | 'default' => 0, |
| 2699 | 2473 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2698,8 +2472,15 @@ | ||
| 2698 | 2472 | 'default' => 0, |
| 2699 | 2473 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2700 | 2474 | 'jp_group' => 'subscriptions', |
| 2701 | 2475 | ), |
| 2476 | + 'jetpack_subscribe_floating_button_enabled' => array( | |
| 2477 | + 'description' => esc_html__( 'Show a floating subscribe button.', 'jetpack' ), | |
| 2478 | + 'type' => 'boolean', | |
| 2479 | + 'default' => 0, | |
| 2480 | + 'validate_callback' => __CLASS__ . '::validate_boolean', | |
| 2481 | + 'jp_group' => 'subscriptions', | |
| 2482 | + ), | |
| 2702 | 2483 | 'jetpack_subscriptions_subscribe_post_end_enabled' => array( |
| 2703 | 2484 | 'description' => esc_html__( 'Add Subscribe block at the end of each post.', 'jetpack' ), |
| 2704 | 2485 | 'type' => 'boolean', |
| 2705 | 2486 | 'default' => 0, |
| @@ -2719,9 +2500,9 @@ | ||
| 2719 | 2500 | 'default' => 0, |
| 2720 | 2501 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2721 | 2502 | 'jp_group' => 'subscriptions', |
| 2722 | 2503 | ), |
| 2723 | - 'social_notifications_subscribe' => array( | |
| 2504 | + 'social_notifications_subscribe' => array( | |
| 2724 | 2505 | 'description' => esc_html__( 'Send email notification when someone subscribes to my blog', 'jetpack' ), |
| 2725 | 2506 | 'type' => 'boolean', |
| 2726 | 2507 | 'default' => 0, |
| 2727 | 2508 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2726,15 +2507,18 @@ | ||
| 2726 | 2507 | 'default' => 0, |
| 2727 | 2508 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2728 | 2509 | 'jp_group' => 'subscriptions', |
| 2729 | 2510 | ), |
| 2730 | - 'subscription_options' => array( | |
| 2731 | - 'description' => esc_html__( 'Three options used in subscription email templates: \'invitation\', \'welcome\' and \'comment_follow\'.', 'jetpack' ), | |
| 2511 | + 'subscription_options' => array( | |
| 2512 | + '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' ), | |
| 2732 | 2513 | 'type' => 'object', |
| 2733 | 2514 | 'default' => array( |
| 2734 | - 'invitation' => '', | |
| 2735 | - 'welcome' => '', | |
| 2736 | - 'comment_follow' => '', | |
| 2515 | + 'invitation' => '', | |
| 2516 | + 'welcome' => '', | |
| 2517 | + 'comment_follow' => '', | |
| 2518 | + 'subscribe_modal_heading' => '', | |
| 2519 | + 'free_tier_description' => '', | |
| 2520 | + 'hide_free_tier' => false, | |
| 2737 | 2521 | ), |
| 2738 | 2522 | 'validate_callback' => __CLASS__ . '::validate_subscription_options', |
| 2739 | 2523 | 'jp_group' => 'subscriptions', |
| 2740 | 2524 | ), |
| @@ -2739,9 +2523,9 @@ | ||
| 2739 | 2523 | 'jp_group' => 'subscriptions', |
| 2740 | 2524 | ), |
| 2741 | 2525 | |
| 2742 | 2526 | // Related Posts. |
| 2743 | - 'show_headline' => array( | |
| 2527 | + 'show_headline' => array( | |
| 2744 | 2528 | 'description' => esc_html__( 'Highlight related content with a heading', 'jetpack' ), |
| 2745 | 2529 | 'type' => 'boolean', |
| 2746 | 2530 | 'default' => 1, |
| 2747 | 2531 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2746,9 +2530,9 @@ | ||
| 2746 | 2530 | 'default' => 1, |
| 2747 | 2531 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2748 | 2532 | 'jp_group' => 'related-posts', |
| 2749 | 2533 | ), |
| 2750 | - 'show_thumbnails' => array( | |
| 2534 | + 'show_thumbnails' => array( | |
| 2751 | 2535 | 'description' => esc_html__( 'Show a thumbnail image where available', 'jetpack' ), |
| 2752 | 2536 | 'type' => 'boolean', |
| 2753 | 2537 | 'default' => 0, |
| 2754 | 2538 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2755,9 +2539,9 @@ | ||
| 2755 | 2539 | 'jp_group' => 'related-posts', |
| 2756 | 2540 | ), |
| 2757 | 2541 | |
| 2758 | 2542 | // Search. |
| 2759 | - 'instant_search_enabled' => array( | |
| 2543 | + 'instant_search_enabled' => array( | |
| 2760 | 2544 | 'description' => esc_html__( 'Enable Instant Search', 'jetpack' ), |
| 2761 | 2545 | 'type' => 'boolean', |
| 2762 | 2546 | 'default' => 0, |
| 2763 | 2547 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2763,9 +2547,9 @@ | ||
| 2763 | 2547 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2764 | 2548 | 'jp_group' => 'search', |
| 2765 | 2549 | ), |
| 2766 | 2550 | |
| 2767 | - 'has_jetpack_search_product' => array( | |
| 2551 | + 'has_jetpack_search_product' => array( | |
| 2768 | 2552 | 'description' => esc_html__( 'Has an active Jetpack Search product purchase', 'jetpack' ), |
| 2769 | 2553 | 'type' => 'boolean', |
| 2770 | 2554 | 'default' => 0, |
| 2771 | 2555 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2771,9 +2555,9 @@ | ||
| 2771 | 2555 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2772 | 2556 | 'jp_group' => 'settings', |
| 2773 | 2557 | ), |
| 2774 | 2558 | |
| 2775 | - 'search_auto_config' => array( | |
| 2559 | + 'search_auto_config' => array( | |
| 2776 | 2560 | 'description' => esc_html__( 'Trigger an auto config of instant search', 'jetpack' ), |
| 2777 | 2561 | 'type' => 'boolean', |
| 2778 | 2562 | 'default' => 0, |
| 2779 | 2563 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2780,9 +2564,9 @@ | ||
| 2780 | 2564 | 'jp_group' => 'search', |
| 2781 | 2565 | ), |
| 2782 | 2566 | |
| 2783 | 2567 | // Verification Tools. |
| 2784 | - 'google' => array( | |
| 2568 | + 'google' => array( | |
| 2785 | 2569 | 'description' => esc_html__( 'Google Search Console', 'jetpack' ), |
| 2786 | 2570 | 'type' => 'string', |
| 2787 | 2571 | 'default' => '', |
| 2788 | 2572 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| @@ -2787,9 +2571,9 @@ | ||
| 2787 | 2571 | 'default' => '', |
| 2788 | 2572 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| 2789 | 2573 | 'jp_group' => 'verification-tools', |
| 2790 | 2574 | ), |
| 2791 | - 'bing' => array( | |
| 2575 | + 'bing' => array( | |
| 2792 | 2576 | 'description' => esc_html__( 'Bing Webmaster Center', 'jetpack' ), |
| 2793 | 2577 | 'type' => 'string', |
| 2794 | 2578 | 'default' => '', |
| 2795 | 2579 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| @@ -2794,9 +2578,9 @@ | ||
| 2794 | 2578 | 'default' => '', |
| 2795 | 2579 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| 2796 | 2580 | 'jp_group' => 'verification-tools', |
| 2797 | 2581 | ), |
| 2798 | - 'pinterest' => array( | |
| 2582 | + 'pinterest' => array( | |
| 2799 | 2583 | 'description' => esc_html__( 'Pinterest Site Verification', 'jetpack' ), |
| 2800 | 2584 | 'type' => 'string', |
| 2801 | 2585 | 'default' => '', |
| 2802 | 2586 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| @@ -2801,9 +2585,9 @@ | ||
| 2801 | 2585 | 'default' => '', |
| 2802 | 2586 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| 2803 | 2587 | 'jp_group' => 'verification-tools', |
| 2804 | 2588 | ), |
| 2805 | - 'yandex' => array( | |
| 2589 | + 'yandex' => array( | |
| 2806 | 2590 | 'description' => esc_html__( 'Yandex Site Verification', 'jetpack' ), |
| 2807 | 2591 | 'type' => 'string', |
| 2808 | 2592 | 'default' => '', |
| 2809 | 2593 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| @@ -2808,9 +2592,9 @@ | ||
| 2808 | 2592 | 'default' => '', |
| 2809 | 2593 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| 2810 | 2594 | 'jp_group' => 'verification-tools', |
| 2811 | 2595 | ), |
| 2812 | - 'facebook' => array( | |
| 2596 | + 'facebook' => array( | |
| 2813 | 2597 | 'description' => esc_html__( 'Facebook Domain Verification', 'jetpack' ), |
| 2814 | 2598 | 'type' => 'string', |
| 2815 | 2599 | 'default' => '', |
| 2816 | 2600 | 'validate_callback' => __CLASS__ . '::validate_verification_service', |
| @@ -2817,9 +2601,9 @@ | ||
| 2817 | 2601 | 'jp_group' => 'verification-tools', |
| 2818 | 2602 | ), |
| 2819 | 2603 | |
| 2820 | 2604 | // WordAds. |
| 2821 | - 'enable_header_ad' => array( | |
| 2605 | + 'enable_header_ad' => array( | |
| 2822 | 2606 | 'description' => esc_html__( 'Display an ad unit at the top of each page.', 'jetpack' ), |
| 2823 | 2607 | 'type' => 'boolean', |
| 2824 | 2608 | 'default' => 1, |
| 2825 | 2609 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2824,9 +2608,9 @@ | ||
| 2824 | 2608 | 'default' => 1, |
| 2825 | 2609 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2826 | 2610 | 'jp_group' => 'wordads', |
| 2827 | 2611 | ), |
| 2828 | - 'wordads_approved' => array( | |
| 2612 | + 'wordads_approved' => array( | |
| 2829 | 2613 | 'description' => esc_html__( 'Is site approved for WordAds?', 'jetpack' ), |
| 2830 | 2614 | 'type' => 'boolean', |
| 2831 | 2615 | 'default' => 0, |
| 2832 | 2616 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2831,9 +2615,9 @@ | ||
| 2831 | 2615 | 'default' => 0, |
| 2832 | 2616 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2833 | 2617 | 'jp_group' => 'wordads', |
| 2834 | 2618 | ), |
| 2835 | - 'wordads_second_belowpost' => array( | |
| 2619 | + 'wordads_second_belowpost' => array( | |
| 2836 | 2620 | 'description' => esc_html__( 'Display second ad below post?', 'jetpack' ), |
| 2837 | 2621 | 'type' => 'boolean', |
| 2838 | 2622 | 'default' => 1, |
| 2839 | 2623 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2838,9 +2622,9 @@ | ||
| 2838 | 2622 | 'default' => 1, |
| 2839 | 2623 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2840 | 2624 | 'jp_group' => 'wordads', |
| 2841 | 2625 | ), |
| 2842 | - 'wordads_inline_enabled' => array( | |
| 2626 | + 'wordads_inline_enabled' => array( | |
| 2843 | 2627 | 'description' => esc_html__( 'Display inline ad within post content?', 'jetpack' ), |
| 2844 | 2628 | 'type' => 'boolean', |
| 2845 | 2629 | 'default' => 1, |
| 2846 | 2630 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2845,9 +2629,9 @@ | ||
| 2845 | 2629 | 'default' => 1, |
| 2846 | 2630 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2847 | 2631 | 'jp_group' => 'wordads', |
| 2848 | 2632 | ), |
| 2849 | - 'wordads_display_front_page' => array( | |
| 2633 | + 'wordads_display_front_page' => array( | |
| 2850 | 2634 | 'description' => esc_html__( 'Display ads on the front page?', 'jetpack' ), |
| 2851 | 2635 | 'type' => 'boolean', |
| 2852 | 2636 | 'default' => 1, |
| 2853 | 2637 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2852,9 +2636,9 @@ | ||
| 2852 | 2636 | 'default' => 1, |
| 2853 | 2637 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2854 | 2638 | 'jp_group' => 'wordads', |
| 2855 | 2639 | ), |
| 2856 | - 'wordads_display_post' => array( | |
| 2640 | + 'wordads_display_post' => array( | |
| 2857 | 2641 | 'description' => esc_html__( 'Display ads on posts?', 'jetpack' ), |
| 2858 | 2642 | 'type' => 'boolean', |
| 2859 | 2643 | 'default' => 1, |
| 2860 | 2644 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2859,9 +2643,9 @@ | ||
| 2859 | 2643 | 'default' => 1, |
| 2860 | 2644 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2861 | 2645 | 'jp_group' => 'wordads', |
| 2862 | 2646 | ), |
| 2863 | - 'wordads_display_page' => array( | |
| 2647 | + 'wordads_display_page' => array( | |
| 2864 | 2648 | 'description' => esc_html__( 'Display ads on pages?', 'jetpack' ), |
| 2865 | 2649 | 'type' => 'boolean', |
| 2866 | 2650 | 'default' => 1, |
| 2867 | 2651 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2866,9 +2650,9 @@ | ||
| 2866 | 2650 | 'default' => 1, |
| 2867 | 2651 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2868 | 2652 | 'jp_group' => 'wordads', |
| 2869 | 2653 | ), |
| 2870 | - 'wordads_display_archive' => array( | |
| 2654 | + 'wordads_display_archive' => array( | |
| 2871 | 2655 | 'description' => esc_html__( 'Display ads on archive pages?', 'jetpack' ), |
| 2872 | 2656 | 'type' => 'boolean', |
| 2873 | 2657 | 'default' => 1, |
| 2874 | 2658 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2873,9 +2657,9 @@ | ||
| 2873 | 2657 | 'default' => 1, |
| 2874 | 2658 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2875 | 2659 | 'jp_group' => 'wordads', |
| 2876 | 2660 | ), |
| 2877 | - 'wordads_custom_adstxt_enabled' => array( | |
| 2661 | + 'wordads_custom_adstxt_enabled' => array( | |
| 2878 | 2662 | 'description' => esc_html__( 'Custom ads.txt', 'jetpack' ), |
| 2879 | 2663 | 'type' => 'boolean', |
| 2880 | 2664 | 'default' => 0, |
| 2881 | 2665 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2880,9 +2664,9 @@ | ||
| 2880 | 2664 | 'default' => 0, |
| 2881 | 2665 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2882 | 2666 | 'jp_group' => 'wordads', |
| 2883 | 2667 | ), |
| 2884 | - 'wordads_custom_adstxt' => array( | |
| 2668 | + 'wordads_custom_adstxt' => array( | |
| 2885 | 2669 | 'description' => esc_html__( 'Custom ads.txt entries', 'jetpack' ), |
| 2886 | 2670 | 'type' => 'string', |
| 2887 | 2671 | 'default' => '', |
| 2888 | 2672 | 'validate_callback' => __CLASS__ . '::validate_string', |
| @@ -2888,9 +2672,9 @@ | ||
| 2888 | 2672 | 'validate_callback' => __CLASS__ . '::validate_string', |
| 2889 | 2673 | 'sanitize_callback' => 'sanitize_textarea_field', |
| 2890 | 2674 | 'jp_group' => 'wordads', |
| 2891 | 2675 | ), |
| 2892 | - 'wordads_ccpa_enabled' => array( | |
| 2676 | + 'wordads_ccpa_enabled' => array( | |
| 2893 | 2677 | 'description' => esc_html__( 'Enable support for California Consumer Privacy Act', 'jetpack' ), |
| 2894 | 2678 | 'type' => 'boolean', |
| 2895 | 2679 | 'default' => 0, |
| 2896 | 2680 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2895,9 +2679,9 @@ | ||
| 2895 | 2679 | 'default' => 0, |
| 2896 | 2680 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2897 | 2681 | 'jp_group' => 'wordads', |
| 2898 | 2682 | ), |
| 2899 | - 'wordads_ccpa_privacy_policy_url' => array( | |
| 2683 | + 'wordads_ccpa_privacy_policy_url' => array( | |
| 2900 | 2684 | 'description' => esc_html__( 'Privacy Policy URL', 'jetpack' ), |
| 2901 | 2685 | 'type' => 'string', |
| 2902 | 2686 | 'default' => '', |
| 2903 | 2687 | 'validate_callback' => __CLASS__ . '::validate_string', |
| @@ -2903,9 +2687,9 @@ | ||
| 2903 | 2687 | 'validate_callback' => __CLASS__ . '::validate_string', |
| 2904 | 2688 | 'sanitize_callback' => 'sanitize_text_field', |
| 2905 | 2689 | 'jp_group' => 'wordads', |
| 2906 | 2690 | ), |
| 2907 | - 'wordads_cmp_enabled' => array( | |
| 2691 | + 'wordads_cmp_enabled' => array( | |
| 2908 | 2692 | 'description' => esc_html__( 'Enable GDPR Consent Management Banner for WordAds', 'jetpack' ), |
| 2909 | 2693 | 'type' => 'boolean', |
| 2910 | 2694 | 'default' => 0, |
| 2911 | 2695 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2912,9 +2696,9 @@ | ||
| 2912 | 2696 | 'jp_group' => 'wordads', |
| 2913 | 2697 | ), |
| 2914 | 2698 | |
| 2915 | 2699 | // Google Analytics. |
| 2916 | - 'google_analytics_tracking_id' => array( | |
| 2700 | + 'google_analytics_tracking_id' => array( | |
| 2917 | 2701 | 'description' => esc_html__( 'Google Analytics', 'jetpack' ), |
| 2918 | 2702 | 'type' => 'string', |
| 2919 | 2703 | 'default' => '', |
| 2920 | 2704 | 'validate_callback' => __CLASS__ . '::validate_alphanum', |
| @@ -2919,11 +2703,16 @@ | ||
| 2919 | 2703 | 'default' => '', |
| 2920 | 2704 | 'validate_callback' => __CLASS__ . '::validate_alphanum', |
| 2921 | 2705 | 'jp_group' => 'google-analytics', |
| 2922 | 2706 | ), |
| 2707 | + 'jetpack_wga' => array( | |
| 2708 | + 'description' => esc_html__( 'Google Analytics', 'jetpack' ), | |
| 2709 | + 'type' => 'object', | |
| 2710 | + 'jp_group' => 'settings', | |
| 2711 | + ), | |
| 2923 | 2712 | |
| 2924 | 2713 | // Stats. |
| 2925 | - 'admin_bar' => array( | |
| 2714 | + 'admin_bar' => array( | |
| 2926 | 2715 | 'description' => esc_html__( 'Include a small chart in your admin bar with a 48-hour traffic snapshot.', 'jetpack' ), |
| 2927 | 2716 | 'type' => 'boolean', |
| 2928 | 2717 | 'default' => 1, |
| 2929 | 2718 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2928,9 +2717,9 @@ | ||
| 2928 | 2717 | 'default' => 1, |
| 2929 | 2718 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2930 | 2719 | 'jp_group' => 'stats', |
| 2931 | 2720 | ), |
| 2932 | - 'enable_odyssey_stats' => array( | |
| 2721 | + 'enable_odyssey_stats' => array( | |
| 2933 | 2722 | 'description' => esc_html__( 'Preview the new Jetpack Stats experience (Experimental).', 'jetpack' ), |
| 2934 | 2723 | 'type' => 'boolean', |
| 2935 | 2724 | 'default' => 1, |
| 2936 | 2725 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2935,9 +2724,9 @@ | ||
| 2935 | 2724 | 'default' => 1, |
| 2936 | 2725 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2937 | 2726 | 'jp_group' => 'stats', |
| 2938 | 2727 | ), |
| 2939 | - 'roles' => array( | |
| 2728 | + 'roles' => array( | |
| 2940 | 2729 | 'description' => esc_html__( 'Select the roles that will be able to view stats reports.', 'jetpack' ), |
| 2941 | 2730 | 'type' => 'array', |
| 2942 | 2731 | 'items' => array( |
| 2943 | 2732 | 'type' => 'string', |
| @@ -2946,9 +2735,9 @@ | ||
| 2946 | 2735 | 'validate_callback' => __CLASS__ . '::validate_stats_roles', |
| 2947 | 2736 | 'sanitize_callback' => __CLASS__ . '::sanitize_stats_allowed_roles', |
| 2948 | 2737 | 'jp_group' => 'stats', |
| 2949 | 2738 | ), |
| 2950 | - 'count_roles' => array( | |
| 2739 | + 'count_roles' => array( | |
| 2951 | 2740 | 'description' => esc_html__( 'Count the page views of registered users who are logged in.', 'jetpack' ), |
| 2952 | 2741 | 'type' => 'array', |
| 2953 | 2742 | 'items' => array( |
| 2954 | 2743 | 'type' => 'string', |
| @@ -2956,9 +2745,9 @@ | ||
| 2956 | 2745 | 'default' => array( 'administrator' ), |
| 2957 | 2746 | 'validate_callback' => __CLASS__ . '::validate_stats_roles', |
| 2958 | 2747 | 'jp_group' => 'stats', |
| 2959 | 2748 | ), |
| 2960 | - 'blog_id' => array( | |
| 2749 | + 'blog_id' => array( | |
| 2961 | 2750 | 'description' => esc_html__( 'Blog ID.', 'jetpack' ), |
| 2962 | 2751 | 'type' => 'boolean', |
| 2963 | 2752 | 'default' => 0, |
| 2964 | 2753 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2963,9 +2752,9 @@ | ||
| 2963 | 2752 | 'default' => 0, |
| 2964 | 2753 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2965 | 2754 | 'jp_group' => 'stats', |
| 2966 | 2755 | ), |
| 2967 | - 'do_not_track' => array( | |
| 2756 | + 'do_not_track' => array( | |
| 2968 | 2757 | 'description' => esc_html__( 'Do not track.', 'jetpack' ), |
| 2969 | 2758 | 'type' => 'boolean', |
| 2970 | 2759 | 'default' => 1, |
| 2971 | 2760 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2970,9 +2759,9 @@ | ||
| 2970 | 2759 | 'default' => 1, |
| 2971 | 2760 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 2972 | 2761 | 'jp_group' => 'stats', |
| 2973 | 2762 | ), |
| 2974 | - 'version' => array( | |
| 2763 | + 'version' => array( | |
| 2975 | 2764 | 'description' => esc_html__( 'Version.', 'jetpack' ), |
| 2976 | 2765 | 'type' => 'integer', |
| 2977 | 2766 | 'default' => 9, |
| 2978 | 2767 | 'validate_callback' => __CLASS__ . '::validate_posint', |
| @@ -2977,9 +2766,9 @@ | ||
| 2977 | 2766 | 'default' => 9, |
| 2978 | 2767 | 'validate_callback' => __CLASS__ . '::validate_posint', |
| 2979 | 2768 | 'jp_group' => 'stats', |
| 2980 | 2769 | ), |
| 2981 | - 'collapse_nudges' => array( | |
| 2770 | + 'collapse_nudges' => array( | |
| 2982 | 2771 | 'description' => esc_html__( 'Collapse upgrade nudges', 'jetpack' ), |
| 2983 | 2772 | 'type' => 'boolean', |
| 2984 | 2773 | 'default' => 0, |
| 2985 | 2774 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2986,9 +2775,9 @@ | ||
| 2986 | 2775 | 'jp_group' => 'stats', |
| 2987 | 2776 | ), |
| 2988 | 2777 | |
| 2989 | 2778 | // Whether to share stats views with WordPress.com Reader. |
| 2990 | - 'wpcom_reader_views_enabled' => array( | |
| 2779 | + 'wpcom_reader_views_enabled' => array( | |
| 2991 | 2780 | 'description' => esc_html__( 'Show post views in the WordPress.com Reader.', 'jetpack' ), |
| 2992 | 2781 | 'type' => 'boolean', |
| 2993 | 2782 | 'default' => 1, |
| 2994 | 2783 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -2995,9 +2784,9 @@ | ||
| 2995 | 2784 | 'jp_group' => 'settings', |
| 2996 | 2785 | ), |
| 2997 | 2786 | |
| 2998 | 2787 | // Akismet - Not a module, but a plugin. The options can be passed and handled differently. |
| 2999 | - 'akismet_show_user_comments_approved' => array( | |
| 2788 | + 'akismet_show_user_comments_approved' => array( | |
| 3000 | 2789 | 'description' => '', |
| 3001 | 2790 | 'type' => 'boolean', |
| 3002 | 2791 | 'default' => 0, |
| 3003 | 2792 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -3003,9 +2792,9 @@ | ||
| 3003 | 2792 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 3004 | 2793 | 'jp_group' => 'settings', |
| 3005 | 2794 | ), |
| 3006 | 2795 | |
| 3007 | - 'wordpress_api_key' => array( | |
| 2796 | + 'wordpress_api_key' => array( | |
| 3008 | 2797 | 'description' => '', |
| 3009 | 2798 | 'type' => 'string', |
| 3010 | 2799 | 'default' => '', |
| 3011 | 2800 | 'validate_callback' => __CLASS__ . '::validate_alphanum', |
| @@ -3012,9 +2801,9 @@ | ||
| 3012 | 2801 | 'jp_group' => 'settings', |
| 3013 | 2802 | ), |
| 3014 | 2803 | |
| 3015 | 2804 | // Empty stats card dismiss. |
| 3016 | - 'dismiss_empty_stats_card' => array( | |
| 2805 | + 'dismiss_empty_stats_card' => array( | |
| 3017 | 2806 | 'description' => '', |
| 3018 | 2807 | 'type' => 'boolean', |
| 3019 | 2808 | 'default' => 0, |
| 3020 | 2809 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -3021,9 +2810,9 @@ | ||
| 3021 | 2810 | 'jp_group' => 'settings', |
| 3022 | 2811 | ), |
| 3023 | 2812 | |
| 3024 | 2813 | // Backup Getting Started card on dashboard. |
| 3025 | - 'dismiss_dash_backup_getting_started' => array( | |
| 2814 | + 'dismiss_dash_backup_getting_started' => array( | |
| 3026 | 2815 | 'description' => '', |
| 3027 | 2816 | 'type' => 'boolean', |
| 3028 | 2817 | 'default' => 0, |
| 3029 | 2818 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -3030,9 +2819,9 @@ | ||
| 3030 | 2819 | 'jp_group' => 'settings', |
| 3031 | 2820 | ), |
| 3032 | 2821 | |
| 3033 | 2822 | // Agencies Learn More card on dashboard. |
| 3034 | - 'dismiss_dash_agencies_learn_more' => array( | |
| 2823 | + 'dismiss_dash_agencies_learn_more' => array( | |
| 3035 | 2824 | 'description' => '', |
| 3036 | 2825 | 'type' => 'boolean', |
| 3037 | 2826 | 'default' => 0, |
| 3038 | 2827 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -3038,9 +2827,9 @@ | ||
| 3038 | 2827 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| 3039 | 2828 | 'jp_group' => 'settings', |
| 3040 | 2829 | ), |
| 3041 | 2830 | |
| 3042 | - 'lang_id' => array( | |
| 2831 | + 'lang_id' => array( | |
| 3043 | 2832 | 'description' => esc_html__( 'Primary language for the site.', 'jetpack' ), |
| 3044 | 2833 | 'type' => 'string', |
| 3045 | 2834 | 'default' => 'en_US', |
| 3046 | 2835 | 'jp_group' => 'settings', |
| @@ -3045,32 +2834,10 @@ | ||
| 3045 | 2834 | 'default' => 'en_US', |
| 3046 | 2835 | 'jp_group' => 'settings', |
| 3047 | 2836 | ), |
| 3048 | 2837 | |
| 3049 | - 'onboarding' => array( | |
| 3050 | - 'description' => '', | |
| 3051 | - 'type' => 'object', | |
| 3052 | - 'default' => array( | |
| 3053 | - 'siteTitle' => '', | |
| 3054 | - 'siteDescription' => '', | |
| 3055 | - 'siteType' => 'personal', | |
| 3056 | - 'homepageFormat' => 'posts', | |
| 3057 | - 'addContactForm' => 0, | |
| 3058 | - 'businessAddress' => array( | |
| 3059 | - 'name' => '', | |
| 3060 | - 'street' => '', | |
| 3061 | - 'city' => '', | |
| 3062 | - 'state' => '', | |
| 3063 | - 'zip' => '', | |
| 3064 | - ), | |
| 3065 | - 'installWooCommerce' => false, | |
| 3066 | - ), | |
| 3067 | - 'validate_callback' => __CLASS__ . '::validate_onboarding', | |
| 3068 | - 'jp_group' => 'settings', | |
| 3069 | - ), | |
| 3070 | - | |
| 3071 | 2838 | // SEO Tools. |
| 3072 | - 'advanced_seo_front_page_description' => array( | |
| 2839 | + 'advanced_seo_front_page_description' => array( | |
| 3073 | 2840 | 'description' => esc_html__( 'Front page meta description.', 'jetpack' ), |
| 3074 | 2841 | 'type' => 'string', |
| 3075 | 2842 | 'default' => '', |
| 3076 | 2843 | 'sanitize_callback' => 'Jetpack_SEO_Utils::sanitize_front_page_meta_description', |
| @@ -3076,9 +2843,9 @@ | ||
| 3076 | 2843 | 'sanitize_callback' => 'Jetpack_SEO_Utils::sanitize_front_page_meta_description', |
| 3077 | 2844 | 'jp_group' => 'seo-tools', |
| 3078 | 2845 | ), |
| 3079 | 2846 | |
| 3080 | - 'advanced_seo_title_formats' => array( | |
| 2847 | + 'advanced_seo_title_formats' => array( | |
| 3081 | 2848 | 'description' => esc_html__( 'SEO page title structures.', 'jetpack' ), |
| 3082 | 2849 | 'type' => 'object', |
| 3083 | 2850 | 'default' => array( |
| 3084 | 2851 | 'archives' => array(), |
| @@ -3091,10 +2858,34 @@ | ||
| 3091 | 2858 | 'validate_callback' => 'Jetpack_SEO_Titles::are_valid_title_formats', |
| 3092 | 2859 | 'sanitize_callback' => 'Jetpack_SEO_Titles::sanitize_title_formats', |
| 3093 | 2860 | ), |
| 3094 | 2861 | |
| 2862 | + // AI tab (Jetpack > SEO). Plain option the SEO package reads to serve | |
| 2863 | + // /llms.txt. The front-end behavior is gated inside the package; this | |
| 2864 | + // only round-trips the persisted state alongside the other seo-tools | |
| 2865 | + // settings. | |
| 2866 | + 'jetpack_seo_llms_txt_enabled' => array( | |
| 2867 | + 'description' => esc_html__( 'Generate an llms.txt file to guide AI assistants around your content.', 'jetpack' ), | |
| 2868 | + 'type' => 'boolean', | |
| 2869 | + 'default' => 0, | |
| 2870 | + 'validate_callback' => __CLASS__ . '::validate_boolean', | |
| 2871 | + 'jp_group' => 'seo-tools', | |
| 2872 | + ), | |
| 2873 | + | |
| 2874 | + // AI tab (Jetpack > SEO). Sparse per-crawler override map the SEO | |
| 2875 | + // package reads to emit robots.txt directives for blocked AI crawlers. | |
| 2876 | + // Stored as `slug => bool` (true = blocked); catalog validation and | |
| 2877 | + // default-pruning happen in `Ai_Crawlers::get_overrides()`. | |
| 2878 | + 'jetpack_seo_ai_crawler_overrides' => array( | |
| 2879 | + 'description' => esc_html__( 'AI crawler allow/block overrides.', 'jetpack' ), | |
| 2880 | + 'type' => 'object', | |
| 2881 | + 'default' => array(), | |
| 2882 | + 'jp_group' => 'seo-tools', | |
| 2883 | + 'sanitize_callback' => __CLASS__ . '::sanitize_ai_crawler_overrides', | |
| 2884 | + ), | |
| 2885 | + | |
| 3095 | 2886 | // VideoPress. |
| 3096 | - 'videopress_private_enabled_for_site' => array( | |
| 2887 | + 'videopress_private_enabled_for_site' => array( | |
| 3097 | 2888 | 'description' => esc_html__( 'Video Privacy: Restrict views to members of this site', 'jetpack' ), |
| 3098 | 2889 | 'type' => 'boolean', |
| 3099 | 2890 | 'default' => 0, |
| 3100 | 2891 | 'validate_callback' => __CLASS__ . '::validate_boolean', |
| @@ -3101,8 +2892,21 @@ | ||
| 3101 | 2892 | 'jp_group' => 'videopress', |
| 3102 | 2893 | ), |
| 3103 | 2894 | ); |
| 3104 | 2895 | |
| 2896 | + // SEO Tools - SEO Enhancer. | |
| 2897 | + // TODO: move this to the main options array? The filter was there while developing the feature. | |
| 2898 | + // It might come in handy to hold its availability behind the filter since it still depends on AI to be available. | |
| 2899 | + if ( apply_filters( 'ai_seo_enhancer_enabled', true ) ) { | |
| 2900 | + $options['ai_seo_enhancer_enabled'] = array( | |
| 2901 | + 'description' => esc_html__( 'Automatically generate SEO title, SEO description, and image alt text for new posts.', 'jetpack' ), | |
| 2902 | + 'type' => 'boolean', | |
| 2903 | + 'default' => 0, | |
| 2904 | + 'validate_callback' => __CLASS__ . '::validate_boolean', | |
| 2905 | + 'jp_group' => 'seo-tools', | |
| 2906 | + ); | |
| 2907 | + } | |
| 2908 | + | |
| 3105 | 2909 | // Add modules to list so they can be toggled. |
| 3106 | 2910 | $modules = Jetpack::get_available_modules(); |
| 3107 | 2911 | if ( is_array( $modules ) && ! empty( $modules ) ) { |
| 3108 | 2912 | $module_args = array( |
| @@ -3148,8 +2952,10 @@ | ||
| 3148 | 2952 | * Validates that the parameters are proper values that can be set during Jetpack onboarding. |
| 3149 | 2953 | * |
| 3150 | 2954 | * @since 5.4.0 |
| 3151 | 2955 | * |
| 2956 | + * @deprecated since 13.9 | |
| 2957 | + * | |
| 3152 | 2958 | * @param array $onboarding_data Values to check. |
| 3153 | 2959 | * @param WP_REST_Request $request The request sent to the WP REST API. |
| 3154 | 2960 | * @param string $param Name of the parameter passed to endpoint holding $value. |
| 3155 | 2961 | * |
| @@ -3154,24 +2960,10 @@ | ||
| 3154 | 2960 | * @param string $param Name of the parameter passed to endpoint holding $value. |
| 3155 | 2961 | * |
| 3156 | 2962 | * @return bool|WP_Error |
| 3157 | 2963 | */ |
| 3158 | - public static function validate_onboarding( $onboarding_data, $request, $param ) { | |
| 3159 | - if ( ! is_array( $onboarding_data ) ) { | |
| 3160 | - return new WP_Error( 'invalid_param', esc_html__( 'Not valid onboarding data.', 'jetpack' ) ); | |
| 3161 | - } | |
| 3162 | - foreach ( $onboarding_data as $value ) { | |
| 3163 | - if ( is_string( $value ) ) { | |
| 3164 | - $onboarding_choice = self::validate_string( $value, $request, $param ); | |
| 3165 | - } elseif ( is_array( $value ) ) { | |
| 3166 | - $onboarding_choice = self::validate_onboarding( $value, $request, $param ); | |
| 3167 | - } else { | |
| 3168 | - $onboarding_choice = self::validate_boolean( $value, $request, $param ); | |
| 3169 | - } | |
| 3170 | - if ( is_wp_error( $onboarding_choice ) ) { | |
| 3171 | - return $onboarding_choice; | |
| 3172 | - } | |
| 3173 | - } | |
| 2964 | + public static function validate_onboarding( $onboarding_data, $request, $param ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 2965 | + _deprecated_function( __METHOD__, '13.9' ); | |
| 3174 | 2966 | return true; |
| 3175 | 2967 | } |
| 3176 | 2968 | |
| 3177 | 2969 | /** |
| @@ -3385,9 +3177,9 @@ | ||
| 3385 | 3177 | * Validates that the parameter is among the roles allowed for Stats. |
| 3386 | 3178 | * |
| 3387 | 3179 | * @since 4.3.0 |
| 3388 | 3180 | * |
| 3389 | - * @param string|bool $value Value to check. | |
| 3181 | + * @param mixed $value Value to check. | |
| 3390 | 3182 | * @param WP_REST_Request $request The request sent to the WP REST API. |
| 3391 | 3183 | * @param string $param Name of the parameter passed to endpoint holding $value. |
| 3392 | 3184 | * |
| 3393 | 3185 | * @return bool|WP_Error |
| @@ -3392,16 +3184,37 @@ | ||
| 3392 | 3184 | * |
| 3393 | 3185 | * @return bool|WP_Error |
| 3394 | 3186 | */ |
| 3395 | 3187 | public static function validate_stats_roles( $value, $request, $param ) { |
| 3396 | - if ( ! empty( $value ) && ! array_intersect( self::$stats_roles, $value ) ) { | |
| 3188 | + // An empty value clears the setting; sanitize_stats_allowed_roles() falls back to 'administrator'. | |
| 3189 | + if ( empty( $value ) ) { | |
| 3190 | + return true; | |
| 3191 | + } | |
| 3192 | + | |
| 3193 | + // Enforce the schema's list-of-strings contract before array_intersect() below sees the value. | |
| 3194 | + if ( ! is_array( $value ) || count( array_filter( $value, 'is_string' ) ) !== count( $value ) ) { | |
| 3397 | 3195 | return new WP_Error( |
| 3398 | 3196 | 'invalid_param', |
| 3399 | 3197 | sprintf( |
| 3198 | + /* Translators: Placeholder is a parameter name. */ | |
| 3199 | + esc_html__( '%s must be an array of user roles.', 'jetpack' ), | |
| 3200 | + $param | |
| 3201 | + ) | |
| 3202 | + ); | |
| 3203 | + } | |
| 3204 | + | |
| 3205 | + if ( ! function_exists( 'get_editable_roles' ) ) { | |
| 3206 | + require_once ABSPATH . 'wp-admin/includes/user.php'; | |
| 3207 | + } | |
| 3208 | + $editable_roles = array_keys( get_editable_roles() ); | |
| 3209 | + if ( ! array_intersect( $editable_roles, $value ) ) { | |
| 3210 | + return new WP_Error( | |
| 3211 | + 'invalid_param', | |
| 3212 | + sprintf( | |
| 3400 | 3213 | /* 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. */ |
| 3401 | 3214 | esc_html__( '%1$s must be %2$s.', 'jetpack' ), |
| 3402 | 3215 | $param, |
| 3403 | - implode( ', ', self::$stats_roles ) | |
| 3216 | + implode( ', ', $editable_roles ) | |
| 3404 | 3217 | ) |
| 3405 | 3218 | ); |
| 3406 | 3219 | } |
| 3407 | 3220 | return true; |
| @@ -3718,9 +3531,12 @@ | ||
| 3718 | 3531 | * |
| 3719 | 3532 | * @return bool|WP_Error |
| 3720 | 3533 | */ |
| 3721 | 3534 | public static function validate_subscription_options( $values ) { |
| 3722 | - if ( is_object( $values ) ) { | |
| 3535 | + // A REST "object" decodes to a PHP associative array. Reject any other | |
| 3536 | + // type (object, string, int, null, ...) up front so the array_keys() | |
| 3537 | + // loop below never runs against a non-array and triggers a PHP warning. | |
| 3538 | + if ( ! is_array( $values ) ) { | |
| 3723 | 3539 | return new WP_Error( |
| 3724 | 3540 | 'invalid_param', |
| 3725 | 3541 | /* Translators: subscription_options is a variable name, and shouldn't be translated. */ |
| 3726 | 3542 | esc_html__( 'subscription_options must be an object.', 'jetpack' ) |
| @@ -3726,9 +3542,9 @@ | ||
| 3726 | 3542 | esc_html__( 'subscription_options must be an object.', 'jetpack' ) |
| 3727 | 3543 | ); |
| 3728 | 3544 | } |
| 3729 | 3545 | foreach ( array_keys( $values ) as $key ) { |
| 3730 | - if ( ! in_array( $key, array( 'welcome', 'invitation', 'comment_follow' ), true ) ) { | |
| 3546 | + if ( ! in_array( $key, array( 'welcome', 'invitation', 'comment_follow', 'subscribe_modal_heading', 'free_tier_description', 'hide_free_tier' ), true ) ) { | |
| 3731 | 3547 | return new WP_Error( |
| 3732 | 3548 | 'invalid_param', |
| 3733 | 3549 | sprintf( |
| 3734 | 3550 | /* Translators: Placeholder is the invalid param being sent. */ |
| @@ -3769,11 +3585,11 @@ | ||
| 3769 | 3585 | * return an array with only 'administrator' as the allowed role and save it for 'roles' option. |
| 3770 | 3586 | * |
| 3771 | 3587 | * @since 4.3.0 |
| 3772 | 3588 | * |
| 3773 | - * @param string|bool $value Value to check. | |
| 3589 | + * @param mixed $value Value to check. | |
| 3774 | 3590 | * |
| 3775 | - * @return bool|array | |
| 3591 | + * @return mixed The value as submitted, or an array holding only 'administrator' when it is empty. | |
| 3776 | 3592 | */ |
| 3777 | 3593 | public static function sanitize_stats_allowed_roles( $value ) { |
| 3778 | 3594 | if ( empty( $value ) ) { |
| 3779 | 3595 | return array( 'administrator' ); |
| @@ -3781,8 +3597,31 @@ | ||
| 3781 | 3597 | return $value; |
| 3782 | 3598 | } |
| 3783 | 3599 | |
| 3784 | 3600 | /** |
| 3601 | + * Sanitize the AI crawler override map. | |
| 3602 | + * | |
| 3603 | + * Keeps the value package-agnostic: each key is normalized with sanitize_key() | |
| 3604 | + * and each value cast to bool. Catalog validation and default-pruning happen in | |
| 3605 | + * `Automattic\Jetpack\SEO\Ai_Crawlers::get_overrides()`. | |
| 3606 | + * | |
| 3607 | + * @param mixed $value The submitted override map. | |
| 3608 | + * | |
| 3609 | + * @return array<string, bool> Sanitized `slug => bool` map. | |
| 3610 | + */ | |
| 3611 | + public static function sanitize_ai_crawler_overrides( $value ) { | |
| 3612 | + if ( ! is_array( $value ) ) { | |
| 3613 | + return array(); | |
| 3614 | + } | |
| 3615 | + | |
| 3616 | + $sanitized = array(); | |
| 3617 | + foreach ( $value as $k => $v ) { | |
| 3618 | + $sanitized[ sanitize_key( $k ) ] = (bool) $v; | |
| 3619 | + } | |
| 3620 | + return $sanitized; | |
| 3621 | + } | |
| 3622 | + | |
| 3623 | + /** | |
| 3785 | 3624 | * Get the currently accessed route and return the module slug in it. |
| 3786 | 3625 | * |
| 3787 | 3626 | * @since 4.3.0 |
| 3788 | 3627 | * |
| @@ -3791,9 +3630,9 @@ | ||
| 3791 | 3630 | * @return array|string |
| 3792 | 3631 | */ |
| 3793 | 3632 | public static function get_module_requested( $route = '/module/(?P<slug>[a-z\-]+)' ) { |
| 3794 | 3633 | |
| 3795 | - if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) ) { | |
| 3634 | + if ( empty( $GLOBALS['wp']->query_vars['rest_route'] ) || ! is_string( $GLOBALS['wp']->query_vars['rest_route'] ) ) { | |
| 3796 | 3635 | return ''; |
| 3797 | 3636 | } |
| 3798 | 3637 | |
| 3799 | 3638 | preg_match( "#$route#", $GLOBALS['wp']->query_vars['rest_route'], $module ); |
| @@ -3844,8 +3683,40 @@ | ||
| 3844 | 3683 | return $modules; |
| 3845 | 3684 | } |
| 3846 | 3685 | |
| 3847 | 3686 | /** |
| 3687 | + * Remove options the current user cannot read. | |
| 3688 | + * | |
| 3689 | + * Covers every `jetpack_waf_*` option, plus the two Protect options that expose the | |
| 3690 | + * same data under a different name: `jetpack_protect_global_whitelist` is populated | |
| 3691 | + * from `jetpack_waf_ip_allow_list`, and `jetpack_protect_key` is a shared secret. | |
| 3692 | + * | |
| 3693 | + * @since 16.2 | |
| 3694 | + * | |
| 3695 | + * @param array $options Option definitions keyed by option name. | |
| 3696 | + * @return array | |
| 3697 | + */ | |
| 3698 | + public static function filter_options_for_response( $options ) { | |
| 3699 | + if ( current_user_can( 'manage_options' ) ) { | |
| 3700 | + return $options; | |
| 3701 | + } | |
| 3702 | + | |
| 3703 | + $restricted = array( | |
| 3704 | + 'jetpack_protect_key', | |
| 3705 | + 'jetpack_protect_global_whitelist', | |
| 3706 | + ); | |
| 3707 | + | |
| 3708 | + return array_filter( | |
| 3709 | + $options, | |
| 3710 | + static function ( $option_name ) use ( $restricted ) { | |
| 3711 | + return 0 !== strpos( $option_name, 'jetpack_waf_' ) | |
| 3712 | + && ! in_array( $option_name, $restricted, true ); | |
| 3713 | + }, | |
| 3714 | + ARRAY_FILTER_USE_KEY | |
| 3715 | + ); | |
| 3716 | + } | |
| 3717 | + | |
| 3718 | + /** | |
| 3848 | 3719 | * Remove 'validate_callback' item from options available for module. |
| 3849 | 3720 | * Fetch current option value and add to array of module options. |
| 3850 | 3721 | * Prepare values of module options that need special handling, like those saved in wpcom. |
| 3851 | 3722 | * |
| @@ -3908,9 +3779,9 @@ | ||
| 3908 | 3779 | $options = self::split_options( $options, $sharer->get_global_options() ); |
| 3909 | 3780 | $options['sharing_services']['current_value'] = $sharer->get_blog_services(); |
| 3910 | 3781 | $other_sharedaddy_options = array( 'jetpack-twitter-cards-site-tag', 'sharedaddy_disable_resources', 'sharing_delete_service' ); |
| 3911 | 3782 | foreach ( $other_sharedaddy_options as $key ) { |
| 3912 | - $default_value = isset( $options[ $key ]['default'] ) ? $options[ $key ]['default'] : ''; | |
| 3783 | + $default_value = $options[ $key ]['default'] ?? ''; | |
| 3913 | 3784 | $current_value = get_option( $key, $default_value ); |
| 3914 | 3785 | $options[ $key ]['current_value'] = self::cast_value( $current_value, $options[ $key ] ); |
| 3915 | 3786 | } |
| 3916 | 3787 | break; |
| @@ -3921,9 +3792,9 @@ | ||
| 3921 | 3792 | break; |
| 3922 | 3793 | default: |
| 3923 | 3794 | // These option are just stored as plain WordPress options. |
| 3924 | 3795 | foreach ( $options as $key => $value ) { |
| 3925 | - $default_value = isset( $options[ $key ]['default'] ) ? $options[ $key ]['default'] : ''; | |
| 3796 | + $default_value = $options[ $key ]['default'] ?? ''; | |
| 3926 | 3797 | $current_value = get_option( $key, $default_value ); |
| 3927 | 3798 | $options[ $key ]['current_value'] = self::cast_value( $current_value, $options[ $key ] ); |
| 3928 | 3799 | } |
| 3929 | 3800 | } |
| @@ -3933,14 +3804,17 @@ | ||
| 3933 | 3804 | // We don't need validate_callback in the response. |
| 3934 | 3805 | if ( isset( $options[ $key ]['validate_callback'] ) ) { |
| 3935 | 3806 | unset( $options[ $key ]['validate_callback'] ); |
| 3936 | 3807 | } |
| 3937 | - $default_value = isset( $options[ $key ]['default'] ) ? $options[ $key ]['default'] : ''; | |
| 3808 | + $default_value = $options[ $key ]['default'] ?? ''; | |
| 3938 | 3809 | if ( ! array_key_exists( 'current_value', $options[ $key ] ) ) { |
| 3939 | 3810 | $options[ $key ]['current_value'] = self::cast_value( $default_value, $options[ $key ] ); |
| 3940 | 3811 | } |
| 3941 | 3812 | } |
| 3942 | - return $options; | |
| 3813 | + | |
| 3814 | + // Filter last: the switch above assigns current_value by key without isset(), | |
| 3815 | + // so filtering earlier would let those assignments re-add a removed option. | |
| 3816 | + return self::filter_options_for_response( $options ); | |
| 3943 | 3817 | } |
| 3944 | 3818 | |
| 3945 | 3819 | /** |
| 3946 | 3820 | * Splits module options saved as arrays like relatedposts or verification_services_codes into separate options to be returned in the response. |
| @@ -4499,6 +4373,55 @@ | ||
| 4499 | 4373 | 'code' => 'success', |
| 4500 | 4374 | 'data' => $data, |
| 4501 | 4375 | ) |
| 4502 | 4376 | ); |
| 4377 | + } | |
| 4378 | + | |
| 4379 | + /** | |
| 4380 | + * Return the list of available features. | |
| 4381 | + * | |
| 4382 | + * @return array | |
| 4383 | + */ | |
| 4384 | + public static function get_features_available() { | |
| 4385 | + $raw_modules = Jetpack::get_available_modules(); | |
| 4386 | + $modules = array(); | |
| 4387 | + foreach ( $raw_modules as $module ) { | |
| 4388 | + $modules[] = Jetpack::get_module_slug( $module ); | |
| 4389 | + } | |
| 4390 | + | |
| 4391 | + return $modules; | |
| 4392 | + } | |
| 4393 | + | |
| 4394 | + /** | |
| 4395 | + * Returns what features are enabled. Uses the slug of the modules files. | |
| 4396 | + * | |
| 4397 | + * @return array | |
| 4398 | + */ | |
| 4399 | + public static function get_features_enabled() { | |
| 4400 | + $raw_modules = Jetpack::get_active_modules(); | |
| 4401 | + $modules = array(); | |
| 4402 | + foreach ( $raw_modules as $module ) { | |
| 4403 | + $modules[] = Jetpack::get_module_slug( $module ); | |
| 4404 | + } | |
| 4405 | + | |
| 4406 | + return $modules; | |
| 4407 | + } | |
| 4408 | + | |
| 4409 | + /** | |
| 4410 | + * Verify that the API client is allowed to replace user token. | |
| 4411 | + * | |
| 4412 | + * @since 1.29.0 | |
| 4413 | + * | |
| 4414 | + * @return bool|WP_Error | |
| 4415 | + */ | |
| 4416 | + public static function get_features_permission_check() { | |
| 4417 | + if ( ! Rest_Authentication::is_signed_with_blog_token() ) { | |
| 4418 | + $message = esc_html__( | |
| 4419 | + 'You do not have the correct user permissions to perform this action. Please contact your site admin if you think this is a mistake.', | |
| 4420 | + 'jetpack' | |
| 4421 | + ); | |
| 4422 | + return new WP_Error( 'invalid_permission_fetch_features', $message, array( 'status' => rest_authorization_required_code() ) ); | |
| 4423 | + } | |
| 4424 | + | |
| 4425 | + return true; | |
| 4503 | 4426 | } |
| 4504 | 4427 | } // class end |