ehssl-admin-init.php
1 year ago
ehssl-admin-menu.php
2 days ago
ehssl-certificate-expiry-menu.php
2 days ago
ehssl-dashboard-menu.php
2 days ago
ehssl-settings-menu-old.php
1 year ago
ehssl-settings-menu.php
2 days ago
ehssl-ssl-management-menu.php
1 year ago
index.php
1 year ago
ehssl-dashboard-menu.php
159 lines
| 1 | <?php |
| 2 | |
| 3 | class EHSSL_Dashboard_Menu extends EHSSL_Admin_Menu |
| 4 | { |
| 5 | public $menu_page_slug = EHSSL_MAIN_MENU_SLUG; |
| 6 | |
| 7 | // Specify all the tabs of this menu in the following array |
| 8 | public $dashboard_menu_tabs = array( |
| 9 | 'status' => 'Status', |
| 10 | // 'tab2' => 'Tab Two' |
| 11 | ); |
| 12 | |
| 13 | public function get_current_tab() |
| 14 | { |
| 15 | $tab = isset($_GET['tab']) ? $_GET['tab'] : array_keys($this->dashboard_menu_tabs)[0]; |
| 16 | return $tab; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Renders our tabs of this menu as nav items |
| 21 | */ |
| 22 | public function render_page_tabs() |
| 23 | { |
| 24 | $current_tab = $this->get_current_tab(); |
| 25 | foreach ($this->dashboard_menu_tabs as $tab_key => $tab_caption) { |
| 26 | $active = $current_tab == $tab_key ? 'nav-tab-active' : ''; |
| 27 | echo '<a class="nav-tab ' . $active . '" href="?page=' . $this->menu_page_slug . '&tab=' . $tab_key . '">' . $tab_caption . '</a>'; |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * The menu rendering goes here |
| 33 | */ |
| 34 | public function render_menu_page() |
| 35 | { |
| 36 | $tab = $this->get_current_tab(); |
| 37 | ?> |
| 38 | <div class="wrap"> |
| 39 | <h2><?php _e("Dashboard", 'https-redirection') ?></h2> |
| 40 | <h2 class="nav-tab-wrapper"><?php $this->render_page_tabs(); ?></h2> |
| 41 | <div id="poststuff"> |
| 42 | <div id="post-body"> |
| 43 | <?php |
| 44 | $tab_keys = array_keys($this->dashboard_menu_tabs); |
| 45 | switch ($tab) { |
| 46 | case 'status': |
| 47 | default: |
| 48 | $this->render_status_tab(); |
| 49 | break; |
| 50 | } |
| 51 | ?> |
| 52 | </div> |
| 53 | </div> |
| 54 | </div><!-- end or wrap --> |
| 55 | <?php |
| 56 | } |
| 57 | |
| 58 | public function render_status_tab() |
| 59 | { |
| 60 | ?> |
| 61 | <div id="ehssl-dashboard-widgets-wrap"> |
| 62 | <div id="ehssl-dashboard-widgets" class="metabox-holder"> |
| 63 | <div class="ehssl-dashboard-widget-column postbox-container"> |
| 64 | <?php $this->widget_ssl_status(); ?> |
| 65 | </div> |
| 66 | <div class="ehssl-dashboard-widget-column postbox-container"> |
| 67 | <?php $this->widget_ssl_info(); ?> |
| 68 | </div> |
| 69 | <div class="ehssl-dashboard-widget-column postbox-container"> |
| 70 | <!-- Widgets here --> |
| 71 | </div> |
| 72 | </div> |
| 73 | </div> |
| 74 | <style> |
| 75 | #ehssl-dashboard-widgets{ |
| 76 | display: flex; |
| 77 | justify-content: space-around; |
| 78 | } |
| 79 | .ehssl-dashboard-widget-column { |
| 80 | flex: 1; |
| 81 | background-color: transparent; |
| 82 | min-width: 200px; |
| 83 | } |
| 84 | .ehssl-dashboard-widget-column .postbox { |
| 85 | margin: 0px 8px 28px; |
| 86 | } |
| 87 | </style> |
| 88 | <?php |
| 89 | } |
| 90 | |
| 91 | public function widget_ssl_status() |
| 92 | { |
| 93 | ?> |
| 94 | <div id="ehssl_dashboard_ssl_status" class="sortable-item postbox" data-item-id="1"> |
| 95 | <div class="postbox-header handle"> |
| 96 | <h2><?php _e("SSL Status", 'https-redirection'); ?></h2> |
| 97 | </div> |
| 98 | |
| 99 | <div class="inside"> |
| 100 | <div style="padding: 12px 0 6px; display: flex; align-items: center; flex-direction: column;"> |
| 101 | <?php if ($this->is_ssl_installed) { ?> |
| 102 | <div style="color: green; height: 5rem"> |
| 103 | <span class="dashicons dashicons-lock" style="transform: scale(4); transform-origin: top center;"></span> |
| 104 | </div> |
| 105 | <div> |
| 106 | <?php _e('Your site is protected!', 'https-redirection') ?> |
| 107 | </div> |
| 108 | <?php } else { ?> |
| 109 | <div style="color: #cc0000; height: 5rem"> |
| 110 | <span class="dashicons dashicons-dismiss" style="transform: scale(4); transform-origin: top center;"></span> |
| 111 | </div> |
| 112 | <div> |
| 113 | <?php _e('No SSL found!', 'https-redirection') ?> |
| 114 | </div> |
| 115 | <?php } ?> |
| 116 | </div> |
| 117 | </div><!-- end of inside --> |
| 118 | </div><!-- end of postbox --> |
| 119 | <?php |
| 120 | } |
| 121 | |
| 122 | public function widget_ssl_info() { |
| 123 | if (empty($this->is_ssl_installed)) { |
| 124 | return; |
| 125 | } |
| 126 | |
| 127 | $ssl_info = EHSSL_SSL_Utils::get_parsed_current_ssl_info_for_dashbaord(); |
| 128 | ?> |
| 129 | <div id="ehssl_dashboard_ssl_info" class="sortable-item postbox" data-item-id="2"> |
| 130 | <div class="postbox-header handle"> |
| 131 | <h2><?php _e("SSL Information", 'https-redirection'); ?></h2> |
| 132 | </div> |
| 133 | <div class="inside"> |
| 134 | <table> |
| 135 | <?php foreach ($ssl_info as $section => $fields) { ?> |
| 136 | <tr valign="top" style="margin: 24px 0;"> |
| 137 | <td scope="row"> |
| 138 | <b style="font-weight: bold;"> |
| 139 | <?php _e($section, 'https-redirection'); ?> |
| 140 | </b> |
| 141 | </td> |
| 142 | <th></th> |
| 143 | <th></th> |
| 144 | </tr> |
| 145 | <?php foreach ($fields as $field => $value) { ?> |
| 146 | <tr valign="top"> |
| 147 | <td><?php _e($field, 'https-redirection'); ?></td> |
| 148 | <td> : </td> |
| 149 | <td><?php echo $value ?></td> |
| 150 | </tr> |
| 151 | <?php } ?> |
| 152 | <?php } ?> |
| 153 | </table> |
| 154 | </div><!-- end of inside --> |
| 155 | </div><!-- end of postbox --> |
| 156 | <?php |
| 157 | } |
| 158 | |
| 159 | } //end class |