Changeset 2228618
- Timestamp:
- 01/16/2020 04:56:08 PM (6 years ago)
- Location:
- vi-member-content/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
vi_member_content.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
vi-member-content/trunk/readme.txt
r2205433 r2228618 5 5 Requires at least: ? 6 6 Tested up to: 5.3 7 Version: 9.1. 1912037 Version: 9.1.200115 8 8 License: GPLv3 9 9 License URI: http://www.gnu.org/licenses/gpl.html … … 52 52 == Changelog == 53 53 54 = 9.1.200115 = 55 * Fixed bug: potential for empty string in foreach 56 * Edit: moved check if $content is null earlier to skip doing extra work 57 54 58 = 9.1.191203 = 55 59 * Fixed bug: missing parameter -
vi-member-content/trunk/vi_member_content.php
r2205421 r2228618 4 4 Plugin URI: https://neathawk.com/2019/plugin-member-content/ 5 5 Description: A collection of generic functions that separate content by visitor/member/ member of type 6 Version: 9.1. 1912036 Version: 9.1.200115 7 7 Author: Joseph Neathawk 8 8 Author URI: http://Neathawk.com … … 87 87 * 88 88 * @link 89 * @version 9.1. 102889 * @version 9.1.200115 90 90 * @since 0.1.181213 91 91 */ 92 92 public static function member_content( $attr, $content = null ) 93 93 { 94 95 extract( shortcode_atts( array( 'type' => 'read' ), $attr ) ); 96 //remove spaces 97 $type = str_replace(" ", "", $type); 98 $ability = explode(",", $type); 94 //default is no access 99 95 $access_allowed = false; 100 96 101 //not NULL and user is at least logged in 102 if ( !is_null( $content ) && is_user_logged_in() ) 97 if ( !is_null( $content ) ) 103 98 { 104 //targetted users get this content 105 foreach( $ability as $item ) 99 extract( shortcode_atts( array( 'type' => 'read' ), $attr ) ); 100 //remove spaces 101 $type = str_replace(" ", "", $type); 102 $ability = explode(",", $type); 103 104 //make absolutely sure $ability isn't empty 105 if( !is_array($ability) ) 106 106 { 107 if( strtolower($item) === 'any' ) 107 $ability[] = 'read'; 108 } 109 110 //not NULL and user is at least logged in 111 if ( is_user_logged_in() ) 112 { 113 //targetted users get this content 114 foreach( $ability as $item ) 108 115 { 109 //ACTION 110 $access_allowed = true; 111 } 112 else if( self::is_user_in_role( get_current_user_id(), $item ) || current_user_can( $item ) ) 113 { 114 //ACTION 115 $access_allowed = true; 116 if( strtolower($item) === 'any' ) 117 { 118 //ACTION 119 $access_allowed = true; 120 } 121 else if( self::is_user_in_role( get_current_user_id(), $item ) || current_user_can( $item ) ) 122 { 123 //ACTION 124 $access_allowed = true; 125 } 116 126 } 117 127 }
Note: See TracChangeset
for help on using the changeset viewer.