Нет описания

Subscribers.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /*******************************************************************************
  3. * Copyright (c) 2019, Code Atlantic LLC
  4. ******************************************************************************/
  5. if ( ! defined( 'ABSPATH' ) ) {
  6. exit;
  7. }
  8. /**
  9. * Class PUM_Admin_Subscribers
  10. */
  11. class PUM_Admin_Subscribers {
  12. /**
  13. *
  14. */
  15. public static function init() {
  16. add_action( 'admin_menu', array( __CLASS__, 'after_page_registration' ), 11 );
  17. add_filter( 'set-screen-option', array( __CLASS__, 'set_option' ), 10, 3 );
  18. }
  19. /**
  20. * Render settings page with tabs.
  21. */
  22. public static function page() {
  23. self::list_table()->prepare_items(); ?>
  24. <div class="wrap">
  25. <h1><?php _e( 'Subscribers', 'popup-maker' ); ?></h1>
  26. <div id="pum-subscribers">
  27. <div id="pum-subscribers-post-body">
  28. <form id="pum-subscribers-list-form" method="get">
  29. <input type="hidden" name="page" value="<?php echo esc_attr( $_REQUEST['page'] ); ?>"/>
  30. <input type="hidden" name="post_type" value="<?php echo esc_attr( $_REQUEST['post_type'] ); ?>"/>
  31. <?php
  32. self::list_table()->search_box( __( 'Find', 'popup-maker' ), 'pum-subscriber-find' );
  33. self::list_table()->display();
  34. ?>
  35. </form>
  36. </div>
  37. </div>
  38. </div>
  39. <?php
  40. }
  41. /**
  42. * @return PUM_Admin_Subscribers_Table
  43. */
  44. public static function list_table() {
  45. static $list_table;
  46. if ( ! isset( $list_table ) ) {
  47. $list_table = new PUM_Admin_Subscribers_Table();
  48. }
  49. return $list_table;
  50. }
  51. public static function after_page_registration() {
  52. add_action( 'load-' . PUM_Admin_Pages::$pages['subscribers'], array( 'PUM_Admin_Subscribers', 'load_user_list_table_screen_options' ) );
  53. }
  54. public static function load_user_list_table_screen_options() {
  55. add_screen_option( 'per_page', array(
  56. 'label' => __( 'Subscribers Per Page', 'popup-maker' ),
  57. 'default' => 20,
  58. 'option' => 'pum_subscribers_per_page',
  59. ) );
  60. /*
  61. * Instantiate the User List Table. Creating an instance here will allow the core WP_List_Table class to automatically
  62. * load the table columns in the screen options panel
  63. */
  64. self::list_table();
  65. }
  66. /**
  67. * Force WP to save the option.
  68. *
  69. * @param $status
  70. * @param $option
  71. * @param $value
  72. *
  73. * @return mixed
  74. */
  75. public static function set_option( $status, $option, $value ) {
  76. if ( 'pum_subscribers_per_page' == $option ) {
  77. return $value;
  78. }
  79. return $status;
  80. }
  81. }