Skip to content

Commit

Permalink
Repurpose sharing-modal to just show recommended tags (#39451)
Browse files Browse the repository at this point in the history
  • Loading branch information
taipeicoder authored and matticbot committed Sep 23, 2024
1 parent 436865d commit 8eaafd3
Show file tree
Hide file tree
Showing 29 changed files with 420 additions and 1,108 deletions.
58 changes: 29 additions & 29 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

This is an alpha version! The changes listed here are not final.

### Changed
- Sharing modal: Repurposed to only display recommended tags.

### Deprecated
- Removed launchpad-save-modal.

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('jetpack-connection', 'lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-data-controls', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-nux', 'wp-plugins', 'wp-primitives', 'wp-private-apis', 'wp-url'), 'version' => '06b12dc642d51b6400f4');
<?php return array('dependencies' => array('jetpack-connection', 'lodash', 'moment', 'react', 'react-dom', 'react-jsx-runtime', 'wp-api-fetch', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-data-controls', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-notices', 'wp-nux', 'wp-plugins', 'wp-primitives', 'wp-private-apis', 'wp-url'), 'version' => 'e50052b88ccd45c9b84c');

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* WP_REST_WPCOM_Block_Editor_Recommended_Tags_Modal_Controller file.
*
* @package Automattic/jetpack-mu-wpcom
*/

namespace Automattic\Jetpack\Jetpack_Mu_Wpcom\NUX;

/**
* Class WP_REST_WPCOM_Block_Editor_Recommended_Tags_Modal_Controller.
*/
class WP_REST_WPCOM_Block_Editor_Recommended_Tags_Modal_Controller extends \WP_REST_Controller {
/**
* WP_REST_WPCOM_Block_Editor_Recommended_Tags_Modal_Controller constructor.
*/
public function __construct() {
$this->namespace = 'wpcom/v2';
$this->rest_base = 'block-editor/recommended-tags-modal-dismissed';
}

/**
* Register available routes.
*/
public function register_rest_route() {
register_rest_route(
$this->namespace,
$this->rest_base,
array(
array(
'methods' => \WP_REST_Server::EDITABLE,
'callback' => array( $this, 'set_wpcom_recommended_tags_modal_dismissed' ),
'permission_callback' => array( $this, 'permission_callback' ),
),
)
);
}

/**
* Callback to determine whether the request can proceed.
*
* @return boolean
*/
public function permission_callback() {
return current_user_can( 'read' );
}

/**
* Get the recommended tags modal dismissed status
*
* @return boolean
*/
public static function get_wpcom_recommended_tags_modal_dismissed() {
return (bool) get_option( 'wpcom_recommended_tags_modal_dismissed', false );
}

/**
* Dismiss the recommended tags modal
*
* @param \WP_REST_Request $request Request object.
* @return \WP_REST_Response
*/
public function set_wpcom_recommended_tags_modal_dismissed( $request ) {
$params = $request->get_json_params();
update_option( 'wpcom_recommended_tags_modal_dismissed', $params['wpcom_recommended_tags_modal_dismissed'] );
return rest_ensure_response( array( 'wpcom_recommended_tags_modal_dismissed' => $this->get_wpcom_recommended_tags_modal_dismissed() ) );
}
}
Loading

0 comments on commit 8eaafd3

Please sign in to comment.