GFConfirmationTable

The Gravity Forms GFConfirmationTable class.

Defined (1)

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

/form_settings.php  
  1. class GFConfirmationTable extends WP_List_Table { 
  2.  
  3. public $form; 
  4.  
  5. function __construct( $form ) { 
  6.  
  7. $this->form = $form; 
  8.  
  9. $this->_column_headers = array( 
  10. array( 
  11. 'cb' => '',  
  12. 'name' => __( 'Name', 'gravityforms' ),  
  13. 'type' => __( 'Type', 'gravityforms' ),  
  14. 'content' => __( 'Content', 'gravityforms' ) 
  15. ),  
  16. array(),  
  17. array(),  
  18. 'name',  
  19. ); 
  20.  
  21. parent::__construct(); 
  22.  
  23. function prepare_items() { 
  24. $this->items = $this->form['confirmations']; 
  25.  
  26. function display() { 
  27. $singular = rgar( $this->_args, 'singular' ); 
  28. ?> 
  29. <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" cellspacing="0"> 
  30. <thead> 
  31. <tr> 
  32. <?php $this->print_column_headers(); ?> 
  33. </tr> 
  34. </thead> 
  35.  
  36. <tfoot> 
  37. <tr> 
  38. <?php $this->print_column_headers( false ); ?> 
  39. </tr> 
  40. </tfoot> 
  41.  
  42. <tbody id="the-list"<?php if ( $singular ) 
  43. echo " class='list:$singular'"; ?>> 
  44.  
  45. <?php $this->display_rows_or_placeholder(); ?> 
  46.  
  47. </tbody> 
  48. </table> 
  49.  
  50. <?php 
  51.  
  52. function single_row( $item ) { 
  53. static $row_class = ''; 
  54. $row_class = ( $row_class == '' ? ' class="alternate"' : '' ); 
  55.  
  56. echo '<tr id="confirmation-' . $item['id'] . '" ' . $row_class . '>'; 
  57. echo $this->single_row_columns( $item ); 
  58. echo '</tr>'; 
  59.  
  60. function get_columns() { 
  61. return $this->_column_headers[0]; 
  62.  
  63. function column_content( $item ) { 
  64. return self::get_column_content( $item ); 
  65.  
  66. function column_default( $item, $column ) { 
  67. echo rgar( $item, $column ); 
  68.  
  69. function column_type( $item ) { 
  70. return self::get_column_type( $item ); 
  71.  
  72. function column_cb( $item ) { 
  73. if ( isset( $item['isDefault'] ) && $item['isDefault'] ) 
  74. return; 
  75.  
  76. $is_active = isset( $item['isActive'] ) ? $item['isActive'] : true; 
  77. ?> 
  78. <img src="<?php echo GFCommon::get_base_url() ?>/images/active<?php echo intval( $is_active ) ?>.png" style="cursor: pointer;margin:-5px 0 0 8px;" alt="<?php $is_active ? __( 'Active', 'gravityforms' ) : __( 'Inactive', 'gravityforms' ); ?>" title="<?php echo $is_active ? __( 'Active', 'gravityforms' ) : __( 'Inactive', 'gravityforms' ); ?>" onclick="ToggleActive(this, '<?php echo $item['id'] ?>'); " /> 
  79. <?php 
  80.  
  81. function column_name( $item ) { 
  82. $edit_url = add_query_arg( array( 'cid' => $item['id'] ) ); 
  83. $duplicate_url = add_query_arg( array( 'cid' => 0, 'duplicatedcid' => $item['id'] ) ); 
  84. $actions = apply_filters( 
  85. 'gform_confirmation_actions', array( 
  86. 'edit' => '<a title="' . __( 'Edit this item', 'gravityforms' ) . '" href="' . esc_url( $edit_url ) . '">' . __( 'Edit', 'gravityforms' ) . '</a>',  
  87. 'duplicate' => '<a title="' . __( 'Duplicate this confirmation', 'gravityforms' ) . '" href="' . esc_url( $duplicate_url ) . '">' . __( 'Duplicate', 'gravityforms' ) . '</a>',  
  88. 'delete' => '<a title="' . __( 'Delete this item', 'gravityforms' ) . '" class="submitdelete" onclick="javascript: if(confirm(\'' . __( 'WARNING: You are about to delete this confirmation.', 'gravityforms' ) . __( "\'Cancel\' to stop, \'OK\' to delete.", 'gravityforms' ) . '\')) { DeleteConfirmation(\'' . esc_js( $item['id'] ) . '\'); }" style="cursor:pointer;">' . __( 'Delete', 'gravityforms' ) . '</a>' 
  89. ); 
  90.  
  91. if ( isset( $item['isDefault'] ) && $item['isDefault'] ) { 
  92. unset( $actions['delete'] ); 
  93.  
  94.  
  95. ?> 
  96.  
  97. <a href="<?php echo esc_url( $edit_url ); ?>"><strong><?php echo esc_html( rgar( $item, 'name' ) ); ?></strong></a> 
  98. <div class="row-actions"> 
  99.  
  100. <?php 
  101. if ( is_array( $actions ) && ! empty( $actions ) ) { 
  102. $keys = array_keys( $actions ); 
  103. $last_key = array_pop( $keys ); 
  104. foreach ( $actions as $key => $html ) { 
  105. $divider = $key == $last_key ? '' : ' | '; 
  106. ?> 
  107. <span class="<?php echo $key; ?>"> 
  108. <?php echo $html . $divider; ?> 
  109. </span> 
  110. <?php 
  111. ?> 
  112.  
  113. </div> 
  114.  
  115. <?php 
  116.  
  117. public static function get_column_content( $item ) { 
  118. switch ( rgar( $item, 'type' ) ) { 
  119.  
  120. case 'message': 
  121. return '<a class="limit-text" title="' . strip_tags( $item['message'] ) . '">' . strip_tags( $item['message'] ) . '</a>'; 
  122.  
  123. case 'page': 
  124.  
  125. $page = get_post( $item['pageId'] ); 
  126. if ( empty( $page ) ) 
  127. return __( '<em>This page does not exist.</em>', 'gravityforms' ); 
  128.  
  129. return '<a href="' . get_permalink( $item['pageId'] ) . '">' . $page->post_title . '</a>'; 
  130.  
  131. case 'redirect': 
  132. $url_pieces = parse_url( $item['url'] ); 
  133. $url_connector = rgar( $url_pieces, 'query' ) ? '&' : '?'; 
  134. $url = rgar( $item, 'queryString' ) ? "{$item['url']}{$url_connector}{$item['queryString']}" : $item['url']; 
  135.  
  136. return '<a class="limit-text" title="' . $url . '">' . $url . '</a>'; 
  137.  
  138. return ''; 
  139.  
  140. public static function get_column_type( $item ) { 
  141. switch ( rgar( $item, 'type' ) ) { 
  142. case 'message': 
  143. return __( 'Text', 'gravityforms' ); 
  144.  
  145. case 'page': 
  146. return __( 'Page', 'gravityforms' ); 
  147.  
  148. case 'redirect': 
  149. return __( 'Redirect', 'gravityforms' ); 
  150.  
  151. return ''; 
  152.