WordPress.org

Plugin Directory

Changeset 592692


Ignore:
Timestamp:
08/30/12 22:51:08 (5 years ago)
Author:
brandon.wamboldt
Message:

Version 3.1.4, added not/or keywords to the role attribute of the members shortcode

Location:
wordpress-access-control
Files:
4 edited
4 copied

Legend:

Unmodified
Added
Removed
  • wordpress-access-control/trunk/documentation/assets/css/readme.css

    r393051 r592692  
    4545h2 { 
    4646font-size:16px; 
    47 border-bottom:1px solid #dadada;     
    48 color:#666;  
     47border-bottom:1px solid #dadada; 
     48color:#666; 
    4949font-weight: 100; 
    50 padding:0 0 4px;     
     50padding:0 0 4px; 
    5151} 
    5252 
     
    227227padding:.3em .6em; 
    228228} 
     229 
     230pre { 
     231    border-left: 5px solid #bbb; 
     232    font-size: 12px; 
     233    margin: 0 0 30px; 
     234    padding: 2px 0 2px 15px; 
     235} 
     236code, pre, tt { 
     237    font-family: Monaco,Consolas,"Lucida Console",monospace; 
     238    font-size: 12px; 
     239    font-style: normal; 
     240    line-height: 18px; 
     241} 
     242xmp, pre, plaintext { 
     243    display: block; 
     244    margin: 1em 0; 
     245    white-space: pre; 
     246} 
  • wordpress-access-control/trunk/documentation/index.html

    r592643 r592692  
    216216 
    217217    <p> 
    218         There are two shortcodes available for use with this plugin.<br /><br /> 
    219  
     218        There are two shortcodes available for use with this plugin. 
     219    </p> 
     220 
     221    <h2>A) members - <a href="#toc">top</a></h2> 
     222 
     223    <p> 
    220224        [members][/members] will hide the content within them unless the user is 
    221225        authenticated. Also works during searching, so that if a user searches for 
    222226        a term found in the shortcodes, but is not logged in, the page/post will 
    223         not show up in the results. This shortcode also has an option to specify 
    224         a specific role, using the syntax [members role="rolename"][/members]. 
    225     </p> 
     227        not show up in the results. 
     228    </p> 
     229 
     230    <p> 
     231        <strong>role attribute</strong><br /> 
     232        This shortcode also has an option to specify a specific role, using the following 
     233        syntax: 
     234    </p> 
     235 
     236    <pre>[members role="rolename"][/members]</pre> 
     237 
     238    <p> 
     239        If you want to specify a list of roles that are able to view the content, the syntax uses the or keyword: 
     240    </p> 
     241 
     242    <pre>[members role="or:author,contributor,editor"]</pre> 
     243 
     244    <p> 
     245        You can also specify a single role or multiple roles that cannot see it: 
     246    </p> 
     247 
     248    <pre>[members role="not:guest"]</pre> 
     249 
     250    <h2>A) nonmembers - <a href="#toc">top</a></h2> 
    226251 
    227252    <p> 
     
    289314 
    290315    <h1 id="changelog">I) Changelog - <a href="#toc">top</a></h1> 
     316 
     317    <p><strong>Version 3.1.4 - August 30, 2012</strong></p> 
     318 
     319    <ul> 
     320        <li>Added not/or keywords to the role option of the members shortcode, syntax: [members role="not:guest,banned"][/members] and [members role="or:editor,author,contributor"] (Thanks to <a href="https://twitter.com/damphlett">Dave Amphlett</a> for the idea)</li> 
     321    </ul> 
    291322 
    292323    <p><strong>Version 3.1.3 - August 30, 2012</strong></p> 
  • wordpress-access-control/trunk/readme.txt

    r592643 r592692  
    55Requires at least: 2.9 
    66Tested up to: 3.3 
    7 Stable tag: 3.1.3 
     7Stable tag: 3.1.4 
    88 
    99Restrict pages, posts, custom post types, menus and widgets to members, nonmembers or specific roles and still add to navigation 
     
    6060 
    6161== Changelog == 
     62 
     63= 3.1.4 - August 30, 2012 = 
     64 
     65* Added not/or keywords to the role option of the members shortcode, syntax: [members role="not:guest,banned"][/members] and [members role="or:editor,author,contributor"] (Thanks to Dave Amphlett for the idea) 
    6266 
    6367= 3.1.3 - August 30, 2012 = 
  • wordpress-access-control/trunk/wordpress-access-control.php

    r592643 r592692  
    55 * Author: Brandon Wamboldt 
    66 * Author URI: http://brandonwamboldt.ca/ 
    7  * Version: 3.1.3 
     7 * Version: 3.1.4 
    88 * Description: This plugin is a powerful tool which gives you fine grained control over your pages and posts (and custom post types), allowing you to restrict a page, post, or custom post type to members, non-members, or even specific roles. You can customize how these pages and posts show up in search results, where users are directed when they visit them, and much more. <strong>You can even make your entire blog members only!</strong>. 
    99 */ 
     
    836836        if ( is_user_logged_in() ) { 
    837837            if (isset($attributes['role'])) { 
    838                 if (!in_array($attributes['role'], $current_user->roles)) { 
    839                     return ''; 
     838 
     839                // Determine the syntax (Singular role, OR syntax or NOT syntax) 
     840                if (substr($attributes['role'], 0, 3) == 'or:') { 
     841                    $roles = explode(',', substr($attributes['role'], 3)); 
     842 
     843                    $has_a_role = false; 
     844 
     845                    foreach ($roles as $role) { 
     846                        if (in_array($role, $current_user->roles)) { 
     847                            $has_a_role = true; 
     848                            break; 
     849                        } 
     850                    } 
     851 
     852                    if (!$has_a_role) { 
     853                        return ''; 
     854                    } 
     855                } else if (substr($attributes['role'], 0, 4) == 'not:') { 
     856                    $roles = explode(',', substr($attributes['role'], 4)); 
     857 
     858                    foreach ($roles as $role) { 
     859                        if (in_array($role, $current_user->roles)) { 
     860                            return ''; 
     861                        } 
     862                    } 
     863                } else { 
     864                    if (!in_array($attributes['role'], $current_user->roles)) { 
     865                        return ''; 
     866                    } 
    840867                } 
    841868            } 
Note: See TracChangeset for help on using the changeset viewer.