GFAddOnFeedsTable

The Gravity Forms GFAddOnFeedsTable class.

Defined (1)

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

/includes/addon/class-gf-feed-addon.php  
  1. class GFAddOnFeedsTable extends WP_List_Table { 
  2.  
  3. private $_feeds; 
  4. private $_slug; 
  5. private $_columns; 
  6. private $_bulk_actions; 
  7. private $_action_links; 
  8.  
  9. private $_column_value_callback = array(); 
  10. private $_no_items_callback = array(); 
  11. private $_message_callback = array(); 
  12.  
  13. function __construct( $feeds, $slug, $columns = array(), $bulk_actions, $action_links, $column_value_callback, $no_items_callback, $message_callback ) { 
  14. $this->_bulk_actions = $bulk_actions; 
  15. $this->_feeds = $feeds; 
  16. $this->_slug = $slug; 
  17. $this->_columns = $columns; 
  18. $this->_column_value_callback = $column_value_callback; 
  19. $this->_action_links = $action_links; 
  20. $this->_no_items_callback = $no_items_callback; 
  21. $this->_message_callback = $message_callback; 
  22.  
  23. $standard_cols = array( 
  24. 'cb' => esc_html__( 'Checkbox', 'gravityforms' ),  
  25. 'is_active' => '',  
  26. ); 
  27.  
  28. $all_cols = array_merge( $standard_cols, $columns ); 
  29.  
  30. $this->_column_headers = array( 
  31. $all_cols,  
  32. array(),  
  33. array(),  
  34. rgar( array_values( $all_cols ), 2 ),  
  35. ); 
  36.  
  37. parent::__construct( 
  38. array( 
  39. 'singular' => esc_html__( 'feed', 'gravityforms' ),  
  40. 'plural' => esc_html__( 'feeds', 'gravityforms' ),  
  41. 'ajax' => false,  
  42. ); 
  43.  
  44. function prepare_items() { 
  45. $this->items = isset( $this->_feeds ) ? $this->_feeds : array(); 
  46.  
  47. function get_columns() { 
  48. return $this->_column_headers[0]; 
  49.  
  50. function get_bulk_actions() { 
  51. return $this->_bulk_actions; 
  52.  
  53. function no_items() { 
  54. echo call_user_func( $this->_no_items_callback ); 
  55.  
  56. function display_rows_or_placeholder() { 
  57. $message = call_user_func( $this->_message_callback ); 
  58.  
  59. if ( $message !== false ) { 
  60. ?> 
  61. <tr class="no-items"> 
  62. <td class="colspanchange" colspan="<?php echo $this->get_column_count() ?>"> 
  63. <?php echo $message ?> 
  64. </td> 
  65. </tr> 
  66. <?php 
  67. } else { 
  68. parent::display_rows_or_placeholder(); 
  69.  
  70.  
  71. function column_default( $item, $column ) { 
  72.  
  73. if ( is_callable( $this->_column_value_callback ) ) { 
  74. $value = call_user_func( $this->_column_value_callback, $item, $column ); 
  75.  
  76. //adding action links to the first column of the list 
  77. $columns = array_keys( $this->_columns ); 
  78. if ( is_array( $columns ) && count( $columns ) > 0 && $columns[0] == $column ) { 
  79. $value = $this->add_action_links( $item, $column, $value ); 
  80.  
  81. return $value; 
  82.  
  83. function column_cb( $item ) { 
  84. $feed_id = rgar( $item, 'id' ); 
  85.  
  86. return sprintf( 
  87. '<input type="checkbox" name="feed_ids[]" value="%s" />', esc_attr( $feed_id ) 
  88. ); 
  89.  
  90. function add_action_links( $item, $column, $value ) { 
  91.  
  92. $actions = apply_filters( $this->_slug . '_feed_actions', $this->_action_links, $item, $column ); 
  93.  
  94. //replacing _id_ merge variable with actual feed id 
  95. foreach ( $actions as $action => &$link ) { 
  96. $link = str_replace( '_id_', $item['id'], $link ); 
  97.  
  98. return sprintf( '%1$s %2$s', $value, $this->row_actions( $actions ) ); 
  99.  
  100. function column_is_active( $item ) { 
  101. $is_active = intval( rgar( $item, 'is_active' ) ); 
  102. $src = GFCommon::get_base_url() . "/images/active{$is_active}.png"; 
  103.  
  104. $title = $is_active ? esc_attr__( 'Active', 'gravityforms' ) : esc_attr__( 'Inactive', 'gravityforms' ); 
  105. $img = sprintf( '<img src="%s" title="%s" onclick="gaddon.toggleFeedActive(this, \'%s\', \'%s\');" style="cursor:pointer";/>', $src, $title, esc_js( $this->_slug ), esc_js( $item['id'] ) ); 
  106.  
  107. return $img;