Members - Version 0.2.5

Version Description

Download this release

Release Info

Developer greenshady
Plugin Icon 128x128 Members
Version 0.2.5
Comparing to
See all releases

Code changes from version 0.2.4 to 0.2.5

admin/settings.php CHANGED
@@ -73,35 +73,35 @@ function members_settings_page_load_meta_boxes() {
73
  *
74
  * @since 0.2.0
75
  */
76
- function members_validate_settings( $input ) {
77
 
78
  /* Check if the role manager is active. */
79
- $settings['role_manager'] = ( isset( $input['role_manager'] ) ? 1 : 0 );
80
 
81
  /* Check if the content permissions feature is active. */
82
- $settings['content_permissions'] = ( isset( $input['content_permissions'] ) ? 1 : 0 );
83
 
84
  /* Set the content permissions error text and kill evil scripts. */
85
- if ( current_user_can( 'unfiltered_html' ) && isset( $input['content_permissions_error'] ) )
86
- $settings['content_permissions_error'] = stripslashes( wp_filter_post_kses( addslashes( $input['content_permissions_error'] ) ) );
87
 
88
- elseif ( isset( $input['content_permissions_error'] ) )
89
- $settings['content_permissions_error'] = $input['content_permissions_error'];
90
 
91
  /* Check if the login form and users widgets are active. */
92
- $settings['login_form_widget'] = ( isset( $input['login_form_widget'] ) ? 1 : 0 );
93
- $settings['users_widget'] = ( isset( $input['users_widget'] ) ? 1 : 0 );
94
 
95
  /* Check if the private blog and private feed features are active. */
96
- $settings['private_blog'] = ( isset( $input['private_blog'] ) ? 1 : 0 );
97
- $settings['private_feed'] = ( isset( $input['private_feed'] ) ? 1 : 0 );
98
 
99
  /* Set the private feed error text and kill evil scripts. */
100
- if ( current_user_can( 'unfiltered_html' ) && isset( $input['private_feed_error'] ) )
101
- $settings['private_feed_error'] = stripslashes( wp_filter_post_kses( addslashes( $input['private_feed_error'] ) ) );
102
 
103
- elseif ( isset( $input['private_feed_error'] ) )
104
- $settings['private_feed_error'] = $input['private_feed_error'];
105
 
106
  /* Return the validated/sanitized settings. */
107
  return $settings;
73
  *
74
  * @since 0.2.0
75
  */
76
+ function members_validate_settings( $settings ) {
77
 
78
  /* Check if the role manager is active. */
79
+ $settings['role_manager'] = ( isset( $settings['role_manager'] ) ? 1 : 0 );
80
 
81
  /* Check if the content permissions feature is active. */
82
+ $settings['content_permissions'] = ( isset( $settings['content_permissions'] ) ? 1 : 0 );
83
 
84
  /* Set the content permissions error text and kill evil scripts. */
85
+ if ( current_user_can( 'unfiltered_html' ) && isset( $settings['content_permissions_error'] ) )
86
+ $settings['content_permissions_error'] = stripslashes( wp_filter_post_kses( addslashes( $settings['content_permissions_error'] ) ) );
87
 
88
+ elseif ( isset( $settings['content_permissions_error'] ) )
89
+ $settings['content_permissions_error'] = $settings['content_permissions_error'];
90
 
91
  /* Check if the login form and users widgets are active. */
92
+ $settings['login_form_widget'] = ( isset( $settings['login_form_widget'] ) ? 1 : 0 );
93
+ $settings['users_widget'] = ( isset( $settings['users_widget'] ) ? 1 : 0 );
94
 
95
  /* Check if the private blog and private feed features are active. */
96
+ $settings['private_blog'] = ( isset( $settings['private_blog'] ) ? 1 : 0 );
97
+ $settings['private_feed'] = ( isset( $settings['private_feed'] ) ? 1 : 0 );
98
 
99
  /* Set the private feed error text and kill evil scripts. */
100
+ if ( current_user_can( 'unfiltered_html' ) && isset( $settings['private_feed_error'] ) )
101
+ $settings['private_feed_error'] = stripslashes( wp_filter_post_kses( addslashes( $settings['private_feed_error'] ) ) );
102
 
103
+ elseif ( isset( $settings['private_feed_error'] ) )
104
+ $settings['private_feed_error'] = $settings['private_feed_error'];
105
 
106
  /* Return the validated/sanitized settings. */
107
  return $settings;
components/content-permissions/comments.php DELETED
@@ -1 +0,0 @@
1
- <?php /* Life is sweet. */ ?>
 
components/content-permissions/content-permissions.php DELETED
@@ -1,112 +0,0 @@
1
- <?php
2
- /**
3
- * The Content Permissions component was created so that access to specific parts of a site
4
- * can be granted or denied. This is the component that gives truly fine-grained control over
5
- * who can see what content on the front end of the site.
6
- *
7
- * Current features of the Content Permissions component:
8
- * - Block content on a post-by-post (or page) basis according to user role.
9
- *
10
- * This feature set should eventually include the ability to block access to taxonomies and
11
- * attachments to be truly useful.
12
- *
13
- * @todo Check and test feeds and filter if necessary.
14
- * @todo Make sure comments aren't shown anywhere.
15
- * @todo Remove pages from wp_list_pages() and wp_page_menu().
16
- * @todo Cover ALL the bases. If something's restricted, make sure it stays that way.
17
- *
18
- * @package Members
19
- * @subpackage Components
20
- */
21
-
22
- /**
23
- * Adds the content permissions meta box to the post/page edit screen
24
- * if the current user has the 'restrict_content' capability.
25
- */
26
- add_action( 'admin_menu', 'members_content_permissions_create_meta_box' );
27
-
28
- /* Saves the content permissions metabox data to a custom field. */
29
- add_action( 'save_post', 'members_content_permissions_save_meta', 1, 2 );
30
-
31
- /* Add messages to the components form. */
32
- add_action( 'members_pre_components_form', 'members_message_no_restrict_content' );
33
-
34
- /* Filter the content and exerpts. */
35
- add_filter( 'the_content', 'members_content_permissions_protect' );
36
- add_filter( 'get_the_excerpt', 'members_content_permissions_protect' );
37
- add_filter( 'the_excerpt', 'members_content_permissions_protect' );
38
-
39
- /* Filter the comments template to make sure comments aren't shown to users without access. */
40
- add_filter( 'comments_template', 'members_content_permissions_comments' );
41
-
42
- /**
43
- * Disables the comments template if the current post has been restricted, unless
44
- * the user has the role needed to view the content of the post.
45
- *
46
- * @todo Allow users to override the "no comments" template if in their theme.
47
- *
48
- * @since 0.1
49
- * @param $template string File URL of the template to display.
50
- * @return $template string File URL of the template to display.
51
- */
52
- function members_content_permissions_comments( $template ) {
53
- global $wp_query;
54
-
55
- $roles = get_post_meta( $wp_query->post->ID, '_role', false );
56
-
57
- if ( !empty( $roles ) && is_array( $roles ) ) {
58
- foreach( $roles as $role ) {
59
- if ( !is_feed() && ( current_user_can( $role ) || current_user_can( 'restrict_content' ) ) )
60
- return $template;
61
- }
62
- $template = MEMBERS_COMPONENTS . '/content-permissions/comments.php';
63
- }
64
- return $template;
65
- }
66
-
67
- /**
68
- * Displays a message if the Content Permissions component is active but no role
69
- * has been given the capability of 'restrict_content', which is a required capability to
70
- * use the component.
71
- *
72
- * @since 0.1
73
- * @uses is_active_members_component() Checks if the content_permissions component is active.
74
- * @uses members_check_form_cap() Checks if the restrict_content capability has been given to a role.
75
- */
76
- function members_message_no_restrict_content() {
77
- if ( is_active_members_component( 'content_permissions' ) && !members_check_for_cap( 'restrict_content' ) ) {
78
- $message = __('No role currently has the <code>restrict_content</code> capability. To use the <em>Content Permissions</em> component, at least one role must have this capability.', 'members');
79
- members_admin_message( '', $message );
80
- }
81
- }
82
-
83
- /**
84
- * Disables content passed through the $content variable given the current user's role. The
85
- * function checks for a custom field key of "Role" and loops through its values, checking
86
- * if the current user has that particular role.
87
- *
88
- * Users with the rescrict_content capability should also be able to see the content.
89
- *
90
- * @since 0.1
91
- * @uses get_post_meta() Gets the meta values of the "_role" custom field key.
92
- * @uses current_user_can() Checks if the current user has a particular role (capability).
93
- * @param $content string The current post's content/excerpt.
94
- * @return $content string Either the current post's content/excerpt or a content inaccessible message.
95
- */
96
- function members_content_permissions_protect( $content ) {
97
- global $post;
98
-
99
- $roles = get_post_meta( $post->ID, '_role', false );
100
-
101
- if ( !empty( $roles ) && is_array( $roles ) ) {
102
- foreach( $roles as $role ) {
103
- if ( !is_feed() && ( current_user_can( $role ) || current_user_can( 'restrict_content' ) ) )
104
- return $content;
105
- }
106
- $content = '<p class="restricted alert warning">' . __('Sorry, but you do not have permission to view this content.', 'members') . '</p>';
107
- }
108
-
109
- return $content;
110
- }
111
-
112
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/content-permissions/meta-box.php DELETED
@@ -1,116 +0,0 @@
1
- <?php
2
- /**
3
- * Adds the meta box for the Content Permissions component. This allows users with
4
- * the 'restrict_content' capability to restrict posts/pages on a post/page basis. Roles
5
- * with the 'restrict_content' capability should be able to see all content, regardless
6
- * of the settings.
7
- *
8
- * @package Members
9
- * @subpackage Components
10
- */
11
-
12
- /**
13
- * Adds the meta box to the post/page edit screen if the current user has
14
- * the 'restrict_content' capability.
15
- *
16
- * @since 0.1
17
- * @uses add_meta_box() Creates an additiona meta box.
18
- */
19
- function members_content_permissions_create_meta_box() {
20
- if ( current_user_can( 'restrict_content' ) ) {
21
- add_meta_box( 'content-permissions-meta-box', 'Content Permissions', 'members_content_permissions_meta_box', 'post', 'advanced', 'high' );
22
- add_meta_box( 'content-permissions-meta-box', 'Content Permissions', 'members_content_permissions_meta_box', 'page', 'advanced', 'high' );
23
- }
24
- }
25
-
26
- /**
27
- * Controls the display of the content permissions meta box. This allows users
28
- * to select roles that should have access to an individual post/page.
29
- *
30
- * @since 0.1
31
- * @global $post
32
- * @global $wp_roles
33
- * @param $object
34
- * @param $box
35
- */
36
- function members_content_permissions_meta_box( $object, $box ) {
37
- global $post, $wp_roles; ?>
38
-
39
- <input type="hidden" name="content_permissions_meta_nonce" value="<?php echo wp_create_nonce(plugin_basename(__FILE__)); ?>" />
40
-
41
- <p>
42
- <label for="roles"><?php _e('<strong>Roles:</strong> Restrict the content to these roles on the front end of the site. If all boxes are left unchecked, everyone can view the content.', 'members'); ?></label>
43
- </p>
44
-
45
- <div style="overflow: hidden;">
46
-
47
- <?php
48
-
49
- /* Get the 'Role' meta key. */
50
- $meta = get_post_meta( $post->ID, '_role', false );
51
-
52
- /* Loop through each of the available roles. */
53
- foreach ( $wp_roles->role_names as $role => $name ) {
54
- $checked = false;
55
-
56
- /* If the role has been selected, make sure it's checked. */
57
- if ( is_array( $meta ) && in_array( $role, $meta ) )
58
- $checked = ' checked="checked" '; ?>
59
-
60
- <p style="width: 32%; float: left; margin-right: 0;">
61
- <label for="role-<?php echo $role; ?>">
62
- <input type="checkbox" name="role[<?php echo $role; ?>]" id="role-<?php echo $role; ?>" <?php echo $checked; ?> value="<?php echo $role; ?>" />
63
- <?php echo str_replace( '|User role', '', $name ); ?>
64
- </label>
65
- </p>
66
- <?php } ?>
67
-
68
- </div><?php
69
- }
70
-
71
- /**
72
- * Saves the content permissions metabox data to a custom field.
73
- *
74
- * @since 0.1
75
- */
76
- function members_content_permissions_save_meta( $post_id, $post ) {
77
- global $wp_roles;
78
-
79
- /* Only allow users that can edit the current post to submit data. */
80
- if ( 'post' == $post->post_type && !current_user_can( 'edit_posts', $post_id ) )
81
- return;
82
-
83
- /* Only allow users that can edit the current page to submit data. */
84
- elseif ( 'page' == $post->post_type && !current_user_can( 'edit_pages', $post_id ) )
85
- return;
86
-
87
- /* Don't save if the post is only a revision. */
88
- if ( 'revision' == $post->post_type )
89
- return;
90
-
91
- /* Loop through each of the site's available roles. */
92
- foreach ( $wp_roles->role_names as $role => $name ) {
93
-
94
- /* Get post metadata for the custom field key 'Role'. */
95
- $meta = (array)get_post_meta( $post_id, '_role', false );
96
-
97
- /* Check if the role was selected. */
98
- if ( $_POST['role'][$role] ) {
99
-
100
- /* If selected and already saved, continue looping through the roles and do nothing for this role. */
101
- if ( in_array( $role, $meta ) )
102
- continue;
103
-
104
- /* If the role was seleted and not already saved, add the role as a new value to the 'Role' custom field. */
105
- else
106
- $add = add_post_meta( $post_id, '_role', $role, false );
107
- }
108
-
109
- /* If role not selected, delete. */
110
- else
111
- $delete = delete_post_meta( $post_id, '_role', $role );
112
-
113
- } // End loop through site's roles.
114
- }
115
-
116
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/private-blog/default.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
- /**
3
- * The Private Blog component is for making your site completely private to people that are
4
- * not logged into the site. If not logged in, it will redirect all people to the 'wp-login.php' page.
5
- *
6
- * @todo Make sure 'blog_public' is set to true.
7
- * @todo Disable content from feeds or add an additional feed component.
8
- *
9
- * @package Members
10
- * @subpackage Components
11
- */
12
-
13
- /* Redirects users to the login page. */
14
- add_action( 'template_redirect', 'members_please_log_in' );
15
-
16
- /**
17
- * Redirects users that are not logged in to the 'wp-login.php' page.
18
- *
19
- * @since 0.1
20
- * @uses is_user_logged_in() Checks if the current user is logged in.
21
- * @uses auth_redirect() Redirects people that are not logged in to the login page.
22
- */
23
- function members_please_log_in() {
24
- if ( !is_user_logged_in() && !strpos( $_SERVER['SCRIPT_NAME'], 'wp-login.php' ) )
25
- auth_redirect();
26
- }
27
-
28
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/role-manager/default.php DELETED
@@ -1,121 +0,0 @@
1
- <?php
2
- /**
3
- * The Role Manager component allows users to create, edit, and delete roles for use on
4
- * their site.
5
- *
6
- * @package Members
7
- * @subpackage Components
8
- */
9
-
10
- /* Add the Edit Roles and New Roles page to the admin. */
11
- add_action( 'admin_menu', 'members_component_load_role_manager' );
12
-
13
- /* Add message when no role has the 'create_roles' capability. */
14
- add_action( 'members_pre_components_form', 'members_message_no_create_roles' );
15
- add_action( 'members_pre_new_role_form', 'members_message_no_create_roles' );
16
-
17
- /* Actions added by the Edit Roles component. */
18
- add_action( 'members_pre_components_form', 'members_message_no_edit_roles' );
19
- add_action( 'members_pre_edit_role_form', 'members_message_no_edit_roles' );
20
- add_action( 'members_pre_edit_roles_form', 'members_message_no_edit_roles' );
21
-
22
- /**
23
- * Loads the settings pages for the Roles and New Roles components. For a logged-in
24
- * user to see the New Roles page, they must have the 'create_roles' capability.
25
- * In order to gain this capability, one should edit a role to give it this capability
26
- *
27
- * @since 0.2
28
- * @global $members
29
- * @uses add_submenu_page() Adds a submenu to the users menu.
30
- */
31
- function members_component_load_role_manager() {
32
- global $members;
33
-
34
- /* Capability to manage roles. Users need to change this on initial setup by giving at least one role the 'edit_roles' capability. */
35
- if ( members_check_for_cap( 'edit_roles' ) )
36
- $edit_roles_cap = 'edit_roles';
37
- else
38
- $edit_roles_cap = 'edit_users';
39
-
40
- /* Create the Manage Roles page. */
41
- $members->edit_roles_page = add_submenu_page( 'users.php', __('Roles', 'members'), __('Roles', 'members'), $edit_roles_cap, 'roles', 'members_edit_roles_page' );
42
-
43
- /* Create the New Role page. */
44
- $members->new_roles_page = add_submenu_page( 'users.php', __('New Role', 'members'), __('New Role', 'members'), 'create_roles', 'new-role', 'members_new_role_page' );
45
- }
46
-
47
- /**
48
- * Loads the Manage Roles page.
49
- * @since 0.1
50
- */
51
- function members_edit_roles_page() {
52
- require_once( MEMBERS_COMPONENTS . '/role-manager/manage-roles.php' );
53
- }
54
-
55
- /**
56
- * Loads the New Role page when its needed.
57
- *
58
- * @since 0.1
59
- */
60
- function members_new_role_page() {
61
- require_once( MEMBERS_COMPONENTS . '/role-manager/new-role.php' );
62
- }
63
-
64
- /**
65
- * Returns an array of capabilities that should be set on the New Role admin screen.
66
- * By default, the only capability checked is 'read' because it's fairly common.
67
- *
68
- * @since 0.1
69
- * @return $capabilities array Default capabilities for new roles.
70
- */
71
- function members_new_role_default_capabilities() {
72
-
73
- $capabilities = array( 'read' );
74
-
75
- /* Filters should return an array. */
76
- return apply_filters( 'members_new_role_default_capabilities', $capabilities );
77
- }
78
-
79
- /**
80
- * Message to show when a single role has been deleted.
81
- * @since 0.1
82
- */
83
- function members_message_role_deleted() {
84
- $message = __('Role deleted.', 'members');
85
- members_admin_message( '', $message );
86
- }
87
-
88
- /**
89
- * Message to show when multiple roles have been deleted (bulk delete).
90
- * @since 0.1
91
- */
92
- function members_message_roles_deleted() {
93
- $message = __('Selected roles deleted.', 'members');
94
- members_admin_message( '', $message );
95
- }
96
-
97
- /**
98
- * Message to show when no role has the 'edit_roles' capability.
99
- * @since 0.1
100
- */
101
- function members_message_no_edit_roles() {
102
- if ( is_active_members_component( 'edit_roles' ) && !members_check_for_cap( 'edit_roles' ) ) {
103
- $message = __('No role currently has the <code>edit_roles</code> capability. Please add this to each role that should be able to manage/edit roles. If you do not change this, any user that has the <code>edit_users</code> capability will be able to edit roles.', 'members');
104
- members_admin_message( '', $message );
105
- }
106
- }
107
-
108
- /**
109
- * Displays a message if the New Roles component is active and no
110
- * roles have the 'create_roles' capability.
111
- *
112
- * @since 0.1
113
- */
114
- function members_message_no_create_roles() {
115
- if ( is_active_members_component( 'new_roles' ) && !members_check_for_cap( 'create_roles' ) ) {
116
- $message = __('To create new roles, you must give the <code>create_roles</code> capability to at least one role.', 'members');
117
- members_admin_message( '', $message );
118
- }
119
- }
120
-
121
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/role-manager/edit-role-form.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * The Edit Role form is for editing individual roles. The role to edit must
4
- * have been selected on the Edit Roles page.
5
- *
6
- * @package Members
7
- * @subpackage Components
8
- */
9
-
10
- /* Get the current role object to edit. */
11
- $role = get_role( $role );
12
-
13
- /* Get all the capabilities */
14
- $capabilities = members_get_capabilities();
15
-
16
- /* Check if the form has been submitted. */
17
- if ( isset($_POST['edit-role-saved']) && 'Y' == $_POST['edit-role-saved'] ) {
18
-
19
- /* Verify the nonce. */
20
- check_admin_referer( members_get_nonce( 'edit-roles' ) );
21
-
22
- /* Set the $role_updated variable to true. */
23
- $role_updated = true;
24
-
25
- /* Loop through all available capabilities. */
26
- foreach ( $capabilities as $cap ) {
27
-
28
- /* Get the posted capability. */
29
- $posted_cap = isset($_POST['role-caps']["{$role->name}-{$cap}"]) ? $_POST['role-caps']["{$role->name}-{$cap}"] : false;
30
-
31
- /* If the role doesn't have the capability and it was selected, add it. */
32
- if ( !$role->has_cap( $cap ) && $posted_cap )
33
- $role->add_cap( $cap );
34
-
35
- /* If the role has the capability and it wasn't selected, remove it. */
36
- elseif ( $role->has_cap( $cap ) && !$posted_cap )
37
- $role->remove_cap( $cap );
38
-
39
- } // End loop through existing capabilities
40
-
41
- /* If new caps were added and are in an array, we need to add them. */
42
- if ( !empty( $_POST['new-cap'] ) && is_array( $_POST['new-cap'] ) ) {
43
-
44
- /* Loop through each new capability from the edit roles form. */
45
- foreach ( $_POST['new-cap'] as $new_cap ) {
46
-
47
- /* Sanitize the new capability to remove any unwanted characters. */
48
- $new_cap = strip_tags( $new_cap );
49
- $new_cap = str_replace( array( '-', ' ', '&nbsp;' ) , '_', $new_cap );
50
- $new_cap = preg_replace('/[^A-Za-z0-9_]/', '', $new_cap );
51
- $new_cap = strtolower( $new_cap );
52
-
53
- /* Run one more check to make sure the new capability exists. Add the cap to the role. */
54
- if ( $new_cap && !$role->has_cap( $new_cap ) )
55
- $role->add_cap( $new_cap );
56
-
57
- } // End loop through new capabilities
58
-
59
- } // End check for new capabilities
60
-
61
- } // End check for form submission ?>
62
-
63
- <div class="wrap">
64
-
65
- <h2><?php printf(__('Edit the %1$s role', 'members'), $role->name ); ?></h2>
66
-
67
- <?php if ( isset($role_updated) and $role_updated ) members_admin_message( '', __('Role updated.', 'members') ); ?>
68
-
69
- <?php do_action( 'members_pre_edit_role_form' ); //Available pre-form hook for displaying messages. ?>
70
-
71
- <div id="poststuff">
72
-
73
- <form name="form0" method="post" action="<?php echo admin_url( esc_url( "users.php?page=roles&amp;action=edit&amp;role={$role->name}" ) ); ?>" style="border:none;background:transparent;">
74
-
75
- <?php wp_nonce_field( members_get_nonce( 'edit-roles' ) ); ?>
76
-
77
- <div class="postbox open">
78
-
79
- <h3><?php printf( __('<strong>Role:</strong> %1$s', 'members'), $role->name ); ?></h3>
80
-
81
- <div class="inside">
82
-
83
- <table class="form-table">
84
-
85
- <tr>
86
- <th style="width: 20%;">
87
- <strong><?php _e('Capabilities', 'members'); ?></strong>
88
- </th>
89
-
90
- <td>
91
- <?php _e('Select which capabilities this role should have. Make sure you understand what the capability does before giving it to just any role. This is a powerful feature, but it can cause you some grief if you give regular ol\' Joe more capabilities than yourself.', 'members'); ?>
92
- <br /><br />
93
- <?php
94
-
95
- /* Looop through each available capability. */
96
- foreach ( $capabilities as $cap ) {
97
-
98
- /* If the role has the capability, set the checkbox to 'checked'. */
99
- if ( $role->has_cap( $cap ) )
100
- $checked = " checked='checked' ";
101
-
102
- /* If the role doesn't have the the capability, set the checkbox value to false. */
103
- else
104
- $checked = ''; ?>
105
-
106
- <div style='overflow: hidden; margin: 0 0 5px 0; float:left; width: 32.67%;'>
107
- <input name='<?php echo "role-caps[{$role->name}-{$cap}]"; ?>' id='<?php echo "{$role->name}-{$cap}"; ?>' <?php echo $checked; ?> type='checkbox' value='true' />
108
- <label for="<?php echo "{$role->name}-{$cap}"; ?>"><?php if ( $checked ) echo "<strong>$cap</strong>"; else echo "<em>$cap</em>"; ?></label>
109
- </div>
110
-
111
- <?php } // Endforeach ?>
112
- </td>
113
- </tr>
114
-
115
- <tr>
116
- <th style="width: 20%;">
117
- <strong><?php _e('New Capabilities', 'members'); ?></strong>
118
- </th>
119
-
120
- <td>
121
- <?php _e('Add up to six new capabilities with this form for this role (more can be added later). Please only use letters, numbers, and underscores.', 'members'); ?>
122
- <br /><br />
123
- <p style="margin: 0 0 5px 0; float:left; width: 32.67%;">
124
- <input type="text" id="new-cap-1" name="new-cap[]" value="" size="20" />
125
- </p>
126
- <p style="margin: 0 0 5px 0; float:left; width: 32.67%;">
127
- <input type="text" id="new-cap-2" name="new-cap[]" value="" size="20" />
128
- </p>
129
- <p style="margin: 0 0 5px 0; float:left; width: 32.67%;">
130
- <input type="text" id="new-cap-3" name="new-cap[]" value="" size="20" />
131
- </p>
132
- <p style="margin: 0 0 5px 0; float:left; width: 32.67%;">
133
- <input type="text" id="new-cap-4" name="new-cap[]" value="" size="20" />
134
- </p>
135
- <p style="margin: 0 0 5px 0; float:left; width: 32.67%;">
136
- <input type="text" id="new-cap-5" name="new-cap[]" value="" size="20" />
137
- </p>
138
- <p style="margin: 0 0 5px 0; float:left; width: 32.67%;">
139
- <input type="text" id="new-cap-6" name="new-cap[]" value="" size="20" />
140
- </p>
141
-
142
- </td>
143
- </tr>
144
-
145
- </table><!-- .form-table -->
146
-
147
- </div><!-- .inside -->
148
-
149
- </div><!-- .postbox .open -->
150
-
151
- <p class="submit" style="clear:both;">
152
- <input type="submit" name="Submit" class="button-primary" value="<?php _e('Update Role', 'members') ?>" />
153
- <input type="hidden" name="edit-role-saved" value="Y" />
154
- </p><!-- .submit -->
155
-
156
- </form>
157
-
158
- </div><!-- #poststuff -->
159
-
160
- </div><!-- .wrap -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/role-manager/edit-roles.php DELETED
@@ -1,253 +0,0 @@
1
- <?php
2
- /**
3
- * The Edit Roles page displays all of the site's roles in an easy-to-read manner. Along with
4
- * each role, the number of users and capabilities are displayed. Roles without users are
5
- * considered "inactive" roles within this plugin's system.
6
- *
7
- * All roles can be edited. However, the current user's role and the default role cannot be
8
- * deleted. To delete the current user's role, another logged-in user with the 'delete_roles'
9
- * capability and a different role must perform this action. To delete the default role, the
10
- * default must be changed under the General Options page in the WordPress admin.
11
- *
12
- * Users of roles that are deleted will be given the default role (typically 'Subscriber'). It
13
- * is advisable to not make such a change with a large number of users because a new user
14
- * object must be created to change each individual user.
15
- *
16
- * @todo Test deleting a role with 100s (even 1,000s) of users to see what sort of strain this has.
17
- *
18
- * @package Members
19
- * @subpackage Components
20
- */
21
-
22
- /* Get the global $members variable. */
23
- global $members;
24
-
25
- /* Current user in the admin. */
26
- $user = new WP_User( $members->current_user->ID );
27
-
28
- /* Set the available roles array.*/
29
- $avail_roles = array();
30
-
31
- /* Get all the users of the current blog. */
32
- $users_of_blog = get_users_of_blog();
33
-
34
- /* Loop through each user. */
35
- foreach ( (array) $users_of_blog as $blog_user ) {
36
-
37
- $meta_values = unserialize( $blog_user->meta_value );
38
-
39
- foreach ( (array) $meta_values as $role => $value ) {
40
- if ( !isset( $avail_roles[$role] ) )
41
- $avail_roles[$role] = 0;
42
-
43
- ++$avail_roles[$role];
44
- }
45
- }
46
-
47
- /* Destroy the $users_of_blog variable. */
48
- unset( $users_of_blog );
49
-
50
- /* Can the current user delete_roles? */
51
- if ( current_user_can( 'delete_roles' ) )
52
- $delete_roles = true;
53
-
54
- /* Get the default role. */
55
- $default_role = get_option( 'default_role' );
56
-
57
- /* Sort out the roles, active roles, and inactive roles. */
58
- $all_roles = $active_roles = $inactive_roles = 0;
59
-
60
- $active_roles_arr = $inactive_roles_arr = array();
61
-
62
- /* Loop through all of the roles, adding each role to its respective category (active, inactive). */
63
- foreach ( $wp_roles->role_names as $role => $name ) {
64
- $all_roles++;
65
- if ( isset($avail_roles[$role]) ) {
66
- $active_roles++;
67
- $active_roles_arr[$role] = $name;
68
- }
69
- else {
70
- $inactive_roles++;
71
- $inactive_roles_arr[$role] = $name;
72
- }
73
- }
74
-
75
- $role_status = isset( $_GET['role_status'] ) ? $_GET['role_status'] : 'all';
76
-
77
- /* Set variables for when role_status is active. */
78
- if ( 'active' == $role_status ) {
79
- $roles_loop_array = $active_roles_arr;
80
- $title = __('Edit Active Roles', 'members');
81
- $current_page = admin_url( esc_url( 'users.php?page=roles&role_status=active' ) );
82
- }
83
-
84
- /* Set variables for when role_status is inactive. */
85
- elseif ( 'inactive' == $role_status ) {
86
- $roles_loop_array = $inactive_roles_arr;
87
- $title = __('Edit Inactive Roles', 'members');
88
- $current_page = admin_url( esc_url( 'users.php?page=roles&role_status=inactive' ) );
89
- }
90
-
91
- /* Set default variables for when role_status is neither active nor inactive. */
92
- else {
93
- $roles_loop_array = $wp_roles->role_names;
94
- $title = __('Edit Roles', 'members');
95
- $current_page = admin_url( esc_url( "users.php?page=roles" ) );
96
- }
97
-
98
- /* Sort the roles array into alphabetical order. */
99
- ksort( $roles_loop_array ); ?>
100
-
101
- <div class="wrap">
102
-
103
- <h2><?php echo $title; ?></h2>
104
-
105
- <?php do_action( 'members_pre_edit_roles_form' ); // Available action hook for displaying messages. ?>
106
-
107
- <div id="poststuff">
108
-
109
- <form id="roles" action="<?php echo $current_page; ?>" method="post">
110
-
111
- <?php wp_nonce_field( members_get_nonce( 'edit-roles' ) ); ?>
112
-
113
- <ul class="subsubsub">
114
- <li><a <?php if ( 'all' == $role_status ) echo 'class="current"'; ?> href="<?php echo admin_url( esc_url( 'users.php?page=roles' ) ); ?>"><?php _e('All', 'members'); ?> <span class="count">(<span id="all_count"><?php echo $all_roles; ?></span>)</span></a> | </li>
115
- <li><a <?php if ( 'active' == $role_status ) echo 'class="current"'; ?> href="<?php echo admin_url( esc_url( 'users.php?page=roles&amp;role_status=active' ) ); ?>"><?php _e('Active', 'members'); ?> <span class="count">(<span id="active_count"><?php echo $active_roles; ?></span>)</span></a> | </li>
116
- <li><a <?php if ( 'inactive' == $role_status ) echo 'class="current"'; ?> href="<?php echo admin_url( esc_url( 'users.php?page=roles&amp;role_status=inactive' ) ); ?>"><?php _e('Inactive', 'members'); ?> <span class="count">(<span id="inactive_count"><?php echo $inactive_roles; ?></span>)</span></a></li>
117
- </ul><!-- .subsubsub -->
118
-
119
- <div class="tablenav">
120
-
121
- <div class="alignleft actions">
122
- <select name="action">
123
- <option value="" selected="selected"><?php _e('Bulk Actions', 'members'); ?></option>
124
- <?php if ( $delete_roles ) echo '<option value="delete">' . __('Delete', 'members') . '</option>'; ?>
125
- </select>
126
- <input type="submit" value="<?php _e('Apply', 'members'); ?>" name="doaction" id="doaction" class="button-secondary action" />
127
- </div><!-- .alignleft .actions -->
128
-
129
- <br class="clear" />
130
-
131
- </div><!-- .tablenav -->
132
-
133
- <table class="widefat fixed" cellspacing="0">
134
- <thead>
135
- <tr>
136
- <th class='check-column'><input type='checkbox' /></th>
137
- <th class='name-column'><?php _e('Role Name', 'members'); ?></th>
138
- <th><?php _e('Role', 'members'); ?></th>
139
- <th><?php _e('Users', 'members'); ?></th>
140
- <th><?php _e('Capabilities', 'members'); ?></th>
141
- </tr>
142
- </thead>
143
-
144
- <tfoot>
145
- <tr>
146
- <th class='check-column'><input type='checkbox' /></th>
147
- <th class='name-column'><?php _e('Role Name', 'members'); ?></th>
148
- <th><?php _e('Role', 'members'); ?></th>
149
- <th><?php _e('Users', 'members'); ?></th>
150
- <th><?php _e('Capabilities', 'members'); ?></th>
151
- </tr>
152
- </tfoot>
153
-
154
- <tbody id="users" class="list:user user-list plugins">
155
-
156
- <?php foreach ( $roles_loop_array as $role => $name ) { ?>
157
-
158
- <?php $name = str_replace( '|User role', '', $name ); ?>
159
-
160
- <tr valign="top" class="<?php if ( isset($avail_roles[$role]) ) echo 'active'; else echo 'inactive'; ?>">
161
-
162
- <th class="manage-column column-cb check-column">
163
- <?php if ( $role !== $default_role && !$user->has_cap( $role ) ) { ?>
164
- <input name="roles[<?php echo $role; ?>]" id="<?php echo $role; ?>" type="checkbox" value="<?php echo $role; ?>" />
165
- <?php } ?>
166
- </th><!-- .manage-column .column-cb .check-column -->
167
-
168
- <td class="plugin-title">
169
- <?php $edit_link = admin_url( wp_nonce_url( "users.php?page=roles&amp;action=edit&amp;role={$role}", members_get_nonce( 'edit-roles' ) ) ); ?>
170
-
171
- <a href="<?php echo $edit_link; ?>" title="<?php printf( __('Edit the %1$s role', 'members'), $name ); ?>"><strong><?php echo $name; ?></strong></a>
172
-
173
- <div class="row-actions">
174
- <a href="<?php echo $edit_link; ?>" title="<?php printf( __('Edit the %1$s role', 'members'), $name ); ?>"><?php _e('Edit', 'members'); ?></a>
175
-
176
- <?php /* Delete role link. */
177
- if ( $delete_roles && $role !== $default_role && !$user->has_cap( $role ) ) {
178
- $delete_link = admin_url( wp_nonce_url( "users.php?page=roles&amp;action=delete&amp;role={$role}", members_get_nonce( 'edit-roles' ) ) ); ?>
179
- | <a href="<?php echo $delete_link; ?>" title="<?php printf( __('Delete the %1$s role', 'members'), $name ); ?>"><?php _e('Delete', 'members'); ?></a>
180
- <?php }
181
-
182
- /* Link to change the default role Options General. */
183
- if ( $role == $default_role ) { ?>
184
- | <a href="<?php echo admin_url( ( 'options-general.php' ) ); ?>" title="<?php _e('Change default role', 'members'); ?>"><?php _e('Default Role', 'members'); ?></a>
185
- <?php }
186
-
187
- /* If there are users, provide a link to the users page of that role. */
188
- if ( isset($avail_roles[$role]) ) { ?>
189
- | <a href="<?php echo admin_url( esc_url( "users.php?role={$role}" ) ); ?>" title="<?php printf( __('View all users with the %1$s role', 'members'), $name ); ?>"><?php _e('View Users', 'members'); ?></a>
190
- <?php } ?>
191
-
192
- </div><!-- .row-actions -->
193
-
194
- </td><!-- .plugin-title -->
195
-
196
- <td class="desc">
197
- <p><?php echo $role; ?></p>
198
- </td><!-- .desc -->
199
-
200
- <td class="desc">
201
- <p><?php /* Check if any users are assigned to the role. If so, display a link to the role's users page. */
202
- if ( isset($avail_roles[$role]) && 1 < $avail_roles[$role] )
203
- echo '<a href="' . admin_url( esc_url( "users.php?role={$role}" ) ) . '" title="' . sprintf( __('View all users with the %1$s role', 'members'), $name ) . '">' . sprintf( __('%1$s Users', 'members'), $avail_roles[$role] ) . '</a>';
204
- elseif ( isset($avail_roles[$role]) && 1 == $avail_roles[$role] )
205
- echo '<a href="' . admin_url( esc_url( "users.php?role={$role}" ) ) . '" title="' . sprintf( __('View all users with the %1$s role', 'members'), $name ) . '">' . __('1 User', 'members') . '</a>';
206
- else
207
- echo '<em>' . __('No users have this role.', 'members') . '</em>';
208
- ?></p>
209
- </td><!-- .desc -->
210
-
211
- <td class="desc">
212
- <p>
213
- <?php /* Check if the role has any capabilities. */
214
-
215
- $role_2 = get_role( $role );
216
-
217
- if ( is_array( $role_2->capabilities ) ) {
218
- $cap_count = count( $role_2->capabilities );
219
- if ( 1 < $cap_count ) printf( __('%1$s Capabilities', 'members'), $cap_count );
220
- elseif ( 1 == $cap_count ) _e('1 Capability', 'members');
221
- }
222
- else
223
- echo '<em>' . __('This role has no capabilities', 'members') . '</em>'; ?>
224
- </p>
225
- </td><!-- .desc -->
226
-
227
- </tr><!-- .active .inactive -->
228
-
229
- <?php } // End foreach ?>
230
-
231
- </tbody><!-- #users .list:user .user-list .plugins -->
232
-
233
- </table><!-- .widefat .fixed -->
234
-
235
- <div class="tablenav">
236
-
237
- <div class="alignleft actions">
238
- <select name="action2">
239
- <option value="" selected="selected"><?php _e('Bulk Actions', 'members'); ?></option>
240
- <?php if ( $delete_roles ) echo '<option value="delete">' . __('Delete', 'members') . '</option>'; ?>
241
- </select>
242
- <input type="submit" value="<?php _e('Apply', 'members'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
243
- </div><!-- .alignleft .actions -->
244
-
245
- <br class="clear" />
246
-
247
- </div><!-- .tablenav -->
248
-
249
- </form><!-- #roles -->
250
-
251
- </div><!-- #poststuff -->
252
-
253
- </div><!-- .wrap -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/role-manager/manage-roles.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * The main file of the Edit Roles component. This is where we run checks to see which page
4
- * needs to be loaded. It also checks if actions have been performed on the Edit Roles page.
5
- *
6
- * @package Members
7
- * @subpackage Components
8
- */
9
-
10
- /* Get the $wp_roles variable and $wpdb. Do we need $wpdb (need to check)? */
11
- global $wp_roles, $wpdb;
12
-
13
- /* Get the current action performed by the user. */
14
- $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : false;
15
-
16
- /* If a role has been updated, set the action to 'role-updated'. */
17
- if ( isset($_POST['edit-role-saved']) and $_POST['edit-role-saved'] == 'Y' )
18
- $action = 'role-updated';
19
-
20
- /* If the bulk delete (first submit) has been selected. */
21
- elseif ( 'delete' == $action && ( isset( $_POST['doaction'] ) && __('Apply', 'members') == $_POST['doaction']) )
22
- $action = 'bulk-delete';
23
-
24
- /* If the bulk delete (second submit) has been selected. */
25
- elseif ( 'delete' == $action && ( isset($_POST['doaction2']) && __('Apply', 'members') == $_POST['doaction2']) )
26
- $action = 'bulk-delete';
27
-
28
- /* Choose which actions to perform and pages to load according to the $action variable. */
29
- switch( $action ) {
30
-
31
- /* If the bulk delete was selected. */
32
- case 'bulk-delete' :
33
-
34
- /* Get the default role (we don't want to delete this). */
35
- $default_role = get_option( 'default_role' );
36
-
37
- /* Get all roles checked for deletion. */
38
- $delete_roles = $_POST['roles'];
39
-
40
- /* If no roles were selected, break. Just load up the edit roles page. */
41
- if ( !is_array( $delete_roles ) ) {
42
- require_once( 'edit-roles.php' );
43
- break;
44
- }
45
-
46
- /* If roles were selected, let's delete some roles. */
47
- else {
48
-
49
- /* Verify the nonce. */
50
- check_admin_referer( members_get_nonce( 'edit-roles' ) );
51
-
52
- /* Send through roles deleted message. */
53
- add_action( 'members_pre_edit_roles_form', 'members_message_roles_deleted' );
54
-
55
- /* Loop through each of the selected roles. */
56
- foreach ( $delete_roles as $role ) {
57
-
58
- /* Get all users with the current role of the loop. */
59
- $wp_user_search = new WP_User_Search( '', '', $role );
60
- $change_users = $wp_user_search->get_results();
61
-
62
- /* If there are users with the role, let's delete them and give them the default role. */
63
- if ( isset( $change_users ) && is_array( $change_users ) ) {
64
-
65
- /* Loop through each of the users we need to change. */
66
- foreach( $change_users as $move_user ) {
67
- $new_user = new WP_User( $move_user );
68
-
69
- /* If the user has the role, remove it and set the default role. Do we need this additional check? */
70
- if ( $new_user->has_cap( $role ) ) {
71
- $new_user->remove_role( $role );
72
- $new_user->set_role( $default_role );
73
- }
74
- }
75
- }
76
-
77
- /* Remove the role. */
78
- remove_role( $role );
79
- }
80
-
81
- /* Load the edit roles page. */
82
- require_once( 'edit-roles.php' );
83
- break;
84
- }
85
- break;
86
-
87
- /* If a single role has been chosen to be deleted. */
88
- case 'delete' :
89
-
90
- /* Verify the referer. */
91
- check_admin_referer( members_get_nonce( 'edit-roles' ) );
92
-
93
- /* Send role deleted message. */
94
- add_action( 'members_pre_edit_roles_form', 'members_message_role_deleted' );
95
-
96
- /* Get the default role. */
97
- $default_role = get_option( 'default_role' );
98
-
99
- /* Get the role we want to delete. */
100
- $role = $_GET['role'];
101
-
102
- /* Get all users with the role to be deleted. */
103
- $wp_user_search = new WP_User_Search( '', '', $role );
104
- $change_users = $wp_user_search->get_results();
105
-
106
- /* If there are users with the role we're deleting, loop through them, remove the role, and set the default role. */
107
- if ( isset( $change_users ) && is_array( $change_users ) ) {
108
- foreach( $change_users as $move_user ) {
109
- $new_user = new WP_User( $move_user );
110
-
111
- /* If the user has the role, remove it and set the default. Do we need this check? */
112
- if ( $new_user->has_cap( $role ) ) {
113
- $new_user->remove_role( $role );
114
- $new_user->set_role( $default_role );
115
- }
116
- }
117
- }
118
-
119
- /* Remove the role. */
120
- remove_role( $role );
121
-
122
- /* Load the edit roles page. */
123
- require_once( 'edit-roles.php' );
124
- break;
125
-
126
- /* If a role has been updated. Is this needed still? */
127
- case 'role-updated' :
128
-
129
- /* Set some default variables. */
130
- $title = __('Edit Role', 'members');
131
- $role = $_GET['role'];
132
-
133
- /* Load the edit role form. */
134
- require_once( 'edit-role-form.php' );
135
- break;
136
-
137
- /* If a role has been selected to be edited. */
138
- case 'edit' :
139
-
140
- /* Verify the referer. */
141
- check_admin_referer( members_get_nonce( 'edit-roles' ) );
142
-
143
- /* Set some default variables. */
144
- $title = __('Edit Role', 'members');
145
- $role = $_GET['role'];
146
-
147
- /* Load the edit role form. */
148
- require_once( 'edit-role-form.php' );
149
-
150
- break;
151
-
152
- /* The default page is the edit roles page. */
153
- default :
154
-
155
- /* Load the edit roles page.*/
156
- require_once( 'edit-roles.php' );
157
- break;
158
- }
159
-
160
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/role-manager/new-role.php DELETED
@@ -1,126 +0,0 @@
1
- <?php
2
- /**
3
- * Page for creating new roles. Displays the new role form and creates
4
- * a new role if a new role has been submitted.
5
- *
6
- * @package Members
7
- * @subpackage Components
8
- */
9
-
10
- /* Check if the form has been submitted. */
11
- if ( isset($_POST['new-role-submit']) && 'Y' == $_POST['new-role-submit'] ) {
12
-
13
- /* Verify the nonce. */
14
- check_admin_referer( members_get_nonce( 'new-role' ) );
15
-
16
- /* Check if any capabilities were selected. */
17
- if ( !empty( $_POST['capabilities'] ) && is_array( $_POST['capabilities'] ) )
18
- $new_user_caps = $_POST['capabilities'];
19
-
20
- /* If no capabilities were selected, set the variable to null. */
21
- else
22
- $new_user_caps = null;
23
-
24
- /* Check if both a role name and role were submitted. */
25
- if ( isset($_POST['role-name']) && isset($_POST['role-id']) ) {
26
-
27
- /* Sanitize the new role, removing any unwanted characters. */
28
- $new_role = strip_tags( $_POST['role-id'] );
29
- $new_role = str_replace( array( '-', ' ', '&nbsp;' ) , '_', $new_role );
30
- $new_role = preg_replace('/[^A-Za-z0-9_]/', '', $new_role );
31
- $new_role = strtolower( $new_role );
32
-
33
- /* Sanitize the new role name/label. We just want to strip any tags here. */
34
- $new_role_name = strip_tags( $_POST['role-name'] ); // Should we use something like the WP user sanitation method?
35
-
36
- /* Add a new role with the data input. */
37
- $new_role_added = add_role( $new_role, $new_role_name, $new_user_caps );
38
-
39
- } // End check for role and role name
40
-
41
- } // End check for form submit ?>
42
-
43
- <div class="wrap">
44
-
45
- <h2><?php _e('Add a new user role', 'members'); ?></h2>
46
-
47
- <?php if ( isset($new_role_added) and $new_role_added ) members_admin_message( '', sprintf( __('The %1$s role has been created.', 'members'), $_POST['role-name'] ) ); ?>
48
-
49
- <?php do_action( 'members_pre_new_role_form' ); // Available action hook for displaying messages. ?>
50
-
51
- <div id="poststuff">
52
-
53
- <form name="form0" method="post" action="<?php echo admin_url( "users.php?page=new-role" ); ?>" style="border:none;background:transparent;">
54
-
55
- <?php wp_nonce_field( members_get_nonce( 'new-role' ) ); ?>
56
-
57
- <div class="postbox open">
58
-
59
- <h3><?php _e('Create a new user role', 'members'); ?></h3>
60
-
61
- <div class="inside">
62
-
63
- <table class="form-table">
64
- <tr>
65
- <th style="width: 20%;">
66
- <strong><?php _e('About:', 'members'); ?></strong>
67
- </th>
68
- <td>
69
- <?php printf( __('Here you can create as many new roles as you\'d like. Roles are a way of grouping your users. You can give individual users a role from the <a href="%1$s" title="Manage Users">user management</a> screen. This will allow you to do specific things for users with a specific role. Once you\'ve created a new role, you can manage it with the <em>Edit Roles</em> component.', 'members'), admin_url( 'users.php' ) ); ?>
70
- </td>
71
- </tr>
72
-
73
- <tr>
74
- <th style="width: 20%;">
75
- <label for="role-id"><strong><?php _e('Role:', 'members'); ?></strong></label>
76
- </th>
77
- <td>
78
- <?php _e('<strong>Required:</strong> Enter the name of your role. This is a unique key that should only contain numbers, letters, and underscores. Please don\'t add spaces or other odd characters.', 'members'); ?>
79
- <br />
80
- <input type="text" id="role-id" name="role-id" value="" size="30" />
81
- </td>
82
- </tr>
83
-
84
- <tr>
85
- <th style="width: 20%;">
86
- <label for="role-name"><strong><?php _e('Role Label:', 'members'); ?></strong></label>
87
- </th>
88
- <td>
89
- <?php _e('<strong>Required:</strong> Enter a label your role. This will be the title that is displayed in most cases.', 'members'); ?>
90
- <br />
91
- <input type="text" id="role-name" name="role-name" value="" size="30" />
92
- </td>
93
- </tr>
94
-
95
- <tr>
96
- <th style="width: 20%;">
97
- <strong><?php _e('Capabilities:', 'members'); ?></strong>
98
- </th>
99
- <td>
100
- <?php _e('<strong>Optional:</strong> Select which capabilities your new role should have. These may be changed later using the <em>Edit Roles</em> component.', 'members'); ?>
101
- <br /><br />
102
- <?php foreach ( members_get_capabilities() as $cap ) : ?>
103
- <div style="float: left; width: 32.67%; margin: 0 0 5px 0;">
104
- <input name='capabilities[<?php echo $cap; ?>]' id='capabilities-<?php echo $cap; ?>' type="checkbox" value='<?php echo $cap; ?>' <?php if ( in_array( $cap, members_new_role_default_capabilities() ) ) echo "checked='checked'"; ?> />
105
- <label for="capabilities-<?php echo $cap; ?>"><?php if ( in_array( $cap, members_new_role_default_capabilities() ) ) echo "<strong>$cap</strong>"; else echo $cap; ?></label>
106
- </div>
107
- <?php endforeach; ?>
108
- </td>
109
- </tr>
110
-
111
- </table><!-- .form-table -->
112
-
113
- </div><!-- .inside -->
114
-
115
- </div><!-- .postbox -->
116
-
117
- <p class="submit">
118
- <input type="submit" name="Submit" class="button-primary" value="<?php _e('Create Role', 'members') ?>" />
119
- <input type="hidden" name="new-role-submit" value="Y" />
120
- </p><!-- .submit -->
121
-
122
- </form>
123
-
124
- </div><!-- #poststuff -->
125
-
126
- </div><!-- .poststuff -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/shortcodes/shortcodes.php DELETED
@@ -1,171 +0,0 @@
1
- <?php
2
- /**
3
- * The Shortcodes component provides additional [shortcodes] for use within posts/pages
4
- * and any other shortcode-capable area.
5
- *
6
- * @todo need a [hide] shortcode or allow [access] to do the opposite.
7
- *
8
- * @package Members
9
- * @subpackage Components
10
- */
11
-
12
- /* Add shortcodes. */
13
- add_action( 'init', 'members_component_shortcodes_register_shortcodes' );
14
-
15
- /**
16
- * Registers shortcodes for the shortcodes component.
17
- *
18
- * @since 0.2.0
19
- */
20
- function members_component_shortcodes_register_shortcodes() {
21
- add_shortcode( 'login-form', 'members_login_form_shortcode' );
22
- add_shortcode( 'access', 'members_access_check_shortcode' );
23
- add_shortcode( 'feed', 'members_access_check_shortcode' );
24
- add_shortcode( 'is_user_logged_in', 'members_is_user_logged_in_shortcode' );
25
- add_shortcode( 'get_avatar', 'members_get_avatar_shortcode' );
26
- add_shortcode( 'avatar', 'members_get_avatar_shortcode' );
27
- }
28
-
29
- /**
30
- * Displays an avatar for any user. At the very least, an ID or email must
31
- * be input. Otherwise, we can't know which avatar to grab.
32
- *
33
- * Users should input the code as [get_avatar id="30" alt="Justin Tadlock"].
34
- *
35
- * @since 0.1
36
- * @uses get_avatar() Grabs the users avatar.
37
- * @param $attr array The shortcode attributes.
38
- */
39
- function members_get_avatar_shortcode( $attr ) {
40
-
41
- /* Set up our default attributes. */
42
- $defaults = array(
43
- 'id' => '',
44
- 'email' => '',
45
- 'size' => 96,
46
- 'default' => '',
47
- 'alt' => ''
48
- );
49
-
50
- /* Merge the input attributes and the defaults. */
51
- extract( shortcode_atts( $defaults, $attr ) );
52
-
53
- /* If an email was input, use it. */
54
- if ( $email )
55
- $id_or_email = $email;
56
-
57
- /* If no email was input, use the ID. */
58
- else
59
- $id_or_email = $id;
60
-
61
- /* Return the avatar. */
62
- return get_avatar( $id_or_email, $size, $default, $alt );
63
- }
64
-
65
- /**
66
- * Displays content if the user viewing it is currently logged in. This also blocks
67
- * content from showing in feeds.
68
- *
69
- * Content needs to be wrapped with this shortcode like
70
- * [is_user_logged_in]This is content.[/is_user_logged_in].
71
- *
72
- * @todo Provide a filter hook for displaying a "please log in to view" message.
73
- *
74
- * @since 0.1
75
- * @uses is_feed() Checks if the content is currently being shown in a feed.
76
- * @uses is_user_logged_in() Checks if the current user is logged in.
77
- * @param $attr array Attributes for the shortcode (not usefule here).
78
- * @param $content string The content located between the opening and closing of the shortcode.
79
- * @return $content string The content to be shown.
80
- */
81
- function members_is_user_logged_in_shortcode( $attr, $content = null ) {
82
-
83
- /* If it is a feed or the user is not logged in, return nothing. */
84
- if ( !is_feed() || !is_user_logged_in() )
85
- return '';
86
-
87
- /* Return the content. */
88
- return do_shortcode( $content );
89
- }
90
-
91
- /**
92
- * Content that should only be shown in feed readers. Can be useful for
93
- * displaying feed-specific items.
94
- *
95
- * Content should be wrapped like [feed]This is content.[/feed].
96
- *
97
- * @since 0.1
98
- * @uses is_feed() Checks if the content is currently being shown in a feed.
99
- * @uses is_null() Checks if there is any content.
100
- * @param $attr array Attributes for the shortcode (not currently useful but may later add a $display/$show parameter).
101
- * @param $content string The content located between the opening and closing of the shortcode.
102
- * @return $content string The content to be shown.
103
- */
104
- function members_feed_shortcode( $attr, $content = null ) {
105
-
106
- /* If not feed or no content exists, return nothing. */
107
- if ( !is_feed() || is_null( $content ) )
108
- return '';
109
-
110
- /* Return the content. */
111
- return do_shortcode( $content );
112
- }
113
-
114
- /**
115
- * Provide/restrict access to specific roles or capabilities. This content should
116
- * not be shown in feeds.
117
- *
118
- * @todo Allow multiple roles and capabilities to be input (comma-separated).
119
- *
120
- * Content should be wrapped like [access role="editor"]This is content.[/access].
121
- *
122
- * @since 0.1
123
- * @uses current_user_can() Checks if the current user has the role or capability.
124
- * @uses is_feed() Checks if we're currently viewing a feed.
125
- * @param $attr array The shortcode attributes.
126
- * @param $content string The content that should be shown/restricted.
127
- * @return $content string The content if it should be shown. Else, return nothing.
128
- */
129
- function members_access_check_shortcode( $attr, $content = null ) {
130
-
131
- /* Set up the default attributes. */
132
- $defaults = array(
133
- 'capability' => '',
134
- 'role' => '',
135
- 'feed' => false,
136
- );
137
-
138
- /* Merge the input attributes and the defaults. */
139
- extract( shortcode_atts( $defaults, $attr ) );
140
-
141
- /* If the current user has the input capability, show the content. */
142
- if ( $capability && current_user_can( $capability ) )
143
- return do_shortcode( $content );
144
-
145
- /* If the current user has the input role, show the content. */
146
- elseif ( $role && current_user_can( $role ) )
147
- return do_shortcode( $content );
148
-
149
- /* If $feed was set to true and we're currently displaying a feed, show the content. */
150
- elseif ( $feed && 'false' !== $feed && is_feed() )
151
- return do_shortcode( $content );
152
-
153
- /* If there is no content, return nothing. */
154
- elseif ( !is_null( $content ) )
155
- return '';
156
-
157
- /* Return nothing if none of the conditions have been met. */
158
- return '';
159
- }
160
-
161
- /**
162
- * Displays a login form.
163
- *
164
- * @since 0.1
165
- * @uses wp_login_form() Displays the login form.
166
- */
167
- function members_login_form_shortcode() {
168
- return wp_login_form( array( 'echo' => false ) );
169
- }
170
-
171
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/statistics/default.php DELETED
@@ -1,137 +0,0 @@
1
- <?php
2
- /**
3
- * Stats package for the plugin. This component displays stats for individual roles. On the main stats
4
- * page, each role is listed. Each role then has its own stats page, which lists users by month. Each
5
- * month should list all of the users that signed up for that particular month for with that role.
6
- *
7
- * To view the stats page, a user must have a role with the 'view_stats' capability.
8
- *
9
- * @package Members
10
- * @subpackage Components
11
- */
12
-
13
- /* Add the stats page to the admin. */
14
- add_action( 'admin_menu', 'members_component_add_stats_page' );
15
-
16
- /* Additional capabilities required by the component. */
17
- add_filter( 'members_get_capabilities', 'members_component_stats_capabilities' );
18
-
19
- /**
20
- * Adds the stats page to the admin menu.
21
- *
22
- * @since 0.2
23
- */
24
- function members_component_add_stats_page() {
25
- global $members;
26
-
27
- $members->stats_page = add_submenu_page( 'users.php', __( 'Members Statistics', 'members' ), __( 'Members Stats', 'members' ), 'view_stats', 'stats', 'members_component_stats_page' );
28
- }
29
-
30
- /**
31
- * Loads the stats page.
32
- *
33
- * @since 0.2
34
- */
35
- function members_component_stats_page() {
36
-
37
- $stats = get_option( 'members_statistics' );
38
-
39
- if ( empty( $stats ) )
40
- members_component_stats_create_initial_stats();
41
-
42
- require_once( MEMBERS_COMPONENTS . '/statistics/statistics.php' );
43
- }
44
-
45
- /**
46
- * Adds additional capabilities required by the stats component.
47
- *
48
- * @since 0.2
49
- */
50
- function members_component_stats_capabilities( $capabilities ) {
51
-
52
- $capabilities['view_stats'] = 'view_stats';
53
-
54
- return $capabilities;
55
- }
56
-
57
- add_action( 'user_register', 'update_stats_package' );
58
-
59
- function update_stats_package( $user_id ) {
60
-
61
- $stats = get_option( 'members_statistics' );
62
- $new_user = new WP_User( $user_id );
63
-
64
- if ( is_array( $new_user->roles ) )
65
- $role = $new_user->roles[0];
66
-
67
- $stats[$role][$new_user->ID] = array(
68
- 'id' => $new_user->ID,
69
- 'role' => $role,
70
- 'date' => $new_user->user_registered,
71
- 'year' => mysql2date( 'Y', $new_user->user_registered ),
72
- 'month' => mysql2date( 'm', $new_user->user_registered ),
73
- 'day' => mysql2date( 'd', $new_user->user_registered ),
74
- );
75
-
76
- update_option( 'members_statistics', $stats );
77
- }
78
-
79
-
80
- /**
81
- * If the stats package was previously unused, this means that prior users stats were
82
- * not tracked. So, we're going to create some default stats based on the user registration
83
- * date and user role.
84
- *
85
- * @since 0.2
86
- */
87
- function members_component_stats_create_initial_stats() {
88
- global $wp_roles;
89
-
90
- $stats = array();
91
-
92
- foreach ( $wp_roles->role_objects as $key => $role ) {
93
-
94
- $sta = array();
95
-
96
- $search = new WP_User_Search( '', '', $role->name );
97
-
98
- $users = $search->get_results();
99
-
100
- if ( isset( $users ) && is_array( $users ) ) {
101
-
102
- foreach ( $users as $user ) {
103
- $new_user = new WP_User( $user );
104
-
105
- $sta[$new_user->ID] = array(
106
- 'id' => $new_user->ID,
107
- 'role' => $role->name,
108
- 'date' => $new_user->user_registered,
109
- 'year' => mysql2date( 'Y', $new_user->user_registered ),
110
- 'month' => mysql2date( 'm', $new_user->user_registered ),
111
- 'day' => mysql2date( 'd', $new_user->user_registered ),
112
- );
113
-
114
- }
115
- }
116
-
117
- $stats[$role->name] = $sta;
118
- }
119
-
120
- add_option( 'members_statistics', $stats );
121
-
122
- }
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/statistics/statistics.php DELETED
@@ -1,170 +0,0 @@
1
- <?php
2
- /**
3
- * The Stats page displays all of the site's roles and each role's stats.
4
- *
5
- * To view this page, a user must have a role with the capability of 'view_stats'.
6
- *
7
- * @package Members
8
- * @subpackage Components
9
- */
10
-
11
-
12
- /* Get the current action performed by the user. */
13
- //$view_role = isset( $_REQUEST['role'] ) ? $_REQUEST['role'] : false;
14
- //$view_stats = isset( $_REQUEST['view'] ) ? $_REQUEST['view'] : false;
15
-
16
- if ( isset( $_REQUEST['role'] ) && isset( $_REQUEST['view'] ) ) {
17
-
18
- /* Verify the referer. */
19
- check_admin_referer( members_get_nonce( 'view-stats' ) );
20
-
21
- /* Set some default variables. */
22
- $role = $_REQUEST['role'];
23
- $view = $_REQUEST['view'];
24
-
25
- /* Load the edit role form. */
26
- require_once( 'view-stats.php' );
27
- }
28
-
29
- else {
30
-
31
-
32
- /* Get the global $members variable. */
33
- global $members, $wp_roles;
34
-
35
- /* Current user in the admin. */
36
- $user = new WP_User( $members->current_user->ID );
37
-
38
- /* Set the available roles array.*/
39
- $avail_roles = array();
40
-
41
- /* Get all the users of the current blog. */
42
- $users_of_blog = get_users_of_blog();
43
-
44
- /* Loop through each user. */
45
- foreach ( (array) $users_of_blog as $blog_user ) {
46
-
47
- $meta_values = unserialize( $blog_user->meta_value );
48
-
49
- foreach ( ( array) $meta_values as $role => $value ) {
50
-
51
- if ( !isset( $avail_roles[$role] ) )
52
- $avail_roles[$role] = 0;
53
-
54
- ++$avail_roles[$role];
55
- }
56
- }
57
-
58
- /* Destroy the $users_of_blog variable. */
59
- unset( $users_of_blog );
60
-
61
- /* Sort out the roles, active roles, and inactive roles. */
62
- $all_roles = $active_roles = $inactive_roles = 0;
63
-
64
- /* Loop through all of the roles, adding each role to its respective category (active, inactive). */
65
- foreach ( $wp_roles->role_names as $role => $name ) {
66
- $all_roles++;
67
- if ( isset($avail_roles[$role]) ) {
68
- $active_roles++;
69
- $active_roles_arr[$role] = $name;
70
- }
71
- else {
72
- $inactive_roles++;
73
- $inactive_roles_arr[$role] = $name;
74
- }
75
- }
76
-
77
- $roles_loop_array = $wp_roles->role_names;
78
-
79
- /* Sort the roles array into alphabetical order. */
80
- ksort( $roles_loop_array ); ?>
81
-
82
- <div class="wrap">
83
-
84
- <h2><?php _e( 'Statistics', 'members' ); ?></h2>
85
-
86
- <?php do_action( 'members_pre_stats_form' ); // Available action hook for displaying messages. ?>
87
-
88
- <div id="poststuff">
89
-
90
- <form id="roles" action="<?php echo admin_url( 'users.php?page=stats' ); ?>" method="post">
91
-
92
- <?php wp_nonce_field( members_get_nonce( 'view-stats' ) ); ?>
93
-
94
- <table class="widefat fixed" cellspacing="0">
95
- <thead>
96
- <tr>
97
- <th class='name-column'><?php _e( 'Role', 'members' ); ?></th>
98
- <th><?php _e( 'Users', 'members' ); ?></th>
99
- <th><?php _e( 'Stats', 'members' ); ?></th>
100
- </tr>
101
- </thead>
102
-
103
- <tfoot>
104
- <tr>
105
- <th class='name-column'><?php _e( 'Role', 'members' ); ?></th>
106
- <th><?php _e( 'Users', 'members' ); ?></th>
107
- <th><?php _e( 'Stats', 'members' ); ?></th>
108
- </tr>
109
- </tfoot>
110
-
111
- <tbody id="users" class="list:user user-list plugins">
112
-
113
- <?php foreach ( $roles_loop_array as $role => $name ) { ?>
114
-
115
- <?php $name = str_replace( '|User role', '', $name ); ?>
116
-
117
- <tr valign="top" class="<?php if ( isset($avail_roles[$role]) ) echo 'active'; else echo 'inactive'; ?>">
118
-
119
- <td class='plugin-title'>
120
- <?php $view_link = admin_url( wp_nonce_url( "users.php?page=stats&amp;role={$role}&amp;view=month", members_get_nonce( 'view-stats' ) ) ); ?>
121
-
122
- <a href="<?php echo $view_link; ?>" title="<?php printf( __( 'View stats for the %1$s role', 'members' ), $name ); ?>"><strong><?php echo $name; ?></strong></a>
123
-
124
- <div class="row-actions">
125
- <a href="<?php echo $view_link; ?>" title="<?php printf( __( 'View stats for the %1$s role', 'members' ), $name ); ?>"><?php _e( 'Stats', 'members' ); ?></a>
126
-
127
- <?php
128
- /* If there are users, provide a link to the users page of that role. */
129
- if ( isset($avail_roles[$role]) ) { ?>
130
- | <a href="<?php echo admin_url( esc_url( "users.php?role={$role}" ) ); ?>" title="<?php printf( __( 'View all users with the %1$s role', 'members' ), $name ); ?>"><?php _e( 'View Users', 'members' ); ?></a>
131
- <?php } ?>
132
-
133
- </div><!-- .row-actions -->
134
-
135
- </td><!-- .plugin-title -->
136
-
137
- <td class='desc'>
138
- <p><?php /* Check if any users are assigned to the role. If so, display a link to the role's users page. */
139
- if ( isset($avail_roles[$role]) && 1 < $avail_roles[$role] )
140
- echo '<a href="' . admin_url( esc_url( "users.php?role={$role}" ) ) . '" title="' . sprintf( __( 'View all users with the %1$s role', 'members' ), $name ) . '">' . sprintf( __( '%1$s Users', 'members' ), $avail_roles[$role] ) . '</a>';
141
- elseif ( isset($avail_roles[$role]) && 1 == $avail_roles[$role] )
142
- echo '<a href="' . admin_url( esc_url( "users.php?role={$role}" ) ) . '" title="' . sprintf( __( 'View all users with the %1$s role', 'members' ), $name ) . '">' . __( '1 User', 'members' ) . '</a>';
143
- else
144
- echo '<em>' . __( 'No users have this role.', 'members' ) . '</em>';
145
- ?></p>
146
- </td><!-- .desc -->
147
-
148
- <td class='desc'>
149
- <p>
150
- <a href="#" title="<?php printf( __( 'View the yearly stats for the %1$s role', 'members' ), $name ); ?>"><?php _e( 'Yearly', 'members' ); ?></a> |
151
- <a href="#" title="<?php printf( __( 'View the monthly stats for the %1$s role', 'members' ), $name ); ?>"><?php _e( 'Monthly', 'members' ); ?></a> |
152
- <a href="#" title="<?php printf( __( 'View the daily stats for the %1$s role', 'members' ), $name ); ?>"><?php _e( 'Daily', 'members' ); ?></a>
153
- </p>
154
- </td><!-- .desc -->
155
-
156
- </tr><!-- .active .inactive -->
157
-
158
- <?php } // End foreach ?>
159
-
160
- </tbody><!-- #users .list:user .user-list .plugins -->
161
-
162
- </table><!-- .widefat .fixed -->
163
-
164
- </form><!-- #roles -->
165
-
166
- </div><!-- #poststuff -->
167
-
168
- </div><!-- .wrap -->
169
-
170
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/statistics/view-stats.php DELETED
@@ -1,77 +0,0 @@
1
- <?php
2
-
3
-
4
- $stats = get_option( 'members_statistics' );
5
-
6
- $stats_view = $stats[$role];
7
-
8
- $overall = array();
9
-
10
- foreach ( $stats_view as $user ) {
11
- //$together = $user['date'];
12
-
13
- $together = $user['year'] . $user['month'];
14
- //echo $together;
15
-
16
- ++$overall[$together];
17
- }
18
-
19
- ksort( $overall ); ?>
20
-
21
- <div class="wrap">
22
-
23
- <h2><?php _e( 'Statistics', 'members' ); ?></h2>
24
-
25
- <?php //do_action( 'members_pre_stats_form' ); // Available action hook for displaying messages. ?>
26
-
27
- <div id="poststuff">
28
-
29
- <?php //wp_nonce_field( members_get_nonce( 'view-stats' ) ); ?>
30
-
31
- <table class="widefat fixed" cellspacing="0">
32
- <thead>
33
- <tr>
34
- <th class='name-column'><?php _e( 'Date', 'members' ); ?></th>
35
- <th><?php _e( 'Users', 'members' ); ?></th>
36
- </tr>
37
- </thead>
38
-
39
- <tfoot>
40
- <tr>
41
- <th class='name-column'><?php _e( 'Date', 'members' ); ?></th>
42
- <th><?php _e( 'Users', 'members' ); ?></th>
43
- </tr>
44
- </tfoot>
45
-
46
- <tbody id="users" class="list:user user-list plugins">
47
-
48
-
49
- <?php foreach ( $overall as $month => $num ) {
50
-
51
- $date = $month;
52
-
53
- //$date = str_split( $month, 4 ); ?>
54
- <tr>
55
- <td><?php echo mysql2date( 'F', $date ) . ' ' . mysql2date( 'Y', $date ); ?></td>
56
- <td><?php echo $num; ?>
57
- </tr>
58
-
59
- <?php
60
- } ?>
61
- </tbody>
62
- </table>
63
- </div>
64
- </div><?php
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/template-tags/template-tags.php DELETED
@@ -1,88 +0,0 @@
1
- <?php
2
- /**
3
- * The Template Tags component is for adding functions that could be useful within the
4
- * template files of a WordPress theme.
5
- *
6
- * @todo Add members_count_users( $role = '' )
7
- *
8
- * @package Members
9
- * @subpackage Components
10
- */
11
-
12
- /**
13
- * Use to put an author box at the end/beginning of a post. This template
14
- * tag should be used within The Loop.
15
- *
16
- * @since 0.1
17
- * @uses get_avatar() Gets the current author's avatar.
18
- * @uses get_the_author_meta() Grabs information about the author.
19
- */
20
- function members_author_profile() { ?>
21
- <div class="author-profile vcard">
22
- <?php echo get_avatar( get_the_author_meta( 'user_email' ), '100', '', get_the_author_meta( 'display_name' ) ); ?>
23
- <h4 class="author-name fn n"><?php the_author_posts_link(); ?></h4>
24
- <p class="author-description author-bio">
25
- <?php the_author_meta( 'description' ); ?>
26
- </p>
27
- </div>
28
- <?php
29
- }
30
-
31
- if ( !function_exists( 'has_role' ) ) {
32
-
33
- /**
34
- * Checks if a given ID of a user has a specific role.
35
- *
36
- * @since 0.1
37
- * @uses WP_User() Gets a user object based on an ID.
38
- * @param $role string Role to check for against the user.
39
- * @param $user_id int The ID of the user to check.
40
- * @return true|false bool Whether the user has the role.
41
- */
42
- function has_role( $role = '', $user_id = '' ) {
43
-
44
- /* If no role or user ID was added, return false. */
45
- if ( !$role || !$user_id )
46
- return false;
47
-
48
- /* Make sure the ID is an integer. */
49
- $user_id = (int)$user_id;
50
-
51
- /* Get the user object. */
52
- $user = new WP_User( $user_id );
53
-
54
- /* If the user has the role, return true. */
55
- if ( $user->has_cap( $role ) )
56
- return true;
57
-
58
- /* Return false if the user doesn't have the role. */
59
- return false;
60
- }
61
- }
62
-
63
- if ( !function_exists( 'current_user_has_role' ) ) {
64
-
65
- /**
66
- * Checks if the currently logged-in user has a specific role.
67
- *
68
- * @since 0.1
69
- * @uses current_user_can() Checks whether the user has the given role.
70
- * @param $role string The role to check for.
71
- * @return true|false bool Whether the user has the role.
72
- */
73
- function current_user_has_role( $role = '' ) {
74
-
75
- /* If no role was input, return false. */
76
- if ( !$role )
77
- return false;
78
-
79
- /* If the current user has the role, return true. */
80
- if ( current_user_can( $role ) )
81
- return true;
82
-
83
- /* If the current user doesn't have the role, return false. */
84
- return false;
85
- }
86
- }
87
-
88
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/widgets/login.php DELETED
@@ -1,174 +0,0 @@
1
- <?php
2
- /**
3
- * Creates a widget that allows users to add a login form to a widget area.
4
- *
5
- * @package Members
6
- * @subpackage Components
7
- */
8
-
9
- class Members_Widget_Login extends WP_Widget {
10
-
11
- function Members_Widget_Login() {
12
- $widget_ops = array( 'classname' => 'login', 'description' => __('A widget that allows users to log into your site.', 'widgets-reloaded') );
13
- $control_ops = array( 'width' => 700, 'height' => 350, 'id_base' => 'members-widget-login' );
14
- $this->WP_Widget( 'members-widget-login', __('Login Form', 'widgets-reloaded'), $widget_ops, $control_ops );
15
- }
16
-
17
- function widget( $args, $instance ) {
18
- global $user_identity, $user_ID;
19
-
20
- extract( $args );
21
-
22
- $title = apply_filters( 'widget_title', $instance['title'] );
23
-
24
- $username_label = $instance['username_label'];
25
- $password_label = $instance['password_label'];
26
- $submit_text = $instance['submit_text'];
27
- $remember_text = $instance['remember_text'];
28
-
29
- $logged_in_text = apply_filters( 'widget_text', $instance['logged_in_text'] );
30
- $logged_out_text = apply_filters( 'widget_text', $instance['logged_out_text'] );
31
-
32
- $show_avatar = isset( $instance['show_avatar'] ) ? $instance['show_avatar'] : false;
33
-
34
- echo $before_widget;
35
-
36
- if ( $title )
37
- echo "\n\t\t\t" . $before_title . $title . $after_title;
38
-
39
- if ( is_user_logged_in() ) {
40
-
41
- if ( $show_avatar )
42
- echo get_avatar( $user_ID );
43
-
44
- if ( $logged_in_text )
45
- echo $logged_in_text;
46
-
47
- }
48
- else {
49
- if ( $show_avatar )
50
- echo get_avatar( $user_ID );
51
-
52
- if ( $logged_out_text )
53
- echo $logged_out_text;
54
-
55
- $login = '<div class="clear log-in login-form">';
56
-
57
- $login .= '<form class="log-in" action="' . get_bloginfo( 'wpurl' ) . '/wp-login.php" method="post">';
58
-
59
- $login .= '<p class="text-input">';
60
- $login .= '<label class="text" for="log">' . $username_label . '</label>';
61
- $login .= '<input class="field" type="text" name="log" id="log" value="' . esc_attr( $user_login ) . '" size="23" />';
62
- $login .= '</p>';
63
-
64
- $login .= '<p class="text-input">';
65
- $login .= '<label class="text" for="pwd">' . $password_label . '</label>';
66
- $login .= '<input class="field" type="password" name="pwd" id="pwd" size="23" />';
67
- $login .= '</p>';
68
-
69
- $login .= '<div class="clear">';
70
- $login .= '<input type="submit" name="submit" value="' . $submit_text . '" class="log-in" />';
71
- $login .= '<label class="remember"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> ' . $remember_text . '</label>';
72
- $login .= '<input type="hidden" name="redirect_to" value="' . $_SERVER['REQUEST_URI'] . '"/>';
73
- $login .= '</div>';
74
-
75
- $login .= '</form>';
76
-
77
- $login .= '</div>';
78
-
79
- echo $login;
80
- }
81
-
82
- echo $after_widget;
83
- }
84
-
85
- function update( $new_instance, $old_instance ) {
86
- $instance = $old_instance;
87
- $instance['title'] = strip_tags( $new_instance['title'] );
88
- $instance['username_label'] = strip_tags( $new_instance['username_label'] );
89
- $instance['password_label'] = strip_tags( $new_instance['password_label'] );
90
- $instance['submit_text'] = strip_tags( $new_instance['submit_text'] );
91
- $instance['remember_text'] = strip_tags( $new_instance['remember_text'] );
92
- $instance['show_avatar'] = $new_instance['show_avatar'];
93
-
94
- if ( current_user_can('unfiltered_html') ) {
95
- $instance['logged_in_text'] = $new_instance['logged_in_text'];
96
- $instance['logged_out_text'] = $new_instance['logged_out_text'];
97
- }
98
- else {
99
- $instance['logged_in_text'] = wp_filter_post_kses( $new_instance['logged_in_text'] );
100
- $instance['logged_out_text'] = wp_filter_post_kses( $new_instance['logged_out_text'] );
101
- }
102
-
103
- return $instance;
104
- }
105
-
106
- function form( $instance ) {
107
-
108
- //Defaults
109
- $defaults = array(
110
- 'title' => __('Log In', 'widgets-reloaded'),
111
- 'username_label' => __('Username:', 'members'),
112
- 'password_label' => __('Password', 'members'),
113
- 'submit_text' => __('Log In', 'members'),
114
- 'remember_text' => __('Remember me?', 'members'),
115
- 'show_avatar' => true,
116
- 'logged_out_text' => __('Please log into the site.', 'members'),
117
- 'logged_in_text' => __('You are currently logged in.', 'members')
118
- );
119
-
120
- $instance = wp_parse_args( (array) $instance, $defaults );
121
- $logged_in_text = format_to_edit( $instance['logged_in_text'] );
122
- $logged_out_text = format_to_edit( $instance['logged_out_text'] ); ?>
123
-
124
- <div style="float: left; width: 48%;">
125
- <p>
126
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'widgets-reloaded'); ?></label>
127
- <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
128
- </p>
129
-
130
- <p>
131
- <label for="<?php echo $this->get_field_id( 'logged_out_text' ); ?>"><?php _e('Logged out text:', 'members'); ?></label>
132
- <textarea class="widefat" rows="3" cols="20" id="<?php echo $this->get_field_id('logged_out_text'); ?>" name="<?php echo $this->get_field_name('logged_out_text'); ?>" style="width:100%;"><?php echo $logged_out_text; ?></textarea>
133
- </p>
134
-
135
- <p>
136
- <label for="<?php echo $this->get_field_id( 'logged_in_text' ); ?>"><?php _e('Logged in text:', 'members'); ?></label>
137
- <textarea class="widefat" rows="3" cols="20" id="<?php echo $this->get_field_id('logged_in_text'); ?>" name="<?php echo $this->get_field_name('logged_in_text'); ?>" style="width:100%;"><?php echo $logged_in_text; ?></textarea>
138
- </p>
139
- </div>
140
-
141
- <div style="float: right; width: 48%;">
142
-
143
- <p>
144
- <label for="<?php echo $this->get_field_id( 'show_avatar' ); ?>">
145
- <input class="checkbox" type="checkbox" <?php checked( $instance['show_avatar'], true ); ?> id="<?php echo $this->get_field_id( 'show_avatar' ); ?>" name="<?php echo $this->get_field_name( 'show_avatar' ); ?>" /> <?php _e('Display avatar?', 'widgets-reloaded'); ?></label>
146
- </p>
147
- <p>
148
- <label for="<?php echo $this->get_field_id( 'username_label' ); ?>"><?php _e('Username Label:', 'widgets-reloaded'); ?></label>
149
- <input id="<?php echo $this->get_field_id( 'username_label' ); ?>" name="<?php echo $this->get_field_name( 'username_label' ); ?>" value="<?php echo $instance['username_label']; ?>" style="width:100%;" />
150
- </p>
151
- <p>
152
- <label for="<?php echo $this->get_field_id( 'password_label' ); ?>"><?php _e('Password Label:', 'widgets-reloaded'); ?></label>
153
- <input id="<?php echo $this->get_field_id( 'password_label' ); ?>" name="<?php echo $this->get_field_name( 'password_label' ); ?>" value="<?php echo $instance['password_label']; ?>" style="width:100%;" />
154
- </p>
155
-
156
- <p>
157
- <label for="<?php echo $this->get_field_id( 'submit_text' ); ?>"><?php _e('Submit Text:', 'widgets-reloaded'); ?></label>
158
- <input id="<?php echo $this->get_field_id( 'submit_text' ); ?>" name="<?php echo $this->get_field_name( 'submit_text' ); ?>" value="<?php echo $instance['submit_text']; ?>" style="width:100%;" />
159
- </p>
160
- <p>
161
- <label for="<?php echo $this->get_field_id( 'remember_text' ); ?>"><?php _e('Remember User Text:', 'widgets-reloaded'); ?></label>
162
- <input id="<?php echo $this->get_field_id( 'remember_text' ); ?>" name="<?php echo $this->get_field_name( 'remember_text' ); ?>" value="<?php echo $instance['remember_text']; ?>" style="width:100%;" />
163
- </p>
164
- </div>
165
-
166
- <div>
167
-
168
- </div>
169
- <div style="clear:both;">&nbsp;</div>
170
- <?php
171
- }
172
- }
173
-
174
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
components/widgets/users.php DELETED
@@ -1,113 +0,0 @@
1
- <?php
2
- /**
3
- * Creates a widget that allows users to list users of their site.
4
- *
5
- * @package Members
6
- * @subpackage Components
7
- */
8
-
9
- class Members_Widget_Users extends WP_Widget {
10
-
11
- function Members_Widget_Users() {
12
- $widget_ops = array( 'classname' => 'users', 'description' => __('An advanced widget that gives you total control over the output of your user lists.','members') );
13
- $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => 'members-widget-users' );
14
- $this->WP_Widget( 'members-widget-users', __('Users', 'members'), $widget_ops, $control_ops );
15
- }
16
-
17
- function widget( $args, $instance ) {
18
-
19
- extract( $args, EXTR_SKIP );
20
-
21
- $title = apply_filters('widget_title', $instance['title'] );
22
- $limit = $instance['limit'];
23
- $order = $instance['order'];
24
- $orderby = $instance['orderby'];
25
- $exclude = $instance['exclude'];
26
- $include = $instance['include'];
27
- $show_fullname = isset( $instance['show_fullname'] ) ? $instance['show_fullname'] : false;
28
-
29
- $users = array(
30
- 'limit' => $limit,
31
- 'order' => $order,
32
- 'orderby' => $orderby,
33
- 'include' => $include,
34
- 'exclude' => $exclude,
35
- 'show_fullname' => $show_fullname,
36
- 'echo' => 0,
37
- );
38
-
39
- echo $before_widget;
40
-
41
- if ( $title )
42
- echo "\n\t\t\t" . $before_title . $title . $after_title;
43
-
44
- echo "\n\t\t\t" . '<ul class="xoxo users">';
45
-
46
- echo "\n\t\t\t\t" . str_replace( array( "\r", "\n", "\t" ), '', members_list_users( $users ) );
47
-
48
- echo "\n\t\t\t" . '</ul><!-- .xoxo .users -->';
49
-
50
- echo $after_widget;
51
- }
52
-
53
- function update( $new_instance, $old_instance ) {
54
- $instance = $old_instance;
55
- $instance['title'] = strip_tags( $new_instance['title'] );
56
- $instance['limit'] = strip_tags( $new_instance['limit'] );
57
- $instance['include'] = strip_tags( $new_instance['include'] );
58
- $instance['exclude'] = strip_tags( $new_instance['exclude'] );
59
- $instance['order'] = $new_instance['order'];
60
- $instance['orderby'] = $new_instance['orderby'];
61
- $instance['show_fullname'] = $new_instance['show_fullname'];
62
-
63
- return $instance;
64
- }
65
-
66
- function form( $instance ) {
67
-
68
- //Defaults
69
- $defaults = array( 'title' => __('Users', 'members'), 'show_fullname' => true, 'order' => 'ASC', 'orderby' => 'display_name' );
70
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
71
-
72
- <p>
73
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title:', 'members'); ?></label>
74
- <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:99%;" />
75
- </p>
76
- <p>
77
- <label for="<?php echo $this->get_field_id( 'limit' ); ?>"><?php _e('Limit:', 'members'); ?> <code>limit</code></label>
78
- <input id="<?php echo $this->get_field_id( 'limit' ); ?>" name="<?php echo $this->get_field_name( 'limit' ); ?>" value="<?php echo $instance['limit']; ?>" style="width:99%;" />
79
- </p>
80
- <p>
81
- <label for="<?php echo $this->get_field_id( 'order' ); ?>"><?php _e('Order:', 'widgets-reloaded'); ?> <code>order</code></label>
82
- <select id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>" class="widefat" style="width:100%;">
83
- <option <?php if ( 'ASC' == $instance['order'] ) echo 'selected="selected"'; ?>>ASC</option>
84
- <option <?php if ( 'DESC' == $instance['order'] ) echo 'selected="selected"'; ?>>DESC</option>
85
- </select>
86
- </p>
87
- <p>
88
- <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><?php _e('Order By:', 'widgets-reloaded'); ?> <code>orderby</code></label>
89
- <select id="<?php echo $this->get_field_id( 'orderby' ); ?>" name="<?php echo $this->get_field_name( 'orderby' ); ?>" class="widefat" style="width:100%;">
90
- <option <?php if ( 'display_name' == $instance['orderby'] ) echo 'selected="selected"'; ?>>display_name</option>
91
- <option <?php if ( 'ID' == $instance['orderby'] ) echo 'selected="selected"'; ?>>ID</option>
92
- <option <?php if ( 'user_login' == $instance['orderby'] ) echo 'selected="selected"'; ?>>user_login</option>
93
- </select>
94
- </p>
95
- <p>
96
- <label for="<?php echo $this->get_field_id( 'include' ); ?>"><?php _e('Include:', 'members'); ?> <code>include</code></label>
97
- <input id="<?php echo $this->get_field_id( 'include' ); ?>" name="<?php echo $this->get_field_name( 'include' ); ?>" value="<?php echo $instance['include']; ?>" style="width:99%;" />
98
- </p>
99
- <p>
100
- <label for="<?php echo $this->get_field_id( 'exclude' ); ?>"><?php _e('Exclude:', 'members'); ?> <code>exclude</code></label>
101
- <input id="<?php echo $this->get_field_id( 'exclude' ); ?>" name="<?php echo $this->get_field_name( 'exclude' ); ?>" value="<?php echo $instance['exclude']; ?>" style="width:99%;" />
102
- </p>
103
- <p>
104
- <label for="<?php echo $this->get_field_id( 'show_fullname' ); ?>">
105
- <input class="checkbox" type="checkbox" <?php checked( $instance['show_fullname'], true ); ?> id="<?php echo $this->get_field_id( 'show_fullname' ); ?>" name="<?php echo $this->get_field_name( 'show_fullname' ); ?>" /> <?php _e('Show full name?', 'members'); ?> <code>show_fullname</code></label>
106
- </p>
107
-
108
- <div style="clear:both;">&nbsp;</div>
109
- <?php
110
- }
111
- }
112
-
113
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/widget-login-form.php CHANGED
@@ -16,9 +16,9 @@ class Members_Widget_Login extends WP_Widget {
16
  /**
17
  * Set up the widget's unique name, ID, class, description, and other options.
18
  *
19
- * @since 0.1.0
20
  */
21
- function Members_Widget_Login() {
22
 
23
  /* Set up the widget options. */
24
  $widget_options = array(
@@ -34,7 +34,17 @@ class Members_Widget_Login extends WP_Widget {
34
  );
35
 
36
  /* Create the widget. */
37
- $this->WP_Widget( 'members-widget-login', esc_attr__( 'Login Form', 'members' ), $widget_options, $control_options );
 
 
 
 
 
 
 
 
 
 
38
  }
39
 
40
  /**
16
  /**
17
  * Set up the widget's unique name, ID, class, description, and other options.
18
  *
19
+ * @since 0.2.5
20
  */
21
+ public function __construct() {
22
 
23
  /* Set up the widget options. */
24
  $widget_options = array(
34
  );
35
 
36
  /* Create the widget. */
37
+ parent::__construct( 'members-widget-login', esc_attr__( 'Login Form', 'members' ), $widget_options, $control_options );
38
+ }
39
+
40
+ /**
41
+ * Set up the widget's unique name, ID, class, description, and other options.
42
+ *
43
+ * @since 0.1.0
44
+ * @deprecated 0.2.5
45
+ */
46
+ function Members_Widget_Login() {
47
+ $this->__construct();
48
  }
49
 
50
  /**
includes/widget-users.php CHANGED
@@ -16,9 +16,9 @@ class Members_Widget_Users extends WP_Widget {
16
  /**
17
  * Set up the widget's unique name, ID, class, description, and other options.
18
  *
19
- * @since 0.1.0
20
  */
21
- function Members_Widget_Users() {
22
 
23
  /* Set up the widget options. */
24
  $widget_options = array(
@@ -34,7 +34,17 @@ class Members_Widget_Users extends WP_Widget {
34
  );
35
 
36
  /* Create the widget. */
37
- $this->WP_Widget( 'members-widget-users', esc_attr__( 'Users', 'members' ), $widget_options, $control_options );
 
 
 
 
 
 
 
 
 
 
38
  }
39
 
40
  /**
@@ -158,7 +168,7 @@ class Members_Widget_Users extends WP_Widget {
158
  <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" />
159
  </p>
160
  <p>
161
- <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><code>orderby</code></label>
162
  <select class="widefat" id="<?php echo $this->get_field_id( 'orderby' ); ?>" name="<?php echo $this->get_field_name( 'orderby' ); ?>">
163
  <?php foreach ( $orderby as $option_value => $option_label ) { ?>
164
  <option value="<?php echo esc_attr( $option_value ); ?>" <?php selected( $instance['orderby'], $option_value ); ?>><?php echo esc_html( $option_label ); ?></option>
@@ -166,7 +176,7 @@ class Members_Widget_Users extends WP_Widget {
166
  </select>
167
  </p>
168
  <p>
169
- <label for="<?php echo $this->get_field_id( 'order' ); ?>"><code>order</code></label>
170
  <select class="widefat" id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>">
171
  <?php foreach ( $order as $option_value => $option_label ) { ?>
172
  <option value="<?php echo esc_attr( $option_value ); ?>" <?php selected( $instance['order'], $option_value ); ?>><?php echo esc_html( $option_label ); ?></option>
@@ -174,7 +184,7 @@ class Members_Widget_Users extends WP_Widget {
174
  </select>
175
  </p>
176
  <p>
177
- <label for="<?php echo $this->get_field_id( 'role' ); ?>"><code>role</code></label>
178
  <select class="widefat" id="<?php echo $this->get_field_id( 'role' ); ?>" name="<?php echo $this->get_field_name( 'role' ); ?>">
179
  <?php foreach ( $roles as $role => $name ) { ?>
180
  <option value="<?php echo esc_attr( $role ); ?>" <?php selected( $instance['role'], $role ); ?>><?php echo esc_html( $name ); ?></option>
@@ -206,7 +216,7 @@ class Members_Widget_Users extends WP_Widget {
206
  <input type="text" class="widefat code" id="<?php echo $this->get_field_id( 'search' ); ?>" name="<?php echo $this->get_field_name( 'search' ); ?>" value="<?php echo esc_attr( $instance['search'] ); ?>" />
207
  </p>
208
  <p>
209
- <label for="<?php echo $this->get_field_id( 'meta_key' ); ?>"><code>meta_key</code></label>
210
  <select class="widefat" id="<?php echo $this->get_field_id( 'meta_key' ); ?>" name="<?php echo $this->get_field_name( 'meta_key' ); ?>">
211
  <?php foreach ( $meta_key as $meta ) { ?>
212
  <option value="<?php echo esc_attr( $meta ); ?>" <?php selected( $instance['meta_key'], $meta ); ?>><?php echo esc_html( $meta ); ?></option>
16
  /**
17
  * Set up the widget's unique name, ID, class, description, and other options.
18
  *
19
+ * @since 0.2.5
20
  */
21
+ public function __construct() {
22
 
23
  /* Set up the widget options. */
24
  $widget_options = array(
34
  );
35
 
36
  /* Create the widget. */
37
+ parent::__construct( 'members-widget-users', esc_attr__( 'Users', 'members' ), $widget_options, $control_options );
38
+ }
39
+
40
+ /**
41
+ * Set up the widget's unique name, ID, class, description, and other options.
42
+ *
43
+ * @since 0.1.0
44
+ * @deprecated 0.2.5
45
+ */
46
+ function Members_Widget_Users() {
47
+ $this->__construct();
48
  }
49
 
50
  /**
168
  <input type="text" class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" />
169
  </p>
170
  <p>
171
+ <label for="<?php echo $this->get_field_id( 'orderby' ); ?>"><code>orderby</code></label>
172
  <select class="widefat" id="<?php echo $this->get_field_id( 'orderby' ); ?>" name="<?php echo $this->get_field_name( 'orderby' ); ?>">
173
  <?php foreach ( $orderby as $option_value => $option_label ) { ?>
174
  <option value="<?php echo esc_attr( $option_value ); ?>" <?php selected( $instance['orderby'], $option_value ); ?>><?php echo esc_html( $option_label ); ?></option>
176
  </select>
177
  </p>
178
  <p>
179
+ <label for="<?php echo $this->get_field_id( 'order' ); ?>"><code>order</code></label>
180
  <select class="widefat" id="<?php echo $this->get_field_id( 'order' ); ?>" name="<?php echo $this->get_field_name( 'order' ); ?>">
181
  <?php foreach ( $order as $option_value => $option_label ) { ?>
182
  <option value="<?php echo esc_attr( $option_value ); ?>" <?php selected( $instance['order'], $option_value ); ?>><?php echo esc_html( $option_label ); ?></option>
184
  </select>
185
  </p>
186
  <p>
187
+ <label for="<?php echo $this->get_field_id( 'role' ); ?>"><code>role</code></label>
188
  <select class="widefat" id="<?php echo $this->get_field_id( 'role' ); ?>" name="<?php echo $this->get_field_name( 'role' ); ?>">
189
  <?php foreach ( $roles as $role => $name ) { ?>
190
  <option value="<?php echo esc_attr( $role ); ?>" <?php selected( $instance['role'], $role ); ?>><?php echo esc_html( $name ); ?></option>
216
  <input type="text" class="widefat code" id="<?php echo $this->get_field_id( 'search' ); ?>" name="<?php echo $this->get_field_name( 'search' ); ?>" value="<?php echo esc_attr( $instance['search'] ); ?>" />
217
  </p>
218
  <p>
219
+ <label for="<?php echo $this->get_field_id( 'meta_key' ); ?>"><code>meta_key</code></label>
220
  <select class="widefat" id="<?php echo $this->get_field_id( 'meta_key' ); ?>" name="<?php echo $this->get_field_name( 'meta_key' ); ?>">
221
  <?php foreach ( $meta_key as $meta ) { ?>
222
  <option value="<?php echo esc_attr( $meta ); ?>" <?php selected( $instance['meta_key'], $meta ); ?>><?php echo esc_html( $meta ); ?></option>
members.php CHANGED
@@ -3,26 +3,26 @@
3
  * Plugin Name: Members
4
  * Plugin URI: http://themehybrid.com/plugins/members
5
  * Description: A user, role, and content management plugin for controlling permissions and access. A plugin for making WordPress a more powerful <acronym title="Content Management System">CMS</acronym>.
6
- * Version: 0.2.4
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
  *
10
- * The members plugin was created because the WordPress community is lacking a solid permissions
11
- * plugin that is both open source and works completely within the confines of the APIs in WordPress.
12
- * But, the plugin is so much more than just a plugin to control permissions. It is meant to extend
13
  * WordPress by making user, role, and content management as simple as using WordPress itself.
14
  *
15
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
16
- * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
17
  * that you can use any other version of the GPL.
18
  *
19
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
20
  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
  *
22
  * @package Members
23
- * @version 0.2.4
24
  * @author Justin Tadlock <justin@justintadlock.com>
25
- * @copyright Copyright (c) 2009 - 2013, Justin Tadlock
26
  * @link http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin
27
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
28
  */
@@ -67,7 +67,7 @@ class Members_Load {
67
  function constants() {
68
 
69
  /* Set the version number of the plugin. */
70
- define( 'MEMBERS_VERSION', '0.2.4' );
71
 
72
  /* Set the database version number of the plugin. */
73
  define( 'MEMBERS_DB_VERSION', 2 );
@@ -176,10 +176,10 @@ class Members_Load {
176
  }
177
 
178
  /**
179
- * If the administrator role does not exist for some reason, we have a bit of a problem
180
- * because this is a role management plugin and requires that someone actually be able to
181
- * manage roles. So, we're going to create a custom role here. The site administrator can
182
- * assign this custom role to any user they wish to work around this problem. We're only
183
  * doing this for single-site installs of WordPress. The 'super admin' has permission to do
184
  * pretty much anything on a multisite install.
185
  */
3
  * Plugin Name: Members
4
  * Plugin URI: http://themehybrid.com/plugins/members
5
  * Description: A user, role, and content management plugin for controlling permissions and access. A plugin for making WordPress a more powerful <acronym title="Content Management System">CMS</acronym>.
6
+ * Version: 0.2.5
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
  *
10
+ * The members plugin was created because the WordPress community is lacking a solid permissions
11
+ * plugin that is both open source and works completely within the confines of the APIs in WordPress.
12
+ * But, the plugin is so much more than just a plugin to control permissions. It is meant to extend
13
  * WordPress by making user, role, and content management as simple as using WordPress itself.
14
  *
15
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
16
+ * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
17
  * that you can use any other version of the GPL.
18
  *
19
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
20
  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
  *
22
  * @package Members
23
+ * @version 0.2.5
24
  * @author Justin Tadlock <justin@justintadlock.com>
25
+ * @copyright Copyright (c) 2009 - 2015, Justin Tadlock
26
  * @link http://justintadlock.com/archives/2009/09/17/members-wordpress-plugin
27
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
28
  */
67
  function constants() {
68
 
69
  /* Set the version number of the plugin. */
70
+ define( 'MEMBERS_VERSION', '0.2.5' );
71
 
72
  /* Set the database version number of the plugin. */
73
  define( 'MEMBERS_DB_VERSION', 2 );
176
  }
177
 
178
  /**
179
+ * If the administrator role does not exist for some reason, we have a bit of a problem
180
+ * because this is a role management plugin and requires that someone actually be able to
181
+ * manage roles. So, we're going to create a custom role here. The site administrator can
182
+ * assign this custom role to any user they wish to work around this problem. We're only
183
  * doing this for single-site installs of WordPress. The 'super admin' has permission to do
184
  * pretty much anything on a multisite install.
185
  */
readme.txt CHANGED
@@ -4,8 +4,7 @@ Contributors: greenshady
4
  Donate link: http://themehybrid.com/donate
5
  Tags: admin, role, roles, member, members, profile, shortcode, user, users, widget, widgets
6
  Requires at least: 3.4
7
- Tested up to: 3.7
8
- Stable tag: 0.2.4
9
 
10
  A user, role, and content management plugin that makes WordPress a more powerful CMS.
11
 
@@ -25,7 +24,7 @@ The foundation of the plugin is its extensive role and capability management sys
25
 
26
  ### Professional Support
27
 
28
- If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](http://themehybrid.com/support), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 40,000+ users (and growing).
29
 
30
  ### Plugin Development
31
 
@@ -79,6 +78,13 @@ Well, that's why you really need to read the documentation for the plugin before
79
 
80
  == Changelog ==
81
 
 
 
 
 
 
 
 
82
  ### Version 0.2.4
83
 
84
  * Fixed content permissions not saving for attachments. Note that this only protects **content** and not media files.
4
  Donate link: http://themehybrid.com/donate
5
  Tags: admin, role, roles, member, members, profile, shortcode, user, users, widget, widgets
6
  Requires at least: 3.4
7
+ Stable tag: 0.2.5
 
8
 
9
  A user, role, and content management plugin that makes WordPress a more powerful CMS.
10
 
24
 
25
  ### Professional Support
26
 
27
+ If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](http://themehybrid.com/support), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 60,000+ users (and growing).
28
 
29
  ### Plugin Development
30
 
78
 
79
  == Changelog ==
80
 
81
+ ### Version 0.2.5 - 2015-07-09
82
+
83
+ #### Fixed
84
+
85
+ * Deprecated old widget constructor method in favor of using `__construct()` in preparation for WP 4.3.
86
+ * Removed old `/components` folder and files that's not used.
87
+
88
  ### Version 0.2.4
89
 
90
  * Fixed content permissions not saving for attachments. Note that this only protects **content** and not media files.