NKLAB_WPCF7SN_Contact_List_Table

The Contact Form 7 Serial Numbers NKLAB WPCF7SN Contact List Table class.

Defined (1)

The class is defined in the following location(s).

/includes/class-contact_list_table.php  
  1. class NKLAB_WPCF7SN_Contact_List_Table extends WP_List_Table { 
  2.  
  3. function __construct() { 
  4. global $status, $page; 
  5.  
  6. parent::__construct( array( 
  7. 'singular' => 'post',  
  8. 'plural' => 'posts',  
  9. 'ajax' => false 
  10. ) ); 
  11.  
  12. // *********** 
  13. function column_default( $item, $column_name ) { 
  14. return ''; 
  15.  
  16. // ******** 
  17. function get_columns() { 
  18. return $columns = array( 
  19. "setting" => __( 'Setting', ContactForm7_Serial_Numbers::DOMAIN ) 
  20. ); 
  21.  
  22. function column_title( $item ) { 
  23. return '<strong>' . esc_html( $item->post_title ) . '</strong>'; 
  24.  
  25. function column_setting( $item ) { 
  26.  
  27. $output = ''; 
  28.  
  29. $item_id = intval( $item->ID ); 
  30. $html_encoded_id = esc_html( $item_id ); 
  31.  
  32. $mail_tag = sprintf( '[cf7_serial_number_%1$d]', $item_id ); 
  33.  
  34. if (($type = get_option('nklab_wpcf7sn_type_' . $item_id)) == false) { 
  35. // ****************** 
  36. update_option('nklab_wpcf7sn_type_' . $item_id, 1); 
  37. $type = intval( get_option('nklab_wpcf7sn_type_' . $item_id) ); 
  38.  
  39. if (($count = get_option('nklab_wpcf7sn_count_' . $item_id)) == false) { 
  40. // ****************** 
  41. update_option('nklab_wpcf7sn_count_' . $item_id, 0); 
  42. $count = intval( get_option('nklab_wpcf7sn_count_' . $item_id) ); 
  43.  
  44. if (($digits = get_option('nklab_wpcf7sn_digits_' . $item_id)) == false) { 
  45. // ****************** 
  46. update_option('nklab_wpcf7sn_digits_' . $item_id, 0); 
  47. $digits = intval( get_option('nklab_wpcf7sn_digits_')); 
  48.  
  49. if (($prefix = get_option('nklab_wpcf7sn_prefix_' . $item_id)) == false) { 
  50. // ****************** 
  51. update_option('nklab_wpcf7sn_prefix_' . $item_id, ''); 
  52. $prefix = get_option('nklab_wpcf7sn_prefix_' . $item_id, ''); 
  53.  
  54. $output .= "\n" . '<div id="wpcf7sn_setting_' . $item_id . '" class="clearfix">' 
  55. . '<form method="post" action="options.php">' 
  56. . wp_nonce_field( 'update-options' ) 
  57. . ' <input type="hidden" name="action" value="update" />' 
  58. . ' <input type="hidden" name="page_options" value="nklab_wpcf7sn_type_' . $html_encoded_id . ', nklab_wpcf7sn_digits_' . $html_encoded_id . ', nklab_wpcf7sn_prefix_' . $html_encoded_id . '" />' 
  59. . ' <div class="wpcf7sn_setting_title">' 
  60. . ' <strong>' . esc_html( $item->post_title ) . '</strong>' 
  61. . ' </div>' 
  62. . ' <div class="wpcf7sn_setting_col_left">' 
  63. . ' <dl>' 
  64. . ' <dt><span class="title">' . __( 'Display type', ContactForm7_Serial_Numbers::DOMAIN ) . '</span></dt>' 
  65. . ' <dd>' 
  66. . ' <p class="setting_body">' 
  67. . ' <input type="radio" name="nklab_wpcf7sn_type_' . $html_encoded_id . '" value="1" ' . ( $type == 1 ? 'checked' : '' ) . ' /><label>' . __( 'Serial Number', ContactForm7_Serial_Numbers::DOMAIN ) . '</label><br />' 
  68. . ' <span class="indent"><label>' . __( 'Now Count value', ContactForm7_Serial_Numbers::DOMAIN ) . '</label> : <input type="text" name="nklab_wpcf7sn_count_' . $html_encoded_id . '" id="nklab_wpcf7sn_count_' . $html_encoded_id . '" value="' . $count . '" size="5" maxlength="4" /> <input type="button" id="CountModify' . $html_encoded_id . '" data-id="' . $html_encoded_id . '" class="button-primary" value="' . __( 'Set', ContactForm7_Serial_Numbers::DOMAIN ) . '" /></span>' 
  69. . ' <span class="indent"><label>' . __( 'Number of digits', ContactForm7_Serial_Numbers::DOMAIN ) . '</label> : <input type="text" name="nklab_wpcf7sn_digits_' . $html_encoded_id . '" value="' . $digits . '" size="2" maxlength="2" /></span>' 
  70. . ' </p>' 
  71. . ' <p class="setting_body">' 
  72. . ' <input type="radio" name="nklab_wpcf7sn_type_' . $html_encoded_id . '" value="2" ' . ( $type == 2 ? 'checked' : '' ) . ' /><label>' . __( 'Timestamp (ms)', ContactForm7_Serial_Numbers::DOMAIN ) . '</label>' 
  73. . ' </p>' 
  74. . ' </dd>' 
  75. . ' </dl>' 
  76. . ' </div>' 
  77. . ' <div class="wpcf7sn_setting_col_center">' 
  78. . ' <dl>' 
  79. . ' <dt><span class="title">' . __( 'Prefix', ContactForm7_Serial_Numbers::DOMAIN ) . '</span></dt>' 
  80. . ' <dd>' 
  81. . ' <p class="setting_body">' 
  82. . ' <input type="text" name="nklab_wpcf7sn_prefix_' . $html_encoded_id . '" value="' . $prefix . '" size="15" maxlength="10" />' 
  83. . ' </p>' 
  84. . ' </dd>' 
  85. . ' </dl>' 
  86. . ' </div>' 
  87. . ' <div class="wpcf7sn_setting_col_right">' 
  88. . ' <dl>' 
  89. . ' <dt><span class="title">' . __( 'Mail Tags', ContactForm7_Serial_Numbers::DOMAIN ) . '</span></dt>' 
  90. . ' <dd>' 
  91. . ' <p class="setting_body">' 
  92. . ' <input type="text" readonly="readonly" value="' . esc_attr( $mail_tag ) . '" size="35" />' 
  93. . ' </p>' 
  94. . ' </dd>' 
  95. . ' </dl>' 
  96. . ' <div class="wpcf7sn_setting_submit">' 
  97. . ' <p class="wpcf7sn_submit"><input type="submit" class="button-primary" value="' . __( 'Update', ContactForm7_Serial_Numbers::DOMAIN ) . '" /></p>' 
  98. . ' </div>' 
  99. . ' </div>' 
  100. . '</form>' 
  101. . '<form method="post" id="frmCountModify' . $html_encoded_id . '" name="frmCountModify' . $html_encoded_id . '" action="options.php">' 
  102. . wp_nonce_field( 'update-options' ) 
  103. . ' <input type="hidden" name="action" value="update" />' 
  104. . ' <input type="hidden" name="page_options" value="nklab_wpcf7sn_count_' . $html_encoded_id . '" />' 
  105. . ' <input type="hidden" name="nklab_wpcf7sn_count_' . $html_encoded_id . '" id="nklab_wpcf7sn_count_' . $html_encoded_id . '" value="" />' 
  106. . '</form>' 
  107. . '</div>'; 
  108.  
  109. return trim( $output ); 
  110.  
  111. // ******* 
  112. function get_sortable_columns() { 
  113. $sortable_columns = array(); 
  114.  
  115. return $sortable_columns; 
  116.  
  117. // ******* 
  118. function get_bulk_actions() { 
  119. $actions = array(); 
  120.  
  121. return $actions; 
  122.  
  123. // **************** 
  124. function process_bulk_action() { 
  125. // none 
  126.  
  127. // ********* 
  128. function prepare_items() { 
  129. // 1********** 
  130. $per_page = 10; 
  131.  
  132. // **** 
  133. $columns = $this->get_columns(); 
  134. $hidden = array(); 
  135. $sortable = $this->get_sortable_columns(); 
  136.  
  137. // ******** 
  138. $this->_column_headers = array( $columns, $hidden, $sortable ); 
  139.  
  140. // ******* 
  141. $this->process_bulk_action(); 
  142.  
  143. // ****** 
  144. $args = array( 
  145. 'post_type' => 'wpcf7_contact_form',  
  146. 'post_status' => 'any',  
  147. 'posts_per_page' => $per_page,  
  148. 'orderby' => 'title',  
  149. 'order' => 'ASC',  
  150. 'offset' => ( $this->get_pagenum() - 1 ) * $per_page 
  151. ); 
  152.  
  153. $data = query_posts( $args ); 
  154.  
  155. $current_page = $this->get_pagenum(); 
  156.  
  157. $total_items = count($data); 
  158. $total_pages = ceil( $total_items / $per_page ); 
  159.  
  160. $this->items = $data; 
  161.  
  162. $this->set_pagination_args( array( 
  163. 'total_items' => $total_items,  
  164. 'per_page' => $per_page,  
  165. 'total_pages' => $total_pages 
  166. ) );