', '' ); ?>
id; } self::leads_page( $id ); } } public static function leads_page( $form_id ) { global $wpdb; //quit if version of wp is not supported if ( ! GFCommon::ensure_wp_version() ) { return; } $form_id = absint( $form_id ); echo GFCommon::get_remote_message(); $action = RGForms::post( 'action' ); $filter = rgget( 'filter' ); $search = stripslashes( rgget( 's' ) ); $page_index = empty( $_GET['paged'] ) ? 0 : intval( $_GET['paged'] ) - 1; $star = $filter == 'star' ? 1 : null; $read = $filter == 'unread' ? 0 : null; $status = in_array( $filter, array( 'trash', 'spam' ) ) ? $filter : 'active'; $form = RGFormsModel::get_form_meta( $form_id ); $search_criteria['status'] = $status; if ( $star ) { $search_criteria['field_filters'][] = array( 'key' => 'is_starred', 'value' => (bool) $star ); } if ( ! is_null( $read ) ) { $search_criteria['field_filters'][] = array( 'key' => 'is_read', 'value' => (bool) $read ); } $search_field_id = rgget( 'field_id' ); $search_operator = rgget( 'operator' ); 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; $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, ); } $update_message = ''; switch ( $action ) { case 'delete' : check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); $lead_id = $_POST['action_argument']; if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { RGFormsModel::delete_lead( $lead_id ); $update_message = esc_html__( 'Entry deleted.', 'gravityforms' ); } else { $update_message = esc_html__( "You don't have adequate permission to delete entries.", 'gravityforms' ); } break; case 'bulk': check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); $bulk_action = ! empty( $_POST['bulk_action'] ) ? $_POST['bulk_action'] : $_POST['bulk_action2']; $select_all = rgpost( 'all_entries' ); $leads = empty( $select_all ) ? $_POST['lead'] : GFFormsModel::search_lead_ids( $form_id, $search_criteria ); $entry_count = count( $leads ) > 1 ? sprintf( esc_html__( '%d entries', 'gravityforms' ), count( $leads ) ) : esc_html__( '1 entry', 'gravityforms' ); switch ( $bulk_action ) { case 'delete': if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { RGFormsModel::delete_leads( $leads ); $update_message = sprintf( esc_html__( '%s deleted.', 'gravityforms' ), $entry_count ); } else { $update_message = esc_html__( "You don't have adequate permission to delete entries.", 'gravityforms' ); } break; case 'trash': RGFormsModel::update_leads_property( $leads, 'status', 'trash' ); $update_message = sprintf( esc_html__( '%s moved to Trash.', 'gravityforms' ), $entry_count ); break; case 'restore': RGFormsModel::update_leads_property( $leads, 'status', 'active' ); $update_message = sprintf( esc_html__( '%s restored from the Trash.', 'gravityforms' ), $entry_count ); break; case 'unspam': RGFormsModel::update_leads_property( $leads, 'status', 'active' ); $update_message = sprintf( esc_html__( '%s restored from the spam.', 'gravityforms' ), $entry_count ); break; case 'spam': RGFormsModel::update_leads_property( $leads, 'status', 'spam' ); $update_message = sprintf( esc_html__( '%s marked as spam.', 'gravityforms' ), $entry_count ); break; case 'mark_read': RGFormsModel::update_leads_property( $leads, 'is_read', 1 ); $update_message = sprintf( esc_html__( '%s marked as read.', 'gravityforms' ), $entry_count ); break; case 'mark_unread': RGFormsModel::update_leads_property( $leads, 'is_read', 0 ); $update_message = sprintf( esc_html__( '%s marked as unread.', 'gravityforms' ), $entry_count ); break; case 'add_star': RGFormsModel::update_leads_property( $leads, 'is_starred', 1 ); $update_message = sprintf( esc_html__( '%s starred.', 'gravityforms' ), $entry_count ); break; case 'remove_star': RGFormsModel::update_leads_property( $leads, 'is_starred', 0 ); $update_message = sprintf( esc_html__( '%s unstarred.', 'gravityforms' ), $entry_count ); break; } break; case 'change_columns': check_admin_referer( 'gforms_entry_list', 'gforms_entry_list' ); $columns = GFCommon::json_decode( stripslashes( $_POST['grid_columns'] ), true ); RGFormsModel::update_grid_column_meta( $form_id, $columns ); break; } if ( rgpost( 'button_delete_permanently' ) ) { if ( GFCommon::current_user_can_any( 'gravityforms_delete_entries' ) ) { RGFormsModel::delete_leads_by_form( $form_id, $filter ); } } $sort_field = empty( $_GET['sort'] ) ? 0 : $_GET['sort']; $sort_direction = empty( $_GET['dir'] ) ? 'DESC' : $_GET['dir']; $sort_field_meta = RGFormsModel::get_field( $form, $sort_field ); $is_numeric = $sort_field_meta['type'] == 'number'; $page_size = gf_apply_filters( 'gform_entry_page_size', $form_id, 20, $form_id ); $first_item_index = $page_index * $page_size; if ( ! empty( $sort_field ) ) { $sorting = array( 'key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric ); } else { $sorting = array(); } $paging = array( 'offset' => $first_item_index, 'page_size' => $page_size ); $total_count = 0; $leads = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count ); $summary = RGFormsModel::get_form_counts( $form_id ); $active_lead_count = $summary['total']; $unread_count = $summary['unread']; $starred_count = $summary['starred']; $spam_count = $summary['spam']; $trash_count = $summary['trash']; $columns = RGFormsModel::get_grid_columns( $form_id, true ); $search_qs = empty( $search ) ? '' : '&s=' . esc_attr( urlencode( $search ) ); $sort_qs = empty( $sort_field ) ? '' : '&sort=' . esc_attr( $sort_field ); $dir_qs = empty( $sort_direction ) ? '' : '&dir=' . esc_attr( $sort_direction ); $star_qs = $star !== null ? '&star=' . esc_attr( $star ) : ''; $read_qs = $read !== null ? '&read=' . esc_attr( $read ) : ''; $filter_qs = '&filter=' . esc_attr( $filter ); $search_field_id_qs = ! isset( $_GET['field_id'] ) ? '' : '&field_id=' . esc_attr( $search_field_id ); $search_operator_urlencoded = urlencode( $search_operator ); $search_operator_qs = empty( $search_operator_urlencoded ) ? '' : '&operator=' . esc_attr( $search_operator_urlencoded ); $display_total = ceil( $total_count / $page_size ); $page_links = paginate_links( array( 'base' => admin_url( 'admin.php' ) . "?page=gf_entries&view=entries&id=$form_id&%_%" . $search_qs . $sort_qs . $dir_qs . $star_qs . $read_qs . $filter_qs . $search_field_id_qs . $search_operator_qs, 'format' => 'paged=%#%', 'prev_text' => esc_html__( '«', 'gravityforms' ), 'next_text' => esc_html__( '»', 'gravityforms' ), 'total' => $display_total, 'current' => $page_index + 1, 'show_all' => false, ) ); wp_print_styles( array( 'thickbox' ) ); $field_filters = GFCommon::get_field_filter_settings( $form ); $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, ), ) ); $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || isset( $_GET['gform_debug'] ) ? '' : '.min'; ?>

ID: :

'; /** * Allows for the modification of the Entry apply button HTML (When modifying entries) * * @param string $apply_button The Entry apply button HTML */ echo apply_filters( 'gform_entry_apply_button', $apply_button ); 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' ); ?>
$field_info ) { $dir = $field_id == 0 ? 'DESC' : 'ASC'; //default every field so ascending sorting except date_created (id=0) if ( $field_id == $sort_field ) { //reverting direction if clicking on the currently sorted field $dir = $sort_direction == 'ASC' ? 'DESC' : 'ASC'; } ?> $field_info ) { $dir = $field_id == 0 ? 'DESC' : 'ASC'; //default every field so ascending sorting except date_created (id=0) if ( $field_id == $sort_field ) { //reverting direction if clicking on the currently sorted field $dir = $sort_direction == 'ASC' ? 'DESC' : 'ASC'; } ?> 0 ) { $field_ids = array_keys( $columns ); $gf_entry_locking = new GFEntryLocking(); $alternate_row = false; foreach ( $leads as $position => $lead ) { $position = ( $page_size * $page_index ) + $position; ?> list_row_class( $lead['id'] ); ?> ' valign="top" data-id=""> type == 'post_category' ) { $value = GFCommon::prepare_post_category_value( $value, $field, 'entry_list' ); } //filtering lead value $value = apply_filters( 'gform_get_field_value', $value, $lead, $field ); $input_type = ! empty( $columns[ $field_id ]['inputType'] ) ? $columns[ $field_id ]['inputType'] : $columns[ $field_id ]['type']; switch ( $input_type ) { case 'source_url' : $value = ".../" . esc_attr( GFCommon::truncate_url( $lead['source_url'] ) ) . ''; break; case 'date_created' : case 'payment_date' : $value = GFCommon::format_date( $value, false ); break; case 'payment_amount' : $value = GFCommon::to_money( $value, $lead['currency'] ); 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, $lead, $field_id, $columns, $form ); } else { $value = esc_html( $value ); } } $value = apply_filters( 'gform_entries_field_value', $value, $form_id, $field_id, $lead ); /* ^ maybe move to function */ $query_string = "gf_entries&view=entry&id={$form_id}&lid={$lead['id']}{$search_qs}{$sort_qs}{$dir_qs}{$filter_qs}&paged=" . ( $page_index + 1 ); if ( $is_first_column ) { ?>
 
 
lock_indicator(); ?> lock_info( $lead['id'] ); ?>
| ::status=active&entry=' title="" 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=' title="" 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=' title="" href=""> ::status=trash&entry=' title="" href="">
   
'; /** * Allows for the modification of the Entry apply button HTML (When modifying entries) * * @param string $apply_button The Entry apply button HTML */ echo apply_filters( 'gform_entry_apply_button', $apply_button ); ?>
'; $range_max = ''; if ( ( $first_item_index + $page_size ) > $total_lead_count ) { $range_max .= $total_lead_count; } else { $range_max .= ( $first_item_index + $page_size ); } $range_max .= ''; $range_min = '' . ( $first_item_index + 1 ) . ''; $paging_total = '' . $total_lead_count . ''; $paging_html .= sprintf( esc_html__( 'Displaying %s - %s of %s', 'gravityforms' ), $range_min, $range_max, $paging_total ); $paging_html .= '' . $page_links . ''; } else { $paging_html = ''; } return $paging_html; } }