PluginProbe
Nested Pages / 1.2.0
Nested Pages v1.2.0
3.3.1 3.2.15 3.2.14 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 All 106 releases
wp-nested-pages / app / Entities / User / UserRepository.php
UserRepository.php
59 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 * Get all roles that arent admin, contributor or subscriber
22 * @return array
23 * @since 1.1.7
24 */
25 public function allRoles()
26 {
27 global $wp_roles;
28 $all_roles = $wp_roles->roles;
29 $editable_roles = apply_filters('editable_roles', $all_roles);
30 $roles = array();
31 $exclude = array('Administrator', 'Contributor', 'Subscriber', 'Author');
32 foreach($editable_roles as $editable_role){
33 if ( !in_array($editable_role['name'], $exclude) ){
34 array_push($roles, $editable_role['name']);
35 }
36 }
37 return $roles;
38 }
39
40
41 /**
42 * Can current user sort pages
43 * @return boolean
44 * @since 1.1.7
45 */
46 public function canSortPages()
47 {
48 $roles = $this->getRoles();
49 $cansort = get_option('nestedpages_allowsorting', array());
50 if ( $cansort == "" ) $cansort = array();
51
52 if ( current_user_can('edit_theme_options') ) return true;
53 foreach($roles as $role){
54 if ( in_array(ucfirst($role), $cansort) ) return true;
55 }
56 return false;
57 }
58
59 }