Code_Manager.php
6 days ago
Code_Manager_Dashboard.php
6 days ago
Code_Manager_Export.php
6 days ago
Code_Manager_Form.php
6 days ago
Code_Manager_Import.php
6 days ago
Code_Manager_Import_File.php
6 days ago
Code_Manager_List.php
6 days ago
Code_Manager_List_View.php
6 days ago
Code_Manager_Model.php
6 days ago
Code_Manager_Preview.php
6 days ago
Code_Manager_Settings.php
6 days ago
Code_Manager_Tabs.php
6 days ago
Message_Box.php
6 days ago
WP_List_Table.php
6 days ago
Code_Manager_Dashboard.php
283 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Code Manager dashboard class |
| 4 | * |
| 5 | * @package Code_Manager |
| 6 | */ |
| 7 | |
| 8 | namespace Code_Manager { |
| 9 | |
| 10 | /** |
| 11 | * Manages the plugin dashboard in the back-end |
| 12 | */ |
| 13 | class Code_Manager_Dashboard { |
| 14 | |
| 15 | /** |
| 16 | * Add plugin dashboard to plugin back-end page |
| 17 | * |
| 18 | * @return void |
| 19 | */ |
| 20 | public static function add_dashboard() { |
| 21 | $dashboard = new Code_Manager_Dashboard(); |
| 22 | $dashboard->dashboard(); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Check if menu is enabled |
| 27 | * |
| 28 | * @return bool |
| 29 | */ |
| 30 | public static function menu_enabled() { |
| 31 | return true; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Add dashboard to page top |
| 36 | * |
| 37 | * @return void |
| 38 | */ |
| 39 | public function dashboard() { |
| 40 | if ( |
| 41 | isset( $_REQUEST['page'] ) && |
| 42 | ( |
| 43 | \Code_Manager_Admin::PAGE_TAB === $_REQUEST['page'] || |
| 44 | \Code_Manager_Admin::PAGE_MAIN === $_REQUEST['page'] || |
| 45 | \Code_Manager_Admin::PAGE_SETTINGS === $_REQUEST['page'] |
| 46 | ) |
| 47 | ) { |
| 48 | $this->dashboard_default(); |
| 49 | $this->dashboard_mobile(); |
| 50 | |
| 51 | if ( \Code_Manager_Admin::PAGE_TAB === $_REQUEST['page'] ) { |
| 52 | $this->toolbar_tabmode(); |
| 53 | } else { |
| 54 | if ( |
| 55 | \Code_Manager_Admin::PAGE_MAIN === $_REQUEST['page'] && |
| 56 | ( |
| 57 | ! isset( $_REQUEST['action'] ) || |
| 58 | ( |
| 59 | '-1' === $_REQUEST['action'] |
| 60 | ) |
| 61 | ) |
| 62 | ) { |
| 63 | $this->toolbar_listmode(); |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Default dashboard, using full page width |
| 71 | * |
| 72 | * @return void |
| 73 | */ |
| 74 | protected function dashboard_default() { |
| 75 | ?> |
| 76 | <div id="cm-dashboard" style="display:none"> |
| 77 | <div class="cm-dashboard"> |
| 78 | <div class="cm-dashboard-group cm-dashboard-group-code"> |
| 79 | <div class="icons"> |
| 80 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url( 'admin.php' ); ?>?page=<?php echo \Code_Manager_Admin::PAGE_MAIN; ?>" title="Standard WordPress list view"> |
| 81 | <i class="fas fa-table-list"></i> |
| 82 | <div class="label">List mode</div> |
| 83 | </a> |
| 84 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url( 'admin.php' ); ?>?page=<?php echo \Code_Manager_Admin::PAGE_TAB; ?>" title="Open multiple code editors simultaneously"> |
| 85 | <i class="fas fa-folder"></i> |
| 86 | <div class="label">Tab mode</div> |
| 87 | </a> |
| 88 | <a class="cm-dashboard-item cm_tooltip_icons" href="https://code-manager.com/code/" title="Download reusable code from plugin website" target="_blank"> |
| 89 | <i class="fas fa-cloud-download"></i> |
| 90 | <div class="label">Download</div> |
| 91 | </a> |
| 92 | </div> |
| 93 | <div class="subject">Code</div> |
| 94 | </div> |
| 95 | <div class="cm-dashboard-group cm-dashboard-group-settings"> |
| 96 | <div class="icons"> |
| 97 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url( 'options-general.php?page=' . \Code_Manager_Admin::PAGE_SETTINGS ); ?>" title="Plugin Settings"> |
| 98 | <i class="fas fa-cog"></i> |
| 99 | <div class="label">Settings</div> |
| 100 | </a> |
| 101 | <?php |
| 102 | if ( code_manager_fs()->is_registered() ) { |
| 103 | ?> |
| 104 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url( 'admin.php' ); ?>?page=code_manager-account" title="Manage Account"> |
| 105 | <i class="fas fa-user"></i> |
| 106 | <div class="label">Account</div> |
| 107 | </a> |
| 108 | <?php |
| 109 | } |
| 110 | ?> |
| 111 | <a class="cm-dashboard-item cm_tooltip_icons" target="_blank" href="https://code-manager.com/pricing/" title="Online Pricing, Licensing and Ordering"> |
| 112 | <i class="fas fa-hand-holding-usd"></i> |
| 113 | <div class="label">Pricing</div> |
| 114 | </a> |
| 115 | <?php |
| 116 | $menufound = false; |
| 117 | if ( self::menu_enabled() ) { |
| 118 | global $submenu; |
| 119 | $plugin_navigation_default_page = get_option( 'plugin_navigation_default_page' ); |
| 120 | if ( isset( $submenu[ $plugin_navigation_default_page ] ) ) { |
| 121 | foreach ( $submenu[ $plugin_navigation_default_page ] as $pluginmenu ) { |
| 122 | if ( 'code_manager-pricing' === $pluginmenu[2] ) { |
| 123 | $menufound = true; |
| 124 | break; |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | } else { |
| 129 | $menufound = true; |
| 130 | } |
| 131 | if ( $menufound ) { |
| 132 | ?> |
| 133 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url( 'admin.php' ); ?>?page=code_manager-pricing" title="Upgrade plugin from dashboard"> |
| 134 | <i class="fas fa-gem"></i> |
| 135 | <div class="label">Upgrade</div> |
| 136 | </a> |
| 137 | <?php |
| 138 | } |
| 139 | ?> |
| 140 | </div> |
| 141 | <div class="subject">Manage</div> |
| 142 | </div> |
| 143 | <div class="cm-dashboard-group cm-dashboard-group-support"> |
| 144 | <div class="icons"> |
| 145 | <a class="cm-dashboard-item cm_tooltip_icons" target="_blank" href="https://code-manager.com/blog/docs/index/getting-started/read-this-first/" title="Online Help and Documentation"> |
| 146 | <i class="fas fa-question-circle"></i> |
| 147 | <div class="label">Docs</div> |
| 148 | </a> |
| 149 | <a class="cm-dashboard-item cm_tooltip_icons" target="_blank" href="https://wordpress.org/support/plugin/code-manager/" title="Public Support Forum"> |
| 150 | <i class="fas fa-life-ring"></i> |
| 151 | <div class="label">Forum</div> |
| 152 | </a> |
| 153 | <?php |
| 154 | if ( code_manager_fs()->is_premium() ) { |
| 155 | ?> |
| 156 | <a class="cm-dashboard-item cm_tooltip_icons" target="_blank" href="https://users.freemius.com/store/2612" title="Premium Support"> |
| 157 | <i class="fas fa-ambulance"></i> |
| 158 | <div class="label">Premium</div> |
| 159 | </a> |
| 160 | <?php |
| 161 | } |
| 162 | ?> |
| 163 | </div> |
| 164 | <div class="subject">Support</div> |
| 165 | </div> |
| 166 | </div> |
| 167 | </div> |
| 168 | <?php |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Mobile dashboard, using hamburger menu icon |
| 173 | * |
| 174 | * @return void |
| 175 | */ |
| 176 | protected function dashboard_mobile() { |
| 177 | ?> |
| 178 | <div id="cm-dashboard-mobile" style="display:none"> |
| 179 | <div id="cm-dashboard-drop-down"> |
| 180 | <div class="cm_nav_toggle" onclick="toggleMenu()"><i class="fas fa-bars"></i></div> |
| 181 | <div class="cm_nav_title">Code Manager</div> |
| 182 | </div> |
| 183 | <ul> |
| 184 | <li class="menu-item"><a href="<?php echo admin_url( 'admin.php' ); ?>?page=code_manager"><i class="fas fa-table-list"></i> List mode</a></li> |
| 185 | <li class="menu-item"><a href="<?php echo admin_url( 'admin.php' ); ?>?page=<?php echo \Code_Manager_Admin::PAGE_TAB; ?>"><i class="fas fa-folder"></i> Tab mode</a></li> |
| 186 | <li class="menu-item cm-separator"><a href="https://code-manager.com/code/" target="_blank"><i class="fas fa-cloud-download"></i> Download reusable code</a></li> |
| 187 | <li class="menu-item"><a href="<?php echo admin_url( 'options-general.php?page=code_manager_settings' ); ?>"><i class="fas fa-cog"></i> Settings</a></li> |
| 188 | <li class="menu-item"><a href="<?php echo admin_url( 'admin.php' ); ?>?page=code_manager-account"><i class="fas fa-user"></i> Account</a></li> |
| 189 | <?php |
| 190 | $menufound = false; |
| 191 | if ( self::menu_enabled() ) { |
| 192 | global $submenu; |
| 193 | $plugin_navigation_default_page = get_option( 'plugin_navigation_default_page' ); |
| 194 | if ( isset( $submenu[ $plugin_navigation_default_page ] ) ) { |
| 195 | foreach ( $submenu[ $plugin_navigation_default_page ] as $pluginmenu ) { |
| 196 | if ( 'code_manager-pricing' === $pluginmenu[2] ) { |
| 197 | $menufound = true; |
| 198 | break; |
| 199 | } |
| 200 | } |
| 201 | } |
| 202 | } else { |
| 203 | $menufound = true; |
| 204 | } |
| 205 | ?> |
| 206 | <li class="menu-item <?php echo $menufound ? '' : 'cm-separator'; ?>"><a href="https://code-manager.com/pricing/" target="_blank"><i class="fas fa-hand-holding-usd"></i> Pricing</a></li> |
| 207 | <?php |
| 208 | if ( $menufound ) { |
| 209 | ?> |
| 210 | <li class="menu-item cm-separator"><a href="<?php echo admin_url( 'admin.php' ); ?>?page=code_manager-pricing"><i class="fas fa-gem"></i> Upgrade</a></li> |
| 211 | <?php |
| 212 | } |
| 213 | ?> |
| 214 | <li class="menu-item"><a target="_blank" href="https://code-manager.com/blog/docs/index/"><i class="fas fa-circle-question"></i> Online Documentation</a></li> |
| 215 | <li class="menu-item"><a target="_blank" href="https://wordpress.org/plugins/code-manager/"><i class="fas fa-life-ring"></i> Support Forum</a></li> |
| 216 | <?php |
| 217 | if ( code_manager_fs()->is_premium() ) { |
| 218 | ?> |
| 219 | <li class="menu-item"><a target="_blank" href="<?php echo admin_url( 'admin.php' ); ?>?page=code_manager-wp-support-forum"><i class="fas fa-ambulance"></i> Premium Support</a></li> |
| 220 | <?php |
| 221 | } |
| 222 | ?> |
| 223 | </ul> |
| 224 | </div> |
| 225 | <?php |
| 226 | } |
| 227 | |
| 228 | /** |
| 229 | * Add tab mode toolbar to dashboard |
| 230 | * |
| 231 | * @return void |
| 232 | */ |
| 233 | protected function toolbar_tabmode() { |
| 234 | ?> |
| 235 | <div class="cm-dashboard-toolbar"> |
| 236 | <div> |
| 237 | <div> |
| 238 | <i id="code_manager_new" class="fas fa-plus-circle cm_tooltip" title="Add new code"></i> |
| 239 | <br/> |
| 240 | Add new code |
| 241 | </div> |
| 242 | </div> |
| 243 | <div> |
| 244 | <div> |
| 245 | <i id="code_manager_open" class="fas fa-folder-open cm_tooltip" title="Open existing code"></i> |
| 246 | <br/> |
| 247 | Open existing code |
| 248 | </div> |
| 249 | </div> |
| 250 | </div> |
| 251 | <?php |
| 252 | } |
| 253 | |
| 254 | /** |
| 255 | * Add list mode toolbar to dashboard |
| 256 | * |
| 257 | * @return void |
| 258 | */ |
| 259 | protected function toolbar_listmode() { |
| 260 | ?> |
| 261 | <div class="cm-dashboard-toolbar"> |
| 262 | <div> |
| 263 | <div> |
| 264 | <i id="code_manager_new" class="fas fa-plus-circle cm_tooltip" title="Add new code" onclick="window.location.href='?page=<?php echo \Code_Manager_Admin::PAGE_MAIN; ?>&action=new'"></i> |
| 265 | <br/> |
| 266 | Add new code |
| 267 | </div> |
| 268 | </div> |
| 269 | <div> |
| 270 | <div> |
| 271 | <i id="code_manager_import" class="fas fa-cloud-upload cm_tooltip" title="Import code" onclick="jQuery('#upload_file_container').toggle()"></i> |
| 272 | <br/> |
| 273 | Import code |
| 274 | </div> |
| 275 | </div> |
| 276 | </div> |
| 277 | <?php |
| 278 | } |
| 279 | |
| 280 | } |
| 281 | |
| 282 | } |
| 283 |