'Terms', // Do not translate ( used for css class ) 'ajax' => false, ) ); $this->model = new \Falang\Model\Falang_Model(); $this->language_list = $this->model->get_languages_list(array( 'hide_default' => true)); } /** * Displays the item information in a column ( default case ) * * @since 1.0 * * @param object $item * @param string $column_name * @return string */ public function column_default( $item, $column_name ) { $language_list_locale = $this->model->get_available_locales(); switch ( $column_name ) { case 'original' : case 'context' : return esc_html( $item->$column_name ); default: //language column fr_FR, en_US, ... if (in_array($column_name,$language_list_locale)){ return $this->display_translation_term_action($item,$column_name); } else { return print_r( $item, true ); //Show the whole array for troubleshooting purposes } } } /** * Displays the item information in the column 'term_name' * * @since 1.0 * * @param object $item * @return string */ public function column_term_name( $item ) { return esc_html($item->name); } /** * Displays the id information in the column 'id' * * @since 1.0.6 * * @param object $item * @return string */ public function column_id( $item ) { return esc_html($item->id); } /** * Gets the list of columns * * @since 0.1 * * @return array the list of column titles */ public function get_columns() { //use term_name column name because it's make problem with name due to thickbox //and copy $columns = array( 'original' => __( 'Original', 'falang' ), 'context' => __( 'Context', 'falang' ), ); //add language column //language list is only non default language foreach ($this->language_list as $language){ $columns[$language->locale] = $language->get_flag(); } //add ID column to the end $columns['id'] = __( 'ID', 'falang' ); return $columns; } /** * Gets the name of the default primary column. * * @since 1.0 * * @return string Name of the default primary column, in this case, 'name'. */ protected function get_default_primary_column_name() { return 'original'; } /** * Prepares the list of items for displaying * * @since 0.1 * * @param array $data */ public function prepare_items( $data = array()) { // Filter for search post $s = empty( $_POST['s'] ) ? '' : wp_unslash( $_POST['s'] ); foreach ( $data as $key => $row ) { // if ( ( -1 !== $this->selected_group && $row['context'] !== $this->selected_group ) || ( ! empty( $s ) && stripos( $row['name'], $s ) === false && stripos( $row['string'], $s ) === false ) ) { if ( ( ! empty( $s ) && stripos( $row->original, $s ) === false && stripos( $row->original, $s ) === false ) ) { unset( $data[ $key ] ); } } $per_page = $this->get_items_per_page('falang_term_per_page'); $this->_column_headers = array( $this->get_columns(), array(), $this->get_sortable_columns() ); $total_items = count( $data ); $this->items = array_slice( $data, ( $this->get_pagenum() - 1 ) * $per_page, $per_page ); $this->set_pagination_args( array( 'total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil( $total_items / $per_page ), ) ); } // status filter links // http://wordpress.stackexchange.com/questions/56883/how-do-i-create-links-at-the-top-of-wp-list-table function get_views() { $views = array(); //TODO check remove query args $base_url = esc_url_raw( remove_query_arg( array( 'term_type' ) ) ); // handle search query if ( isset($_REQUEST['s']) && $_REQUEST['s'] ) { $base_url = add_query_arg( 's', $_REQUEST['s'], $base_url ); } // handle term_type filter if ( isset($_REQUEST['tt-filter']) && $_REQUEST['tt-filter'] ) { $base_url = add_query_arg( 'taxo_type', $_REQUEST['tt-filter'], $base_url ); } return $views; } /** * Add extra markup in the toolbars before or after the list * @param string $which, helps you decide if you add the markup after (bottom) or before (top) the list */ //TODO not yet working function _____extra_tablenav( $which ) { if ( 'top' != $which ) return; $taxonomy_types = $this->model->get_transtable_taxonomy_types(true); ?>