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