PluginProbe ʕ •ᴥ•ʔ
Nested Pages / 1.3.4
Nested Pages v1.3.4
3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.3.0 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.2 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.3.1 1.6.3.2 1.6.4 1.6.5 1.6.5.1 1.6.5.2 1.6.6 1.6.7 1.6.8 1.7.0 1.7.1 2.0.1 2.0.2 2.0.3 2.0.4 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7
wp-nested-pages / app / Entities / User / UserRepository.php
wp-nested-pages / app / Entities / User Last commit date
UserRepository.php 11 years ago
UserRepository.php
105 lines
1 <?php namespace NestedPages\Entities\User;
2 /**
3 * User Repository
4 * @since 1.1.7
5 */
6 class UserRepository {
7
8 /**
9 * Return Current User's Roles
10 * @return array
11 * @since 1.1.7
12 */
13 public function getRoles()
14 {
15 global $current_user;
16 return $current_user->roles;
17 }
18
19
20
21 /**
22 * Get all roles that arent admin, contributor or subscriber
23 * @return array
24 * @since 1.1.7
25 */
26 public function allRoles()
27 {
28 global $wp_roles;
29 $all_roles = $wp_roles->roles;
30 $editable_roles = apply_filters('editable_roles', $all_roles);
31 $roles = array();
32 $exclude = array('Administrator', 'Contributor', 'Subscriber', 'Author');
33 foreach($editable_roles as $key=>$editable_role){
34 if ( !in_array($editable_role['name'], $exclude) ){
35 $role = array(
36 'name' => $key,
37 'label' => $editable_role['name']
38 );
39 array_push($roles, $role);
40 }
41 }
42 return $roles;
43 }
44
45
46 /**
47 * Can current user sort pages
48 * @return boolean
49 * @since 1.1.7
50 */
51 public function canSortPages()
52 {
53 $roles = $this->getRoles();
54 $cansort = get_option('nestedpages_allowsorting', array());
55 if ( $cansort == "" ) $cansort = array();
56
57 if ( current_user_can('edit_theme_options') ) return true;
58 foreach($roles as $role){
59 if ( in_array($role, $cansort) ) return true;
60 }
61 return false;
62 }
63
64
65 /**
66 * Get an array of all users/ids
67 * @since 1.3.0
68 * @return array
69 */
70 public function allUsers()
71 {
72 $users = get_users(array(
73 'fields' => array('ID', 'display_name')
74 ));
75 return $users;
76 }
77
78
79 /**
80 * Get User's Visible Pages
81 * @since 1.3.4
82 * @return array - array of pages user has toggled visible
83 */
84 public function getVisiblePages()
85 {
86 return unserialize(get_user_meta(get_current_user_id(), 'np_visible_posts', true));
87 }
88
89
90 /**
91 * Update User's Visible Pages
92 */
93 public function updateVisiblePages($post_type, $ids)
94 {
95 $visible = $this->getVisiblePages();
96 $visible[$post_type] = $ids;
97 update_user_meta(
98 get_current_user_id(),
99 'np_visible_posts',
100 serialize($visible)
101 );
102 }
103
104
105 }