PluginProbe ʕ •ᴥ•ʔ
Media Cleaner: Clean your WordPress! / 5.5.2
Media Cleaner: Clean your WordPress! v5.5.2
7.1.1 7.1.0 7.0.9 7.0.8 trunk 3.6.8 3.6.9 3.7.0 3.8.0 3.9.0 4.0.0 4.0.2 4.0.4 4.0.6 4.0.7 4.1.0 4.2.0 4.2.2 4.2.3 4.2.4 4.2.5 4.4.0 4.4.2 4.4.4 4.4.6 4.4.7 4.4.8 4.5.0 4.5.4 4.5.6 4.5.7 4.5.8 4.6.2 4.6.3 4.8.0 4.8.4 5.0.0 5.0.1 5.1.0 5.1.1 5.1.3 5.2.0 5.2.1 5.2.4 5.4.0 5.4.1 5.4.2 5.4.3 5.4.4 5.4.5 5.4.6 5.4.9 5.5.0 5.5.1 5.5.2 5.5.3 5.5.4 5.5.7 5.5.8 5.6.1 5.6.2 5.6.3 5.6.4 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.0.6 6.0.7 6.0.8 6.0.9 6.1.2 6.1.3 6.1.4 6.1.5 6.1.6 6.1.7 6.1.8 6.1.9 6.2.0 6.2.1 6.2.3 6.2.4 6.2.5 6.2.6 6.2.7 6.2.8 6.3.0 6.3.1 6.3.2 6.3.4 6.3.5 6.3.7 6.3.8 6.3.9 6.4.0 6.4.1 6.4.2 6.4.3 6.4.4 6.4.5 6.4.6 6.4.7 6.4.8 6.4.9 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.5.8 6.5.9 6.6.1 6.6.2 6.6.3 6.6.4 6.6.5 6.6.6 6.6.7 6.6.8 6.6.9 6.7.0 6.7.1 6.7.2 6.7.3 6.7.4 6.7.5 6.7.6 6.7.7 6.7.8 6.7.9 6.8.0 6.8.1 6.8.2 6.8.3 6.8.4 6.8.5 6.8.6 6.8.7 6.8.8 6.8.9 6.9.0 6.9.1 6.9.2 6.9.3 6.9.4 6.9.5 6.9.6 6.9.7 6.9.8 6.9.9 7.0.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.0.6 7.0.7
media-cleaner / admin.php
media-cleaner Last commit date
common 6 years ago parsers 6 years ago scripts 6 years ago views 6 years ago admin.php 6 years ago api.php 7 years ago core.php 6 years ago engine.php 6 years ago media-cleaner.php 6 years ago parsers.php 6 years ago readme.txt 6 years ago ui.php 6 years ago
admin.php
486 lines
1 <?php
2
3 include "common/admin.php";
4
5 class Meow_WPMC_Admin extends MeowApps_Admin {
6
7 public function __construct( $prefix, $mainfile, $domain ) {
8 parent::__construct( $prefix, $mainfile, $domain );
9 add_action( 'admin_menu', array( $this, 'app_menu' ) );
10 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
11 add_filter( 'pre_update_option', array( $this, 'pre_update_option' ), 10, 3 );
12 }
13
14 /**
15 * Filters and performs validation for certain options
16 * @param mixed $value Option value
17 * @param string $option Option name
18 * @param mixed $old_value The current value of the option
19 * @return mixed The actual value to be stored
20 */
21 function pre_update_option( $value, $option, $old_value ) {
22 if ( strpos( $option, 'wpmc_' ) !== 0 ) return $value; // Never touch extraneous options
23 $validated = $this->validate_option( $option, $value );
24 if ( $validated instanceof WP_Error ) {
25 // TODO: Show warning for invalid option value
26 return $old_value;
27 }
28 return $validated;
29 }
30
31 /**
32 * Validates certain option values
33 * @param string $option Option name
34 * @param mixed $value Option value
35 * @return mixed|WP_Error Validated value if no problem
36 */
37 function validate_option( $option, $value ) {
38 switch ( $option ) {
39 case 'wpmc_dirs_filter':
40 case 'wpmc_files_filter':
41 if ( $value && @preg_match( $value, '' ) === false ) return new WP_Error( 'invalid_option', __( "Invalid Regular-Expression", 'media-cleaner' ) );
42 break;
43 }
44 return $value;
45 }
46
47 function admin_notices() {
48
49 $mediasBuffer = get_option( 'wpmc_medias_buffer', null );
50 $postsBuffer = get_option( 'wpmc_posts_buffer', null );
51 $analysisBuffer = get_option( 'wpmc_analysis_buffer', null );
52 $delay = get_option( 'wpmc_delay', null );
53
54 if ( !is_numeric( $mediasBuffer ) || $mediasBuffer < 1 )
55 update_option( 'wpmc_medias_buffer', 100 );
56 if ( !is_numeric( $postsBuffer ) || $postsBuffer < 1 )
57 update_option( 'wpmc_posts_buffer', 5 );
58 if ( !is_numeric( $analysisBuffer ) || $analysisBuffer < 1 )
59 update_option( 'wpmc_analysis_buffer', 100 );
60 if ( !is_numeric( $delay ) )
61 update_option( 'wpmc_delay', 100 );
62
63 if ( !$this->is_registered() && get_option( 'wpmc_method', 'media' ) == 'files' ) {
64 _e( "<div class='error'><p>The Pro version is required to scan files. You can <a target='_blank' href='http://meowapps.com/plugin/media-cleaner'>get a serial for the Pro version here</a>.</p></div>", 'media-cleaner' );
65 }
66 }
67
68 function common_url( $file ) {
69 return trailingslashit( plugin_dir_url( __FILE__ ) ) . 'common/' . $file;
70 }
71
72 function app_menu() {
73
74 // SUBMENU > Settings
75 add_submenu_page( 'meowapps-main-menu', 'Media Cleaner', 'Media Cleaner', 'manage_options',
76 'wpmc_settings-menu', array( $this, 'admin_settings' ) );
77
78 // SUBMENU > Settings > Settings (Scanning)
79 add_settings_section( 'wpmc_settings', null, null, 'wpmc_settings-menu' );
80 add_settings_field( 'wpmc_method', "Method",
81 array( $this, 'admin_method_callback' ),
82 'wpmc_settings-menu', 'wpmc_settings' );
83 add_settings_field( 'wpmc_content', "Content",
84 array( $this, 'admin_content_callback' ),
85 'wpmc_settings-menu', 'wpmc_settings' );
86 add_settings_field( 'wpmc_media_library', "Media Library",
87 array( $this, 'admin_media_library_callback' ),
88 'wpmc_settings-menu', 'wpmc_settings' );
89 add_settings_field( 'wpmc_live_content', "Live Content<br />(Pro)",
90 array( $this, 'admin_live_content_callback' ),
91 'wpmc_settings-menu', 'wpmc_settings' );
92 // add_settings_field( 'wpmc_posts', "Posts",
93 // array( $this, 'admin_posts_callback' ),
94 // 'wpmc_settings-menu', 'wpmc_settings' );
95 // add_settings_field( 'wpmc_postmeta', "Post Meta",
96 // array( $this, 'admin_postmeta_callback' ),
97 // 'wpmc_settings-menu', 'wpmc_settings' );
98 // add_settings_field( 'wpmc_widgets', "Widgets",
99 // array( $this, 'admin_widgets_callback' ),
100 // 'wpmc_settings-menu', 'wpmc_settings' );
101 // add_settings_field( 'wpmc_shortcode', "Shortcodes<br />(Pro)",
102 // array( $this, 'admin_shortcode_callback' ),
103 // 'wpmc_settings-menu', 'wpmc_settings' );
104 // add_settings_field( 'wpmc_background', "Background CSS<br />(Pro)",
105 // array( $this, 'admin_background_callback' ),
106 // 'wpmc_settings-menu', 'wpmc_settings' );
107 add_settings_field( 'wpmc_debuglogs', "Logs",
108 array( $this, 'admin_debuglogs_callback' ),
109 'wpmc_settings-menu', 'wpmc_settings', array( "Enable" ) );
110
111 // SUBMENU > Settings > Filters
112 add_settings_section( 'wpmc_filters_settings', null, null, 'wpmc_filters_settings-menu' );
113 add_settings_field( 'wpmc_thumbnails_only', "Thumbnails Only",
114 array( $this, 'admin_thumbnails_only_callback' ),
115 'wpmc_filters_settings-menu', 'wpmc_filters_settings' );
116
117 add_settings_field(
118 'wpmc_dirs_filter',
119 'Directories Filter',
120 array( $this, 'admin_dirs_filter_callback' ),
121 'wpmc_filters_settings-menu',
122 'wpmc_filters_settings'
123 );
124
125 add_settings_field(
126 'wpmc_files_filter',
127 'Files Filter',
128 array( $this, 'admin_files_filter_callback' ),
129 'wpmc_filters_settings-menu',
130 'wpmc_filters_settings'
131 );
132
133 // SUBMENU > Settings > UI
134 add_settings_section( 'wpmc_ui_settings', null, null, 'wpmc_ui_settings-menu' );
135 add_settings_field( 'wpmc_hide_thumbnails', "Thumbnails",
136 array( $this, 'admin_hide_thumbnails_callback' ),
137 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
138 add_settings_field( 'wpmc_hide_warning', "Warning Message",
139 array( $this, 'admin_hide_warning_callback' ),
140 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
141 add_settings_field( 'wpmc_results_per_page', "Results Per Page",
142 array( $this, 'admin_results_per_page' ),
143 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
144
145 // SUBMENU > Settings > Advanced
146 add_settings_section( 'wpmc_advanced_settings', null, null, 'wpmc_advanced_settings-menu' );
147 add_settings_field( 'wpmc_medias_buffer', "Medias Buffer",
148 array( $this, 'admin_medias_buffer_callback' ),
149 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
150 add_settings_field( 'wpmc_posts_buffer', "Posts Buffer",
151 array( $this, 'admin_posts_buffer_callback' ),
152 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
153 add_settings_field( 'wpmc_analysis_buffer', "Analysis Buffer",
154 array( $this, 'admin_analysis_buffer_callback' ),
155 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
156 add_settings_field( 'wpmc_delay', "Delay (in ms)",
157 array( $this, 'admin_delay_callback' ),
158 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
159 add_settings_field( 'wpmc_shortcodes_disabled', "Shortcodes",
160 array( $this, 'admin_shortcodes_disabled_callback' ),
161 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
162
163 // SETTINGS
164 register_setting( 'wpmc_settings', 'wpmc_method' );
165 register_setting( 'wpmc_settings', 'wpmc_content' );
166 register_setting( 'wpmc_settings', 'wpmc_live_content' );
167 register_setting( 'wpmc_settings', 'wpmc_media_library' );
168 register_setting( 'wpmc_settings', 'wpmc_debuglogs' );
169
170 register_setting( 'wpmc_filters_settings', 'wpmc_thumbnails_only' );
171 register_setting( 'wpmc_filters_settings', 'wpmc_dirs_filter' );
172 register_setting( 'wpmc_filters_settings', 'wpmc_files_filter' );
173
174 register_setting( 'wpmc_ui_settings', 'wpmc_hide_thumbnails' );
175 register_setting( 'wpmc_ui_settings', 'wpmc_hide_warning' );
176 register_setting( 'wpmc_ui_settings', 'wpmc_results_per_page' );
177
178 register_setting( 'wpmc_advanced_settings', 'wpmc_medias_buffer' );
179 register_setting( 'wpmc_advanced_settings', 'wpmc_posts_buffer' );
180 register_setting( 'wpmc_advanced_settings', 'wpmc_analysis_buffer' );
181 register_setting( 'wpmc_advanced_settings', 'wpmc_delay' );
182 register_setting( 'wpmc_advanced_settings', 'wpmc_shortcodes_disabled' );
183 }
184
185 function admin_medias_buffer_callback( $args ) {
186 $value = get_option( 'wpmc_medias_buffer', 100 );
187 $html = '<input type="number" style="width: 100%;" id="wpmc_medias_buffer" name="wpmc_medias_buffer" value="' . $value . '" />';
188 $html .= '<br /><span class="description">The number of media entries to read at a time. This is fast, so the value should be between 50 and 1000.</label>';
189 echo $html;
190 }
191
192 function admin_posts_buffer_callback( $args ) {
193 $value = get_option( 'wpmc_posts_buffer', 5 );
194 $html = '<input type="number" style="width: 100%;" id="wpmc_posts_buffer" name="wpmc_posts_buffer" value="' . $value . '" />';
195 $html .= '<br /><span class="description">The number of posts (and any other post types) to analyze at a time. This is the most intense part of the process. Recommended value is between 1 (slow server) and 20 (excellent server).</label>';
196 echo $html;
197 }
198
199 function admin_analysis_buffer_callback( $args ) {
200 $value = get_option( 'wpmc_analysis_buffer', 100 );
201 $html = '<input type="number" style="width: 100%;" id="wpmc_analysis_buffer" name="wpmc_analysis_buffer" value="' . $value . '" />';
202 $html .= '<br /><span class="description">The number of media entries or files to analyze at a time. This is the main part of the process, but is is much faster than analyzing each post. Recommended value is between 20 (slow server) and 1000 (excellent server).</label>';
203 echo $html;
204 }
205
206 function admin_delay_callback( $args ) {
207 $value = get_option( 'wpmc_delay', 100 );
208 $html = '<input type="number" style="width: 100%;" id="wpmc_delay" name="wpmc_delay" value="' . $value . '" />';
209 $html .= '<br /><span class="description">Time to wait between each request (in milliseconds). The overall process is intensive so this gives the chance to your server to chill out a bit. A very good server doesn\'t need it, but a slow/shared hosting might even reject requests if they are too fast and frequent. Recommended value is actually 0, 100 for safety, 2000 or 5000 if your hosting is kind of cheap.</label>';
210 echo $html;
211 }
212
213 function admin_settings() {
214 ?>
215 <div class="wrap">
216 <?php
217 echo $this->display_title( "Media Cleaner" );
218 ?>
219 <div class="meow-section meow-group">
220 <div class="meow-box meow-col meow-span_2_of_2">
221 <h3>How to use</h3>
222 <div class="inside">
223 <?php echo _e( "You can choose two kind of methods. Usually, users like to analyze their Media Library for images which are not in used (Media Library Method + Content Check), and then, their Filesystem for images which aren't registered in the Media Library (Filesystem Method + Media Library Check). Check the <a target=\"_blank\" href=\"https://meowapps.com/media-cleaner-tutorial/\">tutorial</a> for more information.", 'media-cleaner' ); ?>
224 <p class="submit">
225 <a class="button button-primary" href="upload.php?page=media-cleaner"><?php echo _e( "Access Media Cleaner Dashboard", 'media-cleaner' ); ?></a>
226 </p>
227 </div>
228 </div>
229 </div>
230
231 <div class="meow-section meow-group">
232
233 <div class="meow-col meow-span_1_of_2">
234
235 <div class="meow-box">
236 <h3>Scanning</h3>
237 <div class="inside">
238 <form method="post" action="options.php">
239 <?php settings_fields( 'wpmc_settings' ); ?>
240 <?php do_settings_sections( 'wpmc_settings-menu' ); ?>
241 <?php submit_button(); ?>
242 </form>
243 </div>
244 </div>
245
246 <div class="meow-box">
247 <h3>Filters</h3>
248 <div class="inside">
249 <form method="post" action="options.php">
250 <?php settings_fields( 'wpmc_filters_settings' ); ?>
251 <?php do_settings_sections( 'wpmc_filters_settings-menu' ); ?>
252 <?php submit_button(); ?>
253 </form>
254 </div>
255
256 </div>
257
258 </div>
259
260 <div class="meow-col meow-span_1_of_2">
261 <?php $this->display_serialkey_box( "https://meowapps.com/plugin/media-cleaner/" ); ?>
262
263 <div class="meow-box">
264 <h3>UI</h3>
265 <div class="inside">
266 <form method="post" action="options.php">
267 <?php settings_fields( 'wpmc_ui_settings' ); ?>
268 <?php do_settings_sections( 'wpmc_ui_settings-menu' ); ?>
269 <?php submit_button(); ?>
270 </form>
271 </div>
272 </div>
273
274 <div class="meow-box">
275 <h3>Advanced</h3>
276 <div class="inside">
277 <form method="post" action="options.php">
278 <?php settings_fields( 'wpmc_advanced_settings' ); ?>
279 <?php do_settings_sections( 'wpmc_advanced_settings-menu' ); ?>
280 <?php submit_button(); ?>
281 </form>
282 </div>
283 </div>
284
285 <!--
286 <?php if ( get_option( 'wpmc_shortcode', false ) ): ?>
287 <div class="meow-box">
288 <h3>Shortcodes</h3>
289 <div class="inside"><small>
290 <p>Here are the shortcodes registered in your WordPress by your theme and other plugins.</p>
291 <?php
292 global $shortcode_tags;
293 try {
294 if ( is_array( $shortcode_tags ) ) {
295 $my_shortcodes = array();
296 foreach ( $shortcode_tags as $sc )
297 if ( $sc != '__return_false' ) {
298 if ( is_string( $sc ) )
299 array_push( $my_shortcodes, str_replace( '_shortcode', '', (string)$sc ) );
300 }
301 $my_shortcodes = implode( ', ', $my_shortcodes );
302 }
303 }
304 catch (Exception $e) {
305 $my_shortcodes = "";
306 }
307 echo $my_shortcodes;
308 ?>
309 </small></div>
310 </div>
311 <?php endif; ?>
312 -->
313
314 </div>
315
316 </div>
317 </div>
318 <?php
319 }
320
321
322
323 /*
324 OPTIONS CALLBACKS
325 */
326
327 function admin_method_callback( $args ) {
328 $value = get_option( 'wpmc_method', 'media' );
329 $html = '<select id="wpmc_method" name="wpmc_method">
330 <option ' . selected( 'media', $value, false ) . 'value="media">Media Library</option>
331 <option ' . disabled( $this->is_registered(), false, false ) . ' ' . selected( 'files', $value, false ) . 'value="files">Filesystem (Pro)</option>
332 </select><small><br />' . __( 'Check the <a target="_blank" href="https://meowapps.com/media-cleaner-tutorial/">tutorial</a> for more information.', 'media-cleaner' ) . '</small>';
333
334 // TODO: This is temporary
335 // $html .= '<br /><br /><small><b style="color: red;">Notice: </b><b> Those settings will be simplified soon. Have a look <a href="https://trello.com/c/qrCuITg8/55-cleaner-simplification-of-the-settings" target="_blank">here</a> and let me know in the comments if you like the idea or not.</b></small>';
336
337 echo $html;
338 }
339
340
341 // function admin_shortcode_callback( $args ) {
342 // $value = get_option( 'wpmc_shortcode', null );
343 // $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wpmc_shortcode" name="wpmc_shortcode" value="1" ' .
344 // checked( 1, get_option( 'wpmc_shortcode' ), false ) . '/>';
345 // $html .= '<label>Resolve</label><br /><small>The shortcodes you are using in your <b>posts</b> and/or <b>widgets</b> (depending on your options) will be resolved and analyzed. You don\'t need to have this option enabled for the WP Gallery (as it is covered by the Galleries option).</small>';
346 // echo $html;
347 // }
348
349 // function admin_background_callback( $args ) {
350 // $value = get_option( 'wpmc_background', null );
351 // $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wpmc_background" name="wpmc_background" value="1" ' .
352 // checked( 1, get_option( 'wpmc_background' ), false ) . '/>';
353 // $html .= '<label>Analyze</label><br /><small>When parsing HTML, the CSS inline background will also be analyzed. A few page builders are using this.</small>';
354 // echo $html;
355 // }
356
357 function admin_debuglogs_callback( $args ) {
358 global $wpmc;
359 $debuglogs = get_option( 'wpmc_debuglogs' );
360 $clearlogs = isset ( $_GET[ 'clearlogs' ] ) ? $_GET[ 'clearlogs' ] : 0;
361 if ( $clearlogs && file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
362 unlink( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' );
363 }
364 $html = '<input type="checkbox" id="wpmc_debuglogs" name="wpmc_debuglogs" value="1" ' .
365 checked( 1, $debuglogs, false ) . '/>';
366 $html .= '<label for="wpmc_debuglogs"> ' . $args[0] . '</label><br>';
367 $html .= '<small>' . __( 'Creates an internal log file, for debugging purposes.', 'media-cleaner' );
368 if ( $debuglogs && !file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
369 if ( !$wpmc->log( "Testing the logging feature. It works!" ) ) {
370 $html .= sprintf( __( '<br /><b>Cannot create the logging file. Logging will not work. The plugin as a whole might not be able to work neither.</b>', 'media-cleaner' ), plugin_dir_url( __FILE__ ) );
371 }
372 }
373 if ( file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
374 $html .= sprintf( __( '<br />The <a target="_blank" href="%smedia-cleaner.log">log file</a> is available. You can also <a href="?page=wpmc_settings-menu&clearlogs=true">clear</a> it.', 'media-cleaner' ), plugin_dir_url( __FILE__ ) );
375 }
376 $html .= '</small>';
377 echo $html;
378 }
379
380 function admin_media_library_callback( $args ) {
381 $value = get_option( 'wpmc_media_library', true );
382 $html = '<input type="checkbox" id="wpmc_media_library" name="wpmc_media_library" value="1" ' .
383 disabled( get_option( 'wpmc_method', 'media' ) == 'files', false, false ) . ' ' .
384 checked( 1, $value, false ) . '/>';
385 $html .= '<label>Check</label><br /><small>Checks if the file is linked to a media. <i>Only matters to the Filesystem Method.</i></small>';
386 echo $html;
387 }
388
389 function admin_content_callback( $args ) {
390 $value = get_option( 'wpmc_content', true );
391 $html = '<input type="checkbox" id="wpmc_content" name="wpmc_content" value="1" ' .
392 checked( 1, $value, false ) . '/>';
393 $html .= '<label>Check</label><br /><small>Check if the media/file is used in the content, such as Posts, Pages (and other Post Types), Metadata, Widgets, etc.</small>';
394 echo $html;
395 }
396
397 function admin_live_content_callback( $args ) {
398 $value = get_option( 'wpmc_live_content', false );
399 $html = '<input ' . disabled( $this->is_registered(), false, false ) .
400 ' type="checkbox" id="wpmc_content" name="wpmc_live_content" value="1" ' .
401 checked( 1, $value, false ) . '/>';
402 $html .= '<label>Check</label><br /><small>The live version of the website will be also analyzed (as if a visitor was loading it). <i>This will increase the accuracy of the results.</i></small>';
403 echo $html;
404 }
405
406 function admin_shortcodes_disabled_callback( $args ) {
407 $value = get_option( 'wpmc_shortcodes_disabled', null );
408 $html = '<input type="checkbox" id="wpmc_shortcodes_disabled" name="wpmc_shortcodes_disabled" value="1" ' .
409 checked( 1, get_option( 'wpmc_shortcodes_disabled' ), false ) . '/>';
410 $html .= '<label>Disable Analysis</label><br /><small>Resolving shortcodes increase accuracy, but makes the process slower and takes more memory.</small>';
411 echo $html;
412 }
413
414 function admin_hide_thumbnails_callback( $args ) {
415 $value = get_option( 'wpmc_hide_thumbnails', null );
416 $html = '<input type="checkbox" id="wpmc_hide_thumbnails" name="wpmc_hide_thumbnails" value="1" ' .
417 checked( 1, get_option( 'wpmc_hide_thumbnails' ), false ) . '/>';
418 $html .= '<label>Hide</label><br /><small>If you prefer not to see the thumbnails.</small>';
419 echo $html;
420 }
421
422 function admin_hide_warning_callback( $args ) {
423 $value = get_option( 'wpmc_hide_warning', null );
424 $html = '<input type="checkbox" id="wpmc_hide_warning" name="wpmc_hide_warning" value="1" ' .
425 checked( 1, get_option( 'wpmc_hide_warning' ), false ) . '/>';
426 $html .= '<label>Hide</label><br /><small>Have you read it twice? If yes, hide it :)</small>';
427 echo $html;
428 }
429
430 function admin_results_per_page( $args ) {
431 $value = get_option( 'wpmc_results_per_page', 20 );
432 $html = <<< HTML
433 <input step="1" min="1" max="999" name="wpmc_results_per_page" id="wpmc_results_per_page" maxlength="3" value="{$value}" type="number">
434 HTML;
435 echo $html;
436 }
437
438 function admin_thumbnails_only_callback( $args ) {
439 $value = get_option( 'wpmc_thumbnails_only', false );
440 $html = '<input type="checkbox" id="wpmc_thumbnails_only" name="wpmc_thumbnails_only" value="1" ' .
441 disabled( get_option( 'wpmc_method', 'media' ) == 'files', false, false ) . ' ' .
442 checked( 1, get_option( 'wpmc_thumbnails_only' ), false ) . '/>';
443 $html .= '<label>Enable</label><br /><small>Restrict the filesystem scan to thumbnails (files containing the resolution). If none of the checks above are selected, you will get the list of all the thumbnails and be able to remove them.</small>';
444 echo $html;
445 }
446
447 function admin_dirs_filter_callback( $args ) {
448 $value = get_option( 'wpmc_dirs_filter', '' );
449 $invalid = @preg_match( $value, '' ) === false;
450 ?>
451 <input type="text" id="wpmc_dirs_filter" name="wpmc_dirs_filter" value="<?php echo $value; ?>" placeholder="/regex/" autocomplete="off" data-needs-validation style="font-family: monospace;">
452 <?php
453 }
454
455 function admin_files_filter_callback( $args ) {
456 $value = get_option( 'wpmc_files_filter', '' );
457 $invalid = @preg_match( $value, '' ) === false;
458 ?>
459 <input type="text" id="wpmc_files_filter" name="wpmc_files_filter" value="<?php echo $value; ?>" placeholder="/regex/" autocomplete="off" data-needs-validation style="font-family: monospace;">
460 <?php
461 }
462
463 /**
464 *
465 * GET / SET OPTIONS (TO REMOVE)
466 *
467 */
468
469 function old_getoption( $option, $section, $default = '' ) {
470 $options = get_option( $section );
471 if ( isset( $options[$option] ) ) {
472 if ( $options[$option] == "off" ) {
473 return false;
474 }
475 if ( $options[$option] == "on" ) {
476 return true;
477 }
478 return $options[$option];
479 }
480 return $default;
481 }
482
483 }
484
485 ?>
486