GFP_Stripe_List_Table

Class GFP_Stripe_List_Table.

Defined (1)

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

/includes/class-gfp-stripe-list-table.php  
  1. class GFP_Stripe_List_Table extends WP_List_Table { 
  2.  
  3. private $_form_id; 
  4.  
  5. function __construct ( $form_id ) { 
  6.  
  7. $this->_form_id = $form_id; 
  8.  
  9. $this->_column_headers = array( 
  10. array( 
  11. 'cb' => '',  
  12. 'name' => __( 'Rule Name', 'gravity-forms-stripe' ),  
  13. 'type' => __( 'Transaction Type', 'gravity-forms-stripe' ) 
  14. ),  
  15. array(),  
  16. array() 
  17. ); 
  18.  
  19. parent::__construct(); 
  20.  
  21. public function get_columns() { 
  22.  
  23. return $this->_column_headers[0]; 
  24.  
  25. function prepare_items () { 
  26.  
  27. $feeds = GFP_Stripe_Data::get_feed_by_form( $this->_form_id ); 
  28. $this->items = $feeds; 
  29.  
  30. function display () { 
  31. $singular = $this->_args['singular']; 
  32. ?> 
  33.  
  34. <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0"> 
  35. <thead> 
  36. <tr> 
  37. <?php $this->print_column_headers(); ?> 
  38. </tr> 
  39. </thead> 
  40.  
  41. <tfoot> 
  42. <tr> 
  43. <?php $this->print_column_headers( false ); ?> 
  44. </tr> 
  45. </tfoot> 
  46.  
  47. <tbody id="the-list"<?php if ( $singular ) { 
  48. echo " class='list:$singular'"; 
  49. } ?>> 
  50.  
  51. <?php $this->display_rows_or_placeholder(); ?> 
  52.  
  53. </tbody> 
  54. </table> 
  55.  
  56. <?php 
  57.  
  58. function single_row ( $item ) { 
  59. static $row_class = ''; 
  60. $row_class = ( $row_class == '' ? ' class="alternate"' : '' ); 
  61.  
  62. echo '<tr id="stripe-' . $item['id'] . '" ' . $row_class . '>'; 
  63. echo $this->single_row_columns( $item ); 
  64. echo '</tr>'; 
  65.  
  66. function column_default ( $item, $column ) { 
  67. echo rgar( $item, $column ); 
  68.  
  69. function column_cb ( $item ) { 
  70. $is_active = isset( $item['is_active'] ) ? $item['is_active'] : true; 
  71. ?> 
  72. <img src="<?php echo GFCommon::get_base_url() ?>/images/active<?php echo intval( $is_active ) ?>.png" 
  73. style="cursor: pointer;" 
  74. alt="<?php echo $is_active ? __( 'Active', 'gravity-forms-stripe' ) : __( 'Inactive', 'gravity-forms-stripe' ); ?>" 
  75. title="<?php echo $is_active ? __( 'Active', 'gravity-forms-stripe' ) : __( 'Inactive', 'gravity-forms-stripe' ); ?>" 
  76. onclick="ToggleStripeFeedActive( this, '<?php echo $item['id'] ?>', '<?php echo $item['form_id'] ?>' ); "/> 
  77. <?php 
  78.  
  79. function column_name ( $item ) { 
  80. $edit_url = add_query_arg( array( 'sid' => $item['id'] ) ); 
  81. $actions = apply_filters( 'gfp_stripe_feed_actions', array( 
  82. 'edit' => '<a title="' . __( 'Edit this item', 'gravity-forms-stripe' ) . '" href="' . $edit_url . '">' . __( 'Edit', 'gravity-forms-stripe' ) . '</a>',  
  83. 'delete' => '<a title="' . __( 'Delete this item', 'gravity-forms-stripe' ) . '" class="submitdelete" onclick="javascript: if(confirm(\'' . __( "WARNING: You are about to delete this Stripe rule.", "gfp-stripe" ) . __( "\'Cancel\' to stop, \'OK\' to delete.", "gfp-stripe" ) . '\')) { DeleteStripeFeed(\'' . $item["id"] . '\'); }" style="cursor:pointer;">' . __( 'Delete', 'gravity-forms-stripe' ) . '</a>' 
  84. ) ); 
  85. ?> 
  86.  
  87. <strong><?php echo rgars( $item, 'meta/rule_name' ); ?></strong> 
  88. <div class="row-actions"> 
  89.  
  90. <?php 
  91. if ( is_array( $actions ) && ! empty( $actions ) ) { 
  92. $action_keys = array_keys( $actions ); 
  93. $last_key = array_pop( $action_keys ); 
  94. foreach ( $actions as $key => $html ) { 
  95. $divider = $key == $last_key ? '' : " | "; 
  96. ?> 
  97. <span class="<?php echo $key; ?>"> 
  98. <?php echo $html . $divider; ?> 
  99. </span> 
  100. <?php 
  101. ?> 
  102.  
  103. </div> 
  104.  
  105. <?php 
  106.  
  107. function column_type ( $item ) { 
  108. if ( has_action( 'gfp_stripe_list_feeds_product_type' ) ) { 
  109. do_action( 'gfp_stripe_list_feeds_product_type', $item ); 
  110. else { 
  111. switch ( $item['meta']['type'] ) { 
  112. case 'product' : 
  113. _e( 'One-Time Payment', 'gravity-forms-stripe' ); 
  114. break; 
  115.  
  116. function no_items () { 
  117. $add_new_url = add_query_arg( array( 'sid' => 0 ) ); 
  118. printf( __( "You currently don't have any Stripe Rules, let's go %screate one%s", 'gravity-forms-stripe' ), "<a href='{$add_new_url}'>", "</a>" );