Skip to content

Commit

Permalink
Revert "Repurpose sharing-modal to just show recommended tags (#39451)…
Browse files Browse the repository at this point in the history
…" (#39487)

This reverts commit fc199e8.
  • Loading branch information
taipeicoder authored Sep 23, 2024
1 parent fc199e8 commit 21011d7
Show file tree
Hide file tree
Showing 19 changed files with 991 additions and 328 deletions.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* WP_REST_WPCOM_Block_Editor_Sharing_Modal_Controller file.
*
* @package Aautomattic/jetpack-mu-wpcom
*/

namespace Automattic\Jetpack\Jetpack_Mu_Wpcom\NUX;

/**
* Class WP_REST_WPCOM_Block_Editor_Sharing_Modal_Controller.
*/
class WP_REST_WPCOM_Block_Editor_Sharing_Modal_Controller extends \WP_REST_Controller {
/**
* WP_REST_WPCOM_Block_Editor_Sharing_Modal_Controller constructor.
*/
public function __construct() {
$this->namespace = 'wpcom/v2';
$this->rest_base = 'block-editor/sharing-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_sharing_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 sharing modal dismissed status
*
* @return boolean
*/
public static function get_wpcom_sharing_modal_dismissed() {
$old_sharing_modal_dismissed = (bool) get_option( 'sharing_modal_dismissed', false );
if ( $old_sharing_modal_dismissed ) {
return true;
}
return (bool) get_option( 'wpcom_sharing_modal_dismissed', false );
}

/**
* Dismiss the sharing modal
*
* @param \WP_REST_Request $request Request object.
* @return \WP_REST_Response
*/
public function set_wpcom_sharing_modal_dismissed( $request ) {
$params = $request->get_json_params();
update_option( 'wpcom_sharing_modal_dismissed', $params['wpcom_sharing_modal_dismissed'] );
return rest_ensure_response( array( 'wpcom_sharing_modal_dismissed' => $this->get_wpcom_sharing_modal_dismissed() ) );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,18 @@ public function enqueue_script_and_style() {
);

/**
* Enqueue the recommended tags modal options.
* Enqueue the sharing modal options.
*/
$recommended_tags_modal_options = wp_json_encode(
$sharing_modal_options = wp_json_encode(
array(
'isDismissed' => WP_REST_WPCOM_Block_Editor_Recommended_Tags_Modal_Controller::get_wpcom_recommended_tags_modal_dismissed(),
'isDismissed' => WP_REST_WPCOM_Block_Editor_Sharing_Modal_Controller::get_wpcom_sharing_modal_dismissed(),
),
JSON_HEX_TAG | JSON_HEX_AMP
);

wp_add_inline_script(
$handle,
"var recommendedTagsModalOptions = $recommended_tags_modal_options;",
"var sharingModalOptions = $sharing_modal_options;",
'before'
);
}
Expand All @@ -102,9 +102,9 @@ public function register_rest_api() {
$video_celebration_modal_controller = new WP_REST_WPCOM_Block_Editor_Video_Celebration_Modal_Controller();
$video_celebration_modal_controller->register_rest_route();

require_once __DIR__ . '/class-wp-rest-wpcom-block-editor-recommended-tags-modal-controller.php';
$recommended_tags_modal_controller = new WP_REST_WPCOM_Block_Editor_Recommended_Tags_Modal_Controller();
$recommended_tags_modal_controller->register_rest_route();
require_once __DIR__ . '/class-wp-rest-wpcom-block-editor-sharing-modal-controller.php';
$sharing_modal_controller = new WP_REST_WPCOM_Block_Editor_Sharing_Modal_Controller();
$sharing_modal_controller->register_rest_route();
}
}
add_action( 'init', array( __NAMESPACE__ . '\WPCOM_Block_Editor_NUX', 'init' ) );
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import { BloggingPromptsModal } from './blogging-prompts-modal';
import DraftPostModal from './draft-post-modal';
import FirstPostPublishedModal from './first-post-published-modal';
import PurchaseNotice from './purchase-notice';
import RecommendedTagsModal from './recommended-tags-modal';
import SellerCelebrationModal from './seller-celebration-modal';
import PostPublishedSharingModal from './sharing-modal';
import { DEFAULT_VARIANT, BLANK_CANVAS_VARIANT } from './store';
import VideoPressCelebrationModal from './video-celebration-modal';
import WpcomNux from './welcome-modal/wpcom-nux';
Expand Down Expand Up @@ -125,7 +125,7 @@ registerPlugin( 'wpcom-block-editor-nux', {
<ShouldShowFirstPostPublishedModalProvider>
<WelcomeTour />
<FirstPostPublishedModal />
<RecommendedTagsModal />
<PostPublishedSharingModal />
<SellerCelebrationModal />
<PurchaseNotice />
<VideoPressCelebrationModal />
Expand Down

This file was deleted.

Loading

0 comments on commit 21011d7

Please sign in to comment.