PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.4
Code Manager v1.0.4
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 5 years ago Code_Manager_Export.php 5 years ago Code_Manager_Form.php 5 years ago Code_Manager_Import.php 5 years ago Code_Manager_Import_File.php 5 years ago Code_Manager_List.php 5 years ago Code_Manager_List_View.php 5 years ago Code_Manager_Model.php 5 years ago Code_Manager_Preview.php 5 years ago Code_Manager_Settings.php 5 years ago Code_Manager_Tabs.php 5 years ago Message_Box.php 5 years ago WP_List_Table.php 5 years ago
Code_Manager_Settings.php
180 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' ) ) {
27 wp_die( __( 'ERROR: Not authorized', 'code-manager' ) );
28 }
29
30 if ( 'save' === $action ) {
31 // Save options
32 update_option(
33 'code_manager_plugin_code_execution',
34 isset( $_REQUEST['plugin_code_execution'] ) ?
35 sanitize_text_field( wp_unslash( $_REQUEST['plugin_code_execution'] ) ) : 'off'
36 ); // input var okay.
37
38 update_option(
39 'code_manager_plugin_tables',
40 isset( $_REQUEST['plugin_tables'] ) ?
41 sanitize_text_field( wp_unslash( $_REQUEST['plugin_tables'] ) ) : 'off'
42 ); // input var okay.
43
44 update_option(
45 'code_manager_plugin_options',
46 isset( $_REQUEST['plugin_options'] ) ?
47 sanitize_text_field( wp_unslash( $_REQUEST['plugin_options'] ) ) : 'off'
48 ); // input var okay.
49
50 } elseif ( 'setdefaults' === $action ) {
51 // Set all plugin settings back to their defaults
52 delete_option('code_manager_plugin_code_execution');
53 delete_option('code_manager_plugin_tables');
54 delete_option('code_manager_plugin_options');
55 }
56
57 $msg = new Message_Box(
58 [
59 'message_text' => __( 'Settings saved', 'code-manager' ),
60 ]
61 );
62 $msg->box();
63 }
64
65 // Get options
66 $plugin_code_execution = get_option('code_manager_plugin_code_execution');
67 if ( false === $plugin_code_execution ) {
68 $plugin_code_execution = 'on';
69 }
70
71 $plugin_tables = get_option('code_manager_plugin_tables');
72 if ( false === $plugin_tables ) {
73 $plugin_tables = 'off';
74 }
75
76 $plugin_options = get_option('code_manager_plugin_options');
77 if ( false === $plugin_options ) {
78 $plugin_options = 'on';
79 }
80 ?>
81 <div class="wrap">
82 <h1 class="wp-heading-inline">
83 <span>
84 <span>
85 <?php echo CODE_MANAGER_SETTINGS_H1_TITLE; ?>
86 </span>
87 <a href="<?php echo CODE_MANAGER_HELP_URL; ?>" target="_blank"
88 title="Plugin help - opens in a new tab or window">
89 <span class="material-icons cm_menu_title">help_outline</span></a>
90 </span>
91 </h1>
92 <br/><br/>
93 <form id="code_manager_settings" method="post" action="?page=<?php echo CODE_MANAGER_SETTINGS_MENU_SLUG; ?>">
94 <table class="code-manager-table-settings">
95 <tr>
96 <th>
97 <?php echo __( 'Code execution' ); ?>
98 </th>
99 <td>
100 <label for="plugin_code_execution">
101 <input type="checkbox"
102 id="plugin_code_execution"
103 name="plugin_code_execution"
104 <?php echo 'on' === $plugin_code_execution ? 'checked' : ''; ?>
105 />
106 <?php echo __( 'Enabled (uncheck to disable)' ); ?>
107 </label>
108 </td>
109 </tr>
110 <tr>
111 <th>
112 <?php echo __( 'On plugin uninstall' ); ?>
113 </th>
114 <td>
115 <label for="plugin_tables">
116 <input type="checkbox"
117 id="plugin_tables"
118 name="plugin_tables"
119 <?php echo 'on' === $plugin_tables ? 'checked' : ''; ?>
120 />
121 <?php echo __( 'Remove plugin tables (this will delete all your code)' ); ?>
122 </label>
123 <br/>
124 <label for="plugin_options">
125 <input type="checkbox"
126 id="plugin_options"
127 name="plugin_options"
128 <?php echo 'on' === $plugin_options ? 'checked' : ''; ?>
129 />
130 <?php echo __( 'Remove plugin options' ); ?>
131 </label>
132 </td>
133 </tr>
134 </table>
135 <div class="code-manager-table-settings-button">
136 <input type="hidden" name="action" value="save"/>
137 <input type="submit"
138 value="<?php echo __( 'Save Code Manager settings', 'code-manager' ); ?>"
139 class="button button-primary"/>
140 <a href="javascript:void(0)"
141 onclick="return reset_defaults()"
142 class="button">
143 <?php echo __( 'Reset Code Manager settings to defaults', 'code-manager' ); ?>
144 </a>
145 </div>
146 <?php wp_nonce_field( 'code-manager-settings', '_wpnonce', false ); ?>
147 </form>
148 </div>
149 <script type="text/javascript">
150 jQuery(function() {
151 jQuery( '.cm_menu_title' ).tooltip();
152 });
153 function reset_defaults() {
154 html = '<div>Reset to defaults?</div>';
155 var dialog = jQuery(html).dialog({
156 dialogClass: "no-close",
157 buttons: {
158 'Yes': function() {
159 dialog.dialog('destroy');
160 jQuery('input[name="action"]').val('setdefaults');
161 jQuery('#code_manager_settings').trigger('submit');
162 },
163 'No': function() {
164 dialog.dialog('destroy');
165 },
166 'Cancel': function() {
167 dialog.dialog('destroy');
168 }
169 }
170 });
171 jQuery(".ui-dialog-titlebar").hide();
172 return false;
173 }
174 </script>
175 <?php
176 }
177
178 }
179
180 }