PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | jetpack_vendor/automattic/jetpack-licensing/src/class-endpoints.php +4 -22 13.5.2 → 16.3-beta View file →
@@ -7,9 +7,8 @@
7 7
8 8 namespace Automattic\Jetpack\Licensing;
9 9
10 10 use Automattic\Jetpack\Connection\Client;
11 -use Automattic\Jetpack\Connection\Manager as Connection_Manager;
12 11 use Automattic\Jetpack\Licensing;
13 12 use Automattic\Jetpack\Status\Visitor;
14 13 use Jetpack_Options;
15 14 use WP_Error;
@@ -108,9 +107,9 @@
108 107 'licensing/user/licenses',
109 108 array(
110 109 'methods' => \WP_REST_Server::READABLE,
111 110 'callback' => __CLASS__ . '::get_user_licenses',
112 - 'permission_callback' => __CLASS__ . '::user_licensing_permission_check',
111 + 'permission_callback' => __CLASS__ . '::can_manage_options_check',
113 112 )
114 113 );
115 114
116 115 /**
@@ -121,9 +120,9 @@
121 120 'licensing/user/counts',
122 121 array(
123 122 'methods' => \WP_REST_Server::READABLE,
124 123 'callback' => __CLASS__ . '::get_user_license_counts',
125 - 'permission_callback' => __CLASS__ . '::user_licensing_permission_check',
124 + 'permission_callback' => __CLASS__ . '::can_manage_options_check',
126 125 )
127 126 );
128 127
129 128 /**
@@ -134,9 +133,9 @@
134 133 'licensing/user/activation-notice-dismiss',
135 134 array(
136 135 'methods' => \WP_REST_Server::EDITABLE,
137 136 'callback' => __CLASS__ . '::update_licensing_activation_notice_dismiss',
138 - 'permission_callback' => __CLASS__ . '::user_licensing_permission_check',
137 + 'permission_callback' => __CLASS__ . '::can_manage_options_check',
139 138 'args' => array(
140 139 'last_detached_count' => array(
141 140 'required' => true,
142 141 'type' => 'integer',
@@ -154,9 +153,9 @@
154 153 '/licensing/attach-licenses',
155 154 array(
156 155 'methods' => \WP_REST_Server::EDITABLE,
157 156 'callback' => __CLASS__ . '::attach_jetpack_licenses',
158 - 'permission_callback' => __CLASS__ . '::user_licensing_permission_check',
157 + 'permission_callback' => __CLASS__ . '::can_manage_options_check',
159 158 'args' => array(
160 159 'licenses' => array(
161 160 'required' => true,
162 161 'type' => 'array',
@@ -183,25 +182,8 @@
183 182 return true;
184 183 }
185 184
186 185 return new WP_Error( 'invalid_user_permission_set_jetpack_license_key', self::$user_permissions_error_msg, array( 'status' => rest_authorization_required_code() ) );
187 - }
188 -
189 - /**
190 - * Verify that user can view and update user-licensing data.
191 - *
192 - * @since 1.7.0
193 - *
194 - * @return bool Whether the user is currently connected and they are the connection owner.
195 - */
196 - public static function user_licensing_permission_check() {
197 - $connection_manager = new Connection_Manager( 'jetpack' );
198 -
199 - if ( $connection_manager->is_user_connected() && $connection_manager->is_connection_owner() ) {
200 - return true;
201 - }
202 -
203 - return new WP_Error( 'invalid_permission_manage_user_licenses', self::$user_permissions_error_msg, array( 'status' => rest_authorization_required_code() ) );
204 186 }
205 187
206 188 /**
207 189 * Verify that user can manage_options