Code_Manager.php
4 years ago
Code_Manager_Dashboard.php
4 years ago
Code_Manager_Export.php
4 years ago
Code_Manager_Form.php
4 years ago
Code_Manager_Import.php
4 years ago
Code_Manager_Import_File.php
4 years ago
Code_Manager_List.php
4 years ago
Code_Manager_List_View.php
4 years ago
Code_Manager_Model.php
4 years ago
Code_Manager_Preview.php
4 years ago
Code_Manager_Settings.php
4 years ago
Code_Manager_Tabs.php
4 years ago
Message_Box.php
4 years ago
WP_List_Table.php
4 years ago
Code_Manager_Dashboard.php
193 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Code_Manager { |
| 4 | |
| 5 | class Code_Manager_Dashboard { |
| 6 | |
| 7 | public static function add_dashboard() { |
| 8 | $dashboard = new Code_Manager_Dashboard(); |
| 9 | $dashboard->dashboard(); |
| 10 | } |
| 11 | |
| 12 | protected static function navigation_enabled( $navigation_type ) { |
| 13 | $code_manager_plugin_navigation = get_option( 'code_manager_plugin_navigation' ); |
| 14 | if ( false === $code_manager_plugin_navigation ) { |
| 15 | $code_manager_plugin_navigation = 'dashboard'; |
| 16 | } |
| 17 | return in_array( $code_manager_plugin_navigation, [ 'both', $navigation_type ] ); |
| 18 | } |
| 19 | |
| 20 | public static function dashboard_enabled() { |
| 21 | return self::navigation_enabled( 'dashboard' ); |
| 22 | } |
| 23 | |
| 24 | public static function menu_enabled() { |
| 25 | return self::navigation_enabled( 'menu' ); |
| 26 | } |
| 27 | |
| 28 | public function dashboard() { |
| 29 | if ( self::dashboard_enabled() ) { |
| 30 | $this->dashboard_default(); |
| 31 | $this->dashboard_mobile(); |
| 32 | |
| 33 | if ( isset( $_REQUEST['tabmode'] ) && 'on' === $_REQUEST['tabmode'] ) { |
| 34 | $this->toolbar(); |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | protected function dashboard_default() { |
| 40 | ?> |
| 41 | <div id="cm-dashboard" style="display:none"> |
| 42 | <div class="cm-dashboard"> |
| 43 | <div class="cm-dashboard-group cm-dashboard-group-code"> |
| 44 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url('admin.php'); ?>?page=code_manager" title="Standard WordPress list view"> |
| 45 | <span class="material-icons">format_list_bulleted</span> |
| 46 | <div class="label">List mode</div> |
| 47 | </a> |
| 48 | <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"> |
| 49 | <span class="material-icons">tab</span> |
| 50 | <div class="label">Tab mode</div> |
| 51 | </a> |
| 52 | <a class="cm-dashboard-item cm_tooltip_icons" href="https://code-manager.com/code/" title="Download reusable code from plugin website" target="_blank"> |
| 53 | <span class="material-icons">cloud_download</span> |
| 54 | <div class="label">Download</div> |
| 55 | </a> |
| 56 | <div class="subject">Code</div> |
| 57 | </div> |
| 58 | <div class="cm-dashboard-group cm-dashboard-group-settings"> |
| 59 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url('options-general.php?page=code_manager_settings'); ?>" title="Plugin Settings"> |
| 60 | <span class="material-icons">settings</span> |
| 61 | <div class="label">Settings</div> |
| 62 | </a> |
| 63 | <?php |
| 64 | if ( code_manager_fs()->is_registered() ) { |
| 65 | ?> |
| 66 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url('admin.php'); ?>?page=code_manager-account" title="Manage Account"> |
| 67 | <span class="material-icons">person</span> |
| 68 | <div class="label">Account</div> |
| 69 | </a> |
| 70 | <?php |
| 71 | } |
| 72 | ?> |
| 73 | <a class="cm-dashboard-item cm_tooltip_icons" target="_blank" href="https://code-manager.com/pricing/" title="Online Pricing, Licensing and Ordering"> |
| 74 | <span class="material-icons">attach_money</span> |
| 75 | <div class="label">Pricing</div> |
| 76 | </a> |
| 77 | <?php |
| 78 | $menufound = false; |
| 79 | if ( self::menu_enabled() ) { |
| 80 | global $submenu; |
| 81 | $plugin_navigation_default_page = get_option('plugin_navigation_default_page'); |
| 82 | if ( isset( $submenu[ $plugin_navigation_default_page ] ) ) { |
| 83 | foreach ( $submenu[ $plugin_navigation_default_page ] as $pluginmenu ) { |
| 84 | if ( 'code_manager-pricing' === $pluginmenu[2] ) { |
| 85 | $menufound = true; |
| 86 | break; |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | } else { |
| 91 | $menufound = true; |
| 92 | } |
| 93 | if ( $menufound ) { |
| 94 | ?> |
| 95 | <a class="cm-dashboard-item cm_tooltip_icons" href="<?php echo admin_url('admin.php'); ?>?page=code_manager-pricing" title="Upgrade plugin from dashboard"> |
| 96 | <span class="material-icons">new_releases</span> |
| 97 | <div class="label">Upgrade</div> |
| 98 | </a> |
| 99 | <?php |
| 100 | } |
| 101 | ?> |
| 102 | <div class="subject">Manage</div> |
| 103 | </div> |
| 104 | <div class="cm-dashboard-group cm-dashboard-group-support"> |
| 105 | <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"> |
| 106 | <span class="material-icons">help</span> |
| 107 | <div class="label">Docs</div> |
| 108 | </a> |
| 109 | <a class="cm-dashboard-item cm_tooltip_icons" target="_blank" href="https://wordpress.org/support/plugin/code-manager/" title="Public Support Forum"> |
| 110 | <span class="material-icons">forum</span> |
| 111 | <div class="label">Forum</div> |
| 112 | </a> |
| 113 | <?php |
| 114 | if ( code_manager_fs()->is_premium() ) { |
| 115 | ?> |
| 116 | <a class="cm-dashboard-item cm_tooltip_icons" target="_blank" href="https://users.freemius.com/store/2612" title="Premium Support"> |
| 117 | <span class="material-icons">stars</span> |
| 118 | <div class="label">Premium</div> |
| 119 | </a> |
| 120 | <?php |
| 121 | } |
| 122 | ?> |
| 123 | <div class="subject">Support</div> |
| 124 | </div> |
| 125 | </div> |
| 126 | </div> |
| 127 | <?php |
| 128 | } |
| 129 | |
| 130 | protected function dashboard_mobile() { |
| 131 | ?> |
| 132 | <div id="cm-dashboard-mobile" style="display:none"> |
| 133 | <div id="cm-dashboard-drop-down"> |
| 134 | <div class="cm_nav_toggle" onclick="toggleMenu()"><i class="fas fa-bars"></i></div> |
| 135 | <div class="cm_nav_title">Code Manager</div> |
| 136 | </div> |
| 137 | <ul> |
| 138 | <li class="menu-item"><a href="<?php echo admin_url('admin.php'); ?>?page=code_manager"><span class="material-icons">format_list_bulleted</span> List mode</a></li> |
| 139 | <li class="menu-item"><a href="<?php echo admin_url('admin.php'); ?>?page=code_manager&tabmode=on"><span class="material-icons">tab</span> Tab mode</a></li> |
| 140 | <li class="menu-item cm-separator"><a href="https://code-manager.com/code/" target="_blank"><span class="material-icons">cloud_download</span> Download reusable code</a></li> |
| 141 | <li class="menu-item"><a href="<?php echo admin_url('options-general.php?page=code_manager_settings'); ?>"><span class="material-icons">settings</span> Settings</a></li> |
| 142 | <li class="menu-item"><a href="<?php echo admin_url('admin.php'); ?>?page=code_manager-account"><span class="material-icons">person</span> Account</a></li> |
| 143 | <?php |
| 144 | $menufound = false; |
| 145 | if ( self::menu_enabled() ) { |
| 146 | global $submenu; |
| 147 | $plugin_navigation_default_page = get_option('plugin_navigation_default_page'); |
| 148 | if ( isset( $submenu[ $plugin_navigation_default_page ] ) ) { |
| 149 | foreach ( $submenu[ $plugin_navigation_default_page ] as $pluginmenu ) { |
| 150 | if ( 'code_manager-pricing' === $pluginmenu[2] ) { |
| 151 | $menufound = true; |
| 152 | break; |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } else { |
| 157 | $menufound = true; |
| 158 | } |
| 159 | ?> |
| 160 | <li class="menu-item <?php echo $menufound ? '' : 'cm-separator'; ?>"><a href="https://code-manager.com/pricing/" target="_blank"><span class="material-icons">attach_money</span> Pricing</a></li> |
| 161 | <?php |
| 162 | if ( $menufound ) { |
| 163 | ?> |
| 164 | <li class="menu-item cm-separator"><a href="<?php echo admin_url('admin.php'); ?>?page=code_manager-pricing"><span class="material-icons">new_releases</span> Upgrade</a></li> |
| 165 | <?php |
| 166 | } |
| 167 | ?> |
| 168 | <li class="menu-item"><a target="_blank" href="https://code-manager.com/blog/docs/index/"><span class="material-icons">help</span> Online Documentation</a></li> |
| 169 | <li class="menu-item"><a target="_blank" href="https://wordpress.org/plugins/code-manager/"><span class="material-icons">forum</span> Support Forum</a></li> |
| 170 | <?php |
| 171 | if ( code_manager_fs()->is_premium() ) { |
| 172 | ?> |
| 173 | <li class="menu-item"><a target="_blank" href="<?php echo admin_url('admin.php'); ?>?page=code_manager-wp-support-forum"><span class="material-icons">stars</span> Premium Support</a></li> |
| 174 | <?php |
| 175 | } |
| 176 | ?> |
| 177 | </ul> |
| 178 | </div> |
| 179 | <?php |
| 180 | } |
| 181 | |
| 182 | protected function toolbar() { |
| 183 | ?> |
| 184 | <div class="cm-dashboard-toolbar"> |
| 185 | <i id="code_manager_new" class="fas fa-plus-circle cm_tooltip" title="Add new tab"></i> |
| 186 | <i id="code_manager_open" class="fas fa-folder-open cm_tooltip" title="Open existing code"></i> |
| 187 | </div> |
| 188 | <?php |
| 189 | } |
| 190 | |
| 191 | } |
| 192 | |
| 193 | } |