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