minileven.php
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Module Name: Mobile Theme |
| 5 | * Module Description: Optimize your site with a mobile-friendly theme for tablets and phones. |
| 6 | * Sort Order: 21 |
| 7 | * First Introduced: 1.8 |
| 8 | * Requires Connection: No |
| 9 | * Auto Activate: No |
| 10 | * Module Tags: Appearance, Mobile |
| 11 | */ |
| 12 | |
| 13 | function jetpack_load_minileven() { |
| 14 | include dirname( __FILE__ ) . "/minileven/minileven.php"; |
| 15 | |
| 16 | if ( get_option( 'wp_mobile_app_promos' ) != '1' ) |
| 17 | remove_action( 'wp_mobile_theme_footer', 'jetpack_mobile_app_promo' ); |
| 18 | } |
| 19 | |
| 20 | add_action( 'jetpack_modules_loaded', 'minileven_loaded' ); |
| 21 | |
| 22 | function minileven_loaded() { |
| 23 | Jetpack::enable_module_configurable( __FILE__ ); |
| 24 | Jetpack::module_configuration_load( __FILE__, 'minileven_configuration_load' ); |
| 25 | Jetpack::module_configuration_screen( __FILE__, 'minileven_configuration_screen' ); |
| 26 | } |
| 27 | |
| 28 | function minileven_configuration_load() { |
| 29 | if ( isset( $_POST['action'] ) && $_POST['action'] == 'save_options' && $_POST['_wpnonce'] == wp_create_nonce( 'minileven' ) ) { |
| 30 | if ( isset( $_POST['wp_mobile_excerpt'] ) ) |
| 31 | update_option( 'wp_mobile_excerpt', '1' == $_POST['wp_mobile_excerpt'] ? '1' : '0' ); |
| 32 | |
| 33 | update_option( 'wp_mobile_app_promos', ( isset( $_POST['wp_mobile_app_promos'] ) ) ? '1' : '0' ); |
| 34 | |
| 35 | Jetpack::state( 'message', 'module_configured' ); |
| 36 | wp_safe_redirect( Jetpack::module_configuration_url( 'minileven' ) ); |
| 37 | exit; |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | function minileven_configuration_screen() { |
| 42 | $excerpts = ( 0 == get_option( 'wp_mobile_excerpt' ) ) ? 0 : 1; |
| 43 | $promos = ( '1' == get_option( 'wp_mobile_app_promos' ) ) ? 1 : 0; |
| 44 | |
| 45 | ?> |
| 46 | <form method="post"> |
| 47 | <input type="hidden" name="action" value="save_options" /> |
| 48 | <?php wp_nonce_field( 'minileven' ); ?> |
| 49 | <table id="menu" class="form-table"> |
| 50 | <tr valign="top"> |
| 51 | <th scope="row"><?php _e( 'Excerpts', 'jetpack' ); ?></th> |
| 52 | <td> |
| 53 | <label> |
| 54 | <input name="wp_mobile_excerpt" type="radio" value="1" class="code" <?php checked( 1, $excerpts, true ); ?> /> |
| 55 | <?php _e( 'Enable excerpts on front page and on archive pages', 'jetpack' ); ?> |
| 56 | </label> |
| 57 | <br /> |
| 58 | <label> |
| 59 | <input name="wp_mobile_excerpt" type="radio" value="0" class="code" <?php checked( 0, $excerpts, true ); ?> /> |
| 60 | <?php _e( 'Show full posts on front page and on archive pages', 'jetpack' ); ?> |
| 61 | </label> |
| 62 | </td> |
| 63 | </tr> |
| 64 | <tr valign="top"> |
| 65 | <th scope="row"><?php _e( 'Mobile App Promos', 'jetpack' ); ?></th> |
| 66 | <td> |
| 67 | <label> |
| 68 | <input name="wp_mobile_app_promos" type="checkbox" value="1" <?php checked( 1, $promos, true ); ?> /> |
| 69 | <?php _e ( 'Show a promo for the WordPress mobile apps in the footer of the mobile theme.', 'jetpack' ); ?> |
| 70 | </label> |
| 71 | </td> |
| 72 | </tr> |
| 73 | </table> |
| 74 | <p class="submit"> |
| 75 | <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save configuration', 'jetpack' ); ?>" /> |
| 76 | </p> |
| 77 | </form> |
| 78 | <h3><?php _e( 'Mobile Apps', 'jetpack' ); ?></h3> |
| 79 | <p><?php _e( 'Take WordPress with you.', 'jetpack' ); ?></p> |
| 80 | <a href="http://wordpress.org/extend/mobile/"><img src="<?php echo plugin_dir_url( __FILE__ ); ?>/minileven/images/wp-app-devices.png" width="332" height="73" /></a> |
| 81 | <p><?php printf( __( 'We have apps for <a href="%s">iOS (iPhone, iPad, iPod Touch)</a>, <a href="%s">Android</a>, <a href="%s">BlackBerry</a>, <a href="%s">Windows Phone</a>, and <a href="%s">more</a>!', 'jetpack' ), 'http://ios.wordpress.org/', 'http://android.wordpress.org/', 'http://blackberry.wordpress.org/', 'http://windowsphone.wordpress.org/', 'http://wordpress.org/extend/mobile/' ); ?></p> |
| 82 | <?php |
| 83 | } |
| 84 | |
| 85 | function minileven_theme_root( $theme_root ) { |
| 86 | if ( jetpack_check_mobile() ) { |
| 87 | return dirname( __FILE__ ) . '/minileven/theme'; |
| 88 | } |
| 89 | |
| 90 | return $theme_root; |
| 91 | } |
| 92 | |
| 93 | add_filter( 'theme_root', 'minileven_theme_root' ); |
| 94 | |
| 95 | function minileven_theme_root_uri( $theme_root_uri ) { |
| 96 | if ( jetpack_check_mobile() ) { |
| 97 | return plugins_url( 'modules/minileven/theme', dirname( __FILE__ ) ); |
| 98 | } |
| 99 | |
| 100 | return $theme_root_uri; |
| 101 | } |
| 102 | |
| 103 | add_filter( 'theme_root_uri', 'minileven_theme_root_uri' ); |
| 104 | |
| 105 | function minileven_enabled( $wp_mobile_disable_option ) { |
| 106 | return true; |
| 107 | } |
| 108 | |
| 109 | add_filter( 'option_wp_mobile_disable', 'minileven_enabled' ); |
| 110 | |
| 111 | jetpack_load_minileven(); |