| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
if( ! class_exists( 'MywpControllerAbstractModule' ) ) { |
| 8 |
return false; |
| 9 |
} |
| 10 |
|
| 11 |
if ( ! class_exists( 'MywpControllerModuleAdminUsers' ) ) : |
| 12 |
|
| 13 |
final class MywpControllerModuleAdminUsers extends MywpControllerAbstractModule { |
| 14 |
|
| 15 |
static protected $id = 'admin_users'; |
| 16 |
|
| 17 |
public static function mywp_controller_initial_data( $initial_data ) { |
| 18 |
|
| 19 |
$initial_data['per_page_num'] = ''; |
| 20 |
$initial_data['hide_add_new'] = ''; |
| 21 |
$initial_data['hide_search_box'] = ''; |
| 22 |
|
| 23 |
return $initial_data; |
| 24 |
|
| 25 |
} |
| 26 |
|
| 27 |
public static function mywp_controller_default_data( $default_data ) { |
| 28 |
|
| 29 |
$default_data['per_page_num'] = 20; |
| 30 |
$default_data['hide_add_new'] = false; |
| 31 |
$default_data['hide_search_box'] = false; |
| 32 |
|
| 33 |
return $default_data; |
| 34 |
|
| 35 |
} |
| 36 |
|
| 37 |
public static function mywp_wp_loaded() { |
| 38 |
|
| 39 |
if( ! is_admin() ) { |
| 40 |
|
| 41 |
return false; |
| 42 |
|
| 43 |
} |
| 44 |
|
| 45 |
if( is_network_admin() ) { |
| 46 |
|
| 47 |
return false; |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
if( ! self::is_do_controller() ) { |
| 52 |
|
| 53 |
return false; |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
add_action( 'load-users.php' , array( __CLASS__ , 'load_users' ) , 1000 ); |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
public static function load_users() { |
| 62 |
|
| 63 |
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_add_new' ) ); |
| 64 |
|
| 65 |
add_action( 'admin_print_styles' , array( __CLASS__ , 'hide_search_box' ) ); |
| 66 |
|
| 67 |
add_filter( 'users_per_page' , array( __CLASS__ , 'users_per_page' ) ); |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
public static function hide_add_new() { |
| 72 |
|
| 73 |
if( ! self::is_do_function( __FUNCTION__ ) ) { |
| 74 |
|
| 75 |
return false; |
| 76 |
|
| 77 |
} |
| 78 |
|
| 79 |
$setting_data = self::get_setting_data(); |
| 80 |
|
| 81 |
if( empty( $setting_data['hide_add_new'] ) ) { |
| 82 |
|
| 83 |
return false; |
| 84 |
|
| 85 |
} |
| 86 |
|
| 87 |
echo '<style>'; |
| 88 |
|
| 89 |
echo 'body.wp-admin .wrap h1 a { display: none; }'; |
| 90 |
echo 'body.wp-admin .wrap .page-title-action { display: none; }'; |
| 91 |
|
| 92 |
echo '</style>'; |
| 93 |
|
| 94 |
self::after_do_function( __FUNCTION__ ); |
| 95 |
|
| 96 |
} |
| 97 |
|
| 98 |
public static function hide_search_box() { |
| 99 |
|
| 100 |
if( ! self::is_do_function( __FUNCTION__ ) ) { |
| 101 |
|
| 102 |
return false; |
| 103 |
|
| 104 |
} |
| 105 |
|
| 106 |
$setting_data = self::get_setting_data(); |
| 107 |
|
| 108 |
if( empty( $setting_data['hide_search_box'] ) ) { |
| 109 |
|
| 110 |
return false; |
| 111 |
|
| 112 |
} |
| 113 |
|
| 114 |
echo '<style>'; |
| 115 |
|
| 116 |
echo 'body.wp-admin .search-box { display: none; }'; |
| 117 |
|
| 118 |
echo '</style>'; |
| 119 |
|
| 120 |
self::after_do_function( __FUNCTION__ ); |
| 121 |
|
| 122 |
} |
| 123 |
|
| 124 |
public static function users_per_page( $per_page ) { |
| 125 |
|
| 126 |
if( ! self::is_do_function( __FUNCTION__ ) ) { |
| 127 |
|
| 128 |
return $per_page; |
| 129 |
|
| 130 |
} |
| 131 |
|
| 132 |
$setting_data = self::get_setting_data(); |
| 133 |
|
| 134 |
if( empty( $setting_data['per_page_num'] ) ) { |
| 135 |
|
| 136 |
return $per_page; |
| 137 |
|
| 138 |
} |
| 139 |
|
| 140 |
$per_page = $setting_data['per_page_num']; |
| 141 |
|
| 142 |
self::after_do_function( __FUNCTION__ ); |
| 143 |
|
| 144 |
return $per_page; |
| 145 |
|
| 146 |
} |
| 147 |
|
| 148 |
} |
| 149 |
|
| 150 |
MywpControllerModuleAdminUsers::init(); |
| 151 |
|
| 152 |
endif; |
| 153 |
|