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