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