wp-smushit
Last commit date
JSON
17 years ago
bulk.php
14 years ago
license.txt
17 years ago
readme.txt
13 years ago
screenshot-1.jpg
17 years ago
settings.php
13 years ago
wp-smushit.php
14 years ago
settings.php
51 lines
| 1 | <?php |
| 2 | |
| 3 | /* |
| 4 | |
| 5 | Each service has a setting specifying whether it should be used automatically on upload. |
| 6 | |
| 7 | Values are: |
| 8 | -1 Don't use (until manually enabled via Media > Settings) |
| 9 | 0 Use automatically |
| 10 | n Any other number is a Unix timestamp indicating when the service can be used again |
| 11 | |
| 12 | */ |
| 13 | |
| 14 | define('WP_SMUSHIT_AUTO_OK', 0); |
| 15 | define('WP_SMUSHIT_AUTO_NEVER', -1); |
| 16 | |
| 17 | |
| 18 | function wp_smushit_register_settings() { |
| 19 | add_settings_section( 'wp_smushit_settings', 'WP Smush.it', 'wp_smushit_settings_cb', 'media' ); |
| 20 | add_settings_field( 'wp_smushit_smushit_auto', 'Use Smush.it on upload?', 'wp_smushit_render_auto_opts', 'media', 'wp_smushit_settings' ); |
| 21 | add_settings_field( 'wp_smushit_smushit_timeout', 'How many seconds should we wait for a response from Smush.it?', 'wp_smushit_render_timeout_opts', 'media', 'wp_smushit_settings' ); |
| 22 | register_setting( 'media', 'wp_smushit_smushit_auto'); |
| 23 | } |
| 24 | add_action('admin_init', 'wp_smushit_register_settings'); |
| 25 | |
| 26 | function wp_smushit_settings_cb() { |
| 27 | } |
| 28 | |
| 29 | function wp_smushit_render_auto_opts() { |
| 30 | $key = 'wp_smushit_smushit_auto'; |
| 31 | $val = intval( get_option( $key, WP_SMUSHIT_AUTO_OK ) ); |
| 32 | printf( "<select name='%1\$s' id='%1\$s'>", esc_attr( $key ) ); |
| 33 | echo '<option value=' . WP_SMUSHIT_AUTO_OK . ' ' . selected( WP_SMUSHIT_AUTO_OK, $val ) . '>Automatically process on upload</option>'; |
| 34 | echo '<option value=' . WP_SMUSHIT_AUTO_NEVER . ' ' . selected( WP_SMUSHIT_AUTO_NEVER, $val ) . '>Do not process on upload</option>'; |
| 35 | |
| 36 | if ( $val > 0 ) { |
| 37 | printf( '<option value="%d" selected="selected">Temporarily disabled until %s</option>', $val, date( 'M j, Y \a\t H:i', $val ) ); |
| 38 | } |
| 39 | echo '</select>'; |
| 40 | } |
| 41 | |
| 42 | function wp_smushit_render_timeout_opts( $key ) { |
| 43 | $key = 'wp_smushit_smushit_timeout'; |
| 44 | $val = intval( get_option( $key, WP_SMUSHIT_AUTO_OK ) ); |
| 45 | printf( "<input type='text' name='%1\$s' id='%1\$s'>", esc_attr( $key ), intval( get_option( $key, 60 ) ) ); |
| 46 | } |
| 47 | |
| 48 | // default is 6hrs |
| 49 | function wp_smushit_temporarily_disable( $seconds = 21600) { |
| 50 | update_option( 'wp_smushit_smushit_auto', time() + $seconds ); |
| 51 | } |