From 840fd3dbfe4078cd9cbb388b34e3d141086d7290 Mon Sep 17 00:00:00 2001 From: Pierre Date: Tue, 26 Oct 2021 11:15:33 +0200 Subject: [PATCH 01/22] VideoPress: Remove X-18 rating option from videos (#21508) --- ...ss-wpcom-rest-api-v2-endpoint-videopress.php | 2 +- .../changelog/videopress-remove-x-18-rating | 4 ++++ .../extensions/blocks/videopress/edit.js | 17 +++++++++++------ .../class.videopress-edit-attachment.php | 9 +++++++-- .../modules/videopress/utility-functions.php | 2 +- 5 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 projects/plugins/jetpack/changelog/videopress-remove-x-18-rating diff --git a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-videopress.php b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-videopress.php index ab5c1682685db..5cde40aace2a7 100644 --- a/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-videopress.php +++ b/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-videopress.php @@ -52,7 +52,7 @@ public function register_routes() { 'sanitize_callback' => 'sanitize_text_field', ), 'rating' => array( - 'description' => __( 'The video content rating. One of G, PG-13, R-17 or X-18', 'jetpack' ), + 'description' => __( 'The video content rating. One of G, PG-13 or R-17', 'jetpack' ), 'type' => 'string', 'required' => false, 'sanitize_callback' => 'sanitize_text_field', diff --git a/projects/plugins/jetpack/changelog/videopress-remove-x-18-rating b/projects/plugins/jetpack/changelog/videopress-remove-x-18-rating new file mode 100644 index 0000000000000..f004e0ba25fed --- /dev/null +++ b/projects/plugins/jetpack/changelog/videopress-remove-x-18-rating @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Remove X-18 rating from VideoPress upload. diff --git a/projects/plugins/jetpack/extensions/blocks/videopress/edit.js b/projects/plugins/jetpack/extensions/blocks/videopress/edit.js index e72f0992389c0..260d0d228af0c 100644 --- a/projects/plugins/jetpack/extensions/blocks/videopress/edit.js +++ b/projects/plugins/jetpack/extensions/blocks/videopress/edit.js @@ -88,9 +88,13 @@ const VideoPressEdit = CoreVideoEdit => setRating = async () => { const id = get( this.props, 'attributes.id' ); const media = await this.requestMedia( id ); - const rating = get( media, 'jetpack_videopress.rating' ); + let rating = get( media, 'jetpack_videopress.rating' ); if ( rating ) { + // X-18 was previously supported but is now removed to better comply with our TOS. + if ( 'X-18' === rating ) { + rating = 'R-17'; + } this.setState( { rating } ); } }; @@ -247,7 +251,12 @@ const VideoPressEdit = CoreVideoEdit => return; } - if ( -1 === indexOf( [ 'G', 'PG-13', 'R-17', 'X-18' ], rating ) ) { + // X-18 was previously supported but is now removed to better comply with our TOS. + if ( 'X-18' === rating ) { + rating = 'R-17'; + } + + if ( -1 === indexOf( [ 'G', 'PG-13', 'R-17' ], rating ) ) { return; } @@ -430,10 +439,6 @@ const VideoPressEdit = CoreVideoEdit => ), value: 'R-17', }, - { - label: _x( 'X', 'Video rating for "Explicit" content.', 'jetpack' ), - value: 'X-18', - }, ] } onChange={ this.onChangeRating } /> diff --git a/projects/plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php b/projects/plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php index 51885be111f52..3102c646ee2ae 100644 --- a/projects/plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php +++ b/projects/plugins/jetpack/modules/videopress/class.videopress-edit-attachment.php @@ -284,13 +284,18 @@ protected function display_rating( $info ) { 'G' => 'G', 'PG-13' => 'PG-13', 'R-17' => 'R', - 'X-18' => 'X', ); + $displayed_rating = $info->rating; + // X-18 was previously supported but is now removed to better comply with our TOS. + if ( 'X-18' === $displayed_rating ) { + $displayed_rating = 'R-17'; + } + foreach ( $ratings as $r => $label ) { $id = "attachments-{$info->post_id}-rating-$r"; $out .= "