Skip to content

Commit 3918c52

Browse files
committed
Merge branch 'develop'
2 parents bdec732 + e09bf27 commit 3918c52

File tree

8 files changed

+67
-21
lines changed

8 files changed

+67
-21
lines changed

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ module.exports = function ( grunt ) {
1515
jshint : {
1616
options : {
1717
smarttabs : true
18-
}
18+
},
19+
all: ['js/*']
1920
},
2021
sass : {
2122
dist : {

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "editorial-access-manager-wp",
3-
"version": "0.2.0",
3+
"version": "0.3.1",
44
"homepage": "https://github.com/tlovett1/editorial-access-manager",
55
"authors": [
66
"Taylor Lovett <[email protected]>"

classes/class-editorial-access-manager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,17 @@ public function filter_map_meta_cap( $caps, $cap, $user_id, $args ) {
128128
// If user is admin, we do nothing
129129
if ( ! in_array( 'administrator', $user->roles ) ) {
130130

131-
if ( 'roles' == $enable_custom_access ) {
131+
if ( 'roles' === $enable_custom_access ) {
132132
// Limit access to whitelisted roles
133133

134134
$allowed_roles = (array) get_post_meta( $post_id, 'eam_allowed_roles', true );
135135

136-
if ( count( array_diff( $user->roles, $allowed_roles ) ) >= 1 ) {
136+
if ( empty( $user->roles ) || count( array_diff( $user->roles, $allowed_roles ) ) >= 1 ) {
137137
$caps[] = 'do_not_allow';
138138
} else {
139139
$caps = array();
140140
}
141-
} elseif ( 'users' == $enable_custom_access ) {
141+
} elseif ( 'users' === $enable_custom_access ) {
142142
// Limit access to whitelisted users
143143

144144
$allowed_users = (array) get_post_meta( $post_id, 'eam_allowed_users', true );

editorial-access-manager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Plugin URI: http://www.taylorlovett.com
55
* Description: Allow for granular editorial access control for all post types
66
* Author: Taylor Lovett
7-
* Version: 0.3.0
7+
* Version: 0.3.1
88
* Author URI: http://www.taylorlovett.com
99
*/
1010

languages/editorial-access-manager.pot

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
# This file is distributed under the same license as the Editorial Access Manager package.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Editorial Access Manager 0.1.1\n"
5+
"Project-Id-Version: Editorial Access Manager 0.3.1\n"
66
"Report-Msgid-Bugs-To: "
77
"https://github.com/tlovett1/editorial-access-manager/issues\n"
8-
"POT-Creation-Date: 2014-10-08 19:32:32+00:00\n"
8+
"POT-Creation-Date: 2014-11-26 15:26:48+00:00\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=utf-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
1212
"PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
15-
"X-Generator: grunt-wp-i18n 0.4.8\n"
15+
"X-Generator: grunt-wp-i18n 0.4.9\n"
1616
"Plural-Forms: nplurals=2; plural=n != 1;\n"
1717
"X-Poedit-Basepath: .\n"
1818
"X-Poedit-Language: English\n"
@@ -29,34 +29,38 @@ msgstr ""
2929
msgid "Editorial Access Manager"
3030
msgstr ""
3131

32-
#: classes/class-editorial-access-manager.php:269
32+
#: classes/class-editorial-access-manager.php:346
3333
msgid "Enable custom access management by"
3434
msgstr ""
3535

36-
#: classes/class-editorial-access-manager.php:271
37-
#: classes/class-editorial-access-manager.php:365
36+
#: classes/class-editorial-access-manager.php:348
37+
msgid "&mdash; No Change &mdash;"
38+
msgstr ""
39+
40+
#: classes/class-editorial-access-manager.php:349
41+
#: classes/class-editorial-access-manager.php:443
3842
msgid "Off"
3943
msgstr ""
4044

41-
#: classes/class-editorial-access-manager.php:272
42-
#: classes/class-editorial-access-manager.php:340
45+
#: classes/class-editorial-access-manager.php:350
46+
#: classes/class-editorial-access-manager.php:418
4347
msgid "Roles"
4448
msgstr ""
4549

46-
#: classes/class-editorial-access-manager.php:273
47-
#: classes/class-editorial-access-manager.php:353
50+
#: classes/class-editorial-access-manager.php:351
51+
#: classes/class-editorial-access-manager.php:431
4852
msgid "Users"
4953
msgstr ""
5054

51-
#: classes/class-editorial-access-manager.php:278
55+
#: classes/class-editorial-access-manager.php:356
5256
msgid "Manage access for roles:"
5357
msgstr ""
5458

55-
#: classes/class-editorial-access-manager.php:293
59+
#: classes/class-editorial-access-manager.php:371
5660
msgid "Manage access for users:"
5761
msgstr ""
5862

59-
#: classes/class-editorial-access-manager.php:319
63+
#: classes/class-editorial-access-manager.php:398
6064
msgid "Editorial access"
6165
msgstr ""
6266

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "editorial-access-manager-wp",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/tlovett1/editorial-access-manager.git"

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Donate link: http://www.taylorlovett.com
44
Tags: editorial access management, user roles, user capabilities, role management, user permissions, administrator permissions
55
Requires at least: 3.6
66
Tested up to: 4.1
7-
Stable tag: 0.3.0
7+
Stable tag: 0.3.1
88
License: GPLv2 or later
99
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1010

@@ -48,6 +48,9 @@ the sidebar.
4848

4949
== Changelog ==
5050

51+
= 0.3.1 =
52+
* Fix bug where logged out user could edit role restricted post [@tripgrass](https://github.com/tripgrass)
53+
5154
= 0.3.0 =
5255
* Bulk edit access. Props [@marcochiesi](https://github.com/marcochiesi)
5356
* Filterable post types. Props [@marcochiesi](https://github.com/marcochiesi)

tests/test-core.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,4 +362,42 @@ public function testPageEditByNonWhitelistedEditorUser() {
362362

363363
$this->assertTrue( ! ( current_user_can( 'edit_page', $page_id ) && current_user_can( 'publish_posts' ) && current_user_can( 'edit_others_posts' ) ) );
364364
}
365+
366+
/**
367+
* Test an edit of a role restricted post by a logged out user
368+
*
369+
* @since 0.3.1
370+
*/
371+
public function testLoggedOutUserRoleAccess() {
372+
wp_set_current_user( 0 );
373+
374+
$page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
375+
376+
$this->_configureAccess( $page_id, 'roles', array( 'editor' ) );
377+
378+
$_POST['post_ID'] = $page_id;
379+
$_GET['post'] = $page_id;
380+
381+
$this->assertTrue( ! current_user_can( 'edit_page', $page_id ) );
382+
}
383+
384+
/**
385+
* Test an edit of a user restricted post by a logged out user
386+
*
387+
* @since 0.3.1
388+
*/
389+
public function testLoggedOutUserUserAccess() {
390+
$page_id = $this->factory->post->create( array( 'post_type' => 'page' ) );
391+
392+
$user = $this->_createAndSignInUser( 'author' );
393+
394+
$this->_configureAccess( $page_id, 'users', array(), array( $user->ID ) );
395+
396+
wp_set_current_user( 0 );
397+
398+
$_POST['post_ID'] = $page_id;
399+
$_GET['post'] = $page_id;
400+
401+
$this->assertTrue( ! current_user_can( 'edit_page', $page_id ) );
402+
}
365403
}

0 commit comments

Comments
 (0)