PluginProbe ʕ •ᴥ•ʔ
Media Cleaner: Clean your WordPress! / 5.2.4
Media Cleaner: Clean your WordPress! v5.2.4
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 scripts 7 years ago views 7 years ago admin.php 7 years ago api.php 7 years ago core.php 7 years ago engine.php 7 years ago media-cleaner.php 7 years ago parsers.php 7 years ago readme.txt 7 years ago ui.php 7 years ago
admin.php
478 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/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_media_library', "Media Library",
84 array( $this, 'admin_media_library_callback' ),
85 'wpmc_settings-menu', 'wpmc_settings' );
86 add_settings_field( 'wpmc_posts', "Posts",
87 array( $this, 'admin_posts_callback' ),
88 'wpmc_settings-menu', 'wpmc_settings' );
89 add_settings_field( 'wpmc_postmeta', "Post Meta",
90 array( $this, 'admin_postmeta_callback' ),
91 'wpmc_settings-menu', 'wpmc_settings' );
92 add_settings_field( 'wpmc_widgets', "Widgets",
93 array( $this, 'admin_widgets_callback' ),
94 'wpmc_settings-menu', 'wpmc_settings' );
95 // add_settings_field( 'wpmc_shortcode', "Shortcodes<br />(Pro)",
96 // array( $this, 'admin_shortcode_callback' ),
97 // 'wpmc_settings-menu', 'wpmc_settings' );
98 // add_settings_field( 'wpmc_background', "Background CSS<br />(Pro)",
99 // array( $this, 'admin_background_callback' ),
100 // 'wpmc_settings-menu', 'wpmc_settings' );
101 add_settings_field( 'wpmc_debuglogs', "Logs",
102 array( $this, 'admin_debuglogs_callback' ),
103 'wpmc_settings-menu', 'wpmc_settings', array( "Enable" ) );
104
105 // SUBMENU > Settings > Filters
106 add_settings_section( 'wpmc_filters_settings', null, null, 'wpmc_filters_settings-menu' );
107 add_settings_field( 'wpmc_thumbnails_only', "Thumbnails Only",
108 array( $this, 'admin_thumbnails_only_callback' ),
109 'wpmc_filters_settings-menu', 'wpmc_filters_settings' );
110
111 add_settings_field(
112 'wpmc_dirs_filter',
113 'Directories Filter',
114 array( $this, 'admin_dirs_filter_callback' ),
115 'wpmc_filters_settings-menu',
116 'wpmc_filters_settings'
117 );
118
119 add_settings_field(
120 'wpmc_files_filter',
121 'Files Filter',
122 array( $this, 'admin_files_filter_callback' ),
123 'wpmc_filters_settings-menu',
124 'wpmc_filters_settings'
125 );
126
127 // SUBMENU > Settings > UI
128 add_settings_section( 'wpmc_ui_settings', null, null, 'wpmc_ui_settings-menu' );
129 add_settings_field( 'wpmc_hide_thumbnails', "Thumbnails",
130 array( $this, 'admin_hide_thumbnails_callback' ),
131 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
132 add_settings_field( 'wpmc_hide_warning', "Warning Message",
133 array( $this, 'admin_hide_warning_callback' ),
134 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
135 add_settings_field( 'wpmc_results_per_page', "Results Per Page",
136 array( $this, 'admin_results_per_page' ),
137 'wpmc_ui_settings-menu', 'wpmc_ui_settings' );
138
139 // SUBMENU > Settings > Advanced
140 add_settings_section( 'wpmc_advanced_settings', null, null, 'wpmc_advanced_settings-menu' );
141 add_settings_field( 'wpmc_medias_buffer', "Medias Buffer",
142 array( $this, 'admin_medias_buffer_callback' ),
143 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
144 add_settings_field( 'wpmc_posts_buffer', "Posts Buffer",
145 array( $this, 'admin_posts_buffer_callback' ),
146 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
147 add_settings_field( 'wpmc_analysis_buffer', "Analysis Buffer",
148 array( $this, 'admin_analysis_buffer_callback' ),
149 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
150 add_settings_field( 'wpmc_delay', "Delay (in ms)",
151 array( $this, 'admin_delay_callback' ),
152 'wpmc_advanced_settings-menu', 'wpmc_advanced_settings' );
153
154 // SETTINGS
155 register_setting( 'wpmc_settings', 'wpmc_method' );
156 register_setting( 'wpmc_settings', 'wpmc_posts' );
157 // register_setting( 'wpmc_settings', 'wpmc_shortcode' );
158 // register_setting( 'wpmc_settings', 'wpmc_background' );
159 register_setting( 'wpmc_settings', 'wpmc_widgets' );
160 register_setting( 'wpmc_settings', 'wpmc_media_library' );
161 register_setting( 'wpmc_settings', 'wpmc_postmeta' );
162 register_setting( 'wpmc_settings', 'wpmc_debuglogs' );
163
164 register_setting( 'wpmc_filters_settings', 'wpmc_thumbnails_only' );
165 register_setting( 'wpmc_filters_settings', 'wpmc_dirs_filter' );
166 register_setting( 'wpmc_filters_settings', 'wpmc_files_filter' );
167
168 register_setting( 'wpmc_ui_settings', 'wpmc_hide_thumbnails' );
169 register_setting( 'wpmc_ui_settings', 'wpmc_hide_warning' );
170 register_setting( 'wpmc_ui_settings', 'wpmc_results_per_page' );
171
172 register_setting( 'wpmc_advanced_settings', 'wpmc_medias_buffer' );
173 register_setting( 'wpmc_advanced_settings', 'wpmc_posts_buffer' );
174 register_setting( 'wpmc_advanced_settings', 'wpmc_analysis_buffer' );
175 register_setting( 'wpmc_advanced_settings', 'wpmc_delay' );
176 }
177
178 function admin_medias_buffer_callback( $args ) {
179 $value = get_option( 'wpmc_medias_buffer', 100 );
180 $html = '<input type="number" style="width: 100%;" id="wpmc_medias_buffer" name="wpmc_medias_buffer" value="' . $value . '" />';
181 $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>';
182 echo $html;
183 }
184
185 function admin_posts_buffer_callback( $args ) {
186 $value = get_option( 'wpmc_posts_buffer', 5 );
187 $html = '<input type="number" style="width: 100%;" id="wpmc_posts_buffer" name="wpmc_posts_buffer" value="' . $value . '" />';
188 $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>';
189 echo $html;
190 }
191
192 function admin_analysis_buffer_callback( $args ) {
193 $value = get_option( 'wpmc_analysis_buffer', 100 );
194 $html = '<input type="number" style="width: 100%;" id="wpmc_analysis_buffer" name="wpmc_analysis_buffer" value="' . $value . '" />';
195 $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>';
196 echo $html;
197 }
198
199 function admin_delay_callback( $args ) {
200 $value = get_option( 'wpmc_delay', 100 );
201 $html = '<input type="number" style="width: 100%;" id="wpmc_delay" name="wpmc_delay" value="' . $value . '" />';
202 $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>';
203 echo $html;
204 }
205
206 function admin_settings() {
207 ?>
208 <div class="wrap">
209 <?php
210 echo $this->display_title( "Media Cleaner" );
211 ?>
212 <div class="meow-section meow-group">
213 <div class="meow-box meow-col meow-span_2_of_2">
214 <h3>How to use</h3>
215 <div class="inside">
216 <?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' ); ?>
217 <p class="submit">
218 <a class="button button-primary" href="upload.php?page=media-cleaner"><?php echo _e( "Access Media Cleaner Dashboard", 'media-cleaner' ); ?></a>
219 </p>
220 </div>
221 </div>
222 </div>
223
224 <div class="meow-section meow-group">
225
226 <div class="meow-col meow-span_1_of_2">
227
228 <div class="meow-box">
229 <h3>Scanning</h3>
230 <div class="inside">
231 <form method="post" action="options.php">
232 <?php settings_fields( 'wpmc_settings' ); ?>
233 <?php do_settings_sections( 'wpmc_settings-menu' ); ?>
234 <?php submit_button(); ?>
235 </form>
236 </div>
237 </div>
238
239 <div class="meow-box">
240 <h3>Filters</h3>
241 <div class="inside">
242 <form method="post" action="options.php">
243 <?php settings_fields( 'wpmc_filters_settings' ); ?>
244 <?php do_settings_sections( 'wpmc_filters_settings-menu' ); ?>
245 <?php submit_button(); ?>
246 </form>
247 </div>
248
249 </div>
250
251 </div>
252
253 <div class="meow-col meow-span_1_of_2">
254 <?php $this->display_serialkey_box( "https://meowapps.com/media-cleaner/" ); ?>
255
256 <div class="meow-box">
257 <h3>UI</h3>
258 <div class="inside">
259 <form method="post" action="options.php">
260 <?php settings_fields( 'wpmc_ui_settings' ); ?>
261 <?php do_settings_sections( 'wpmc_ui_settings-menu' ); ?>
262 <?php submit_button(); ?>
263 </form>
264 </div>
265 </div>
266
267 <div class="meow-box">
268 <h3>Advanced</h3>
269 <div class="inside">
270 <form method="post" action="options.php">
271 <?php settings_fields( 'wpmc_advanced_settings' ); ?>
272 <?php do_settings_sections( 'wpmc_advanced_settings-menu' ); ?>
273 <?php submit_button(); ?>
274 </form>
275 </div>
276 </div>
277
278 <!--
279 <?php if ( get_option( 'wpmc_shortcode', false ) ): ?>
280 <div class="meow-box">
281 <h3>Shortcodes</h3>
282 <div class="inside"><small>
283 <p>Here are the shortcodes registered in your WordPress by your theme and other plugins.</p>
284 <?php
285 global $shortcode_tags;
286 try {
287 if ( is_array( $shortcode_tags ) ) {
288 $my_shortcodes = array();
289 foreach ( $shortcode_tags as $sc )
290 if ( $sc != '__return_false' ) {
291 if ( is_string( $sc ) )
292 array_push( $my_shortcodes, str_replace( '_shortcode', '', (string)$sc ) );
293 }
294 $my_shortcodes = implode( ', ', $my_shortcodes );
295 }
296 }
297 catch (Exception $e) {
298 $my_shortcodes = "";
299 }
300 echo $my_shortcodes;
301 ?>
302 </small></div>
303 </div>
304 <?php endif; ?>
305 -->
306
307 </div>
308
309 </div>
310 </div>
311 <?php
312 }
313
314
315
316 /*
317 OPTIONS CALLBACKS
318 */
319
320 function admin_method_callback( $args ) {
321 $value = get_option( 'wpmc_method', 'media' );
322 $html = '<select id="wpmc_method" name="wpmc_method">
323 <option ' . selected( 'media', $value, false ) . 'value="media">Media Library</option>
324 <option ' . disabled( $this->is_registered(), false, false ) . ' ' . selected( 'files', $value, false ) . 'value="files">Filesystem (Pro)</option>
325 </select><small><br />' . __( 'Check the <a target="_blank" href="//meowapps.com/media-cleaner/tutorial/">tutorial</a> for more information.', 'media-cleaner' ) . '</small>';
326
327 // TODO: This is temporary
328 $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>';
329
330 echo $html;
331 }
332
333
334 // function admin_shortcode_callback( $args ) {
335 // $value = get_option( 'wpmc_shortcode', null );
336 // $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wpmc_shortcode" name="wpmc_shortcode" value="1" ' .
337 // checked( 1, get_option( 'wpmc_shortcode' ), false ) . '/>';
338 // $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>';
339 // echo $html;
340 // }
341
342 // function admin_background_callback( $args ) {
343 // $value = get_option( 'wpmc_background', null );
344 // $html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="wpmc_background" name="wpmc_background" value="1" ' .
345 // checked( 1, get_option( 'wpmc_background' ), false ) . '/>';
346 // $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>';
347 // echo $html;
348 // }
349
350 function admin_debuglogs_callback( $args ) {
351 global $wpmc;
352 $debuglogs = get_option( 'wpmc_debuglogs' );
353 $clearlogs = isset ( $_GET[ 'clearlogs' ] ) ? $_GET[ 'clearlogs' ] : 0;
354 if ( $clearlogs && file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
355 unlink( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' );
356 }
357 $html = '<input type="checkbox" id="wpmc_debuglogs" name="wpmc_debuglogs" value="1" ' .
358 checked( 1, $debuglogs, false ) . '/>';
359 $html .= '<label for="wpmc_debuglogs"> ' . $args[0] . '</label><br>';
360 $html .= '<small>' . __( 'Creates an internal log file, for debugging purposes.', 'media-cleaner' );
361 if ( $debuglogs && !file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
362 if ( !$wpmc->log( "Testing the logging feature. It works!" ) ) {
363 $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__ ) );
364 }
365 }
366 if ( file_exists( plugin_dir_path( __FILE__ ) . '/media-cleaner.log' ) ) {
367 $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__ ) );
368 }
369 $html .= '</small>';
370 echo $html;
371 }
372
373 function admin_media_library_callback( $args ) {
374 $value = get_option( 'wpmc_media_library', true );
375 $html = '<input type="checkbox" id="wpmc_media_library" name="wpmc_media_library" value="1" ' .
376 disabled( get_option( 'wpmc_method', 'media' ) == 'files', false, false ) . ' ' .
377 checked( 1, get_option( 'wpmc_media_library' ), false ) . '/>';
378 $html .= '<label>Check</label><br /><small>Checks if the file is linked to a media. Only makes sense with the Filesystem scan.</small>';
379 echo $html;
380 }
381
382 function admin_posts_callback( $args ) {
383 $value = get_option( 'wpmc_posts', true );
384 $html = '<input type="checkbox" id="wpmc_posts" name="wpmc_posts" value="1" ' .
385 checked( 1, get_option( 'wpmc_posts' ), false ) . '/>';
386 $html .= '<label>Analyze</label><br /><small>Check if the media/file is used by any post types.</small>';
387 echo $html;
388 }
389
390 function admin_postmeta_callback( $args ) {
391 $value = get_option( 'wpmc_postmeta', true );
392 $html = '<input type="checkbox" id="wpmc_postmeta" name="wpmc_postmeta" value="1" ' .
393 checked( 1, get_option( 'wpmc_postmeta' ), false ) . '/>';
394 $html .= '<label>Analyze</label><br /><small>Checks if the media/file is used in the meta.</small>';
395 echo $html;
396 }
397
398 function admin_widgets_callback( $args ) {
399 $value = get_option( 'wpmc_widgets', false );
400 $html = '<input type="checkbox" id="wpmc_widgets" name="wpmc_widgets" value="1" ' .
401 checked( 1, get_option( 'wpmc_widgets' ), false ) . '/>';
402 $html .= '<label>Analyze</label><br /><small>Checks if the media/file is used by any widget.</small>';
403 echo $html;
404 }
405
406 function admin_hide_thumbnails_callback( $args ) {
407 $value = get_option( 'wpmc_hide_thumbnails', null );
408 $html = '<input type="checkbox" id="wpmc_hide_thumbnails" name="wpmc_hide_thumbnails" value="1" ' .
409 checked( 1, get_option( 'wpmc_hide_thumbnails' ), false ) . '/>';
410 $html .= '<label>Hide</label><br /><small>If you prefer not to see the thumbnails.</small>';
411 echo $html;
412 }
413
414 function admin_hide_warning_callback( $args ) {
415 $value = get_option( 'wpmc_hide_warning', null );
416 $html = '<input type="checkbox" id="wpmc_hide_warning" name="wpmc_hide_warning" value="1" ' .
417 checked( 1, get_option( 'wpmc_hide_warning' ), false ) . '/>';
418 $html .= '<label>Hide</label><br /><small>Have you read it twice? If yes, hide it :)</small>';
419 echo $html;
420 }
421
422 function admin_results_per_page( $args ) {
423 $value = get_option( 'wpmc_results_per_page', 20 );
424 $html = <<< HTML
425 <input step="1" min="1" max="999" name="wpmc_results_per_page" id="wpmc_results_per_page" maxlength="3" value="{$value}" type="number">
426 HTML;
427 echo $html;
428 }
429
430 function admin_thumbnails_only_callback( $args ) {
431 $value = get_option( 'wpmc_thumbnails_only', false );
432 $html = '<input type="checkbox" id="wpmc_thumbnails_only" name="wpmc_thumbnails_only" value="1" ' .
433 disabled( get_option( 'wpmc_method', 'media' ) == 'files', false, false ) . ' ' .
434 checked( 1, get_option( 'wpmc_thumbnails_only' ), false ) . '/>';
435 $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>';
436 echo $html;
437 }
438
439 function admin_dirs_filter_callback( $args ) {
440 $value = get_option( 'wpmc_dirs_filter', '' );
441 $invalid = @preg_match( $value, '' ) === false;
442 ?>
443 <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;">
444 <?php
445 }
446
447 function admin_files_filter_callback( $args ) {
448 $value = get_option( 'wpmc_files_filter', '' );
449 $invalid = @preg_match( $value, '' ) === false;
450 ?>
451 <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;">
452 <?php
453 }
454
455 /**
456 *
457 * GET / SET OPTIONS (TO REMOVE)
458 *
459 */
460
461 function old_getoption( $option, $section, $default = '' ) {
462 $options = get_option( $section );
463 if ( isset( $options[$option] ) ) {
464 if ( $options[$option] == "off" ) {
465 return false;
466 }
467 if ( $options[$option] == "on" ) {
468 return true;
469 }
470 return $options[$option];
471 }
472 return $default;
473 }
474
475 }
476
477 ?>
478