C:\xampp\htdocs\landing\wp-content\plugins\better-wp-security\core\admin-pages\module-settings.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<?php

/**
 * The iThemes Security Module Settings Page API parent class.
 *
 * @property-read string $id
 * @property-read string $title
 * @property-read string $description
 * @property-read string $type
 * @property-read string $pro
 * @property-read bool $can_save
 * @property-read bool $redraw_on_save
 * @property-read bool $upsell
 * @property-read string $upsell_url
 * @property-read bool $information_only
 * @property-read string $status
 * @property-read string $documentation
 */
class ITSEC_Module_Settings_Page {
    
/**
     * Unique ID for the module.
     *
     * This is used to store the module's data and generate form inputs.
     *
     * @access protected
     * @var string
     */
    
protected $id '';

    
/**
     * User-friendly display title for the module.
     *
     * @access protected
     * @var string
     */
    
protected $title '';

    
/**
     * User-friendly display description for the module.
     *
     * @access protected
     * @var string
     */
    
protected $description '';

    
/**
     * Whether the module is categorized as additional or recommended.
     *
     * @access protected
     * @var string
     */
    
protected $type 'recommended'// "advanced" or "recommended"

    /**
     * Whether the settings require resaving after activation in order to fully-activate the module.
     *
     * @access protected
     * @var boolean
     */
    
protected $requires_resave_after_activation false;

    
/**
     * Whether the module is part of iThemes Security Pro or not.
     *
     * @access protected
     * @var bool
     */
    
protected $pro false;

    
/**
     * Whether the module settings can be saved.
     *
     * @access protected
     * @var bool
     */
    
protected $can_save true;

    
/**
     * Whether the module settings should be redrawn on save.
     *
     * @access protected
     * @var bool
     */
    
protected $redraw_on_save false;

    
/**
     * Whether the module is an iThemes Security Pro module being shown as an upsell or not.
     *
     * @access protected
     * @var bool
     */
    
protected $upsell false;

    
/**
     * URL to use for upsell if this is one.
     *
     * @access protected
     * @var string
     */
    
protected $upsell_url 'https://ithemes.com/security/';

    
/**
     * Whether the module is for informational purposes only - no settings, no actions
     *
     * @access protected
     * @var bool
     */
    
protected $information_only false;

    
/**
     * Set the module status to 'warning' to signal to the user it needs attention.
     *
     * @var string
     */
    
protected $status '';

    
/**
     * Link to documentation for this module.
     *
     * @var string
     */
    
protected $documentation '';

    
/**
     * Constructor.
     *
     * Register the module settings to register themselves on init. Each subclass should use the constructor to set the
     * id, title, description, type, pro, can_save, and redraw_on_save properties to values specific to that module and then call
     * parent::__construct().
     *
     * @access public
     */
    
public function __construct() {
        
add_action'itsec-settings-page-register-modules', array( $this'register' ) );
    }

    
/**
     * Make protected properties public read-only.
     *
     * This function should be left as-is in subclasses.
     *
     * @access public
     *
     * @param string $name Property to get.
     *
     * @return mixed Property.
     */
    
public function __get$name ) {
        if ( 
in_array$name, array( 'id''title''description''type''pro''can_save''redraw_on_save''upsell''upsell_url''information_only''status''documentation' ) ) ) {
            return 
$this->$name;
        }

        
trigger_error'Attempted to check invalid property: ' get_class$this ) . "->$name"E_USER_ERROR );
    }

    
/**
     * Register the module's settings with the settings page.
     *
     * This function should be left as-is in subclasses.
     *
     * @access public
     */
    
public function register() {
        foreach ( array( 
'id''title''description' ) as $name ) {
            if ( empty( 
$this->$name ) ) {
                
trigger_errorget_class$this ) . " has not set the $name variable."E_USER_ERROR );
            }
        }

        
do_action'itsec-settings-page-register-module'$this );
    }

    
/**
     * Allow the module to enqueue module-specific scripts and styles.
     *
     * @access public
     */
    
public function enqueue_scripts_and_styles() {}

    
/**
     * Allow a module to process an AJAX request.
     *
     * The module's implementation of this function can either handle all input manually or return a data structure to
     * be returned by the module API. The module's Javascript can make use of the itsec_module_send_ajax_request()
     * Javascript function in order to make the AJAX request. It has a request format of:
     *     itsecSettingsPage.sendModuleAJAXRequest( module, data, callback );
     *
     * @access public
     *
     * @param array $data Array of data sent by the AJAX request.
     */
    
public function handle_ajax_request$data ) {}

    
/**
     * Return the settings for the module.
     *
     * @access public
     *
     * @return array List of settings.
     */
    
public function get_settings() {
        return 
ITSEC_Modules::get_settings$this->id );
    }

    
/**
     * Render the module's settings content.
     *
     * This function should be left as-is in subclasses.
     *
     * @access public
     *
     * @param ITSEC_Form $form ITSEC_Form object used to create inputs.
     */
    
public function render$form ) {

        
$messages ITSEC_Lib_Remote_Messages::get_messages_for_placement( array( 'module' => $this->id ) );

?>
    <div class="itsec-settings-module-description">
        <?php $this->render_description$form ); ?>
    </div>
    <?php if ( $messages ) : ?>
        <div class="itsec-settings-module-service-status">
            <?php foreach ( $messages as $message ): ?>
                <div class="notice notice-alt notice-<?php echo esc_attr$message['type'] ); ?> below-h2">
                    <p><?php echo $message['message']; ?></p>
                </div>
            <?php endforeach; ?>
        </div>
    <?php endif; ?>
    <div class="itsec-settings-module-settings">
        <?php $this->render_settings$form ); ?>
    </div>
<?php

    
}

    
/**
     * Render the module description.
     *
     * The description is shown whether the module is active or not. Ensure that the description adequately informs the
     * user of the value of the module without requiring them to see the actual settings.
     *
     * @access protected
     *
     * @param object $form ITSEC_Form object used to create inputs.
     */
    
protected function render_description$form ) {

?>
    <p>Example module description.</p>
<?php

    
}

    
/**
     * Render the module settings.
     *
     * The inputs and input descriptions should be output in this function. This output is hidden when a module is
     * deactivated.
     *
     * @access protected
     *
     * @param ITSEC_Form $form ITSEC_Form object used to create inputs.
     */
    
protected function render_settings$form ) {

?>
    <table class="form-table itsec-settings-section">
        <tbody>
            <tr>
                <th><label>Setting 1</label></th>
                <td>
                    <?php $form->add_text'setting_1' ); ?>
                </td>
            </tr>
            <tr>
                <th><label>Setting 2</label></th>
                <td>
                    <?php $form->add_text'setting_2' ); ?>
                </td>
            </tr>
        </tbody>
    </table>
<?php

    
}

    
/**
     * Process form input.
     *
     * This function should be left as-is in subclasses unless specific processing is required.
     *
     * @access public
     *
     * @param array $data Array of form inputs to be processed and stored.
     */
    
public function handle_form_post$data ) {
        
ITSEC_Modules::set_settings$this->id$data );
    }

    
/**
     * Returns the errors array.
     *
     * This function should be left as-is in subclasses.
     *
     * @access public
     *
     * @return array Array of WP_Error objects.
     */
    
public function get_errors() {
        
$validator ITSEC_Modules::get_validator$this->id );

        if ( 
is_null$validator ) ) {
            return array();
        }

        return 
$validator->get_errors();
    }

    
/**
     * Returns the messages array.
     *
     * This function should be left as-is in subclasses.
     *
     * @access public
     *
     * @return array Array of status or update messages.
     */
    
public function get_messages() {
        
$validator ITSEC_Modules::get_validator$this->id );

        if ( 
is_null$validator ) ) {
            return array();
        }

        return 
$validator->get_messages();
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586