'Title' * * @since 3.1.0 * @access public * * @return array */ public function getColumns() { $columns = [ 'cb' => '', 'image' => 'Thumb', 'title' => 'Title', 'external_id' => 'SKU', 'user_schedule_time' => 'Shedule time' ]; return $columns; } /** * Prepares the list of items for displaying. * @uses WP_List_Table::set_pagination_args() * * @since 3.1.0 * @access public */ public function prepareItems() { $current_page = $this->getPagenum(); $db = Db::getInstance()->getDb(); $importer = AffiliateImporter::getInstance()->getImporter($this->getType()); $sql = 'SELECT count(*) FROM ' . $importer->getTableName('goods_archive') . ' where user_schedule_time is not null and user_schedule_time <> "0000-00-00 00:00:00" '; $total = $db->get_var($sql); $sql = 'SELECT ' . $importer->getTableName('goods_archive') . '.* FROM ' . $importer->getTableName('goods_archive') . ' where user_schedule_time is not null and user_schedule_time <> "0000-00-00 00:00:00" order by %s limit ' . (($current_page - 1) * 20) . ',20'; $this->items = $db->get_results( $db->prepare( $sql, (isset($_GET['orderby']) ? sanitize_text_field($_GET['orderby']) . ' ' . sanitize_text_field($_GET['order']) : 'title desc') ) ); $this->setPagination(['total_items' => $total, 'per_page' => 20]); $this->initTable(); } public function columnCb($item) { return sprintf( '', $item->external_id ); } /** * @return array * @override */ public function getBulkActions() { $actions = [ 'unshedule' => 'Remove from shedule' ]; return $actions; } public function needLoadMoreDetail($item) { foreach (get_object_vars($item) as $f => $val) { if (!is_array($val) && (string)$val === '#needload#') { return true; } } return false; } public function getId($item) { return $this->getType() . '#' . $item->external_id; } /** * @return mixed */ public function getType() { return $this->type; } /** * @param mixed $type */ public function setType($type) { $this->type = $type; } /** * Get a list of sortable columns. The format is: * 'internal-name' => 'orderby' * or * 'internal-name' => array( 'orderby', true ) * * The second format will make the initial sorting order be descending * * @since 3.1.0 * @access protected * * @return array */ protected function getSortableColumns() { return [ 'external_id' => ['external_id', false], 'title' => ['title', false], 'user_schedule_time' => ['user_schedule_time', false] ]; } protected function columnImage($item) { return ''; } protected function columnTitle($item) { $actions = []; $product = ProductFactory::getWithId($this->getType() . '#' . $item->external_id); $actions['id'] = 'Product page' . "seller_url ? "" : "style='display:none'") . "> | Seller page"; // $actions['import'] = $goods->post_id ? 'Posted' : 'Post to Woocommerce'; $actions['load_more_detail'] = $product->isNeedLoad() ? 'Load more details' : 'Details loaded'; $actions['schedule_import'] = 'Schedule Post'; // $cat_name = ""; // foreach ($this->link_categories as $c) { // if ($c['term_id'] === $item->link_category_id) { // $cat_name = $c['name']; // break; // } // } $html = ProductAddTable::putField($product, "title", true, "edit", "Title", "") . ProductAddTable::putField($product, 'subtitle', true, "edit", "Subtitle", "subtitle-block") . ProductAddTable::putField($product, 'keywords', true, "edit", "Keywords", "subtitle-block") . ProductAddTable::putDescriptionEdit($product); // $html .= $item->title . ''; $html .= $this->rowActions($actions); return $html; } }