'New', 'read' => 'Read', 'replied' => 'Replied', 'spam' => 'Spam', ); return array( 'id' => 'contact_form_messages', 'label' => 'Contact form messages', 'description' => '', 'scope' => 'local', 'source' => 'rows', 'registry_id' => 'contact_form.list', 'version' => '1', 'per_page' => 50, 'rows' => static function () { if ( ! class_exists( 'AIEO_Contact_Form_Store' ) ) { return array(); } $base = add_query_arg( array( 'page' => AIEO_DMM::MENU_SLUG, 'dmm_tab' => 'contact_form', ), admin_url( 'admin.php' ) ); $list = AIEO_Contact_Form_Store::list_messages( array( 'per_page' => 500, 'paged' => 1 ) ); $all = (array) $list['rows']; $page = 1; while ( count( $all ) < (int) $list['total'] && $page < 40 ) { ++$page; $more = AIEO_Contact_Form_Store::list_messages( array( 'per_page' => 500, 'paged' => $page ) ); if ( empty( $more['rows'] ) ) { break; } $all = array_merge( $all, (array) $more['rows'] ); } $out = array(); foreach ( $all as $r ) { $name = trim( (string) $r->first_name . ' ' . (string) $r->last_name ); $text = trim( (string) preg_replace( '/\s+/', ' ', (string) $r->message ) ); $out[] = array( 'id' => (int) $r->id, 'select' => '', 'created_at' => (string) $r->created_at, 'status' => (string) $r->status, 'who' => '' !== $name ? $name : (string) $r->email, 'email' => (string) $r->email, 'company' => (string) $r->company, 'country' => '' !== (string) $r->country ? AIEO_Contact_Form::country_name( (string) $r->country ) : '', 'excerpt' => '' !== $text ? ( function_exists( 'mb_substr' ) ? mb_substr( $text, 0, 90 ) : substr( $text, 0, 90 ) ) : '', 'phone' => (string) $r->phone, 'city' => (string) $r->city, 'message' => (string) $r->message, 'detail_url' => add_query_arg( 'message_id', (int) $r->id, $base ), ); } return $out; }, 'row_key' => 'id', 'default_sort' => array( 'created_at', 'desc' ), 'empty_state' => 'No messages yet.', 'bulk_actions' => array( array( 'id' => 'status', 'label' => 'Set status', 'confirm' => 'Set %1$s messages to "%2$s"?', 'param' => array( 'type' => 'select', 'options' => $aieo_cfm_statuses, 'required' => true ), ), array( 'id' => 'delete', 'label' => 'Delete', 'confirm' => 'Delete %s messages? This cannot be undone.', 'destructive' => true, ), ), 'actions' => array( array( 'id' => 'open', 'label' => 'Open', 'href' => '{detail_url}', ), array( 'id' => 'delete', 'label' => 'Delete', 'hook' => 'aieo-cf-delete', 'destructive' => true, 'confirm_noun' => 'message', 'confirm' => 'This cannot be undone.', ), ), 'columns' => array( array( 'key' => 'id', 'label' => 'ID', 'type' => 'id', 'sortable' => true, 'hidden' => true ), array( 'key' => 'select', 'label' => '', 'type' => 'selector', 'width' => '28px', 'sortable' => false ), array( 'key' => 'created_at', 'label' => sprintf( __( 'Date (%s)', 'ai-eshop-optimizer' ), wp_timezone_string() ), 'type' => 'datetime', 'nowrap' => true, 'sortable' => true, 'format' => array( 'tz' => 'utc' ), ), array( 'key' => 'status', 'label' => 'Status', 'type' => 'badge', 'sortable' => true, 'filter' => 'select', 'counts' => true, 'format' => array( 'labels' => $aieo_cfm_statuses, 'map' => array( 'new' => 'warning', 'read' => 'secondary', 'replied' => 'success', 'spam' => 'danger', ), ), ), array( 'key' => 'who', 'label' => 'From', 'type' => 'link', 'subline' => 'email', 'sortable' => true, 'searchable' => true, 'format' => array( 'href' => 'detail_url' ), ), array( 'key' => 'email', 'label' => 'Email', 'type' => 'text', 'searchable' => true, 'hidden' => true ), array( 'key' => 'company', 'label' => 'Company', 'type' => 'text', 'sortable' => true, 'searchable' => true, 'empty' => '—' ), array( 'key' => 'country', 'label' => 'Country', 'type' => 'text', 'sortable' => true, 'empty' => '—' ), array( 'key' => 'excerpt', 'label' => 'Message', 'type' => 'text', 'empty' => '—' ), array( 'key' => 'phone', 'label' => 'Phone', 'type' => 'text', 'searchable' => true, 'hidden' => true ), array( 'key' => 'city', 'label' => 'City', 'type' => 'text', 'searchable' => true, 'hidden' => true ), array( 'key' => 'message', 'label' => 'Full message', 'type' => 'text', 'searchable' => true, 'hidden' => true ), array( 'key' => 'detail_url', 'label' => 'Link', 'type' => 'text', 'hidden' => true ), ), );