/modules/minileven.php

  1. <?php 
  2.  
  3. /** 
  4. * Module Name: Mobile Theme 
  5. * Module Description: Optimize your site with a mobile-friendly theme for smartphones. 
  6. * Sort Order: 21 
  7. * Recommendation Order: 11 
  8. * First Introduced: 1.8 
  9. * Requires Connection: No 
  10. * Auto Activate: No 
  11. * Module Tags: Appearance, Mobile, Recommended 
  12. * Feature: Recommended 
  13. * Additional Search Queries: mobile, theme, minileven 
  14. */ 
  15.  
  16. function jetpack_load_minileven() { 
  17. include dirname( __FILE__ ) . "/minileven/minileven.php"; 
  18.  
  19. if ( get_option( 'wp_mobile_app_promos' ) != '1' ) 
  20. remove_action( 'wp_mobile_theme_footer', 'jetpack_mobile_app_promo' ); 
  21.  
  22. add_action( 'jetpack_modules_loaded', 'minileven_loaded' ); 
  23.  
  24. function minileven_loaded() { 
  25. Jetpack::enable_module_configurable( __FILE__ ); 
  26. Jetpack::module_configuration_load( __FILE__, 'minileven_configuration_load' ); 
  27. Jetpack::module_configuration_screen( __FILE__, 'minileven_configuration_screen' ); 
  28.  
  29. function minileven_configuration_load() { 
  30. if ( isset( $_POST['action'] ) && $_POST['action'] == 'save_options' && $_POST['_wpnonce'] == wp_create_nonce( 'minileven' ) ) { 
  31. if ( isset( $_POST['wp_mobile_excerpt'] ) ) { 
  32. update_option( 'wp_mobile_excerpt', '1' == $_POST['wp_mobile_excerpt'] ? '1' : '0' ); 
  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. update_option( 'wp_mobile_app_promos', ( isset( $_POST['wp_mobile_app_promos'] ) ) ? '1' : '0' ); 
  38.  
  39. Jetpack::state( 'message', 'module_configured' ); 
  40. wp_safe_redirect( Jetpack::module_configuration_url( 'minileven' ) ); 
  41. exit; 
  42.  
  43. function minileven_configuration_screen() { 
  44. $excerpts = ( 0 == get_option( 'wp_mobile_excerpt' ) ) ? 0 : 1; 
  45. $featured_images = ( 0 == get_option( 'wp_mobile_featured_images' ) ) ? 0 : 1; 
  46. $promos = ( '1' == get_option( 'wp_mobile_app_promos' ) ) ? 1 : 0; 
  47.  
  48. ?> 
  49. <form method="post"> 
  50. <input type="hidden" name="action" value="save_options" /> 
  51. <?php wp_nonce_field( 'minileven' ); ?> 
  52. <table id="menu" class="form-table"> 
  53. <tr valign="top"> 
  54. <th scope="row"><?php _e( 'Excerpts', 'jetpack' ); ?></th> 
  55. <td> 
  56. <label> 
  57. <input name="wp_mobile_excerpt" type="radio" value="1" class="code" <?php checked( 1, $excerpts, true ); ?> /> 
  58. <?php _e( 'Enable excerpts on front page and on archive pages', 'jetpack' ); ?> 
  59. </label> 
  60. <br /> 
  61. <label> 
  62. <input name="wp_mobile_excerpt" type="radio" value="0" class="code" <?php checked( 0, $excerpts, true ); ?> /> 
  63. <?php _e( 'Show full posts on front page and on archive pages', 'jetpack' ); ?> 
  64. </label> 
  65. </td> 
  66. </tr> 
  67. <tr valign="top"> 
  68. <th scope="row"><?php _e( 'Featured Images', 'jetpack' ); ?></th> 
  69. <td> 
  70. <label> 
  71. <input name="wp_mobile_featured_images" type="radio" value="0" class="code" <?php checked( 0, $featured_images, true ); ?> /> 
  72. <?php _e( 'Hide all featured images', 'jetpack' ); ?> 
  73. </label> 
  74. <br /> 
  75. <label> 
  76. <input name="wp_mobile_featured_images" type="radio" value="1" class="code" <?php checked( 1, $featured_images, true ); ?> /> 
  77. <?php _e( 'Display featured images', 'jetpack' ); ?> 
  78. </label> 
  79. </td> 
  80. </tr> 
  81. <tr valign="top"> 
  82. <th scope="row"><?php _e( 'Mobile App Promos', 'jetpack' ); ?></th> 
  83. <td> 
  84. <label> 
  85. <input name="wp_mobile_app_promos" type="checkbox" value="1" <?php checked( 1, $promos, true ); ?> /> 
  86. <?php _e ( 'Show a promo for the WordPress mobile apps in the footer of the mobile theme.', 'jetpack' ); ?> 
  87. </label> 
  88. </td> 
  89. </tr> 
  90. </table> 
  91. <p class="submit"> 
  92. <input type="submit" class="button-primary" value="<?php esc_attr_e( 'Save configuration', 'jetpack' ); ?>" /> 
  93. </p> 
  94. </form> 
  95. <h3><?php _e( 'Mobile Apps', 'jetpack' ); ?></h3> 
  96. <p><?php _e( 'Take WordPress with you.', 'jetpack' ); ?></p> 
  97. <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> 
  98. <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> 
  99. <?php 
  100.  
  101. function minileven_theme_root( $theme_root ) { 
  102. if ( jetpack_check_mobile() ) { 
  103. return dirname( __FILE__ ) . '/minileven/theme'; 
  104.  
  105. return $theme_root; 
  106.  
  107. add_filter( 'theme_root', 'minileven_theme_root' ); 
  108.  
  109. function minileven_theme_root_uri( $theme_root_uri ) { 
  110. if ( jetpack_check_mobile() ) { 
  111. return plugins_url( 'modules/minileven/theme', dirname( __FILE__ ) ); 
  112.  
  113. return $theme_root_uri; 
  114.  
  115. add_filter( 'theme_root_uri', 'minileven_theme_root_uri' ); 
  116.  
  117. function minileven_enabled( $wp_mobile_disable_option ) { 
  118. return true; 
  119.  
  120. add_filter( 'option_wp_mobile_disable', 'minileven_enabled' ); 
  121.  
  122. jetpack_load_minileven(); 
.