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