PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.33
Code Manager v1.0.33
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 2 years ago Code_Manager_Dashboard.php 2 years ago Code_Manager_Export.php 2 years ago Code_Manager_Form.php 2 years ago Code_Manager_Import.php 2 years ago Code_Manager_Import_File.php 2 years ago Code_Manager_List.php 2 years ago Code_Manager_List_View.php 2 years ago Code_Manager_Model.php 2 years ago Code_Manager_Preview.php 2 years ago Code_Manager_Settings.php 2 years ago Code_Manager_Tabs.php 2 years ago Message_Box.php 2 years ago WP_List_Table.php 2 years ago
Code_Manager_Tabs.php
200 lines
1 <?php
2
3 /**
4 * Code Manager tab mode
5 *
6 * @package Code_Manager
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 * Nonce used to get code from user login
28 *
29 * @var string
30 */
31 protected $wpnonce_get_code ;
32 /**
33 * Code_Manager_Tabs constructor
34 *
35 * Creates a number of wpnonces needed to authorize ajax calls
36 *
37 * @since 1.0.0
38 */
39 public function __construct()
40 {
41 $this->wpnonce = wp_create_nonce( 'code-manager-' . Code_manager::get_current_user_login() );
42 $this->wpnonce_get_code = wp_create_nonce( 'code-manager-get-code' . Code_manager::get_current_user_login() );
43 }
44
45 /**
46 * Shows the tab mode IDE
47 *
48 * JavaScript depending on server variables not available in the browser are added here. Generic JavaScript
49 * code is added as a script file.
50 *
51 * @since 1.0.0
52 */
53 public function show()
54 {
55 $cm_message = Code_Manager::get_cm_message();
56 ?>
57 <script type="text/javascript">
58 var wpnonce = '<?php
59 echo esc_attr( $this->wpnonce ) ;
60 ?>';
61 var wpnonce_get_code = '<?php
62 echo esc_attr( $this->wpnonce_get_code ) ;
63 ?>';
64 var code_manager_code_groups = [];
65 <?php
66 $code_manager_tab = null;
67 if ( null === $code_manager_tab ) {
68 $code_manager_tab = new Code_Manager_Tabs();
69 }
70 $code_types = $code_manager_tab->get_code_types();
71 foreach ( $code_types as $code_type_group => $value ) {
72 echo 'code_manager_code_group = [];' ;
73 foreach ( $value as $code_type => $code_type_label ) {
74 echo "code_manager_code_group['" . esc_attr( $code_type ) . "'] = '" . esc_attr( $code_type_label ) . "';" ;
75 }
76 echo "code_manager_code_groups['" . esc_attr( $code_type_group ) . "'] = code_manager_code_group;" ;
77 }
78 ?>
79 function filter_code_list() {
80 jQuery("#code_manager_code_list > option").each(function() {
81 showCode = true;
82 if (jQuery("#code_manager_filter_code_type").val()!=="") {
83 if (jQuery("#code_manager_filter_code_type").val()!==jQuery(this).data("type")) {
84 jQuery(this).hide();
85 showCode = false;
86 }
87 }
88 if (showCode && jQuery("#code_manager_filter_code_name").val()!=="") {
89 if (!jQuery(this).data("name").toLowerCase().includes(jQuery("#code_manager_filter_code_name").val().toLowerCase())) {
90 jQuery(this).hide();
91 showCode = false;
92 }
93 }
94 if (showCode) {
95 jQuery(this).show();
96 }
97 });
98 }
99 <?php
100 if ( 'hide' !== $cm_message ) {
101 ?>
102 jQuery(function() {
103 cm_warning();
104 });
105 <?php
106 }
107 ?>
108 </script>
109 <div class="wrap">
110 <table cellspacing="0" cellpadding="0" border="0" width="100%">
111 <tr>
112 <td>
113 <h1 class="wp-heading-inline">
114 <?php
115 echo CODE_MANAGER_H1_TITLE . ' - tab mode' ;
116 ?>
117 </h1>
118 </td>
119 <td style="text-align:right;padding-right:10px;padding-top:4px">
120 <a id="disable_preview"
121 href="javascript:void(0)"
122 class="fas fa-eye-slash cm_menu_title"
123 style="line-height: 30px; text-decoration: none"
124 title="Turn of preview mode for all code IDs"
125 ></a>
126 </td>
127 </tr>
128 </table>
129 <style>
130 #code_manager_code_list {
131 background-image: none;
132 min-width: 100%;
133 width: 100%;
134 max-width: 100%;
135 font-family: monospace;
136 font-size: 90%;
137 }
138 #code_manager_code_list option {
139 width: 100%;
140 }
141 </style>
142 <div id="code_manager_open_frame" style="display: none; background-color: transparent;">
143 <p style="margin-top:0">Hold ctrl key to select multiple code blocks, double click to select single code block</p>
144 <div style="margin-right:-2px">
145 <span>
146 <input type="text" placeholder="Filter code name" id="code_manager_filter_code_name" onkeyup="filter_code_list()" autocomplete="off"/>
147 </span>
148 <span style="float: right">
149 <select id="code_manager_filter_code_type" onchange="filter_code_list()"></select>
150 </span>
151 </div>
152 <div>
153 <select id="code_manager_code_list" size="14" multiple="multiple">
154 <option>Loading data...</option>
155 </select>
156 </div>
157 </div>
158 <div id="code_manager_taskbar_tabmode" class="nav-tab-wrapper"></div>
159 <div id="code_manager_workspace_tabmode"></div>
160 <div class="cm_tab_mode_intro">
161 <p>
162 <i class="fas fa-hand-point-right"></i>
163 Press the "add new code" icon in the toolbar to start writing new code
164 </p>
165 <p>
166 <i class="fas fa-hand-point-right"></i>
167 Press the "open existing code" icon in the toolbar to change existing code
168 </p>
169 <div class="cm_tab_mode_intro_close">
170 <a href="#" onclick="javascript:jQuery('.cm_tab_mode_intro').remove()">
171 <i class="fas fa-times-circle"></i>
172 </a>
173 </div>
174 </div>
175 </div>
176 <?php
177 }
178
179 /**
180 * Get code types
181 *
182 * Code types are organized in group to allow grouping in list boxes.
183 *
184 * @since 1.0.0
185 *
186 * @return string[][]
187 */
188 public function get_code_types()
189 {
190 return array(
191 'Shortcodes' => array(
192 'php shortcode' => 'PHP Shortcode',
193 'javascript shortcode' => 'JavaScript Shortcode',
194 'css shortcode' => 'CSS Shortcode',
195 'html shortcode' => 'HTML Shortcode',
196 ),
197 );
198 }
199
200 }