minileven.php 4.8 KB

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