PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.9
Code Manager v1.0.9
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_Settings.php
code-manager / Code_Manager Last commit date
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_Settings.php
230 lines
1 <?php
2
3 namespace Code_Manager {
4
5 /**
6 * Class Code_Manager_Settings
7 *
8 * Handles plugin settings page
9 *
10 * @author Peter Schulz
11 * @since 1.0.0
12 */
13 class Code_Manager_Settings {
14
15 /**
16 * Builds the settings page and stores the settings in WP options
17 *
18 * @since 1.0.0
19 */
20 public function show() {
21 if ( isset( $_REQUEST['action'] ) ) {
22 $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // input var okay.
23
24 // Security check
25 $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay.
26 if ( ! wp_verify_nonce( $wp_nonce, 'code-manager-settings' . Code_manager::get_current_user_login() ) ) {
27 wp_die( __( 'ERROR: Not authorized', 'code-manager' ) );
28 }
29
30 if ( 'save' === $action ) {
31 // Save options
32 update_option(
33 'code_manager_plugin_navigation',
34 isset( $_REQUEST['plugin_navigation'] ) ?
35 sanitize_text_field( wp_unslash( $_REQUEST['plugin_navigation'] ) ) : 'dashboard'
36 ); // input var okay.
37
38 update_option(
39 'code_manager_plugin_hide_foreign_notices',
40 isset( $_REQUEST['plugin_hide_foreign_notices'] ) ?
41 sanitize_text_field( wp_unslash( $_REQUEST['plugin_hide_foreign_notices'] ) ) : 'off'
42 ); // input var okay.
43
44 update_option(
45 'code_manager_plugin_code_execution',
46 isset( $_REQUEST['plugin_code_execution'] ) ?
47 sanitize_text_field( wp_unslash( $_REQUEST['plugin_code_execution'] ) ) : 'off'
48 ); // input var okay.
49
50 update_option(
51 'code_manager_plugin_tables',
52 isset( $_REQUEST['plugin_tables'] ) ?
53 sanitize_text_field( wp_unslash( $_REQUEST['plugin_tables'] ) ) : 'off'
54 ); // input var okay.
55
56 update_option(
57 'code_manager_plugin_options',
58 isset( $_REQUEST['plugin_options'] ) ?
59 sanitize_text_field( wp_unslash( $_REQUEST['plugin_options'] ) ) : 'off'
60 ); // input var okay.
61 } elseif ( 'setdefaults' === $action ) {
62 // Set all plugin settings back to their defaults
63 delete_option('code_manager_plugin_navigation');
64 delete_option('code_manager_plugin_hide_foreign_notices');
65 delete_option('code_manager_plugin_code_execution');
66 delete_option('code_manager_plugin_tables');
67 delete_option('code_manager_plugin_options');
68 }
69
70 $msg = new Message_Box(
71 [
72 'message_text' => __( 'Settings saved', 'code-manager' ),
73 ]
74 );
75 $msg->box();
76 }
77
78 // Get options
79 $plugin_navigation = get_option('code_manager_plugin_navigation');
80 if ( false === $plugin_navigation ) {
81 $plugin_navigation = 'dashboard';
82 }
83
84 $plugin_hide_foreign_notices = get_option('code_manager_plugin_hide_foreign_notices');
85 if ( false === $plugin_hide_foreign_notices ) {
86 $plugin_hide_foreign_notices = 'on';
87 }
88
89 $plugin_code_execution = get_option('code_manager_plugin_code_execution');
90 if ( false === $plugin_code_execution ) {
91 $plugin_code_execution = 'on';
92 }
93
94 $plugin_tables = get_option('code_manager_plugin_tables');
95 if ( false === $plugin_tables ) {
96 $plugin_tables = 'off';
97 }
98
99 $plugin_options = get_option('code_manager_plugin_options');
100 if ( false === $plugin_options ) {
101 $plugin_options = 'on';
102 }
103 ?>
104 <div class="wrap">
105 <h1 class="wp-heading-inline">
106 <span>
107 <span>
108 <?php echo CODE_MANAGER_SETTINGS_H1_TITLE; ?>
109 </span>
110 <?php
111 if ( ! Code_Manager_Dashboard::dashboard_enabled() ) {
112 ?>
113 <a href="<?php echo CODE_MANAGER_HELP_URL; ?>" target="_blank"
114 title="Plugin help - opens in a new tab or window">
115 <span class="material-icons cm_menu_title">help_outline</span></a>
116 <?php
117 }
118 ?>
119 </span>
120 </h1>
121 <br/><br/>
122 <form id="code_manager_settings" method="post" action="?page=<?php echo CODE_MANAGER_SETTINGS_MENU_SLUG; ?>">
123 <table class="code-manager-table-settings">
124
125 <tr>
126 <th><?php echo __( 'Plugin navigation', 'wp-data-access' ); ?></th>
127 <td>
128 <select name="plugin_navigation">
129 <option value="both" <?php echo 'both' === $plugin_navigation ? 'selected' : ''; ?>>Show submenus and dashboard</option>
130 <option value="dashboard" <?php echo 'dashboard' === $plugin_navigation ? 'selected' : ''; ?>>Show dashboard only (hide submenus)</option>
131 <option value="menu" <?php echo 'menu' === $plugin_navigation ? 'selected' : ''; ?>>Show submenus only (hide dashboard)</option>
132 </select>
133 </td>
134 </tr>
135 <tr>
136 <th><?php echo __( 'Notices', 'wp-data-access' ); ?></th>
137 <td>
138 <label>
139 <input type="checkbox" name="plugin_hide_foreign_notices" <?php echo $plugin_hide_foreign_notices==='on' ? 'checked' : ''; ?> />
140 <?php echo __( 'Hide notices of other themes and plugins on Code Manager admin pages', 'wp-data-access' ); ?>
141 </label>
142 </td>
143 </tr>
144
145 <tr>
146 <th>
147 <?php echo __( 'Code execution' ); ?>
148 </th>
149 <td>
150 <label for="plugin_code_execution">
151 <input type="checkbox"
152 id="plugin_code_execution"
153 name="plugin_code_execution"
154 <?php echo 'on' === $plugin_code_execution ? 'checked' : ''; ?>
155 />
156 <?php echo __( 'Enabled (uncheck to disable)' ); ?>
157 </label>
158 </td>
159 </tr>
160 <tr>
161 <th>
162 <?php echo __( 'On plugin uninstall' ); ?>
163 </th>
164 <td>
165 <label for="plugin_tables">
166 <input type="checkbox"
167 id="plugin_tables"
168 name="plugin_tables"
169 <?php echo 'on' === $plugin_tables ? 'checked' : ''; ?>
170 />
171 <?php echo __( 'Remove plugin tables (this will delete all your code)' ); ?>
172 </label>
173 <br/>
174 <label for="plugin_options">
175 <input type="checkbox"
176 id="plugin_options"
177 name="plugin_options"
178 <?php echo 'on' === $plugin_options ? 'checked' : ''; ?>
179 />
180 <?php echo __( 'Remove plugin options' ); ?>
181 </label>
182 </td>
183 </tr>
184 </table>
185 <div class="code-manager-table-settings-button">
186 <input type="hidden" name="action" value="save"/>
187 <input type="submit"
188 value="<?php echo __( 'Save Code Manager settings', 'code-manager' ); ?>"
189 class="button button-primary"/>
190 <a href="javascript:void(0)"
191 onclick="return reset_defaults()"
192 class="button">
193 <?php echo __( 'Reset Code Manager settings to defaults', 'code-manager' ); ?>
194 </a>
195 </div>
196 <?php wp_nonce_field( 'code-manager-settings' . Code_manager::get_current_user_login(), '_wpnonce', false ); ?>
197 </form>
198 </div>
199 <script type="text/javascript">
200 jQuery(function() {
201 jQuery( '.cm_menu_title' ).tooltip();
202 });
203 function reset_defaults() {
204 html = '<div>Reset to defaults?</div>';
205 var dialog = jQuery(html).dialog({
206 dialogClass: "no-close",
207 buttons: {
208 'Yes': function() {
209 dialog.dialog('destroy');
210 jQuery('input[name="action"]').val('setdefaults');
211 jQuery('#code_manager_settings').trigger('submit');
212 },
213 'No': function() {
214 dialog.dialog('destroy');
215 },
216 'Cancel': function() {
217 dialog.dialog('destroy');
218 }
219 }
220 });
221 jQuery(".ui-dialog-titlebar").hide();
222 return false;
223 }
224 </script>
225 <?php
226 }
227
228 }
229
230 }