| 1 |
<?php |
| 2 |
|
| 3 |
namespace wpforo\modules\mentioning\classes; |
| 4 |
|
| 5 |
class Template { |
| 6 |
public function __construct() { |
| 7 |
$this->init_hooks(); |
| 8 |
} |
| 9 |
|
| 10 |
private function init_hooks() { |
| 11 |
add_filter( 'wpforo_member_get_actions', [ $this, 'add_member_action' ], 9, 2 ); |
| 12 |
} |
| 13 |
|
| 14 |
public function get_currentstate_ico( $currentstate ) { |
| 15 |
return ( $currentstate ? '<i class="fas fa-bell-slash"></i>' : '<i class="fas fa-bell"></i>' ); |
| 16 |
} |
| 17 |
|
| 18 |
public function add_member_action( $actions, $user ) { |
| 19 |
$userid = $user['userid']; |
| 20 |
return array_merge( [ 'mute_mention' => [ |
| 21 |
'label' => ( $user['is_mention_muted'] ? wpforo_phrase( 'Unmute Mentioning Emails', false ) : wpforo_phrase( 'Mute Mentioning Emails', false ) ), |
| 22 |
'ico' => $this->get_currentstate_ico( $user['is_mention_muted'] ), |
| 23 |
'callback_for_can' => function() use ($userid){ |
| 24 |
return $userid === WPF()->current_userid; |
| 25 |
}, |
| 26 |
'callback_for_get_url' => function() use ( $userid ){ |
| 27 |
return ''; |
| 28 |
}, |
| 29 |
'data' => [ |
| 30 |
'currentstate' => (int) $user['is_mention_muted'], |
| 31 |
'active_label' => wpforo_phrase( 'Unmute Mentioning Emails', false ), |
| 32 |
'inactive_label' => wpforo_phrase( 'Mute Mentioning Emails', false ), |
| 33 |
], |
| 34 |
] ], $actions ); |
| 35 |
} |
| 36 |
} |
| 37 |
|