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