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.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / vendor / automattic / jetpack-connection / src / class-connection-notice.php
woocommerce / vendor / automattic / jetpack-connection / src Last commit date
identity-crisis 1 year ago sso 1 year ago webhooks 1 year ago class-authorize-json-api.php 1 year ago class-client.php 1 year ago class-connection-assets.php 1 year ago class-connection-notice.php 1 year ago class-error-handler.php 1 year ago class-heartbeat.php 1 year ago class-initial-state.php 1 year ago class-manager.php 1 year ago class-nonce-handler.php 2 years ago class-package-version-tracker.php 1 year ago class-package-version.php 1 year ago class-partner-coupon.php 1 year ago class-partner.php 1 year ago class-plugin-storage.php 1 year ago class-plugin.php 1 year ago class-rest-authentication.php 1 year ago class-rest-connector.php 1 year ago class-secrets.php 1 year ago class-server-sandbox.php 1 year ago class-terms-of-service.php 2 years ago class-tokens-locks.php 2 years ago class-tokens.php 2 years ago class-tracking.php 1 year ago class-urls.php 1 year ago class-utils.php 1 year ago class-webhooks.php 1 year ago class-xmlrpc-async-call.php 1 year ago class-xmlrpc-connector.php 1 year ago interface-manager.php 3 years ago
class-connection-notice.php
240 lines
1 <?php
2 /**
3 * Admin connection notices.
4 *
5 * @package automattic/jetpack-admin-ui
6 */
7
8 namespace Automattic\Jetpack\Connection;
9
10 use Automattic\Jetpack\Redirect;
11 use Automattic\Jetpack\Tracking;
12
13 /**
14 * Admin connection notices.
15 */
16 class Connection_Notice {
17
18 /**
19 * Whether the class has been initialized.
20 *
21 * @var bool
22 */
23 private static $is_initialized = false;
24
25 /**
26 * The constructor.
27 */
28 public function __construct() {
29 if ( ! static::$is_initialized ) {
30 add_action( 'current_screen', array( $this, 'initialize_notices' ) );
31 static::$is_initialized = true;
32 }
33 }
34
35 /**
36 * Initialize the notices if needed.
37 *
38 * @param \WP_Screen $screen WP Core's screen object.
39 *
40 * @return void
41 */
42 public function initialize_notices( $screen ) {
43 if ( in_array(
44 $screen->id,
45 array(
46 'jetpack_page_akismet-key-config',
47 'admin_page_jetpack_modules',
48 ),
49 true
50 ) ) {
51 return;
52 }
53
54 /*
55 * phpcs:disable WordPress.Security.NonceVerification.Recommended
56 *
57 * This function is firing within wp-admin and checks (below) if it is in the midst of a deletion on the users
58 * page. Nonce will be already checked by WordPress, so we do not need to check ourselves.
59 */
60
61 if ( isset( $screen->base ) && 'users' === $screen->base
62 && isset( $_REQUEST['action'] ) && 'delete' === $_REQUEST['action']
63 ) {
64 add_action( 'admin_notices', array( $this, 'delete_user_update_connection_owner_notice' ) );
65 }
66 }
67
68 /**
69 * This is an entire admin notice dedicated to messaging and handling of the case where a user is trying to delete
70 * the connection owner.
71 */
72 public function delete_user_update_connection_owner_notice() {
73 // Get connection owner or bail.
74 $connection_manager = new Manager();
75 $connection_owner_id = $connection_manager->get_connection_owner_id();
76 if ( ! $connection_owner_id ) {
77 return;
78 }
79 $connection_owner_userdata = get_userdata( $connection_owner_id );
80
81 // Bail if we're not trying to delete connection owner.
82 $user_ids_to_delete = array();
83 if ( isset( $_REQUEST['users'] ) ) {
84 $user_ids_to_delete = array_map( 'sanitize_text_field', wp_unslash( $_REQUEST['users'] ) );
85 } elseif ( isset( $_REQUEST['user'] ) ) {
86 $user_ids_to_delete[] = sanitize_text_field( wp_unslash( $_REQUEST['user'] ) );
87 }
88
89 // phpcs:enable
90 $user_ids_to_delete = array_map( 'absint', $user_ids_to_delete );
91 $deleting_connection_owner = in_array( $connection_owner_id, (array) $user_ids_to_delete, true );
92 if ( ! $deleting_connection_owner ) {
93 return;
94 }
95
96 // Bail if they're trying to delete themselves to avoid confusion.
97 if ( get_current_user_id() === $connection_owner_id ) {
98 return;
99 }
100
101 $tracking = new Tracking();
102
103 // Track it!
104 if ( method_exists( $tracking, 'record_user_event' ) ) {
105 $tracking->record_user_event( 'delete_connection_owner_notice_view' );
106 }
107
108 $connected_admins = $connection_manager->get_connected_users( 'jetpack_disconnect' );
109 $user = is_a( $connection_owner_userdata, 'WP_User' ) ? esc_html( $connection_owner_userdata->data->user_login ) : '';
110
111 echo "<div class='notice notice-warning' id='jetpack-notice-switch-connection-owner'>";
112 echo '<h2>' . esc_html__( 'Important notice about your Jetpack connection:', 'jetpack-connection' ) . '</h2>';
113 echo '<p>' . sprintf(
114 /* translators: WordPress User, if available. */
115 esc_html__( 'Warning! You are about to delete the Jetpack connection owner (%s) for this site, which may cause some of your Jetpack features to stop working.', 'jetpack-connection' ),
116 esc_html( $user )
117 ) . '</p>';
118
119 if ( ! empty( $connected_admins ) && count( $connected_admins ) > 1 ) {
120 echo '<form id="jp-switch-connection-owner" action="" method="post">';
121 echo "<label for='owner'>" . esc_html__( 'You can choose to transfer connection ownership to one of these already-connected admins:', 'jetpack-connection' ) . ' </label>';
122
123 $connected_admin_ids = array_map(
124 function ( $connected_admin ) {
125 return $connected_admin->ID;
126 },
127 $connected_admins
128 );
129
130 wp_dropdown_users(
131 array(
132 'name' => 'owner',
133 'include' => array_diff( $connected_admin_ids, array( $connection_owner_id ) ),
134 'show' => 'display_name_with_login',
135 )
136 );
137
138 echo '<p>';
139 submit_button( esc_html__( 'Set new connection owner', 'jetpack-connection' ), 'primary', 'jp-switch-connection-owner-submit', false );
140 echo '</p>';
141
142 echo "<div id='jp-switch-user-results'></div>";
143 echo '</form>';
144 ?>
145 <script type="text/javascript">
146 ( function() {
147 const switchOwnerButton = document.getElementById('jp-switch-connection-owner');
148 if ( ! switchOwnerButton ) {
149 return;
150 }
151
152 switchOwnerButton.addEventListener( 'submit', function ( e ) {
153 e.preventDefault();
154
155 const submitBtn = document.getElementById('jp-switch-connection-owner-submit');
156 submitBtn.disabled = true;
157
158 const results = document.getElementById('jp-switch-user-results');
159 results.innerHTML = '';
160 results.classList.remove( 'error-message' );
161
162 const handleAPIError = ( message ) => {
163 submitBtn.disabled = false;
164
165 results.classList.add( 'error-message' );
166 results.innerHTML = message || "<?php esc_html_e( 'Something went wrong. Please try again.', 'jetpack-connection' ); ?>";
167 }
168
169 fetch(
170 <?php echo wp_json_encode( esc_url_raw( get_rest_url() . 'jetpack/v4/connection/owner' ), JSON_HEX_TAG | JSON_HEX_AMP ); ?>,
171 {
172 method: 'POST',
173 headers: {
174 'X-WP-Nonce': <?php echo wp_json_encode( wp_create_nonce( 'wp_rest' ), JSON_HEX_TAG | JSON_HEX_AMP ); ?>,
175 },
176 body: new URLSearchParams( new FormData( this ) ),
177 }
178 )
179 .then( response => response.json() )
180 .then( data => {
181 if ( data.hasOwnProperty( 'code' ) && data.code === 'success' ) {
182 // Owner successfully changed.
183 results.innerHTML = <?php echo wp_json_encode( esc_html__( 'Success!', 'jetpack-connection' ), JSON_HEX_TAG | JSON_HEX_AMP ); ?>;
184 setTimeout(function () {
185 document.getElementById( 'jetpack-notice-switch-connection-owner' ).style.display = 'none';
186 }, 1000);
187
188 return;
189 }
190
191 handleAPIError( data?.message );
192 } )
193 .catch( () => handleAPIError() );
194 });
195 } )();
196 </script>
197 <?php
198 } else {
199 echo '<p>' . esc_html__( 'Every Jetpack site needs at least one connected admin for the features to work properly. Please connect to your WordPress.com account via the button below. Once you connect, you may refresh this page to see an option to change the connection owner.', 'jetpack-connection' ) . '</p>';
200 $connect_url = $connection_manager->get_authorization_url();
201 $connect_url = add_query_arg( 'from', 'delete_connection_owner_notice', $connect_url );
202 echo "<a href='" . esc_url( $connect_url ) . "' target='_blank' rel='noopener noreferrer' class='button-primary'>" . esc_html__( 'Connect to WordPress.com', 'jetpack-connection' ) . '</a>';
203 }
204
205 echo '<p>';
206 printf(
207 wp_kses(
208 /* translators: URL to Jetpack support doc regarding the primary user. */
209 __( "<a href='%s' target='_blank' rel='noopener noreferrer'>Learn more</a> about the connection owner and what will break if you do not have one.", 'jetpack-connection' ),
210 array(
211 'a' => array(
212 'href' => true,
213 'target' => true,
214 'rel' => true,
215 ),
216 )
217 ),
218 esc_url( Redirect::get_url( 'jetpack-support-primary-user' ) )
219 );
220 echo '</p>';
221 echo '<p>';
222 printf(
223 wp_kses(
224 /* translators: URL to contact Jetpack support. */
225 __( 'As always, feel free to <a href="%s" target="_blank" rel="noopener noreferrer">contact our support team</a> if you have any questions.', 'jetpack-connection' ),
226 array(
227 'a' => array(
228 'href' => true,
229 'target' => true,
230 'rel' => true,
231 ),
232 )
233 ),
234 esc_url( Redirect::get_url( 'jetpack-contact-support' ) )
235 );
236 echo '</p>';
237 echo '</div>';
238 }
239 }
240