PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.19
Code Manager v1.0.19
1.0.47 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.3 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.4 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
code-manager / Code_Manager / Code_Manager_Tabs.php
code-manager / Code_Manager Last commit date
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_Tabs.php
214 lines
1 <?php
2 /**
3 * Code Manager tab mode
4 *
5 * @package Code_Manager
6 */
7
8 namespace Code_Manager {
9
10 /**
11 * Class Code_Manager_Tabs
12 *
13 * Builds the Code Manager tab mode IDE
14 *
15 * @author Peter Schulz
16 * @since 1.0.0
17 */
18 class Code_Manager_Tabs {
19
20 /**
21 * Nonce using user login
22 *
23 * @var string
24 */
25 protected $wpnonce;
26
27 /**
28 * Nonce used to get code from user login
29 *
30 * @var string
31 */
32 protected $wpnonce_get_code;
33
34 /**
35 * Code_Manager_Tabs constructor
36 *
37 * Creates a number of wpnonces needed to authorize ajax calls
38 *
39 * @since 1.0.0
40 */
41 public function __construct() {
42 $this->wpnonce = wp_create_nonce( 'code-manager-' . Code_manager::get_current_user_login() );
43 $this->wpnonce_get_code = wp_create_nonce( 'code-manager-get-code' . Code_manager::get_current_user_login() );
44 }
45
46 /**
47 * Shows the tab mode IDE
48 *
49 * JavaScript depending on server variables not available in the browser are added here. Generic JavaScript
50 * code is added as a script file.
51 *
52 * @since 1.0.0
53 */
54 public function show() {
55 $cm_message = Code_Manager::get_cm_message();
56 ?>
57 <script type="text/javascript">
58 var wpnonce = '<?php echo esc_attr( $this->wpnonce ); ?>';
59 var wpnonce_get_code = '<?php echo esc_attr( $this->wpnonce_get_code ); ?>';
60 var code_manager_code_groups = [];
61 <?php
62 $code_manager_tab_class = CODE_MANAGER_TAB_CLASS;
63 $code_manager_tab = new $code_manager_tab_class();
64 $code_types = $code_manager_tab->get_code_types();
65 foreach ( $code_types as $code_type_group => $value ) {
66 echo 'code_manager_code_group = [];';
67 foreach ( $value as $code_type => $code_type_label ) {
68 echo "code_manager_code_group['" . esc_attr( $code_type ) . "'] = '" . esc_attr( $code_type_label ) . "';";
69 }
70 echo "code_manager_code_groups['" . esc_attr( $code_type_group ) . "'] = code_manager_code_group;";
71 }
72 ?>
73 function filter_code_list() {
74 jQuery("#code_manager_code_list > option").each(function() {
75 showCode = true;
76 if (jQuery("#code_manager_filter_code_type").val()!=="") {
77 if (jQuery("#code_manager_filter_code_type").val()!==jQuery(this).data("type")) {
78 jQuery(this).hide();
79 showCode = false;
80 }
81 }
82 if (showCode && jQuery("#code_manager_filter_code_name").val()!=="") {
83 if (!jQuery(this).data("name").toLowerCase().includes(jQuery("#code_manager_filter_code_name").val().toLowerCase())) {
84 jQuery(this).hide();
85 showCode = false;
86 }
87 }
88 if (showCode) {
89 jQuery(this).show();
90 }
91 });
92 }
93 <?php
94 if ( 'hide' !== $cm_message ) {
95 ?>
96 jQuery(function() {
97 cm_warning();
98 });
99 <?php
100 }
101 ?>
102 </script>
103 <div class="wrap">
104 <table cellspacing="0" cellpadding="0" border="0" width="100%">
105 <tr>
106 <td>
107 <h1 class="wp-heading-inline">
108 <span>
109 <span class="cm_page_title">
110 <?php echo CODE_MANAGER_H1_TITLE . ' - tab mode'; ?>
111 </span>
112 <?php
113 if ( ! Code_Manager_Dashboard::dashboard_enabled() ) {
114 ?>
115 <a href="?page=<?php echo CODE_MANAGER_MENU_SLUG; ?>"
116 title="Switch to list mode (standard WordPress list view)">
117 <i class="fas fa-table-list cm_menu_title"></i></a>
118 <a id="code_manager_new" href="javascript:void(0)" title="Add new code">
119 <i class="fas fa-plus-circle cm_menu_title"></i></a>
120 <a id="code_manager_open" href="javascript:void(0)" title="Open existing code">
121 <i class="fas fa-cloud-upload cm_menu_title"></i></a>
122 <a href="<?php echo CODE_MANAGER_HELP_URL; ?>" target="_blank"
123 title="Plugin help - opens in a new tab or window">
124 <i class="fas fa-circle-question cm_menu_title"></i></a>
125 <?php
126 }
127 ?>
128 </span>
129 </h1>
130 </td>
131 <td style="text-align:right;padding-right:10px;padding-top:4px">
132 <a id="disable_preview"
133 href="javascript:void(0)"
134 class="fas fa-eye-slash cm_menu_title"
135 style="line-height: 30px; text-decoration: none"
136 title="Turn of preview mode for all code IDs"
137 ></a>
138 </td>
139 </tr>
140 </table>
141 <style>
142 #code_manager_code_list {
143 background-image: none;
144 min-width: 100%;
145 width: 100%;
146 max-width: 100%;
147 font-family: monospace;
148 font-size: 90%;
149 }
150 #code_manager_code_list option {
151 width: 100%;
152 }
153 </style>
154 <div id="code_manager_open_frame" style="display: none; background-color: transparent;">
155 <p style="margin-top:0">Hold ctrl key to select multiple code blocks, double click to select single code block</p>
156 <div style="margin-right:-2px">
157 <span>
158 <input type="text" placeholder="Filter code name" id="code_manager_filter_code_name" onkeyup="filter_code_list()" autocomplete="off"/>
159 </span>
160 <span style="float: right">
161 <select id="code_manager_filter_code_type" onchange="filter_code_list()"></select>
162 </span>
163 </div>
164 <div>
165 <select id="code_manager_code_list" size="14" multiple="multiple">
166 <option>Loading data...</option>
167 </select>
168 </div>
169 </div>
170 <div id="code_manager_taskbar_tabmode" class="nav-tab-wrapper"></div>
171 <div id="code_manager_workspace_tabmode"></div>
172 <div class="cm_tab_mode_intro">
173 <p>
174 <i class="fas fa-hand-point-right"></i>
175 Press the "add new code" icon in the toolbar to start writing new code
176 </p>
177 <p>
178 <i class="fas fa-hand-point-right"></i>
179 Press the "open existing code" icon in the toolbar to change existing code
180 </p>
181 <div class="cm_tab_mode_intro_close">
182 <a href="#" onclick="javascript:jQuery('.cm_tab_mode_intro').remove()">
183 <i class="fas fa-times-circle"></i>
184 </a>
185 </div>
186 </div>
187 </div>
188 <?php
189 }
190
191 /**
192 * Get code types
193 *
194 * Code types are organized in group to allow grouping in list boxes.
195 *
196 * @since 1.0.0
197 *
198 * @return string[][]
199 */
200 public function get_code_types() {
201 return array(
202 'Shortcodes' => array(
203 'php shortcode' => 'PHP Shortcode',
204 'javascript shortcode' => 'JavaScript Shortcode',
205 'css shortcode' => 'CSS Shortcode',
206 'html shortcode' => 'HTML Shortcode',
207 ),
208 );
209 }
210
211 }
212
213 }
214