PluginProbe
Assistant – Every Day Productivity Apps / 1.5.1
Assistant – Every Day Productivity Apps v1.5.1
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
assistant / backend / src / Hooks / Actions / OnEditUserProfile.php

OnEditUserProfile.php in Assistant – Every Day Productivity Apps 1.5.1, at backend/src/Hooks/Actions/OnEditUserProfile.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
2
3 namespace FL\Assistant\Hooks\Actions;
4
5 use FL\Assistant\Data\UserState;
6 use FL\Assistant\System\View;
7 /**
8 * Class OnEditUserProfile
9 * @package FL\Assistant\Hooks\Actions
10 *
11 */
12 class OnEditUserProfile {
13
14 /**
15 * @var View
16 */
17 protected $view;
18
19 /**
20 * OnEditUserProfile constructor.
21 *
22 * @param View $view
23 */
24 public function __construct( View $view ) {
25 $this->view = $view;
26 }
27
28
29 /**
30 * @param $user
31 */
32 public function __invoke( $user ) {
33
34 if ( ! current_user_can( 'edit_others_posts' ) ) {
35 return false;
36 }
37
38 $state = get_user_meta( $user->ID, UserState::FL_ASSISTANT_STATE, true );
39 $state = $state ? $state : UserState::$default_state;
40 $window = $state['window'];
41
42 if ( ! apply_filters( 'fl_assistant_should_enqueue', true ) ) {
43 return false;
44 }
45
46 $this->view->render(
47 'user-profile', [
48 'show_in_admin' => $state['shouldShowInAdmin'],
49 'window' => $window,
50 'hidden_appearance' => isset( $window['hiddenAppearance'] ) ? $window['hiddenAppearance'] : '',
51 'hidden_appearances' => [
52 '' => __( 'Button (Default)', 'assistant' ),
53 'admin_bar' => __( 'Admin Bar Item', 'assistant' ),
54 ],
55 ]
56 );
57 }
58 }
59