Skip to content

Commit d04c82f

Browse files
committed
Store consumer and token in object properties
1 parent b618216 commit d04c82f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

authorize-page.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,22 @@ public function render_page() {
4545
}
4646

4747
// Set up fields
48-
$token = $_REQUEST['oauth_token'];
48+
$token_key = $_REQUEST['oauth_token'];
4949
$scope = '*';
5050
if ( ! empty( $_REQUEST['wp_scope'] ) ) {
5151
$scope = $_REQUEST['wp_scope'];
5252
}
5353

5454
$authenticator = new WP_JSON_Authentication_OAuth1();
5555
$errors = array();
56-
$token = $authenticator->get_request_token( $_REQUEST['oauth_token'] );
57-
if ( is_wp_error( $token ) ) {
58-
$this->display_error( $token );
56+
$this->token = $authenticator->get_request_token( $token_key );
57+
if ( is_wp_error( $this->token ) ) {
58+
$this->display_error( $this->token );
5959
exit;
6060
}
6161

6262
// Fetch consumer
63-
$consumer = get_post( $token['consumer'] );
63+
$this->consumer = $consumer = get_post( $this->token['consumer'] );
6464

6565
if ( ! empty( $_POST['wp-submit'] ) ) {
6666
check_admin_referer( 'json_oauth1_authorize' );
@@ -86,7 +86,8 @@ public function render_page() {
8686
* nonce field.
8787
*/
8888
public function page_fields() {
89-
echo '<input type="hidden" name="consumer" value="' . absint( $consumer->ID ) . '" />';
89+
echo '<input type="hidden" name="consumer" value="' . absint( $this->consumer->ID ) . '" />';
90+
echo '<input type="hidden" name="oauth_token" value="' . esc_attr( $this->token['key'] ) . '" />';
9091
wp_nonce_field( 'json_oauth1_authorize' );
9192
}
9293

0 commit comments

Comments
 (0)