Nessuna descrizione

class.jetpack-settings-page.php 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. use Automattic\Jetpack\Tracking;
  3. use Automattic\Jetpack\Assets;
  4. include_once( 'class.jetpack-admin-page.php' );
  5. include_once( JETPACK__PLUGIN_DIR . 'class.jetpack-modules-list-table.php' );
  6. // Builds the settings page and its menu
  7. class Jetpack_Settings_Page extends Jetpack_Admin_Page {
  8. // Show the settings page only when Jetpack is connected or in dev mode
  9. protected $dont_show_if_not_active = true;
  10. function add_page_actions( $hook ) {}
  11. // Adds the Settings sub menu
  12. function get_page_hook() {
  13. return add_submenu_page(
  14. null,
  15. __( 'Jetpack Settings', 'jetpack' ),
  16. __( 'Settings', 'jetpack' ),
  17. 'jetpack_manage_modules',
  18. 'jetpack_modules',
  19. array( $this, 'render' )
  20. );
  21. }
  22. // Renders the module list table where you can use bulk action or row
  23. // actions to activate/deactivate and configure modules
  24. function page_render() {
  25. $list_table = new Jetpack_Modules_List_Table;
  26. // We have static.html so let's continue trying to fetch the others
  27. $noscript_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-noscript-notice.html' );
  28. $rest_api_notice = @file_get_contents( JETPACK__PLUGIN_DIR . '_inc/build/static-version-notice.html' );
  29. $noscript_notice = str_replace(
  30. '#HEADER_TEXT#',
  31. esc_html__( 'You have JavaScript disabled', 'jetpack' ),
  32. $noscript_notice
  33. );
  34. $noscript_notice = str_replace(
  35. '#TEXT#',
  36. esc_html__( "Turn on JavaScript to unlock Jetpack's full potential!", 'jetpack' ),
  37. $noscript_notice
  38. );
  39. $rest_api_notice = str_replace(
  40. '#HEADER_TEXT#',
  41. esc_html( __( 'WordPress REST API is disabled', 'jetpack' ) ),
  42. $rest_api_notice
  43. );
  44. $rest_api_notice = str_replace(
  45. '#TEXT#',
  46. esc_html( __( "Enable WordPress REST API to unlock Jetpack's full potential!", 'jetpack' ) ),
  47. $rest_api_notice
  48. );
  49. if ( ! $this->is_rest_api_enabled() ) {
  50. echo $rest_api_notice;
  51. }
  52. echo $noscript_notice;
  53. ?>
  54. <div class="page-content configure">
  55. <div class="frame top hide-if-no-js">
  56. <div class="wrap">
  57. <div class="manage-left">
  58. <table class="table table-bordered fixed-top">
  59. <thead>
  60. <tr>
  61. <th class="check-column"><input type="checkbox" class="checkall"></th>
  62. <th colspan="2">
  63. <?php $list_table->unprotected_display_tablenav( 'top' ); ?>
  64. <span class="filter-search">
  65. <button type="button" class="button">Filter</button>
  66. </span>
  67. </th>
  68. </tr>
  69. </thead>
  70. </table>
  71. </div>
  72. </div><!-- /.wrap -->
  73. </div><!-- /.frame -->
  74. <div class="frame bottom">
  75. <div class="wrap">
  76. <div class="manage-right" style="display: none;">
  77. <div class="bumper">
  78. <form class="navbar-form" role="search">
  79. <input type="hidden" name="page" value="jetpack_modules" />
  80. <?php $list_table->search_box( __( 'Search', 'jetpack' ), 'srch-term' ); ?>
  81. <p><?php esc_html_e( 'View:', 'jetpack' ); ?></p>
  82. <div class="button-group filter-active">
  83. <button type="button" class="button <?php if ( empty( $_GET['activated'] ) ) echo 'active'; ?>"><?php esc_html_e( 'All', 'jetpack' ); ?></button>
  84. <button type="button" class="button <?php if ( ! empty( $_GET['activated'] ) && 'true' == $_GET['activated'] ) echo 'active'; ?>" data-filter-by="activated" data-filter-value="true"><?php esc_html_e( 'Active', 'jetpack' ); ?></button>
  85. <button type="button" class="button <?php if ( ! empty( $_GET['activated'] ) && 'false' == $_GET['activated'] ) echo 'active'; ?>" data-filter-by="activated" data-filter-value="false"><?php esc_html_e( 'Inactive', 'jetpack' ); ?></button>
  86. </div>
  87. <p><?php esc_html_e( 'Sort by:', 'jetpack' ); ?></p>
  88. <div class="button-group sort">
  89. <button type="button" class="button <?php if ( empty( $_GET['sort_by'] ) ) echo 'active'; ?>" data-sort-by="name"><?php esc_html_e( 'Alphabetical', 'jetpack' ); ?></button>
  90. <button type="button" class="button <?php if ( ! empty( $_GET['sort_by'] ) && 'introduced' == $_GET['sort_by'] ) echo 'active'; ?>" data-sort-by="introduced" data-sort-order="reverse"><?php esc_html_e( 'Newest', 'jetpack' ); ?></button>
  91. <button type="button" class="button <?php if ( ! empty( $_GET['sort_by'] ) && 'sort' == $_GET['sort_by'] ) echo 'active'; ?>" data-sort-by="sort"><?php esc_html_e( 'Popular', 'jetpack' ); ?></button>
  92. </div>
  93. <p><?php esc_html_e( 'Show:', 'jetpack' ); ?></p>
  94. <?php $list_table->views(); ?>
  95. </form>
  96. </div>
  97. </div>
  98. <div class="manage-left" style="width: 100%;">
  99. <form class="jetpack-modules-list-table-form" onsubmit="return false;">
  100. <table class="<?php echo implode( ' ', $list_table->get_table_classes() ); ?>">
  101. <tbody id="the-list">
  102. <?php $list_table->display_rows_or_placeholder(); ?>
  103. </tbody>
  104. </table>
  105. </form>
  106. </div>
  107. </div><!-- /.wrap -->
  108. </div><!-- /.frame -->
  109. </div><!-- /.content -->
  110. <?php
  111. $tracking = new Tracking();
  112. $tracking->record_user_event( 'wpa_page_view', array( 'path' => 'old_settings' ) );
  113. }
  114. /**
  115. * Load styles for static page.
  116. *
  117. * @since 4.3.0
  118. */
  119. function additional_styles() {
  120. Jetpack_Admin_Page::load_wrapper_styles();
  121. }
  122. // Javascript logic specific to the list table
  123. function page_admin_scripts() {
  124. wp_enqueue_script(
  125. 'jetpack-admin-js',
  126. Assets::get_file_url_for_environment( '_inc/build/jetpack-admin.min.js', '_inc/jetpack-admin.js' ),
  127. array( 'jquery' ),
  128. JETPACK__VERSION
  129. );
  130. }
  131. }