| 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 |
$state = get_user_meta( $user->ID, UserState::FL_ASSISTANT_STATE, true ); |
| 35 |
$state = $state ? $state : UserState::$default_state; |
| 36 |
$window = $state['window']; |
| 37 |
|
| 38 |
$this->view->render( |
| 39 |
'user-profile', [ |
| 40 |
'show_in_admin' => $state['shouldShowInAdmin'], |
| 41 |
'window' => $window, |
| 42 |
'hidden_appearance' => isset( $window['hiddenAppearance'] ) ? $window['hiddenAppearance'] : '', |
| 43 |
'hidden_appearances' => [ |
| 44 |
'' => __( 'Button (Default)', 'fl-assistant' ), |
| 45 |
'admin_bar' => __( 'Admin Bar Item', 'fl-assistant' ), |
| 46 |
], |
| 47 |
] |
| 48 |
); |
| 49 |
} |
| 50 |
} |
| 51 |
|