PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.26
Code Manager v1.0.26
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
194 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 <?php echo CODE_MANAGER_H1_TITLE . ' - tab mode'; ?>
109 </h1>
110 </td>
111 <td style="text-align:right;padding-right:10px;padding-top:4px">
112 <a id="disable_preview"
113 href="javascript:void(0)"
114 class="fas fa-eye-slash cm_menu_title"
115 style="line-height: 30px; text-decoration: none"
116 title="Turn of preview mode for all code IDs"
117 ></a>
118 </td>
119 </tr>
120 </table>
121 <style>
122 #code_manager_code_list {
123 background-image: none;
124 min-width: 100%;
125 width: 100%;
126 max-width: 100%;
127 font-family: monospace;
128 font-size: 90%;
129 }
130 #code_manager_code_list option {
131 width: 100%;
132 }
133 </style>
134 <div id="code_manager_open_frame" style="display: none; background-color: transparent;">
135 <p style="margin-top:0">Hold ctrl key to select multiple code blocks, double click to select single code block</p>
136 <div style="margin-right:-2px">
137 <span>
138 <input type="text" placeholder="Filter code name" id="code_manager_filter_code_name" onkeyup="filter_code_list()" autocomplete="off"/>
139 </span>
140 <span style="float: right">
141 <select id="code_manager_filter_code_type" onchange="filter_code_list()"></select>
142 </span>
143 </div>
144 <div>
145 <select id="code_manager_code_list" size="14" multiple="multiple">
146 <option>Loading data...</option>
147 </select>
148 </div>
149 </div>
150 <div id="code_manager_taskbar_tabmode" class="nav-tab-wrapper"></div>
151 <div id="code_manager_workspace_tabmode"></div>
152 <div class="cm_tab_mode_intro">
153 <p>
154 <i class="fas fa-hand-point-right"></i>
155 Press the "add new code" icon in the toolbar to start writing new code
156 </p>
157 <p>
158 <i class="fas fa-hand-point-right"></i>
159 Press the "open existing code" icon in the toolbar to change existing code
160 </p>
161 <div class="cm_tab_mode_intro_close">
162 <a href="#" onclick="javascript:jQuery('.cm_tab_mode_intro').remove()">
163 <i class="fas fa-times-circle"></i>
164 </a>
165 </div>
166 </div>
167 </div>
168 <?php
169 }
170
171 /**
172 * Get code types
173 *
174 * Code types are organized in group to allow grouping in list boxes.
175 *
176 * @since 1.0.0
177 *
178 * @return string[][]
179 */
180 public function get_code_types() {
181 return array(
182 'Shortcodes' => array(
183 'php shortcode' => 'PHP Shortcode',
184 'javascript shortcode' => 'JavaScript Shortcode',
185 'css shortcode' => 'CSS Shortcode',
186 'html shortcode' => 'HTML Shortcode',
187 ),
188 );
189 }
190
191 }
192
193 }
194