1
1
<?php
2
2
3
- class Wombat_Admin {
4
- const BASE_SLUG = 'wombat -apps ' ;
3
+ class WP_REST_OAuth1_Admin {
4
+ const BASE_SLUG = 'rest-oauth1 -apps ' ;
5
5
6
6
/**
7
7
* Register the admin page
@@ -10,14 +10,14 @@ public static function register() {
10
10
/**
11
11
* Include anything we need that relies on admin classes/functions
12
12
*/
13
- include_once dirname ( __FILE__ ) . '/class-wombat -listtable.php ' ;
13
+ include_once dirname ( __FILE__ ) . '/class-wp-rest-oauth1 -listtable.php ' ;
14
14
15
15
$ hook = add_users_page (
16
16
// Page title
17
- __ ( 'Registered OAuth Applications ' , 'wombat ' ),
17
+ __ ( 'Registered OAuth Applications ' , 'rest_oauth1 ' ),
18
18
19
19
// Menu title
20
- _x ( 'Applications ' , 'menu title ' , 'wombat ' ),
20
+ _x ( 'Applications ' , 'menu title ' , 'rest_oauth1 ' ),
21
21
22
22
// Capability
23
23
'list_users ' ,
@@ -68,7 +68,7 @@ public static function load() {
68
68
default :
69
69
global $ wp_list_table ;
70
70
71
- $ wp_list_table = new Wombat_ListTable ();
71
+ $ wp_list_table = new WP_REST_OAuth1_ListTable ();
72
72
73
73
$ wp_list_table ->prepare_items ();
74
74
@@ -99,11 +99,11 @@ public static function render() {
99
99
<div class="wrap">
100
100
<h2>
101
101
<?php
102
- esc_html_e ( 'Registered Applications ' , 'wombat ' );
102
+ esc_html_e ( 'Registered Applications ' , 'rest_oauth1 ' );
103
103
104
104
if ( current_user_can ( 'create_users ' ) ): ?>
105
105
<a href="<?php echo esc_url ( self ::get_url ( 'action=add ' ) ) ?> "
106
- class="add-new-h2"><?php echo esc_html_x ( 'Add New ' , 'application ' , 'wombat ' ); ?> </a>
106
+ class="add-new-h2"><?php echo esc_html_x ( 'Add New ' , 'application ' , 'rest_oauth1 ' ); ?> </a>
107
107
<?php
108
108
endif ;
109
109
?>
@@ -113,7 +113,7 @@ class="add-new-h2"><?php echo esc_html_x( 'Add New', 'application', 'wombat' );
113
113
114
114
<form action="" method="get">
115
115
116
- <?php $ wp_list_table ->search_box ( __ ( 'Search Applications ' , 'wombat ' ), 'wombat ' ); ?>
116
+ <?php $ wp_list_table ->search_box ( __ ( 'Search Applications ' , 'rest_oauth1 ' ), 'rest_oauth1 ' ); ?>
117
117
118
118
<?php $ wp_list_table ->display (); ?>
119
119
@@ -129,17 +129,17 @@ protected static function validate_parameters( $params ) {
129
129
$ valid = array ();
130
130
131
131
if ( empty ( $ params ['name ' ] ) ) {
132
- return new WP_Error ( 'wombat_missing_name ' , __ ( 'Consumer name is required ' , 'wombat ' ) );
132
+ return new WP_Error ( 'rest_oauth1_missing_name ' , __ ( 'Consumer name is required ' , 'rest_oauth1 ' ) );
133
133
}
134
134
$ valid ['name ' ] = wp_filter_post_kses ( $ params ['name ' ] );
135
135
136
136
if ( empty ( $ params ['description ' ] ) ) {
137
- return new WP_Error ( 'wombat_missing_description ' , __ ( 'Consumer description is required ' , 'wombat ' ) );
137
+ return new WP_Error ( 'rest_oauth1_missing_description ' , __ ( 'Consumer description is required ' , 'rest_oauth1 ' ) );
138
138
}
139
139
$ valid ['description ' ] = wp_filter_post_kses ( $ params ['description ' ] );
140
140
141
141
if ( empty ( $ params ['callback ' ] ) ) {
142
- return new WP_Error ( 'wombat_missing_description ' , __ ( 'Consumer callback is required and must be a valid URL. ' , 'wombat ' ) );
142
+ return new WP_Error ( 'rest_oauth1_missing_description ' , __ ( 'Consumer callback is required and must be a valid URL. ' , 'rest_oauth1 ' ) );
143
143
}
144
144
if ( ! empty ( $ params ['callback ' ] ) ) {
145
145
$ valid ['callback ' ] = $ params ['callback ' ];
@@ -157,11 +157,11 @@ protected static function handle_edit_submit( $consumer ) {
157
157
$ messages = array ();
158
158
if ( empty ( $ consumer ) ) {
159
159
$ did_action = 'add ' ;
160
- check_admin_referer ( 'wombat -add ' );
160
+ check_admin_referer ( 'rest-oauth1 -add ' );
161
161
}
162
162
else {
163
163
$ did_action = 'edit ' ;
164
- check_admin_referer ( 'wombat -edit- ' . $ consumer ->ID );
164
+ check_admin_referer ( 'rest-oauth1 -edit- ' . $ consumer ->ID );
165
165
}
166
166
167
167
// Check that the parameters are correct first
@@ -202,15 +202,12 @@ protected static function handle_edit_submit( $consumer ) {
202
202
}
203
203
204
204
// Success, redirect to alias page
205
- $ location = add_query_arg (
205
+ $ location = self :: get_url (
206
206
array (
207
- 'action ' => 'wombat- edit ' ,
207
+ 'action ' => 'edit ' ,
208
208
'id ' => $ consumer ->ID ,
209
209
'did_action ' => $ did_action ,
210
- 'processed ' => 1 ,
211
- '_wpnonce ' => wp_create_nonce ( 'wombat-edit- ' . $ id ),
212
- ),
213
- network_admin_url ( 'admin.php ' )
210
+ )
214
211
);
215
212
wp_safe_redirect ( $ location );
216
213
exit ;
@@ -226,15 +223,15 @@ public static function render_edit_page() {
226
223
227
224
// Are we editing?
228
225
$ consumer = null ;
229
- $ form_action = admin_url ( ' admin.php? action=wombat- add ' );
226
+ $ form_action = self :: get_url ( ' action=add ' );
230
227
if ( ! empty ( $ _REQUEST ['id ' ] ) ) {
231
228
$ id = absint ( $ _REQUEST ['id ' ] );
232
229
$ consumer = get_post ( $ id );
233
230
if ( is_wp_error ( $ consumer ) || empty ( $ consumer ) ) {
234
231
wp_die ( __ ( 'Invalid consumer ID. ' ) );
235
232
}
236
233
237
- $ form_action = admin_url ( ' admin.php? action=wombat- edit ' );
234
+ $ form_action = self :: get_url ( array ( ' action ' => ' edit ', ' id ' => $ id ) );
238
235
}
239
236
240
237
// Handle form submission
@@ -258,7 +255,7 @@ public static function render_edit_page() {
258
255
259
256
// Header time!
260
257
global $ title , $ parent_file , $ submenu_file ;
261
- $ title = $ consumer ? __ ( 'Edit Application ' , 'wombat ' ) : __ ( 'Add Application ' , 'wombat ' );
258
+ $ title = $ consumer ? __ ( 'Edit Application ' , 'rest_oauth1 ' ) : __ ( 'Add Application ' , 'rest_oauth1 ' );
262
259
$ parent_file = 'users.php ' ;
263
260
$ submenu_file = self ::BASE_SLUG ;
264
261
@@ -332,12 +329,12 @@ public static function render_edit_page() {
332
329
<?php
333
330
334
331
if ( empty ( $ consumer ) ) {
335
- wp_nonce_field ( 'wombat -add ' );
332
+ wp_nonce_field ( 'rest-oauth1 -add ' );
336
333
submit_button ( __ ( 'Add Consumer ' ) );
337
334
}
338
335
else {
339
336
echo '<input type="hidden" name="id" value=" ' . esc_attr ( $ consumer ->ID ) . '" /> ' ;
340
- wp_nonce_field ( 'wombat -edit- ' . $ consumer ->ID );
337
+ wp_nonce_field ( 'rest-oauth1 -edit- ' . $ consumer ->ID );
341
338
submit_button ( __ ( 'Save Consumer ' ) );
342
339
}
343
340
@@ -356,7 +353,7 @@ public static function handle_delete() {
356
353
}
357
354
358
355
$ id = $ _GET ['id ' ];
359
- check_admin_referer ( 'wombat -delete: ' . $ id );
356
+ check_admin_referer ( 'rest-oauth1 -delete: ' . $ id );
360
357
361
358
if ( ! rest_delete_client ( $ id ) ) {
362
359
$ message = 'Invalid consumer ID ' ;
0 commit comments