screen-attachment.php
7 months ago
screen-options-page.php
7 months ago
screen-post.php
7 months ago
screen-settings.php
7 months ago
screen-taxonomy.php
3 months ago
screen-user.php
7 months ago
screen-user.php
257 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_screen_user')): |
| 8 | |
| 9 | class acfe_screen_user{ |
| 10 | |
| 11 | // vars |
| 12 | var $user_id; |
| 13 | |
| 14 | /** |
| 15 | * construct |
| 16 | */ |
| 17 | function __construct(){ |
| 18 | |
| 19 | /** |
| 20 | * hooks: |
| 21 | * |
| 22 | * acfe/load_user_new |
| 23 | * acfe/add_user_new_meta_boxes |
| 24 | * |
| 25 | * acfe/load_user $user_id |
| 26 | * acfe/add_user_meta_boxes $user |
| 27 | * |
| 28 | * acfe/load_users |
| 29 | * acfe/add_users_meta_boxes |
| 30 | */ |
| 31 | |
| 32 | // add |
| 33 | add_action('load-user-new.php', array($this, 'user_new_load')); |
| 34 | |
| 35 | // edit |
| 36 | add_action('load-profile.php', array($this, 'user_load')); |
| 37 | add_action('load-user-edit.php', array($this, 'user_load')); |
| 38 | |
| 39 | // list |
| 40 | add_action('load-users.php', array($this, 'users_load')); |
| 41 | |
| 42 | } |
| 43 | |
| 44 | |
| 45 | /** |
| 46 | * user_new_load |
| 47 | * |
| 48 | * load-user-new.php |
| 49 | */ |
| 50 | function user_new_load(){ |
| 51 | |
| 52 | // do not process on multisite |
| 53 | if(is_multisite()){ |
| 54 | return; |
| 55 | } |
| 56 | |
| 57 | // actions |
| 58 | do_action("acfe/load_user_new"); |
| 59 | |
| 60 | // hooks |
| 61 | add_action('user_new_form', array($this, 'user_new_meta_boxes')); |
| 62 | |
| 63 | } |
| 64 | |
| 65 | |
| 66 | /** |
| 67 | * user_new_meta_boxes |
| 68 | * |
| 69 | * user_new_form |
| 70 | * |
| 71 | * @param $user |
| 72 | */ |
| 73 | function user_new_meta_boxes($user){ |
| 74 | |
| 75 | // add meta boxes |
| 76 | do_action('acfe/add_user_new_meta_boxes'); |
| 77 | |
| 78 | // enhanced ui |
| 79 | if(acf_get_setting('acfe/modules/ui')){ |
| 80 | |
| 81 | // do meta boxes |
| 82 | $screen = get_current_screen(); |
| 83 | |
| 84 | do_meta_boxes($screen, 'acf_after_title', $user); |
| 85 | do_meta_boxes($screen, 'normal', $user); |
| 86 | do_meta_boxes($screen, 'side', $user); |
| 87 | |
| 88 | } |
| 89 | |
| 90 | } |
| 91 | |
| 92 | |
| 93 | /** |
| 94 | * user_load |
| 95 | * |
| 96 | * load-profile.php |
| 97 | */ |
| 98 | function user_load(){ |
| 99 | |
| 100 | // do not process on network screens |
| 101 | if(acf_is_screen(array('user-edit-network', 'profile-network'))){ |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | // vars |
| 106 | $this->user_id = acfe_get_post_id('id'); |
| 107 | |
| 108 | // actions |
| 109 | do_action("acfe/load_user", $this->user_id); |
| 110 | |
| 111 | // hooks |
| 112 | add_action('show_user_profile', array($this, 'user_meta_boxes')); |
| 113 | add_action('edit_user_profile', array($this, 'user_meta_boxes')); |
| 114 | |
| 115 | } |
| 116 | |
| 117 | |
| 118 | /** |
| 119 | * user_meta_boxes |
| 120 | * |
| 121 | * show_user_profile |
| 122 | * |
| 123 | * @param $user |
| 124 | */ |
| 125 | function user_meta_boxes($user){ |
| 126 | |
| 127 | // add meta boxes |
| 128 | do_action('acfe/add_user_meta_boxes', $user); |
| 129 | |
| 130 | // enhanced ui |
| 131 | if(acf_get_setting('acfe/modules/ui')){ |
| 132 | |
| 133 | // do meta boxes |
| 134 | $screen = get_current_screen(); |
| 135 | |
| 136 | do_meta_boxes($screen, 'acf_after_title', $user); |
| 137 | do_meta_boxes($screen, 'normal', $user); |
| 138 | do_meta_boxes($screen, 'side', $user); |
| 139 | |
| 140 | } |
| 141 | |
| 142 | } |
| 143 | |
| 144 | |
| 145 | /** |
| 146 | * users_load |
| 147 | * |
| 148 | * load-users.php |
| 149 | */ |
| 150 | function users_load(){ |
| 151 | |
| 152 | // do not process on network screens |
| 153 | if(acf_is_screen(array('users-network'))){ |
| 154 | return; |
| 155 | } |
| 156 | |
| 157 | // actions |
| 158 | do_action("acfe/load_users"); |
| 159 | |
| 160 | // hooks |
| 161 | add_action('admin_footer', array($this, 'users_footer')); |
| 162 | |
| 163 | } |
| 164 | |
| 165 | |
| 166 | /** |
| 167 | * users_footer |
| 168 | * |
| 169 | * admin_footer |
| 170 | */ |
| 171 | function users_footer(){ |
| 172 | |
| 173 | do_action('acfe/add_users_meta_boxes', 'user'); |
| 174 | |
| 175 | $this->users_do_meta_boxes(); |
| 176 | |
| 177 | } |
| 178 | |
| 179 | |
| 180 | /** |
| 181 | * users_do_meta_boxes |
| 182 | */ |
| 183 | function users_do_meta_boxes(){ |
| 184 | |
| 185 | // check filter |
| 186 | if(!acf_is_filter_enabled('acfe/user_list')){ |
| 187 | return; |
| 188 | } |
| 189 | |
| 190 | // enqueue |
| 191 | acf_enqueue_scripts(); |
| 192 | |
| 193 | ?> |
| 194 | <template id="tmpl-acf-after-title"> |
| 195 | |
| 196 | <div id="poststuff" class="acfe-list-postboxes"> |
| 197 | <form method="post"> |
| 198 | <?php do_meta_boxes('edit', 'acf_after_title', 'user'); ?> |
| 199 | </form> |
| 200 | </div> |
| 201 | |
| 202 | </template> |
| 203 | |
| 204 | <template id="tmpl-acf-normal"> |
| 205 | |
| 206 | <div id="poststuff" class="acfe-list-postboxes"> |
| 207 | <form method="post"> |
| 208 | <?php do_meta_boxes('edit', 'normal', 'user'); ?> |
| 209 | </form> |
| 210 | </div> |
| 211 | |
| 212 | </template> |
| 213 | |
| 214 | <template id="tmpl-acf-side"> |
| 215 | |
| 216 | <div class="acf-column-2"> |
| 217 | |
| 218 | <div id="poststuff" class="acfe-list-postboxes -side"> |
| 219 | <form method="post"> |
| 220 | <?php do_meta_boxes('edit', 'side', 'user'); ?> |
| 221 | </form> |
| 222 | </div> |
| 223 | |
| 224 | </div> |
| 225 | |
| 226 | </template> |
| 227 | <script type="text/javascript"> |
| 228 | (function($){ |
| 229 | |
| 230 | // main form |
| 231 | var $main = $('.wrap > form'); |
| 232 | |
| 233 | $main.wrap('<div class="acf-columns-2" />'); |
| 234 | $main.prepend($('.subsubsub')); |
| 235 | $main.wrap('<div class="acf-column-1" />'); |
| 236 | |
| 237 | // field groups |
| 238 | var $column_1 = $('.acf-column-1'); |
| 239 | |
| 240 | $column_1.prepend($('#tmpl-acf-after-title').html()); |
| 241 | $column_1.append($('#tmpl-acf-normal').html()); |
| 242 | $column_1.after($('#tmpl-acf-side').html()); |
| 243 | |
| 244 | <?php if(!acf_is_filter_enabled('acfe/user_list/side')): ?> |
| 245 | $('.acf-columns-2').removeClass('acf-columns-2'); |
| 246 | <?php endif; ?> |
| 247 | |
| 248 | })(jQuery); |
| 249 | </script> |
| 250 | <?php |
| 251 | } |
| 252 | |
| 253 | } |
| 254 | |
| 255 | acf_new_instance('acfe_screen_user'); |
| 256 | |
| 257 | endif; |