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