', '' ), 'success' ); } if ( sizeof( $forms ) == 0 ) { ?>
', '' ); ?>
id; } /** * Fires before the entry list content is generated. * * Echoed content would appear above the page title. * * @param int $form_id The ID of the form that the entry list is being displayed for. */ do_action( 'gform_pre_entry_list', $form_id ); self::leads_page( $form_id ); /** * Fires after the entry list content is generated. * * Echoed content would appear after the bulk actions/paging links below the entry list table. * * @param int $form_id The ID of the form that the entry list is being displayed for. */ do_action( 'gform_post_entry_list', $form_id ); } } /** * Returns the default filter for the form ID specified in the URL. If no form ID is specified then the first form is used. * @since 2.0 * @return string */ public static function get_default_filter() { $forms = GFFormsModel::get_forms( null, 'title' ); $form_id = rgget( 'id' ); if ( sizeof( $forms ) == 0 ) { return ''; } else { if ( empty( $form_id ) ) { $form_id = $forms[0]->id; } } $form = GFAPI::get_form( $form_id ); $filters = self::get_filter_links( $form, false ); $option_values = self::get_screen_options_values(); // If the filter is not available for the form then use 'all' $selected_filter = 'all'; foreach ( $filters as $filter ) { if ( $option_values['default_filter'] == $filter['id'] ) { $selected_filter = $option_values['default_filter']; break; } } return $selected_filter; } /** * Returns the markup for the screen options. * * @since 2.0 * * @param $status * @param $args * * @return string */ public static function get_screen_options_markup( $status, $args ) { $return = $status; if ( ! GFForms::get_page() == 'entry_list' ) { return $return; } $screen_options = self::get_screen_options_values(); $per_page = $screen_options['per_page']; $forms = GFFormsModel::get_forms( null, 'title' ); $form_id = rgget( 'id' ); if ( sizeof( $forms ) == 0 ) { return ''; } else { if ( empty( $form_id ) ) { $form_id = $forms[0]->id; } } $form = GFAPI::get_form( $form_id ); $filters = self::get_filter_links( $form, false ); $option_values = self::get_screen_options_values(); // If the filter is not available for the form then use 'all' $selected_filter = 'all'; foreach ( $filters as $filter ) { if ( $option_values['default_filter'] == $filter['id'] ) { $selected_filter = $option_values['default_filter']; break; } } $radios_arr = array(); foreach ( $filters as $filter ) { $id = esc_attr( $filter['id'] ); $label = esc_attr( $filter['label'] ); $checked = checked( $filter['id'], $selected_filter, false ); $radios_arr[] = sprintf( '', $id, $id, $checked, $id, $label ); } $radios_str = join( "\n", $radios_arr ); $filter_title = esc_html__( 'Default Filter', 'gravityforms' ); $pagination_title = esc_html__( 'Pagination', 'gravityforms' ); $entries_label = esc_html__( 'Number of entries per page:', 'gravityforms' ); $button = get_submit_button( esc_html__( 'Apply', 'gravityforms' ), 'button button-primary', 'screen-options-apply', false ); $return .= "
{$filter_title}
{$radios_str}
{$pagination_title}

$button

"; return $return; } /** * Returns the values for the user-specific screen options. If not saved by the current user, the default values are returned. * * @since 2.0 * @return array */ public static function get_screen_options_values() { $default_values = array( 'per_page' => 20, 'default_filter' => 'all', ); $option_values = get_user_option( 'gform_entries_screen_options' ); if ( empty( $option_values ) || ! is_array( $option_values ) ) { $option_values = array(); } $option_values = array_merge( $default_values, $option_values ); return $option_values; } public static function leads_page( $form_id ) { global $wpdb; //quit if version of wp is not supported if ( ! GFCommon::ensure_wp_version() ) { return; } $form = GFFormsModel::get_form_meta( $form_id ); $table = new GF_Entry_List_Table( array( 'form_id' => $form_id, 'form' => $form ) ); $table->prepare_items(); $table->output_styles(); $table->output_scripts(); wp_print_styles( array( 'thickbox' ) ); echo GFCommon::get_remote_message(); ?>
views(); $table->display(); ?>
'all', 'field_filters' => array(), 'count' => $active_entry_count, 'label' => esc_html_x( 'All', 'Entry List', 'gravityforms' ), ), array( 'id' => 'unread', 'field_filters' => array( array( 'key' => 'is_read', 'value' => false ), ), 'count' => $unread_count, 'label' => esc_html_x( 'Unread', 'Entry List', 'gravityforms' ), ), array( 'id' => 'star', 'field_filters' => array( array( 'key' => 'is_starred', 'value' => true ), ), 'count' => $starred_count, 'label' => esc_html_x( 'Starred', 'Entry List', 'gravityforms' ), ), ); if ( ( $spam_count > 0 ) || GFCommon::spam_enabled( $form_id ) ) { $filter_links[] = array( 'id' => 'spam', 'field_filters' => array(), 'count' => $spam_count, 'label' => esc_html__( 'Spam', 'gravityforms' ), ); } $filter_links[] = array( 'id' => 'trash', 'field_filters' => array(), 'count' => $trash_count, 'label' => esc_html__( 'Trash', 'gravityforms' ), ); /** * Allow the row of filter links to be modified. * * Array elements: * selected - bool * filter - string * label - string * * @param array $filter_links The filter links. * */ $filter_links = apply_filters( 'gform_filter_links_entry_list', $filter_links, $form, $include_counts ); return $filter_links; } public static function all_leads_page() { self::all_entries_page(); } } if ( ! class_exists( 'WP_List_Table' ) ) { require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); } /** * Class GF_Entry_List_Table * * @since 2.0 */ final class GF_Entry_List_Table extends WP_List_Table { /** * The current filter e.g. trash, spam, unread * * @var string */ public $filter = ''; /** * The name of the primary column. The primary column will not get collapsed on narrower displays. * * @var null|string */ public $primary_column_name = null; /** * The locking mechanism for the entry list. * * @var GFEntryLocking */ public $locking_info; /** * Tracks the cuurent row during output. * * @var int */ public $row_index = 0; /** * The Form array. * * @var array */ private $_form; /** * The columns to display on the entry list for this form. * @var array */ private $_grid_columns = null; /** * GF_Entry_List constructor. * * @param array $args */ public function __construct( $args = array() ) { $this->_form = isset( $args['form'] ) ? $args['form'] : null; if ( ! isset( $this->_form ) ) { $form_id = isset( $args['form_id'] ) ? $args['form_id'] : absint( rgget( 'id' ) ); $this->_form = RGFormsModel::get_form_meta( $form_id ); } $args = wp_parse_args( $args, array( 'plural' => 'gf_entries', 'singular' => 'gf_entry', 'ajax' => false, 'screen' => null, 'filter' => sanitize_text_field( rgget( 'filter' ) ), ) ); parent::__construct( $args ); $this->filter = $args['filter']; $this->set_columns(); $this->locking_info = new GFEntryLocking(); } /** * Set the hidden, sortable and primary columns. */ public function set_columns() { $columns = $this->get_columns(); $hidden = array(); $sortable = $this->get_sortable_columns(); $primary = $this->get_primary_column_name(); $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); } /** * Returns the curent filter. * * @return string */ public function get_filter() { return $this->filter; } /** * Returns the current form array. * * @return array */ public function get_form() { return $this->_form; } /** * Returns the current form ID. * * @return int */ public function get_form_id() { $form_id = isset( $this->_form ) ? $this->_form['id'] : rgget( 'id' ); return absint( $form_id ); } /** * Returns an associative array of views. * * @return array */ function get_views() { $views = array(); $form_id = $this->get_form_id(); $filter_links = $this->get_filter_links(); $filter = $this->filter; foreach ( $filter_links as $filter_link_index => $filter_link ) { $filter_arg = '&filter='; if ( $filter_link['id'] !== 'all' ) { $filter_arg .= $filter_link['id']; } if ( $filter == '' ) { $selected = $filter_link['id'] == 'all' ? 'current' : ''; } else { $selected = ( $filter == $filter_link['id'] ) ? 'current' : ''; } $link = '' . esc_html( $filter_link['label'] ) . ' (' . absint( rgar( $filter_link, 'count' ) ) . ')'; $views[ $filter_link['id'] ] = $link; } return $views; } /** * Returns the array of filter links. * * @param bool $include_counts * * @return array|mixed|void */ public function get_filter_links( $include_counts = true ) { $form = $this->get_form(); return GFEntryList::get_filter_links( $form, $include_counts ); } /** * Gets the ordering for the entry list table. * * Also formats the query string to uppercase. If none is present, sets it to ascending. * * @since 2.0.3.6 * @access public * * @return string The ordering to be used. */ public function get_order() { return empty( $_GET['order'] ) ? 'ASC' : strtoupper( $_GET['order'] ); } /** * Gets the column that list is ordered by. * * If none is set, defaults to 0 (the first column) * * @since 2.0.3.6 * @access public * * @return int The column to be used. */ public function get_orderby() { return empty( $_GET['orderby'] ) ? 0 : $_GET['orderby']; } /** * Performs the search and prepares the entries for display. */ function prepare_items() { $this->process_action(); $form_id = $this->get_form_id(); $page_index = empty( $_GET['paged'] ) ? 0 : absint( $_GET['paged'] - 1 ); $search_criteria = $this->get_search_criteria(); $screen_options = get_user_option( 'gform_entries_screen_options' ); $page_size = isset( $screen_options['per_page'] ) ? absint( $screen_options['per_page'] ) : 20; $page_size = gf_apply_filters( array( 'gform_entry_page_size', $form_id ), $page_size, $form_id ); $first_item_index = $page_index * $page_size; $sort_field = $this->get_orderby(); if ( ! empty( $sort_field ) ) { $sort_direction = $this->get_order(); $sort_field_meta = GFAPI::get_field( $form_id, $sort_field ); if ( $sort_field_meta instanceof GF_Field ) { $is_numeric = $sort_field_meta->get_input_type() == 'number'; } else { $entry_meta = GFFormsModel::get_entry_meta( $form_id ); $is_numeric = rgars( $entry_meta, $sort_field . '/is_numeric' ); } $sorting = array( 'key' => $sort_field, 'direction' => $sort_direction, 'is_numeric' => $is_numeric ); } else { $sorting = array(); } $paging = array( 'offset' => $first_item_index, 'page_size' => $page_size ); $total_count = 0; /** * Filter the arguments that will be used to fetch entries for display on the Entry List view. * * @since 2.2.3.4 * * @param array $args { * * Array of arguments that will be passed to GFAPI::get_entries() to fetch the entries to be displayed. * * @var int $form_id The form ID for which entries will be loaded. * @var array $search_criteria An array of search critiera that will be used to filter entries. * @var array $sorting An array containing properties that specify how the entries will be sorted. * @var array $paging An array containing properties that specify how the entries will be paginated. * } */ $args = gf_apply_filters( array( 'gform_get_entries_args_entry_list', $form_id ), compact( 'form_id', 'search_criteria', 'sorting', 'paging' ) ); $entries = GFAPI::get_entries( $args['form_id'], $args['search_criteria'], $args['sorting'], $args['paging'], $total_count ); $this->set_pagination_args( array( 'total_items' => $total_count, 'per_page' => $args['paging']['page_size'], ) ); $this->items = $entries; } /** * Returns the array of search criteria. * * @return array */ function get_search_criteria() { $search_criteria = array(); $filter_links = $this->get_filter_links( false ); foreach ( $filter_links as $filter_link ) { if ( $this->filter == $filter_link['id'] ) { $search_criteria['field_filters'] = $filter_link['field_filters']; break; } } $search_field_id = rgget( 'field_id' ); $search_operator = rgget( 'operator' ); $status = in_array( $this->filter, array( 'trash', 'spam' ) ) ? $this->filter : 'active'; $search_criteria['status'] = $status; if ( isset( $_GET['field_id'] ) && $_GET['field_id'] !== '' ) { $key = $search_field_id; $val = stripslashes( rgget( 's' ) ); $strpos_row_key = strpos( $search_field_id, '|' ); if ( $strpos_row_key !== false ) { //multi-row likert $key_array = explode( '|', $search_field_id ); $key = $key_array[0]; $val = $key_array[1] . ':' . $val; } if ( 'entry_id' == $key ) { $key = 'id'; } $filter_operator = empty( $search_operator ) ? 'is' : $search_operator; $form = $this->get_form(); $field = GFFormsModel::get_field( $form, $key ); if ( $field ) { $input_type = GFFormsModel::get_input_type( $field ); if ( $field->type == 'product' && in_array( $input_type, array( 'radio', 'select' ) ) ) { $filter_operator = 'contains'; } } $search_criteria['field_filters'][] = array( 'key' => $key, 'operator' => $filter_operator, 'value' => $val, ); } $form_id = $this->get_form_id(); /** * Allow the entry list search criteria to be overridden. * * @since 1.9.14.30 * * @param array $search_criteria An array containing the search criteria. * @param int $form_id The ID of the current form. */ $search_criteria = gf_apply_filters( array( 'gform_search_criteria_entry_list', $form_id ), $search_criteria, $form_id ); return $search_criteria; } /** * Returns the associative array of columns for the table. * * @return array */ function get_columns() { $table_columns = array( 'cb' => '', ); if ( ! in_array( $this->filter, array( 'trash', 'spam' ) ) ) { $table_columns['is_starred'] = ''; } $form_id = $this->get_form_id(); $columns = $this->get_grid_columns(); foreach ( $columns as $key => $column_info ) { $table_columns[ 'field_id-' . $key ] = $column_info['label']; } if ( empty( $columns ) ) { $table_columns['field_id-id'] = esc_html__( 'Entry Id', 'gravityforms' ); } $column_selector_url = add_query_arg( array( 'gf_page' => 'select_columns', 'id' => absint( $form_id ), 'TB_iframe' => 'true', 'height' => 365, 'width' => 600, ), admin_url() ); $table_columns['column_selector'] = ''; /** * Allow the columns to be displayed in the entry list table to be overridden. * * @since 2.0.7.6 * * @param array $table_columns The columns to be displayed in the entry list table. * @param int $form_id The ID of the form the entries to be listed belong to. */ $table_columns = apply_filters( 'gform_entry_list_columns', $table_columns, $form_id ); return apply_filters( 'gform_entry_list_columns_' . $form_id, $table_columns, $form_id ); } /** * Returns the associative array of sortable columns for the table. * * @return array */ function get_sortable_columns() { $columns = $this->get_grid_columns(); $table_columns = array(); foreach ( $columns as $key => $column_info ) { $table_columns[ 'field_id-' . (string) $key ] = array( (string) $key, false ); } return $table_columns; } /** * Displays the checkbox column. * * @param array $entry */ function column_cb( $entry ) { $entry_id = $entry['id']; ?> locking_info->lock_indicator(); } /** * Displays an empty cell for the column selector column. * * @param $entry * * @return string */ function column_column_selector( $entry ) { return ''; } /** * Displays the is_starred row for the given entry. * * @param $entry * @param $classes * @param $data * @param $primary */ function _column_is_starred( $entry, $classes, $data, $primary ) { echo ''; if ( $this->filter !== 'trash' ) { ?> '; } /** * Displays the entry value. * * @param object $entry * @param string $column_id */ function column_default( $entry, $column_id ) { $field_id = (string) str_replace( 'field_id-', '', $column_id ); $form = $this->get_form(); $form_id = $this->get_form_id(); $field = GFFormsModel::get_field( $form, $field_id ); $columns = $this->get_grid_columns(); $value = rgar( $entry, $field_id ); if ( ! empty( $field ) && $field->type == 'post_category' ) { $value = GFCommon::prepare_post_category_value( $value, $field, 'entry_list' ); } // Filtering lead value $value = apply_filters( 'gform_get_field_value', $value, $entry, $field ); switch ( $field_id ) { case 'source_url' : $value = ".../" . esc_attr( GFCommon::truncate_url( $entry['source_url'] ) ) . ''; break; case 'date_created' : case 'payment_date' : $value = GFCommon::format_date( $value, false ); break; case 'payment_amount' : $value = GFCommon::to_money( $value, $entry['currency'] ); break; case 'payment_status' : $value = GFCommon::get_entry_payment_status_text( $entry['payment_status'] ); break; case 'created_by' : if ( ! empty( $value ) ) { $userdata = get_userdata( $value ); if ( ! empty( $userdata ) ) { $value = $userdata->user_login; } } break; default: if ( $field !== null ) { $value = $field->get_value_entry_list( $value, $entry, $field_id, $columns, $form ); } else { $value = esc_html( $value ); } } $value = apply_filters( 'gform_entries_field_value', $value, $form_id, $field_id, $entry ); $primary = $this->get_primary_column_name(); $query_string = $this->get_detail_query_string( $entry ); if ( $column_id == $primary ) { $edit_url = $this->get_detail_url( $entry ); echo '' . $value . ''; } else { /** * Used to inject markup and replace the value of any non-first column in the entry list grid. * * @param string $value The value of the field * @param int $form_id The ID of the current form * @param int $field_id The ID of the field * @param array $entry The Entry object * @param string $query_string The current page's query string */ echo apply_filters( 'gform_entries_column_filter', $value, $form_id, $field_id, $entry, $query_string ); // Maintains gap between value and content from gform_entries_column which existed when using 1.9 and earlier. echo '  '; /** * Fired within the entries column * * Used to insert additional entry details * * @param int $form_id The ID of the current form * @param int $field_id The ID of the field * @param string $value The value of the field * @param array $entry The Entry object * @param string $query_string The current page's query string */ do_action( 'gform_entries_column', $form_id, $field_id, $value, $entry, $query_string ); } } /** * Returns the entry detail query string. * * @param $entry * * @return string */ function get_detail_query_string( $entry ) { $form_id = $this->get_form_id(); $search = stripslashes( rgget( 's' ) ); $search_field_id = rgget( 'field_id' ); $search_operator = rgget( 'operator' ); $order = $this->get_order(); $orderby = $this->get_orderby(); $search_qs = empty( $search ) ? '' : '&s=' . esc_attr( urlencode( $search ) ); $orderby_qs = empty( $orderby ) ? '' : '&orderby=' . esc_attr( $orderby ); $order_qs = empty( $order ) ? '' : '&order=' . esc_attr( $order ); $filter_qs = '&filter=' . esc_attr( $this->filter ); $page_size = $this->get_pagination_arg( 'per_page' ); $page_num = $this->get_pagenum(); $page_index = $page_num - 1; $position = ( $page_size * $page_index ) + $this->row_index; $edit_url = 'page=gf_entries&view=entry&id=' . absint( $form_id ) . '&lid=' . esc_attr( $entry['id'] ) . $search_qs . $orderby_qs . $order_qs . $filter_qs . '&paged=' . $page_num .'&pos=' . $position .'&field_id=' . esc_attr( $search_field_id ) . '&operator=' . esc_attr( $search_operator ); return $edit_url; } /** * Returns the entry detail url. * * @param $entry * * @return string|void */ function get_detail_url( $entry ) { $query_string = $this->get_detail_query_string( $entry ); $url = admin_url( 'admin.php?' . $query_string ); return $url; } /** * Displays a single row. * * @param array $entry */ public function single_row( $entry ) { $class = 'entry_row'; $class .= $entry['is_read'] ? '' : ' entry_unread'; $class .= $this->locking_info->list_row_class( $entry['id'], false ); $class .= $entry['is_starred'] ? ' entry_starred' : ''; $class .= in_array( $this->filter, array( 'trash', 'spam' ) ) ? ' entry_spam_trash' : ''; echo sprintf( '', $entry['id'], $class, $entry['id'] ); $this->single_row_columns( $entry ); echo ''; } /** * Displays the no items message according to the context. */ function no_items() { switch ( $this->filter ) { case 'unread' : $message = isset( $_GET['field_id'] ) ? esc_html__( 'This form does not have any unread entries matching the search criteria.', 'gravityforms' ) : esc_html__( 'This form does not have any unread entries.', 'gravityforms' ); break; case 'star' : $message = isset( $_GET['field_id'] ) ? esc_html__( 'This form does not have any starred entries matching the search criteria.', 'gravityforms' ) : esc_html__( 'This form does not have any starred entries.', 'gravityforms' ); break; case 'spam' : $message = esc_html__( 'This form does not have any spam.', 'gravityforms' ); break; case 'trash' : $message = isset( $_GET['field_id'] ) ? esc_html__( 'This form does not have any entries in the trash matching the search criteria.', 'gravityforms' ) : esc_html__( 'This form does not have any entries in the trash.', 'gravityforms' ); break; default : $message = isset( $_GET['field_id'] ) ? esc_html__( 'This form does not have any entries matching the search criteria.', 'gravityforms' ) : esc_html__( 'This form does not have any entries yet.', 'gravityforms' ); } echo $message; } /** * Displays the row action if the column is primary. * * @param array $entry * @param string $column_name * @param string $primary * * @return string */ protected function handle_row_actions( $entry, $column_name, $primary ) { if ( $primary !== $column_name ) { return ''; } $form_id = $this->get_form_id(); $field_id = (string) str_replace( 'field_id-', '', $column_name ); $value = $entry[ $field_id ]; $detail_url = $this->get_detail_url( $entry ); ?>
filter ) { case 'trash' : ?> ::status=restore&entry=' href=""> | ' . esc_html__( 'Delete Permanently', 'gravityforms' ) . ''; /** * Allows for modification of a Form entry "delete" link * * @param string $delete_link The Entry Delete Link (Formatted in HTML) */ echo apply_filters( 'gform_delete_entry_link', $delete_link ); ?> | ::status=unspam&entry=' aria-label="" href=""> ' . esc_html__( 'Delete Permanently', 'gravityforms' ) . ''; /** * Allows for modification of a Form entry "delete" link * * @param string $delete_link The Entry Delete Link (Formatted in HTML) */ echo apply_filters( 'gform_delete_entry_link', $delete_link ); ?> | ::status=spam&entry=' aria-label="" href=""> ::status=trash&entry=' aria-label="" href=""> get_detail_query_string( $entry ); do_action( 'gform_entries_first_column_actions', $form_id, $field_id, $value, $entry, $query_string ); ?>
row_index++; return ''; } /** * Returns the name of the primary column. * * @return string */ function get_primary_column_name() { if ( ! isset( $this->primary_column_name ) ) { $columns = $this->get_columns(); $column_keys = array_keys( $columns ); $column_index = in_array( $this->filter, array( 'trash', 'spam' ) ) ? 1 : 2; $primary = isset( $column_keys[ $column_index ] ) ? $column_keys[ $column_index ] : ''; $this->primary_column_name = $primary; } return $this->primary_column_name; } /** * Returns the options for the bulk actions menu. * * @return array */ function get_bulk_actions() { $actions = array(); switch ( $this->filter ) { case 'trash' : if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { $actions['restore'] = esc_html__( 'Restore', 'gravityforms' ); $actions['delete'] = esc_html__( 'Delete Permanently', 'gravityforms' ); } break; case 'spam' : $actions['unspam'] = esc_html__( 'Not Spam', 'gravityforms' ); if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { $actions['delete'] = esc_html__( 'Delete Permanently', 'gravityforms' ); } break; default: $actions['mark_read'] = esc_html__( 'Mark as Read', 'gravityforms' ); $actions['mark_unread'] = esc_html__( 'Mark as Unread', 'gravityforms' ); $actions['add_star'] = esc_html__( 'Add Star', 'gravityforms' ); $actions['remove_star'] = esc_html__( 'Remove Star', 'gravityforms' ); $actions['resend_notifications'] = esc_html__( 'Resend Notifications', 'gravityforms' ); $actions['print'] = esc_html__( 'Print', 'gravityforms' ); if ( GFCommon::spam_enabled( $this->get_form_id() ) ) { $actions['spam'] = esc_html__( 'Spam', 'gravityforms' ); } if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { $actions['trash'] = esc_html__( 'Trash', 'gravityforms' ); } } // Get the current form ID. $form_id = $this->get_form_id(); /** * Modifies available bulk actions for the entries list. * * @since 2.2.3.12 * * @param array $actions Bulk actions. * @param int $form_id The ID of the current form. */ return gf_apply_filters( array( 'gform_entry_list_bulk_actions', $form_id ), $actions, $form_id ); } /** * Displays the bulk actions. * * @param string $which */ function bulk_actions( $which = '' ) { parent::bulk_actions( $which ); $filter = $this->filter; if ( 'trash' === $filter && ! GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { return; } if ( in_array( $filter, array( 'trash', 'spam' ) ) ) { $message = $filter == 'trash' ? esc_html__( "WARNING! This operation cannot be undone. Empty trash? 'Ok' to empty trash. 'Cancel' to abort.", 'gravityforms' ) : esc_html__( "WARNING! This operation cannot be undone. Permanently delete all spam? 'Ok' to delete. 'Cancel' to abort.", 'gravityforms' ); $button_label = $filter == 'trash' ? __( 'Empty Trash', 'gravityforms' ) : __( 'Delete All Spam', 'gravityforms' ); ?> current_action(); $delete_permanently = (bool) rgpost( 'button_delete_permanently' ); if ( ! ( $single_action || $bulk_action || $delete_permanently ) ) { return; } check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); $form_id = $this->get_form_id(); if ( $delete_permanently ) { if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { RGFormsModel::delete_leads_by_form( $form_id, $this->filter ); } return; } if ( $single_action ) { $entry_id = rgpost( 'single_action_argument' ); switch ( $single_action ) { case 'delete' : if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { RGFormsModel::delete_entry( $entry_id ); $message = esc_html__( 'Entry deleted.', 'gravityforms' ); } else { $message = esc_html__( "You don't have adequate permission to delete entries.", 'gravityforms' ); } break; case 'change_columns': $columns = GFCommon::json_decode( stripslashes( $_POST['grid_columns'] ), true ); RGFormsModel::update_grid_column_meta( $form_id, $columns ); $this->_grid_columns = null; $this->set_columns(); break; } /** * Fires after the default entry list actions have been processed. * * @param string $action Action being performed. * @param array $entries The entry IDs the action is being applied to. * @param int $form_id The current form ID. */ gf_do_action( array( 'gform_entry_list_action', $single_action, $form_id ), $single_action, array( $entry_id ), $form_id ); } elseif ( $bulk_action ) { $select_all = rgpost( 'all_entries' ); $search_criteria = $this->get_search_criteria(); $entries = empty( $select_all ) ? $_POST['entry'] : GFAPI::get_entry_ids( $form_id, $search_criteria ); $entry_count = count( $entries ) > 1 ? sprintf( esc_html__( '%d entries', 'gravityforms' ), count( $entries ) ) : esc_html__( '1 entry', 'gravityforms' ); $message_class = 'updated'; switch ( $bulk_action ) { case 'delete': if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { GFFormsModel::delete_entries( $entries ); $message = sprintf( esc_html__( '%s deleted.', 'gravityforms' ), $entry_count ); } else { $message = esc_html__( "You don't have adequate permission to delete entries.", 'gravityforms' ); $message_class = 'error'; } break; case 'trash': if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { GFFormsModel::update_entries_property( $entries, 'status', 'trash' ); $message = sprintf( esc_html__( '%s moved to Trash.', 'gravityforms' ), $entry_count ); } else { $message = esc_html__( "You don't have adequate permissions to trash entries.", 'gravityforms' ); $message_class = 'error'; } break; case 'restore': if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { GFFormsModel::update_entries_property( $entries, 'status', 'active' ); $message = sprintf( esc_html__( '%s restored from the Trash.', 'gravityforms' ), $entry_count ); } else { $message = esc_html__( "You don't have adequate permissions to restore entries.", 'gravityforms' ); $message_class = 'error'; } break; case 'unspam': GFFormsModel::update_entries_property( $entries, 'status', 'active' ); $message = sprintf( esc_html__( '%s restored from the spam.', 'gravityforms' ), $entry_count ); break; case 'spam': GFFormsModel::update_entries_property( $entries, 'status', 'spam' ); $message = sprintf( esc_html__( '%s marked as spam.', 'gravityforms' ), $entry_count ); break; case 'mark_read': GFFormsModel::update_entries_property( $entries, 'is_read', 1 ); $message = sprintf( esc_html__( '%s marked as read.', 'gravityforms' ), $entry_count ); break; case 'mark_unread': GFFormsModel::update_entries_property( $entries, 'is_read', 0 ); $message = sprintf( esc_html__( '%s marked as unread.', 'gravityforms' ), $entry_count ); break; case 'add_star': GFFormsModel::update_entries_property( $entries, 'is_starred', 1 ); $message = sprintf( esc_html__( '%s starred.', 'gravityforms' ), $entry_count ); break; case 'remove_star': GFFormsModel::update_entries_property( $entries, 'is_starred', 0 ); $message = sprintf( esc_html__( '%s unstarred.', 'gravityforms' ), $entry_count ); break; } /** * Fires after the default entry list actions have been processed. * * @param string $action Action being performed. * @param array $entries The entry IDs the action is being applied to. * @param int $form_id The current form ID. */ gf_do_action( array( 'gform_entry_list_action', $bulk_action, $form_id ), $bulk_action, $entries, $form_id ); } if ( ! empty( $message ) ) { echo '

' . $message . '

'; }; } /** * Displays additional fields required by FORM and displays the modals. * * @param string $which */ function extra_tablenav( $which ) { if ( $which !== 'top' ) { return; } wp_nonce_field( 'gforms_entry_list', 'gforms_entry_list' ); ?> modals(); } /** * Output the styles */ function output_styles() { $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min'; ?> get_form_id(); $form = $this->get_form(); $search = isset( $_GET['s'] ) ? stripslashes( $_GET['s'] ) : null; $orderby = empty( $_GET['orderby'] ) ? 0 : $_GET['orderby']; $order = empty( $_GET['order'] ) ? 'ASC' : strtoupper( $_GET['order'] ); $filter = sanitize_text_field( rgget( 'filter ' ) ); $field_filters = GFCommon::get_field_filter_settings( $form ); $search_field_id = rgget( 'field_id' ); $search_operator = rgget( 'operator' ); $init_field_id = empty( $search_field_id ) ? 0 : $search_field_id; $init_field_operator = empty( $search_operator ) ? 'contains' : $search_operator; $init_filter_vars = array( 'mode' => 'off', 'filters' => array( array( 'field' => $init_field_id, 'operator' => $init_field_operator, 'value' => $search, ), ), ); ?> get_form(); ?> _grid_columns ) ) { $this->_grid_columns = GFFormsModel::get_grid_columns( $this->get_form_id(), true ); } return $this->_grid_columns; } }