PluginProbe ʕ •ᴥ•ʔ
Media Cleaner: Clean your WordPress! / 5.2.0
Media Cleaner: Clean your WordPress! v5.2.0
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 7 years ago parsers 7 years ago views 7 years ago admin.php 7 years ago checkers.php 8 years ago core.php 7 years ago media-cleaner.css 7 years ago media-cleaner.js 7 years ago media-cleaner.php 7 years ago parsers.php 7 years ago readme.txt 7 years ago settings.js 7 years ago ui.php 7 years ago
admin.php
475 lines
1 <?php
2
3 include "common/admin.php";
4
5 class Meow_WPMC_Admin extends MeowApps_Admin {
6
7 public $core;
8
9 public function __construct( $prefix, $mainfile, $domain ) {
10 parent::__construct( $prefix, $mainfile, $domain );
11 add_action( 'admin_menu', array( $this, 'app_menu' ) );
12 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
13 add_filter( 'pre_update_option', array( $this, 'pre_update_option' ), 10, 3 );
14 }
15
16 /**
17 * Filters and performs validation for certain options
18 * @param mixed $value Option value
19 * @param string $option Option name
20 * @param mixed $old_value The current value of the option
21 * @return mixed The actual value to be stored
22 */
23 function pre_update_option( $value, $option, $old_value ) {
24 if ( strpos( $option, 'wpmc_' ) !== 0 ) return $value; // Never touch extraneous options
25 $validated = $this->validate_option( $option, $value );
26 if ( $validated instanceof WP_Error ) {
27 // TODO: Show warning for invalid option value
28 return $old_value;
29 }
30 return $validated;
31 }
32
33 /**
34 * Validates certain option values
35 * @param string $option Option name
36 * @param mixed $value Option value
37 * @return mixed|WP_Error Validated value if no problem
38 */
39 function validate_option( $option, $value ) {
40 switch ( $option ) {
41 case 'wpmc_dirs_filter':
42 case 'wpmc_files_filter':
43 if ( $value && @preg_match( $value, '' ) === false ) return new WP_Error( 'invalid_option', __( "Invalid Regular-Expression", 'media-cleaner' ) );
44 break;
45 }
46 return $value;
47 }
48
49 function admin_notices() {
50
51 $mediasBuffer = get_option( 'wpmc_medias_buffer', null );
52 $postsBuffer = get_option( 'wpmc_posts_buffer', null );
53 $analysisBuffer = get_option( 'wpmc_analysis_buffer', null );
54 $delay = get_option( 'wpmc_delay', null );
55
56 if ( !is_numeric( $mediasBuffer ) || $mediasBuffer < 1 )
57 update_option( 'wpmc_medias_buffer', 100 );
58 if ( !is_numeric( $postsBuffer ) || $postsBuffer < 1 )
59 update_option( 'wpmc_posts_buffer', 5 );
60 if ( !is_numeric( $analysisBuffer ) || $analysisBuffer < 1 )
61 update_option( 'wpmc_analysis_buffer', 100 );
62 if ( !is_numeric( $delay ) )
63 update_option( 'wpmc_delay', 100 );
64
65 if ( !$this->is_registered() && get_option( 'wpmc_method', 'media' ) == 'files' ) {
66 _e( "<div class='error'><p>The Pro version is required to scan files. You can <a target='_blank' href='http://meowapps.com/media-cleaner'>get a serial for the Pro version here</a>.</p></div>", 'media-cleaner' );
67 }
68 }
69
70 function common_url( $file ) {
71 return trailingslashit( plugin_dir_url( __FILE__ ) ) . 'common/' . $file;
72 }
73
74 function app_menu() {
75
76 // SUBMENU > Settings
77 add_submenu_page( 'meowapps-main-menu', 'Media Cleaner', 'Media Cleaner', 'manage_options',
78 'wpmc_settings-menu', array( $this, 'admin_settings' ) );
79
80 // SUBMENU > Settings > Settings (Scanning)
81 add_settings_section( 'wpmc_settings', null, null, 'wpmc_settings-menu' );
82 add_settings_field( 'wpmc_method', "Method",
83 array( $this, 'admin_method_callback' ),
84 'wpmc_settings-menu', 'wpmc_settings' );
85 add_settings_field( 'wpmc_media_library', "Media Library",
86 array( $this, 'admin_media_library_callback' ),
87 'wpmc_settings-menu', 'wpmc_settings' );
88 add_settings_field( 'wpmc_posts', "Posts",
89 array( $this, 'admin_posts_callback' ),
90 'wpmc_settings-menu', 'wpmc_settings' );
91 add_settings_field( 'wpmc_postmeta', "Post Meta",
92 array( $this, 'admin_postmeta_callback' ),
93 'wpmc_settings-menu', 'wpmc_settings' );
94 add_settings_field( 'wpmc_widgets', "Widgets",
95 array( $this, 'admin_widgets_callback' ),
96 'wpmc_settings-menu', 'wpmc_settings' );
97 // add_settings_field( 'wpmc_shortcode', "Shortcodes<br />(Pro)",
98 // array( $this, 'admin_shortcode_callback' ),
99 // 'wpmc_settings-menu', 'wpmc_settings' );
100 // add_settings_field( 'wpmc_background', "Background CSS<br />(Pro)",
101 // array( $this, 'admin_background_callback' ),
102 // 'wpmc_settings-menu', 'wpmc_settings' );
103 add_settings_field( 'wpmc_debuglogs', "Logs",
104 array( $this, 'admin_debuglogs_callback' ),
105 'wpmc_settings-menu', 'wpmc_settings', array( "Enable" ) );
106
107 // SUBMENU > Settings > Filters
108 add_settings_section( 'wpmc_filters_settings', null, null, 'wpmc_filters_settings-menu' );
109 add_settings_field( 'wpmc_thumbnails_only', "Thumbnails Only",
110 array( $this, 'admin_thumbnails_only_callback' ),
111 'wpmc_filters_settings-menu', 'wpmc_filters_settings' );
112
113 add_settings_field(
114 'wpmc_dirs_filter',
115 'Directories Filter',
116 array( $this, 'admin_dirs_filter_callback' ),
117 'wpmc_filters_settings-menu',
118 'wpmc_filters_settings'
119 );
120
121 add_settings_field(
122 'wpmc_files_filter',
123 'Files Filter',
124 array( $this, 'admin_files_filter_callback' ),
125 'wpmc_filters_settings-menu',
126 'wpmc_filters_settings'
127 );
128
129 // SUBMENU > Settings > UI
130 add_settings_section( 'wpmc_ui_settings', null, null, 'wpmc_ui_settings-menu' );
131 add_settings_field( 'wpmc_hide_thumbnails', "Thumbnails",
132 array( $this, 'admin_hide_thumbnails_callback' ),
133 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
134 add_settings_field( 'wpmc_hide_warning', "Warning Message",
135 array( $this, 'admin_hide_warning_callback' ),
136 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
137 add_settings_field( 'wpmc_results_per_page', "Results Per Page",
138 array( $this, 'admin_results_per_page' ),
139 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
140
141 // SUBMENU > Settings > Advanced
142 add_settings_section( 'wpmc_advanced_settings', null, null, 'wpmc_advanced_settings-menu' );
143 add_settings_field( 'wpmc_medias_buffer', "Medias Buffer",
144 array( $this, 'admin_medias_buffer_callback' ),
145 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
146 add_settings_field( 'wpmc_posts_buffer', "Posts Buffer",
147 array( $this, 'admin_posts_buffer_callback' ),
148 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
149 add_settings_field( 'wpmc_analysis_buffer', "Analysis Buffer",
150 array( $this, 'admin_analysis_buffer_callback' ),
151 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
152 add_settings_field( 'wpmc_delay', "Delay (in ms)",
153 array( $this, 'admin_delay_callback' ),
154 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
155
156 // SETTINGS
157 register_setting( 'wpmc_settings', 'wpmc_method' );
158 register_setting( 'wpmc_settings', 'wpmc_posts' );
159 // register_setting( 'wpmc_settings', 'wpmc_shortcode' );
160 // register_setting( 'wpmc_settings', 'wpmc_background' );
161 register_setting( 'wpmc_settings', 'wpmc_widgets' );
162 register_setting( 'wpmc_settings', 'wpmc_media_library' );
163 register_setting( 'wpmc_settings', 'wpmc_postmeta' );
164 register_setting( 'wpmc_settings', 'wpmc_debuglogs' );
165
166 register_setting( 'wpmc_filters_settings', 'wpmc_thumbnails_only' );
167 register_setting( 'wpmc_filters_settings', 'wpmc_dirs_filter' );
168 register_setting( 'wpmc_filters_settings', 'wpmc_files_filter' );
169
170 register_setting( 'wpmc_ui_settings', 'wpmc_hide_thumbnails' );
171 register_setting( 'wpmc_ui_settings', 'wpmc_hide_warning' );
172 register_setting( 'wpmc_ui_settings', 'wpmc_results_per_page' );
173
174 register_setting( 'wpmc_advanced_settings', 'wpmc_medias_buffer' );
175 register_setting( 'wpmc_advanced_settings', 'wpmc_posts_buffer' );
176 register_setting( 'wpmc_advanced_settings', 'wpmc_analysis_buffer' );
177 register_setting( 'wpmc_advanced_settings', 'wpmc_delay' );
178 }
179
180 function admin_medias_buffer_callback( $args ) {
181 $value = get_option( 'wpmc_medias_buffer', 100 );
182 $html = '<input type="number" style="width: 100%;" id="wpmc_medias_buffer" name="wpmc_medias_buffer" value="' . $value . '" />';
183 $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>';
184 echo $html;
185 }
186
187 function admin_posts_buffer_callback( $args ) {
188 $value = get_option( 'wpmc_posts_buffer', 5 );
189 $html = '<input type="number" style="width: 100%;" id="wpmc_posts_buffer" name="wpmc_posts_buffer" value="' . $value . '" />';
190 $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>';
191 echo $html;
192 }
193
194 function admin_analysis_buffer_callback( $args ) {
195 $value = get_option( 'wpmc_analysis_buffer', 100 );
196 $html = '<input type="number" style="width: 100%;" id="wpmc_analysis_buffer" name="wpmc_analysis_buffer" value="' . $value . '" />';
197 $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>';
198 echo $html;
199 }
200
201 function admin_delay_callback( $args ) {
202 $value = get_option( 'wpmc_delay', 100 );
203 $html = '<input type="number" style="width: 100%;" id="wpmc_delay" name="wpmc_delay" value="' . $value . '" />';
204 $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>';
205 echo $html;
206 }
207
208 function admin_settings() {
209 ?>
210 <div class="wrap">
211 <?php
212 echo $this->display_title( "Media Cleaner" );
213 ?>
214 <div class="meow-section meow-group">
215 <div class="meow-box meow-col meow-span_2_of_2">
216 <h3>How to use</h3>
217 <div class="inside">
218 <?php echo _e( "You can choose two kind of methods, analyzing your Media Library for images which are not in used, or in your Filesystem for images which aren't registered in the Media Library or not in used. <b>Those checks can be very expensive in term of resources and might fail so you might want to play with those options depending on your install and what you need.</b> Check the <a target=\"_blank\" href=\"//meowapps.com/media-cleaner/tutorial/\">tutorial</a> for more information.", 'media-cleaner' ); ?>
219 <p class="submit">
220 <a class="button button-primary" href="upload.php?page=media-cleaner"><?php echo _e( "Access Media Cleaner Dashboard", 'media-cleaner' ); ?></a>
221 </p>
222 </div>
223 </div>
224 </div>
225
226 <div class="meow-section meow-group">
227
228 <div class="meow-col meow-span_1_of_2">
229
230 <div class="meow-box">
231 <h3>Scanning</h3>
232 <div class="inside">
233 <form method="post" action="options.php">
234 <?php settings_fields( 'wpmc_settings' ); ?>
235 <?php do_settings_sections( 'wpmc_settings-menu' ); ?>
236 <?php submit_button(); ?>
237 </form>
238 </div>
239 </div>
240
241 <div class="meow-box">
242 <h3>Filters</h3>
243 <div class="inside">
244 <form method="post" action="options.php">
245 <?php settings_fields( 'wpmc_filters_settings' ); ?>
246 <?php do_settings_sections( 'wpmc_filters_settings-menu' ); ?>
247 <?php submit_button(); ?>
248 </form>
249 </div>
250
251 </div>
252
253 </div>
254
255 <div class="meow-col meow-span_1_of_2">
256 <?php $this->display_serialkey_box( "https://meowapps.com/media-cleaner/" ); ?>
257
258 <div class="meow-box">
259 <h3>UI</h3>
260 <div class="inside">
261 <form method="post" action="options.php">
262 <?php settings_fields( 'wpmc_ui_settings' ); ?>
263 <?php do_settings_sections( 'wpmc_ui_settings-menu' ); ?>
264 <?php submit_button(); ?>
265 </form>
266 </div>
267 </div>
268
269 <div class="meow-box">
270 <h3>Advanced</h3>
271 <div class="inside">
272 <form method="post" action="options.php">
273 <?php settings_fields( 'wpmc_advanced_settings' ); ?>
274 <?php do_settings_sections( 'wpmc_advanced_settings-menu' ); ?>
275 <?php submit_button(); ?>
276 </form>
277 </div>
278 </div>
279
280 <!--
281 <?php if ( get_option( 'wpmc_shortcode', false ) ): ?>
282 <div class="meow-box">
283 <h3>Shortcodes</h3>
284 <div class="inside"><small>
285 <p>Here are the shortcodes registered in your WordPress by your theme and other plugins.</p>
286 <?php
287 global $shortcode_tags;
288 try {
289 if ( is_array( $shortcode_tags ) ) {
290 $my_shortcodes = array();
291 foreach ( $shortcode_tags as $sc )
292 if ( $sc != '__return_false' ) {
293 if ( is_string( $sc ) )
294 array_push( $my_shortcodes, str_replace( '_shortcode', '', (string)$sc ) );
295 }
296 $my_shortcodes = implode( ', ', $my_shortcodes );
297 }
298 }
299 catch (Exception $e) {
300 $my_shortcodes = "";
301 }
302 echo $my_shortcodes;
303 ?>
304 </small></div>
305 </div>
306 <?php endif; ?>
307 -->
308
309 </div>
310
311 </div>
312 </div>
313 <?php
314 }
315
316
317
318 /*
319 OPTIONS CALLBACKS
320 */
321
322 function admin_method_callback( $args ) {
323 $value = get_option( 'wpmc_method', 'media' );
324 $html = '<select id="wpmc_method" name="wpmc_method">
325 <option ' . selected( 'media', $value, false ) . 'value="media">Media Library</option>
326 <option ' . disabled( $this->is_registered(), false, false ) . ' ' . selected( 'files', $value, false ) . 'value="files">Filesystem (Pro)</option>
327 </select><small><br />' . __( 'Check the <a target="_blank" href="//meowapps.com/media-cleaner/tutorial/">tutorial</a> for more information.', 'media-cleaner' ) . '</small>';
328 echo $html;
329 }
330
331
332 // function admin_shortcode_callback( $args ) {
333 // $value = get_option( 'wpmc_shortcode', null );
334 // $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wpmc_shortcode" name="wpmc_shortcode" value="1" ' .
335 // checked( 1, get_option( 'wpmc_shortcode' ), false ) . '/>';
336 // $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>';
337 // echo $html;
338 // }
339
340 // function admin_background_callback( $args ) {
341 // $value = get_option( 'wpmc_background', null );
342 // $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wpmc_background" name="wpmc_background" value="1" ' .
343 // checked( 1, get_option( 'wpmc_background' ), false ) . '/>';
344 // $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>';
345 // echo $html;
346 // }
347
348 function admin_debuglogs_callback( $args ) {
349 $debuglogs = get_option( 'wpmc_debuglogs' );
350 $clearlogs = isset ( $_GET[ 'clearlogs' ] ) ? $_GET[ 'clearlogs' ] : 0;
351 if ( $clearlogs && file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
352 unlink( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' );
353 }
354 $html = '<input type="checkbox" id="wpmc_debuglogs" name="wpmc_debuglogs" value="1" ' .
355 checked( 1, $debuglogs, false ) . '/>';
356 $html .= '<label for="wpmc_debuglogs"> ' . $args[0] . '</label><br>';
357 $html .= '<small>' . __( 'Creates an internal log file, for debugging purposes.', 'media-cleaner' );
358 if ( $debuglogs && !file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
359 if ( !$this->core->log( "Testing the logging feature. It works!" ) ) {
360 $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__ ) );
361 }
362 }
363 if ( file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
364 $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__ ) );
365 }
366 $html .= '</small>';
367 echo $html;
368 }
369
370 function admin_media_library_callback( $args ) {
371 $value = get_option( 'wpmc_media_library', true );
372 $html = '<input type="checkbox" id="wpmc_media_library" name="wpmc_media_library" value="1" ' .
373 disabled( get_option( 'wpmc_method', 'media' ) == 'files', false, false ) . ' ' .
374 checked( 1, get_option( 'wpmc_media_library' ), false ) . '/>';
375 $html .= '<label>Check</label><br /><small>Checks if the file is linked to a media. Only makes sense with the Filesystem scan.</small>';
376 echo $html;
377 }
378
379 function admin_posts_callback( $args ) {
380 $value = get_option( 'wpmc_posts', true );
381 $html = '<input type="checkbox" id="wpmc_posts" name="wpmc_posts" value="1" ' .
382 checked( 1, get_option( 'wpmc_posts' ), false ) . '/>';
383 $html .= '<label>Analyze</label><br /><small>Check if the media/file is used by any post types.</small>';
384 echo $html;
385 }
386
387 function admin_postmeta_callback( $args ) {
388 $value = get_option( 'wpmc_postmeta', true );
389 $html = '<input type="checkbox" id="wpmc_postmeta" name="wpmc_postmeta" value="1" ' .
390 checked( 1, get_option( 'wpmc_postmeta' ), false ) . '/>';
391 $html .= '<label>Analyze</label><br /><small>Checks if the media/file is used in the meta.</small>';
392 echo $html;
393 }
394
395 function admin_widgets_callback( $args ) {
396 $value = get_option( 'wpmc_widgets', false );
397 $html = '<input type="checkbox" id="wpmc_widgets" name="wpmc_widgets" value="1" ' .
398 checked( 1, get_option( 'wpmc_widgets' ), false ) . '/>';
399 $html .= '<label>Analyze</label><br /><small>Checks if the media/file is used by any widget.</small>';
400 echo $html;
401 }
402
403 function admin_hide_thumbnails_callback( $args ) {
404 $value = get_option( 'wpmc_hide_thumbnails', null );
405 $html = '<input type="checkbox" id="wpmc_hide_thumbnails" name="wpmc_hide_thumbnails" value="1" ' .
406 checked( 1, get_option( 'wpmc_hide_thumbnails' ), false ) . '/>';
407 $html .= '<label>Hide</label><br /><small>If you prefer not to see the thumbnails.</small>';
408 echo $html;
409 }
410
411 function admin_hide_warning_callback( $args ) {
412 $value = get_option( 'wpmc_hide_warning', null );
413 $html = '<input type="checkbox" id="wpmc_hide_warning" name="wpmc_hide_warning" value="1" ' .
414 checked( 1, get_option( 'wpmc_hide_warning' ), false ) . '/>';
415 $html .= '<label>Hide</label><br /><small>Have you read it twice? If yes, hide it :)</small>';
416 echo $html;
417 }
418
419 function admin_results_per_page( $args ) {
420 $value = get_option( 'wpmc_results_per_page', 20 );
421 $html = <<< HTML
422 <input step="1" min="1" max="999" name="wpmc_results_per_page" id="wpmc_results_per_page" maxlength="3" value="{$value}" type="number">
423 HTML;
424 echo $html;
425 }
426
427 function admin_thumbnails_only_callback( $args ) {
428 $value = get_option( 'wpmc_thumbnails_only', false );
429 $html = '<input type="checkbox" id="wpmc_thumbnails_only" name="wpmc_thumbnails_only" value="1" ' .
430 disabled( get_option( 'wpmc_method', 'media' ) == 'files', false, false ) . ' ' .
431 checked( 1, get_option( 'wpmc_thumbnails_only' ), false ) . '/>';
432 $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>';
433 echo $html;
434 }
435
436 function admin_dirs_filter_callback( $args ) {
437 $value = get_option( 'wpmc_dirs_filter', '' );
438 $invalid = @preg_match( $value, '' ) === false;
439 ?>
440 <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;">
441 <?php
442 }
443
444 function admin_files_filter_callback( $args ) {
445 $value = get_option( 'wpmc_files_filter', '' );
446 $invalid = @preg_match( $value, '' ) === false;
447 ?>
448 <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;">
449 <?php
450 }
451
452 /**
453 *
454 * GET / SET OPTIONS (TO REMOVE)
455 *
456 */
457
458 function old_getoption( $option, $section, $default = '' ) {
459 $options = get_option( $section );
460 if ( isset( $options[$option] ) ) {
461 if ( $options[$option] == "off" ) {
462 return false;
463 }
464 if ( $options[$option] == "on" ) {
465 return true;
466 }
467 return $options[$option];
468 }
469 return $default;
470 }
471
472 }
473
474 ?>
475