diff --git a/projects/packages/my-jetpack/changelog/try-fix_WP-CLI_fatal b/projects/packages/my-jetpack/changelog/try-fix_WP-CLI_fatal new file mode 100644 index 000000000000..9f3d1860b9c9 --- /dev/null +++ b/projects/packages/my-jetpack/changelog/try-fix_WP-CLI_fatal @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Prevent PHP fatal when using WP-CLI. diff --git a/projects/packages/my-jetpack/src/class-rest-products.php b/projects/packages/my-jetpack/src/class-rest-products.php index e72664aa3c07..2aa74a1824c8 100644 --- a/projects/packages/my-jetpack/src/class-rest-products.php +++ b/projects/packages/my-jetpack/src/class-rest-products.php @@ -32,7 +32,7 @@ public function __construct() { 'permission_callback' => __CLASS__ . '::view_products_permissions_callback', 'args' => array( 'products' => array( - 'description' => __( 'Comma seperated list of product slugs that should be retrieved.', 'jetpack-my-jetpack' ), + 'description' => __( 'Comma-separated list of product slugs that should be retrieved.', 'jetpack-my-jetpack' ), 'type' => 'string', 'required' => false, 'validate_callback' => __CLASS__ . '::check_products_string', @@ -113,24 +113,7 @@ public function __construct() { ), ), ), - 'schema' => array( - '$schema' => 'http://json-schema.org/draft-04/schema#', - 'title' => 'Products interstitials', - 'type' => 'object', - 'properties' => array( - 'products' => array( - 'type' => 'object', - 'description' => __( 'Key-value pairs of product slugs and their interstitial states.', 'jetpack-my-jetpack' ), - 'properties' => array_fill_keys( - Products::get_products_slugs(), - array( - 'description' => __( 'Interstitial state for the product. True means that the user has seen the interstitial for the product.', 'jetpack-my-jetpack' ), - 'type' => 'boolean', - ) - ), - ), - ), - ), + 'schema' => array( self::class, 'get_interstitials_schema' ), ) ); @@ -176,6 +159,32 @@ public function get_products_schema() { ); } + /** + * Get the schema for the interstitials endpoint + * + * @return array + */ + public static function get_interstitials_schema() { + return array( + '$schema' => 'http://json-schema.org/draft-04/schema#', + 'title' => 'Products interstitials', + 'type' => 'object', + 'properties' => array( + 'products' => array( + 'type' => 'object', + 'description' => __( 'Key-value pairs of product slugs and their interstitial states.', 'jetpack-my-jetpack' ), + 'properties' => array_fill_keys( + Products::get_products_slugs(), + array( + 'description' => __( 'Interstitial state for the product. True means that the user has seen the interstitial for the product.', 'jetpack-my-jetpack' ), + 'type' => 'boolean', + ) + ), + ), + ), + ); + } + /** * Check user capability to access the endpoint. * diff --git a/projects/plugins/jetpack/changelog/try-fix_WP-CLI_fatal b/projects/plugins/jetpack/changelog/try-fix_WP-CLI_fatal new file mode 100644 index 000000000000..0725de146a4e --- /dev/null +++ b/projects/plugins/jetpack/changelog/try-fix_WP-CLI_fatal @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +My Jetpack: Prevent PHP error when using WP-CLI.