Skip to content

Commit 9d3a326

Browse files
committed
Remove filter changes
1 parent 02d47e5 commit 9d3a326

File tree

9 files changed

+75
-122
lines changed

9 files changed

+75
-122
lines changed

.phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@
2323
<rule ref="WordPress">
2424
<exclude name="Generic.Commenting" />
2525
<exclude name="Squiz.Commenting" />
26+
<exclude name="WordPress.NamingConventions.ValidHookName.UseUnderscores" />
2627
</rule>
2728
</ruleset>

inc/admin/profile/namespace.php

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Administration UI and utilities
44
*
5-
* @package WordPress
5+
* @package WordPress
66
* @subpackage JSON API
77
*/
88

@@ -63,18 +63,20 @@ function ( Access_Token $token ) {
6363
?>
6464
</tbody>
6565
<tfoot>
66-
<tr>
67-
<td colspan="2">
68-
<a href="<?php echo esc_url( $personal_url ); ?>">
69-
<?php esc_html_e( 'Create personal access token', 'oauth2' ); ?>
70-
</a>
71-
</td>
72-
</tr>
66+
<tr>
67+
<td colspan="2">
68+
<a href="<?php echo esc_url( $personal_url ); ?>">
69+
<?php esc_html_e( 'Create personal access token', 'oauth2' ); ?>
70+
</a>
71+
</td>
72+
</tr>
7373
</tfoot>
7474
</table>
7575
<?php else : ?>
7676
<p class="description"><?php esc_html_e( 'No applications authorized.', 'oauth2' ); ?></p>
77-
<p><a href="<?php echo esc_url( $personal_url ); ?>"><?php esc_html_e( 'Create personal access token', 'oauth2' ); ?></a></p>
77+
<p>
78+
<a href="<?php echo esc_url( $personal_url ); ?>"><?php esc_html_e( 'Create personal access token', 'oauth2' ); ?></a>
79+
</p>
7880
<?php endif ?>
7981
<?php
8082
}
@@ -106,21 +108,11 @@ function render_token_row( WP_User $user, Access_Token $token ) {
106108
/**
107109
* Filter details shown for an access token on the profile screen.
108110
*
109-
* @deprecated
110-
* @param string[] $details List of HTML snippets to render in table.
111-
* @param Access_Token $token Token being displayed.
112-
* @param WP_User $user User whose profile is being rendered.
113-
*/
114-
$details = apply_filters_deprecated( 'oauth2.admin.profile.render_token_row.details', $details, $token, $user ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
115-
116-
/**
117-
* Filter details shown for an access token on the profile screen.
118-
*
119-
* @param string[] $details List of HTML snippets to render in table.
120-
* @param Access_Token $token Token being displayed.
121-
* @param WP_User $user User whose profile is being rendered.
111+
* @param string[] $details List of HTML snippets to render in table.
112+
* @param Access_Token $token Token being displayed.
113+
* @param WP_User $user User whose profile is being rendered.
122114
*/
123-
$details = apply_filters( 'oauth2_admin_profile_render_token_row_details', $details, $token, $user );
115+
$details = apply_filters( 'oauth2.admin.profile.render_token_row.details', $details, $token, $user );
124116

125117
// Build actions.
126118
if ( $is_personal ) {
@@ -149,21 +141,11 @@ function render_token_row( WP_User $user, Access_Token $token ) {
149141
/**
150142
* Filter actions shown for an access token on the profile screen.
151143
*
152-
* @deprecated
153-
* @param string[] $actions List of HTML snippets to render in table.
154-
* @param Access_Token $token Token being displayed.
155-
* @param WP_User $user User whose profile is being rendered.
156-
*/
157-
$actions = apply_filters_deprecated( 'oauth2.admin.profile.render_token_row.actions', $actions, $token, $user ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
158-
159-
/**
160-
* Filter actions shown for an access token on the profile screen.
161-
*
162-
* @param string[] $actions List of HTML snippets to render in table.
163-
* @param Access_Token $token Token being displayed.
164-
* @param WP_User $user User whose profile is being rendered.
144+
* @param string[] $actions List of HTML snippets to render in table.
145+
* @param Access_Token $token Token being displayed.
146+
* @param WP_User $user User whose profile is being rendered.
165147
*/
166-
$actions = apply_filters( 'oauth2_admin_profile_render_token_row_actions', $actions, $token, $user );
148+
$actions = apply_filters( 'oauth2.admin.profile.render_token_row.actions', $actions, $token, $user );
167149

168150
$name = sprintf( '<strong>%s</strong>', $client->get_name() );
169151
if ( $is_personal ) {

inc/class-client.php

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
*
4-
* @package WordPress
4+
* @package WordPress
55
* @subpackage JSON API
66
*/
77

@@ -15,15 +15,15 @@
1515
use WP_User;
1616

1717
class Client implements ClientInterface {
18-
const POST_TYPE = 'oauth2_client';
19-
const CLIENT_SECRET_KEY = '_oauth2_client_secret';
20-
const TYPE_KEY = '_oauth2_client_type';
21-
const REDIRECT_URI_KEY = '_oauth2_redirect_uri';
18+
const POST_TYPE = 'oauth2_client';
19+
const CLIENT_SECRET_KEY = '_oauth2_client_secret';
20+
const TYPE_KEY = '_oauth2_client_type';
21+
const REDIRECT_URI_KEY = '_oauth2_redirect_uri';
2222
const AUTH_CODE_KEY_PREFIX = '_oauth2_authcode_';
23-
const AUTH_CODE_LENGTH = 12;
24-
const CLIENT_ID_LENGTH = 12;
23+
const AUTH_CODE_LENGTH = 12;
24+
const CLIENT_ID_LENGTH = 12;
2525
const CLIENT_SECRET_LENGTH = 48;
26-
const AUTH_CODE_AGE = 600; // 10 * MINUTE_IN_SECONDS
26+
const AUTH_CODE_AGE = 600; // 10 * MINUTE_IN_SECONDS
2727

2828
/**
2929
* @var WP_Post
@@ -72,6 +72,7 @@ public function get_name() {
7272
* Get the client's description.
7373
*
7474
* @param boolean $raw True to get raw database value for editing, false to get rendered value for display.
75+
*
7576
* @return string
7677
*/
7778
public function get_description( $raw = false ) {
@@ -137,6 +138,7 @@ public function get_redirect_uris() {
137138
* just HTTP with standard ports.
138139
*
139140
* @param string $url URL for the callback.
141+
*
140142
* @return bool True for a valid callback URL, false otherwise.
141143
*/
142144
public static function validate_callback( $url ) {
@@ -163,10 +165,11 @@ public static function validate_callback( $url ) {
163165
/**
164166
* Check if a redirect URI is valid for the client.
165167
*
166-
* @todo Implement this properly :)
167-
*
168168
* @param string $uri Supplied redirect URI to check.
169+
*
169170
* @return boolean True if the URI is valid, false otherwise.
171+
* @todo Implement this properly :)
172+
*
170173
*/
171174
public function check_redirect_uri( $uri ) {
172175
if ( ! $this->validate_callback( $uri ) ) {
@@ -207,30 +210,12 @@ public function check_redirect_uri( $uri ) {
207210
* Filter whether a callback is counted as valid. (deprecated).
208211
* User rest_oauth_check_callback.
209212
*
210-
* @param boolean $valid True if the callback URL is valid, false otherwise.
211-
* @param string $url Supplied callback URL.
212-
* @param string $registered_uri URI being checked.
213-
* @param Client $client OAuth 2 client object.
214-
*/
215-
$valid = apply_filters_deprecated( 'rest_oauth.check_callback', $valid, $uri, $registered_uri, $this ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
216-
217-
/**
218-
* Filter whether a callback is counted as valid.
219-
*
220-
* By default, the URLs must match scheme, host, port, user, pass, and
221-
* path. Query and fragment segments are allowed to be different.
222-
*
223-
* To change this behaviour, filter this value. Note that consumers must
224-
* have a callback registered, even if you relax this restruction. It is
225-
* highly recommended not to change this behaviour, as clients will
226-
* expect the same behaviour across all WP sites.
227-
*
228-
* @param boolean $valid True if the callback URL is valid, false otherwise.
229-
* @param string $url Supplied callback URL.
230-
* @param string $registered_uri URI being checked.
231-
* @param Client $client OAuth 2 client object.
213+
* @param boolean $valid True if the callback URL is valid, false otherwise.
214+
* @param string $url Supplied callback URL.
215+
* @param string $registered_uri URI being checked.
216+
* @param Client $client OAuth 2 client object.
232217
*/
233-
$valid = apply_filters( 'rest_oauth_check_callback', $valid, $uri, $registered_uri, $this );
218+
$valid = apply_filters( 'rest_oauth.check_callback', $valid, $uri, $registered_uri, $this );
234219

235220
if ( $valid ) {
236221
// Stop checking, we have a match.
@@ -254,6 +239,7 @@ public function generate_authorization_code( WP_User $user ) {
254239
* Get data stored for an authorization code.
255240
*
256241
* @param string $code Authorization code to fetch.
242+
*
257243
* @return Authorization_Code|WP_Error Data if available, error if invalid code.
258244
*/
259245
public function get_authorization_code( $code ) {
@@ -288,6 +274,7 @@ public function issue_token( WP_User $user, $meta = [] ) {
288274
* Get a client by ID.
289275
*
290276
* @param string $id Client ID.
277+
*
291278
* @return static|null Token if ID is found, null otherwise.
292279
*/
293280
public static function get_by_id( $id ) {
@@ -312,6 +299,7 @@ public static function get_by_id( $id ) {
312299
* Get a client by post ID.
313300
*
314301
* @param int $id Client/post ID.
302+
*
315303
* @return static|null Client instance on success, null if invalid/not found.
316304
*/
317305
public static function get_by_post_id( $id ) {
@@ -327,7 +315,8 @@ public static function get_by_post_id( $id ) {
327315
* Create a new client.
328316
*
329317
* @param array $data {
330-
* }
318+
* }
319+
*
331320
* @return WP_Error|Client Client instance on success, error otherwise.
332321
*/
333322
public static function create( $data ) {
@@ -417,6 +406,7 @@ public function approve() {
417406
'post_status' => 'publish',
418407
];
419408
$result = wp_update_post( wp_slash( $data ), true );
409+
420410
return is_wp_error( $result ) ? $result : true;
421411
}
422412

inc/class-clientinterface.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
*
4-
* @package WordPress
4+
* @package WordPress
55
* @subpackage JSON API
66
*/
77

@@ -28,6 +28,7 @@ public function get_name();
2828
* Get the client's description.
2929
*
3030
* @param boolean $raw True to get raw database value for editing, false to get rendered value for display.
31+
*
3132
* @return string
3233
*/
3334
public function get_description( $raw = false );
@@ -56,10 +57,11 @@ public function get_redirect_uris();
5657
/**
5758
* Check if a redirect URI is valid for the client.
5859
*
59-
* @todo Implement this properly :)
60-
*
6160
* @param string $uri Supplied redirect URI to check.
61+
*
6262
* @return boolean True if the URI is valid, false otherwise.
63+
* @todo Implement this properly :)
64+
*
6365
*/
6466
public function check_redirect_uri( $uri );
6567

@@ -74,6 +76,7 @@ public function generate_authorization_code( WP_User $user );
7476
* Get data stored for an authorization code.
7577
*
7678
* @param string $code Authorization code to fetch.
79+
*
7780
* @return Authorization_Code|WP_Error Data if available, error if invalid code.
7881
*/
7982
public function get_authorization_code( $code );

inc/class-personalclient.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
*
4-
* @package WordPress
4+
* @package WordPress
55
* @subpackage JSON API
66
*/
77

@@ -42,6 +42,7 @@ public static function get_instance() {
4242
if ( empty( $instance ) ) {
4343
$instance = new static();
4444
}
45+
4546
return $instance;
4647
}
4748

@@ -67,6 +68,7 @@ public function get_name() {
6768
* Get the client's description.
6869
*
6970
* @param boolean $raw True to get raw database value for editing, false to get rendered value for display.
71+
*
7072
* @return string
7173
*/
7274
public function get_description( $raw = false ) {
@@ -104,6 +106,7 @@ public function get_redirect_uris() {
104106
* Check if a redirect URI is valid for the client.
105107
*
106108
* @param string $uri Supplied redirect URI to check.
109+
*
107110
* @return boolean Always false: personal tokens do not support redirections.
108111
*/
109112
public function check_redirect_uri( $uri ) {
@@ -126,6 +129,7 @@ public function generate_authorization_code( WP_User $user ) {
126129
* Get data stored for an authorization code.
127130
*
128131
* @param string $code Authorization code to fetch.
132+
*
129133
* @return Authorization_Code|WP_Error Data if available, error if invalid code.
130134
*/
131135
public function get_authorization_code( $code ) {

inc/class-scopes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
/**
33
*
4-
* @package WordPress
4+
* @package WordPress
55
* @subpackage JSON API
66
*/
77

0 commit comments

Comments
 (0)