| 1 |
<?php |
| 2 |
/** |
| 3 |
* Authorizer |
| 4 |
* |
| 5 |
* @license GPL-2.0+ |
| 6 |
* @link https://github.com/uhm-coe/authorizer |
| 7 |
* @package authorizer |
| 8 |
*/ |
| 9 |
|
| 10 |
namespace Authorizer; |
| 11 |
|
| 12 |
use Authorizer\Helper; |
| 13 |
use Authorizer\Options; |
| 14 |
use Authorizer\Options\Access_Lists; |
| 15 |
use Authorizer\Options\Login_Access; |
| 16 |
|
| 17 |
/** |
| 18 |
* Builds the Dashboard widget. |
| 19 |
*/ |
| 20 |
class Dashboard_Widget extends Static_Instance { |
| 21 |
|
| 22 |
/** |
| 23 |
* Load Authorizer dashboard widget if it's enabled. |
| 24 |
* |
| 25 |
* Action: wp_dashboard_setup |
| 26 |
*/ |
| 27 |
public function add_dashboard_widgets() { |
| 28 |
$options = Options::get_instance(); |
| 29 |
$widget_enabled = $options->get( 'advanced_widget_enabled', Helper::SINGLE_CONTEXT, 'allow override' ) === '1'; |
| 30 |
|
| 31 |
// Load authorizer dashboard widget if it's enabled and user has permission. |
| 32 |
if ( current_user_can( 'create_users' ) && $widget_enabled ) { |
| 33 |
// Add dashboard widget for adding/editing users with access. |
| 34 |
wp_add_dashboard_widget( 'auth_dashboard_widget', __( 'Authorizer Settings', 'authorizer' ), array( $this, 'add_auth_dashboard_widget' ) ); |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
/** |
| 40 |
* Render Authorizer dashboard widget (callback). |
| 41 |
*/ |
| 42 |
public function add_auth_dashboard_widget() { |
| 43 |
$access_lists = Access_Lists::get_instance(); |
| 44 |
$login_access = Login_Access::get_instance(); |
| 45 |
?> |
| 46 |
<form method="post" id="auth_settings_access_form" action=""> |
| 47 |
<?php $login_access->print_section_info_access_login(); ?> |
| 48 |
<div> |
| 49 |
<h2><?php esc_html_e( 'Pending Users', 'authorizer' ); ?></h2> |
| 50 |
<?php $access_lists->print_combo_auth_access_users_pending(); ?> |
| 51 |
</div> |
| 52 |
<div> |
| 53 |
<h2><?php esc_html_e( 'Approved Users', 'authorizer' ); ?></h2> |
| 54 |
<?php $access_lists->print_combo_auth_access_users_approved(); ?> |
| 55 |
</div> |
| 56 |
<div> |
| 57 |
<h2><?php esc_html_e( 'Blocked Users', 'authorizer' ); ?></h2> |
| 58 |
<?php $access_lists->print_combo_auth_access_users_blocked(); ?> |
| 59 |
</div> |
| 60 |
<br class="clear" /> |
| 61 |
</form> |
| 62 |
<?php |
| 63 |
} |
| 64 |
|
| 65 |
} |
| 66 |
|