diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c99cb9..074c5ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.10.5-alpha] - unreleased - -This is an alpha version! The changes listed here are not final. +## [0.11.0] - 2023-10-23 +### Added +- DSP media endpoints allowlisting. [#33598] ### Changed -- Updated package dependencies. +- Updated package dependencies. [#33646] [#33687] + +### Fixed +- Fix unsetting `sub_path` in `Dashboard_REST_Controller`. [#33668] ## [0.10.4] - 2023-10-16 ### Changed @@ -222,7 +225,7 @@ This is an alpha version! The changes listed here are not final. ### Changed - Updated package dependencies. [#27906] -[0.10.5-alpha]: https://github.com/automattic/jetpack-blaze/compare/v0.10.4...v0.10.5-alpha +[0.11.0]: https://github.com/automattic/jetpack-blaze/compare/v0.10.4...v0.11.0 [0.10.4]: https://github.com/automattic/jetpack-blaze/compare/v0.10.3...v0.10.4 [0.10.3]: https://github.com/automattic/jetpack-blaze/compare/v0.10.2...v0.10.3 [0.10.2]: https://github.com/automattic/jetpack-blaze/compare/v0.10.1...v0.10.2 diff --git a/composer.json b/composer.json index 0f5cbc2..41a1996 100644 --- a/composer.json +++ b/composer.json @@ -4,12 +4,12 @@ "type": "jetpack-library", "license": "GPL-2.0-or-later", "require": { - "automattic/jetpack-assets": "^1.18.12", - "automattic/jetpack-connection": "^1.58.1", - "automattic/jetpack-plans": "^0.3.4", + "automattic/jetpack-assets": "^1.18.13", + "automattic/jetpack-connection": "^1.58.2", + "automattic/jetpack-plans": "^0.3.5", "automattic/jetpack-redirect": "^1.7.27", "automattic/jetpack-status": "^1.18.5", - "automattic/jetpack-sync": "^1.58.1" + "automattic/jetpack-sync": "^1.60.0" }, "require-dev": { "yoast/phpunit-polyfills": "1.1.0", @@ -53,7 +53,7 @@ "link-template": "https://github.com/automattic/jetpack-blaze/compare/v${old}...v${new}" }, "branch-alias": { - "dev-trunk": "0.10.x-dev" + "dev-trunk": "0.11.x-dev" }, "textdomain": "jetpack-blaze", "version-constants": { diff --git a/package.json b/package.json index 3385b40..98de739 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@automattic/jetpack-blaze", - "version": "0.10.5-alpha", + "version": "0.11.0", "description": "Attract high-quality traffic to your site using Blaze. Using this service, you can advertise a post or page on some of the millions of pages across WordPress.com and Tumblr from just $5 per day.", "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/blaze/#readme", "bugs": { @@ -23,16 +23,16 @@ }, "dependencies": { "@automattic/jetpack-analytics": "^0.1.27", - "@automattic/jetpack-components": "^0.43.4", - "@automattic/jetpack-shared-extension-utils": "^0.12.3", - "@wordpress/block-editor": "12.11.0", - "@wordpress/components": "25.9.0", - "@wordpress/compose": "6.20.0", - "@wordpress/data": "9.13.0", - "@wordpress/element": "5.20.0", - "@wordpress/i18n": "4.43.0", - "@wordpress/icons": "9.34.0", - "@wordpress/plugins": "6.11.0", + "@automattic/jetpack-components": "^0.44.1", + "@automattic/jetpack-shared-extension-utils": "^0.12.4", + "@wordpress/block-editor": "12.12.0", + "@wordpress/components": "25.10.0", + "@wordpress/compose": "6.21.0", + "@wordpress/data": "9.14.0", + "@wordpress/element": "5.21.0", + "@wordpress/i18n": "4.44.0", + "@wordpress/icons": "9.35.0", + "@wordpress/plugins": "6.12.0", "react": "18.2.0", "react-dom": "18.2.0" }, @@ -41,7 +41,7 @@ "@babel/core": "7.23.2", "@babel/preset-env": "7.23.2", "@babel/runtime": "7.23.2", - "@wordpress/browserslist-config": "5.26.0", + "@wordpress/browserslist-config": "5.27.0", "sass": "1.64.1", "sass-loader": "12.4.0", "webpack": "5.76.0", diff --git a/src/class-dashboard-rest-controller.php b/src/class-dashboard-rest-controller.php index 79d380b..b780339 100644 --- a/src/class-dashboard-rest-controller.php +++ b/src/class-dashboard-rest-controller.php @@ -85,6 +85,28 @@ public function register_rest_routes() { ) ); + // WordAds DSP API media query routes + register_rest_route( + static::$namespace, + sprintf( '/sites/%1$d/wordads/dsp/api/v1/wpcom/sites/%1$d/media(?P[a-zA-Z0-9-_\/]*)(\?.*)?', $site_id ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_dsp_media' ), + 'permission_callback' => array( $this, 'can_user_view_dsp_callback' ), + ) + ); + + // WordAds DSP API media openverse query routes + register_rest_route( + static::$namespace, + sprintf( '/sites/%1$d/wordads/dsp/api/v1/wpcom/media(?P[a-zA-Z0-9-_\/]*)(\?.*)?', $site_id ), + array( + 'methods' => WP_REST_Server::READABLE, + 'callback' => array( $this, 'get_dsp_openverse' ), + 'permission_callback' => array( $this, 'can_user_view_dsp_callback' ), + ) + ); + // WordAds DSP API Experiment route register_rest_route( static::$namespace, @@ -274,8 +296,8 @@ public function get_blaze_posts( $req ) { } // We don't use sub_path in the blaze posts, only query strings - if ( isset( $params['sub_path'] ) ) { - unset( $req->get_params()['sub_path'] ); + if ( isset( $req['sub_path'] ) ) { + unset( $req['sub_path'] ); } return $this->request_as_user( @@ -322,13 +344,37 @@ public function get_dsp_blaze_posts( $req ) { } // We don't use sub_path in the blaze posts, only query strings - if ( isset( $params['sub_path'] ) ) { - unset( $req->get_params()['sub_path'] ); + if ( isset( $req['sub_path'] ) ) { + unset( $req['sub_path'] ); } return $this->get_dsp_generic( sprintf( 'v1/wpcom/sites/%d/blaze/posts', $site_id ), $req ); } + /** + * Redirect GET requests to WordAds DSP Blaze media endpoint for the site. + * + * @param WP_REST_Request $req The request object. + * @return array|WP_Error + */ + public function get_dsp_media( $req ) { + $site_id = $this->get_site_id(); + if ( is_wp_error( $site_id ) ) { + return array(); + } + return $this->get_dsp_generic( sprintf( 'v1/wpcom/sites/%d/media', $site_id ), $req ); + } + + /** + * Redirect GET requests to WordAds DSP Blaze openverse endpoint. + * + * @param WP_REST_Request $req The request object. + * @return array|WP_Error + */ + public function get_dsp_openverse( $req ) { + return $this->get_dsp_generic( 'v1/wpcom/media', $req ); + } + /** * Redirect GET requests to WordAds DSP Credits endpoint for the site. * diff --git a/src/class-dashboard.php b/src/class-dashboard.php index 9dd26dd..c152b13 100644 --- a/src/class-dashboard.php +++ b/src/class-dashboard.php @@ -21,7 +21,7 @@ class Dashboard { * * @var string */ - const PACKAGE_VERSION = '0.10.5-alpha'; + const PACKAGE_VERSION = '0.11.0'; /** * List of dependencies needed to render the dashboard in wp-admin.