'', 'subject' => __( 'Subject', 'flamingo' ), 'from' => __( 'From', 'flamingo' ), 'date' => __( 'Date', 'flamingo' ), ); $columns = apply_filters( 'manage_flamingo_outbound_posts_columns', $columns ); return $columns; } function __construct() { parent::__construct( array( 'singular' => 'post', 'plural' => 'posts', 'ajax' => false, ) ); } function prepare_items() { $current_screen = get_current_screen(); $per_page = $this->get_items_per_page( $current_screen->id . '_per_page' ); $this->_column_headers = $this->get_column_info(); $args = array( 'posts_per_page' => $per_page, 'offset' => ( $this->get_pagenum() - 1 ) * $per_page, 'orderby' => 'date', 'order' => 'DESC', ); if ( ! empty( $_REQUEST['s'] ) ) { $args['s'] = $_REQUEST['s']; } if ( ! empty( $_REQUEST['orderby'] ) ) { if ( 'subject' == $_REQUEST['orderby'] ) { $args['meta_key'] = '_subject'; $args['orderby'] = 'meta_value'; } elseif ( 'from' == $_REQUEST['orderby'] ) { $args['meta_key'] = '_from'; $args['orderby'] = 'meta_value'; } } if ( ! empty( $_REQUEST['order'] ) && 'asc' == strtolower( $_REQUEST['order'] ) ) { $args['order'] = 'ASC'; } if ( ! empty( $_REQUEST['m'] ) ) { $args['m'] = $_REQUEST['m']; } if ( ! empty( $_REQUEST['post_status'] ) ) { if ( 'trash' == $_REQUEST['post_status'] ) { $args['post_status'] = 'trash'; $this->is_trash = true; } } $this->items = Flamingo_Outbound_Message::find( $args ); $total_items = Flamingo_Outbound_Message::$found_items; $total_pages = ceil( $total_items / $per_page ); $this->set_pagination_args( array( 'total_items' => $total_items, 'total_pages' => $total_pages, 'per_page' => $per_page, ) ); } function get_views() { $status_links = array(); $post_status = empty( $_REQUEST['post_status'] ) ? '' : $_REQUEST['post_status']; // Inbox Flamingo_Outbound_Message::find( array( 'post_status' => 'any' ) ); $posts_in_inbox = Flamingo_Outbound_Message::$found_items; $inbox = sprintf( _nx( 'Inbox (%s)', 'Inbox (%s)', $posts_in_inbox, 'posts', 'flamingo' ), number_format_i18n( $posts_in_inbox ) ); $status_links['inbox'] = sprintf( '%3$s', menu_page_url( 'flamingo_outbound', false ), ( $this->is_trash ) ? '' : ' class="current"', $inbox ); // Trash Flamingo_Outbound_Message::find( array( 'post_status' => 'trash' ) ); $posts_in_trash = Flamingo_Outbound_Message::$found_items; if ( empty( $posts_in_trash ) ) { return $status_links; } $trash = sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $posts_in_trash, 'posts', 'flamingo' ), number_format_i18n( $posts_in_trash ) ); $status_links['trash'] = sprintf( '%3$s', esc_url( add_query_arg( array( 'post_status' => 'trash', ), menu_page_url( 'flamingo_outbound', false ) ) ), 'trash' == $post_status ? ' class="current"' : '', $trash ); return $status_links; } function get_columns() { return get_column_headers( get_current_screen() ); } function get_sortable_columns() { $columns = array( 'subject' => array( 'subject', false ), 'from' => array( 'from', false ), 'date' => array( 'date', true ), ); return $columns; } function get_bulk_actions() { $actions = array(); if ( $this->is_trash ) { $actions['untrash'] = __( 'Restore', 'flamingo' ); } if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { $actions['delete'] = __( 'Delete Permanently', 'flamingo' ); } else { $actions['trash'] = __( 'Move to Trash', 'flamingo' ); } return $actions; } function extra_tablenav( $which ) { ?>