diff --git a/common/lib/acm-wp-list-table.php b/common/lib/acm-wp-list-table.php index a795ef1..897f3cf 100644 --- a/common/lib/acm-wp-list-table.php +++ b/common/lib/acm-wp-list-table.php @@ -15,6 +15,13 @@ class ACM_WP_List_Table extends WP_List_Table { + /** + * Row actions should be displayed once per row. This tracks if the row + * action method has been accessed. + * @var bool + */ + var $row_actions_processed = false; + function __construct( $params = array() ) { parent::__construct( $params ); } @@ -141,6 +148,9 @@ function single_row( $item ) { echo ''; echo $this->single_row_columns( $item ); echo ''; + + // Reset to false after each row is complete + $this->row_actions_processed = false; } /** @@ -162,10 +172,12 @@ function column_default( $item, $column_name ) { case 'operator': return ( ! empty( $item['operator'] ) ) ? $item['operator'] : $ad_code_manager->logical_operator; default: - // @todo need to make the first column (whatever it is filtered) to show row actions // Handle custom columns, if any - if ( isset( $item['url_vars'][$column_name] ) ) - return esc_html( $item['url_vars'][$column_name] ); + if ( isset( $item['url_vars'][ $column_name ] ) ) { + $output = esc_html( $item['url_vars'][ $column_name ] ); + $output .= $this->row_actions_output( $item ); + return $output; + } break; } @@ -293,6 +305,12 @@ function column_conditionals( $item ) { */ function row_actions_output( $item ) { + // If row actions have already been processed for this row, return an empty string, + if ( $this->row_actions_processed ) + return ''; + else + $this->row_actions_processed = true; + $output = ''; // $row_actions['preview-ad-code'] = '' . __( 'Preview Ad Code', 'ad-code-manager' ) . ''; $row_actions['edit'] = '' . __( 'Edit Ad Code', 'ad-code-manager' ) . '';