| @@ -16,9 +16,9 @@ | ||
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * Builds the Dashboard widget. |
| 19 | 19 | */ |
| 20 | -class Dashboard_Widget extends Static_Instance { | |
| 20 | +class Dashboard_Widget extends Singleton { | |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * Load Authorizer dashboard widget if it's enabled. |
| 24 | 24 | * |
| @@ -41,8 +41,13 @@ | ||
| 41 | 41 | */ |
| 42 | 42 | public function add_auth_dashboard_widget() { |
| 43 | 43 | $access_lists = Access_Lists::get_instance(); |
| 44 | 44 | $login_access = Login_Access::get_instance(); |
| 45 | + | |
| 46 | + // Get link to Authorizer options (for dashboard widget settings button). | |
| 47 | + $options = Options::get_instance(); | |
| 48 | + $admin_menu = $options->get( 'advanced_admin_menu' ); | |
| 49 | + $settings_url = 'settings' === $admin_menu ? admin_url( 'options-general.php?page=authorizer&tab=access_lists' ) : admin_url( 'admin.php?page=authorizer&tab=access_lists' ); | |
| 45 | 50 | ?> |
| 46 | 51 | <form method="post" id="auth_settings_access_form" action=""> |
| 47 | 52 | <?php $login_access->print_section_info_access_login(); ?> |
| 48 | 53 | <div> |
| @@ -48,12 +53,14 @@ | ||
| 48 | 53 | <div> |
| 49 | 54 | <h2><?php esc_html_e( 'Pending Users', 'authorizer' ); ?></h2> |
| 50 | 55 | <?php $access_lists->print_combo_auth_access_users_pending(); ?> |
| 51 | 56 | </div> |
| 57 | + <br class="clear" /> | |
| 52 | 58 | <div> |
| 53 | 59 | <h2><?php esc_html_e( 'Approved Users', 'authorizer' ); ?></h2> |
| 54 | 60 | <?php $access_lists->print_combo_auth_access_users_approved(); ?> |
| 55 | 61 | </div> |
| 62 | + <br class="clear" /> | |
| 56 | 63 | <div> |
| 57 | 64 | <h2><?php esc_html_e( 'Blocked Users', 'authorizer' ); ?></h2> |
| 58 | 65 | <?php $access_lists->print_combo_auth_access_users_blocked(); ?> |
| 59 | 66 | </div> |
| @@ -58,8 +65,38 @@ | ||
| 58 | 65 | <?php $access_lists->print_combo_auth_access_users_blocked(); ?> |
| 59 | 66 | </div> |
| 60 | 67 | <br class="clear" /> |
| 61 | 68 | </form> |
| 69 | + <button type="button" class="handlediv js-toggle-auth_settings_dashboard_widget_control" aria-expanded="true" data-href="<?php echo esc_attr( $settings_url ); ?>"> | |
| 70 | + <span class="screen-reader-text"><?php esc_html_e( 'Settings', 'authorizer' ); ?></span> | |
| 71 | + <span class="toggle-indicator" aria-hidden="true"></span> | |
| 72 | + </button> | |
| 73 | + <?php | |
| 74 | + } | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * Add scripts for dashboard widget. | |
| 78 | + * | |
| 79 | + * Action: admin_head-index.php | |
| 80 | + */ | |
| 81 | + public function widget_scripts() { | |
| 82 | + ?> | |
| 83 | + <script type="text/javascript"> | |
| 84 | + /* <![CDATA[ */ | |
| 85 | + jQuery( function( $ ) { | |
| 86 | + if ( $( '#auth_dashboard_widget' ).length ) { | |
| 87 | + // Widget settings toggle. | |
| 88 | + var toggle = $( '.js-toggle-auth_settings_dashboard_widget_control' ); | |
| 89 | + toggle.appendTo( '#auth_dashboard_widget .handle-actions' ); | |
| 90 | + toggle.click( function( e ) { | |
| 91 | + e.preventDefault(); | |
| 92 | + e.stopImmediatePropagation(); | |
| 93 | + window.location.href = $( this ).data( 'href' ); | |
| 94 | + } ); | |
| 95 | + } | |
| 96 | + } ); | |
| 97 | + /* ]]> */ | |
| 98 | + </script> | |
| 62 | 99 | <?php |
| 63 | 100 | } |
| 64 | 101 | |
| 65 | 102 | } |