| 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 |
|
| 34 |
if ( isset( $_POST['wp_mobile_featured_images'] ) ) { |
| 35 |
update_option( 'wp_mobile_featured_images', '1' == $_POST['wp_mobile_featured_images'] ? '1' : '0' ); |
| 36 |
} |
| 37 |
|
| 38 |
update_option( 'wp_mobile_app_promos', ( isset( $_POST['wp_mobile_app_promos'] ) ) ? '1' : '0' ); |
| 39 |
|
| 40 |
Jetpack::state( 'message', 'module_configured' ); |
| 41 |
wp_safe_redirect( Jetpack::module_configuration_url( 'minileven' ) ); |
| 42 |
exit; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
function minileven_configuration_screen() { |
| 47 |
$excerpts = ( 0 == get_option( 'wp_mobile_excerpt' ) ) ? 0 : 1; |
| 48 |
$featured_images = ( 0 == get_option( 'wp_mobile_featured_images' ) ) ? 0 : 1; |
| 49 |
$promos = ( '1' == get_option( 'wp_mobile_app_promos' ) ) ? 1 : 0; |
| 50 |
|
| 51 |
?> |
| 52 |
<form method="post"> |
| 53 |
<input type="hidden" name="action" value="save_options" /> |
| 54 |
<?php wp_nonce_field( 'minileven' ); ?> |
| 55 |
<table id="menu" class="form-table"> |
| 56 |
<tr valign="top"> |
| 57 |
<th scope="row"><?php _e( 'Excerpts', 'jetpack' ); ?></th> |
| 58 |
<td> |
| 59 |
<label> |
| 60 |
<input name="wp_mobile_excerpt" type="radio" value="1" class="code" <?php checked( 1, $excerpts, true ); ?> /> |
| 61 |
<?php _e( 'Enable excerpts on front page and on archive pages', 'jetpack' ); ?> |
| 62 |
</label> |
| 63 |
<br /> |
| 64 |
<label> |
| 65 |
<input name="wp_mobile_excerpt" type="radio" value="0" class="code" <?php checked( 0, $excerpts, true ); ?> /> |
| 66 |
<?php _e( 'Show full posts on front page and on archive pages', 'jetpack' ); ?> |
| 67 |
</label> |
| 68 |
</td> |
| 69 |
</tr> |
| 70 |
<tr valign="top"> |
| 71 |
<th scope="row"><?php _e( 'Featured Images', 'jetpack' ); ?></th> |
| 72 |
<td> |
| 73 |
<label> |
| 74 |
<input name="wp_mobile_featured_images" type="radio" value="0" class="code" <?php checked( 0, $featured_images, true ); ?> /> |
| 75 |
<?php _e( 'Hide all featured images', 'jetpack' ); ?> |
| 76 |
</label> |
| 77 |
<br /> |
| 78 |
<label> |
| 79 |
<input name="wp_mobile_featured_images" type="radio" value="1" class="code" <?php checked( 1, $featured_images, true ); ?> /> |
| 80 |
<?php _e( 'Display featured images', 'jetpack' ); ?> |
| 81 |
</label> |
| 82 |
</td> |
| 83 |
</tr> |
| 84 |
<tr valign="top"> |
| 85 |
<th scope="row"><?php _e( 'Mobile App Promos', 'jetpack' ); ?></th> |
| 86 |
<td> |
| 87 |
<label> |
| 88 |
<input name="wp_mobile_app_promos" type="checkbox" value="1" <?php checked( 1, $promos, true ); ?> /> |
| 89 |
<?php _e ( 'Show a promo for the WordPress mobile apps in the footer of the mobile theme.', 'jetpack' ); ?> |
| 90 |
</label> |
| 91 |
</td> |
| 92 |
</tr> |
| 93 |
</table> |
| 94 |
<p class="submit"> |
| 95 |
<input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save configuration', 'jetpack' ); ?>" /> |
| 96 |
</p> |
| 97 |
</form> |
| 98 |
<h3><?php _e( 'Mobile Apps', 'jetpack' ); ?></h3> |
| 99 |
<p><?php _e( 'Take WordPress with you.', 'jetpack' ); ?></p> |
| 100 |
<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> |
| 101 |
<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>, and <a href="%s">more</a>!', 'jetpack' ), 'http://ios.wordpress.org/', 'http://android.wordpress.org/', 'http://blackberry.wordpress.org/', 'http://wordpress.org/mobile/' ); ?></p> |
| 102 |
<?php |
| 103 |
} |
| 104 |
|
| 105 |
function minileven_theme_root( $theme_root ) { |
| 106 |
if ( jetpack_check_mobile() ) { |
| 107 |
return dirname( __FILE__ ) . '/minileven/theme'; |
| 108 |
} |
| 109 |
|
| 110 |
return $theme_root; |
| 111 |
} |
| 112 |
|
| 113 |
add_filter( 'theme_root', 'minileven_theme_root' ); |
| 114 |
|
| 115 |
function minileven_theme_root_uri( $theme_root_uri ) { |
| 116 |
if ( jetpack_check_mobile() ) { |
| 117 |
return plugins_url( 'modules/minileven/theme', dirname( __FILE__ ) ); |
| 118 |
} |
| 119 |
|
| 120 |
return $theme_root_uri; |
| 121 |
} |
| 122 |
|
| 123 |
add_filter( 'theme_root_uri', 'minileven_theme_root_uri' ); |
| 124 |
|
| 125 |
function minileven_enabled( $wp_mobile_disable_option ) { |
| 126 |
return true; |
| 127 |
} |
| 128 |
|
| 129 |
add_filter( 'option_wp_mobile_disable', 'minileven_enabled' ); |
| 130 |
|
| 131 |
jetpack_load_minileven(); |