Skip to content

Commit 5522b87

Browse files
committed
Merge branch 'master' into fix-array-string-generation
2 parents d1d9864 + fe7f452 commit 5522b87

13 files changed

+128
-23
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This plugin uses the OAuth 1.0a protocol to allow delegated authorization; that
66

77
This plugin only supports WordPress >= 4.4.
88

9+
The latest stable version is also available from the [WordPress Plugin Directory](https://wordpress.org/plugins/rest-api-oauth1/).
10+
911
## New to OAuth
1012

1113
We strongly recommend you use an existing OAuth library. You'll be best off if you understand the authorization process, but leave the actual implementation to well-tested libraries, as there are a lot of edge cases.

admin.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@ function rest_oauth1_profile_section( $user ) {
1818
global $wpdb;
1919

2020
$results = $wpdb->get_col( "SELECT option_value FROM {$wpdb->options} WHERE option_name LIKE 'oauth1_access_%'", 0 );
21-
$results = array_map( 'unserialize', $results );
22-
$approved = array_filter( $results, function ( $row ) use ( $user ) {
23-
return $row['user'] === $user->ID;
24-
} );
21+
$approved = array();
22+
foreach ( $results as $result ) {
23+
$row = unserialize( $result );
24+
if ( $row['user'] === $user->ID ) {
25+
$approved[] = $row;
26+
}
27+
}
2528

2629
$authenticator = new WP_REST_OAuth1();
2730

@@ -46,7 +49,7 @@ function rest_oauth1_profile_section( $user ) {
4649
?>
4750
<tr>
4851
<td><?php echo esc_html( $application->post_title ) ?></td>
49-
<td><button class="button" name="oauth_revoke" value="<?php echo esc_attr( $row['key'] ) ?>"><?php esc_html_e( 'Revoke', 'rest_oauth1' ) ?></button>
52+
<td><button class="button" name="rest_oauth1_revoke" value="<?php echo esc_attr( $row['key'] ) ?>"><?php esc_html_e( 'Revoke', 'rest_oauth1' ) ?></button>
5053
</tr>
5154

5255
<?php endforeach ?>

assets/banner-1544x500.png

23.3 KB
Loading

assets/banner-772x250.png

21.8 KB
Loading

assets/icon-128x128.png

9.88 KB
Loading

assets/icon-256x256.png

20.4 KB
Loading

bin/readme.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
=== WordPress REST API - OAuth 1.0a Server ===
2+
Contributors: rmccue, rachelbaker, danielbachhuber, joehoyle
3+
Tags: json, rest, api, rest-api
4+
Requires at least: 4.4
5+
Tested up to: 4.7-alpha
6+
Stable tag: {{TAG}}
7+
License: GPLv2 or later
8+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
9+
10+
== Description ==
11+
Connect applications to your WordPress site without ever giving away your password.
12+
13+
This plugin uses the OAuth 1.0a protocol to allow delegated authorization; that is, to allow applications to access a site using a set of secondary credentials. This allows server administrators to control which applications can access the site, as well as allowing users to control which applications have access to their data.
14+
15+
This plugin only supports WordPress >= 4.4.

bin/release.sh

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# release.sh
2+
#
3+
# Takes a tag to release, and syncs it to WordPress.org
4+
5+
TAG=$1
6+
7+
PLUGIN="rest-api-oauth1"
8+
TMPDIR=/tmp/rest-api-oauth1-release-svn
9+
PLUGINDIR="$PWD"
10+
PLUGINSVN="https://plugins.svn.wordpress.org/$PLUGIN"
11+
12+
# Fail on any error
13+
set -e
14+
15+
# Is the tag valid?
16+
if [ -z "$TAG" ] || ! git rev-parse "$TAG" > /dev/null; then
17+
echo "Invalid tag. Make sure you tag before trying to release."
18+
exit 1
19+
fi
20+
21+
if [[ $VERSION == "v*" ]]; then
22+
# Starts with an extra "v", strip for the version
23+
VERSION=${TAG:1}
24+
else
25+
VERSION="$TAG"
26+
fi
27+
28+
if [ -d "$TMPDIR" ]; then
29+
# Wipe it clean
30+
rm -r "$TMPDIR"
31+
fi
32+
33+
# Ensure the directory exists first
34+
mkdir "$TMPDIR"
35+
36+
# Grab an unadulterated copy of SVN
37+
svn co "$PLUGINSVN/trunk" "$TMPDIR" > /dev/null
38+
39+
# Extract files from the Git tag to there
40+
git archive --format="zip" -0 "$TAG" | tar -C "$TMPDIR" -xf -
41+
42+
# Switch to build dir
43+
cd "$TMPDIR"
44+
45+
# Run build tasks
46+
sed -e "s/{{TAG}}/$VERSION/g" < "$PLUGINDIR/bin/readme.txt" > readme.txt
47+
48+
# Remove special files
49+
rm ".gitignore"
50+
rm "composer.json"
51+
rm "book.json"
52+
rm -r "bin"
53+
rm -r "docs"
54+
55+
# Add any new files
56+
svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add
57+
58+
# Pause to allow checking
59+
echo "About to commit $VERSION. Double-check $TMPDIR to make sure everything looks fine."
60+
read -p "Hit Enter to continue."
61+
62+
# Commit the changes
63+
svn commit -m "Tag $VERSION"
64+
65+
# tag_ur_it
66+
svn copy "$PLUGINSVN/trunk" "$PLUGINSVN/tags/$VERSION" -m "Tag $VERSION"

lib/class-wp-rest-oauth1-listtable.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@ public function prepare_items() {
1313
'value' => 'oauth1',
1414
),
1515
),
16-
1716
'paged' => $paged,
1817
);
1918

20-
$query = new WP_Query();
21-
$this->items = $query->query( $args );
19+
$query = new WP_Query( $args );
20+
$this->items = $query->posts;
21+
22+
$pagination_args = array(
23+
'total_items' => $query->found_posts,
24+
'total_pages' => $query->max_num_pages,
25+
'per_page' => $query->get('posts_per_page')
26+
);
27+
$this->set_pagination_args( $pagination_args );
2228
}
2329

2430
/**

lib/class-wp-rest-oauth1-ui.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,7 @@ public function page_fields() {
136136
* @return null|WP_Error Null on success, error otherwise
137137
*/
138138
public function handle_callback_redirect( $verifier ) {
139-
if ( ! empty( $this->token['callback'] ) && $this->token['callback'] === 'oob' ) {
140-
return apply_filters( 'json_oauth1_handle_callback', null, $this->token );
141-
}
142-
143-
if ( empty( $this->token['callback'] ) ) {
139+
if ( empty( $this->token['callback'] ) || $this->token['callback'] === 'oob' ) {
144140
// No callback registered, display verification code to the user
145141
login_header( __( 'Access Token', 'rest_oauth1' ) );
146142
echo '<p>' . sprintf( __( 'Your verification token is <code>%s</code>', 'rest_oauth1' ), $verifier ) . '</p>';

0 commit comments

Comments
 (0)