'board', //singular name of the listed records 'plural' => 'boards', //plural name of the listed records 'ajax' => false, //does this table support ajax? 'screen' => 'wpForoBoards', ] ); } function column_default( $item, $column_name ) { return $item[ $column_name ]; } function column_pageid( $item ) { return ( (get_post( $item['pageid'] )) ? ( ( $edit_post_link = get_edit_post_link( $item['pageid'] ) ) ? '' . $item['pageid'] . '' : $item['pageid'] ) : '' . $item['pageid'] . ' ' . __( 'not found', 'wpforo' ) . '' ); } function column_status( $item ) { return ( $item['status'] ? '' . __( 'YES', 'wpforo' ) . '' : '' . __( 'NO', 'wpforo' ) . '' ); } function column_is_standalone( $item ) { return ( $item['is_standalone'] ? '' . __( 'YES', 'wpforo' ) . '' : '' . __( 'NO', 'wpforo' ) . '' ); } /** ************************************************************************ * Recommended. This is a custom column method and is responsible for what * is rendered in any column with a name/slug of 'title'. Every time the class * needs to render a column, it first looks for a method named * column_{$column_title} - if it exists, that method is run. If it doesn't * exist, column_default() is called instead. * * This example also illustrates how to implement rollover actions. Actions * should be an associative array formatted as 'slug'=>'link html' - and you * will need to generate the URLs yourself. You could even ensure the links * * * @param array $item A singular item (one full row's worth of data) * * @return string Text to be placed inside the column (movie title only) **************************************************************************@see WP_List_Table::::single_row_columns() */ function column_boardid( $item ) { $ehref = admin_url( sprintf( 'admin.php?page=%1$s&wpfaction=%2$s&boardid=%3$s', 'wpforo-boards', 'wpforo_board_save_form', $item['boardid'] ) ); $vhref = wpforo_url( '', $item['slug'] ); $shref = rtrim( wpforo_url( 'sitemap.xml', $item['slug'] ), '/' ); $rhref = wp_nonce_url( admin_url( sprintf( 'admin.php?page=%1$s&wpfaction=%2$s&boardid=%3$s', 'wpforo-boards', 'board_repair', $item['boardid'] ) ), 'wpforo-board-repair-' . $item['boardid'] ); $dhref = wp_nonce_url( admin_url( sprintf( 'admin.php?page=%1$s&wpfaction=%2$s&boardid=%3$s', 'wpforo-boards', 'board_delete', $item['boardid'] ) ), 'wpforo-board-delete-' . $item['boardid'] ); //Build row actions $actions = [ 'edit' => '' . __( 'Edit', 'wpforo' ) . '', 'view' => '' . __( 'View', 'wpforo' ) . '', 'sitemap' => '' . __( 'Sitemap', 'wpforo' ) . '', 'repair' => '' . __( 'Repair', 'wpforo' ) . '', 'delete' => '' . __( 'Delete', 'wpforo' ) . '', ]; if( ! $item['boardid'] ) unset( $actions['delete'] ); if( ! $item['status'] ) unset( $actions['view'] ); //Return the title contents return sprintf( '%1$s %2$s', /*$1%s*/ $item['boardid'], /*$2%s*/ $this->row_actions( $actions ) ); } /** ************************************************************************ * REQUIRED! This method dictates the table's columns and titles. This should * return an array where the key is the column slug (and class) and the value * is the column's title text. If you need a checkbox for bulk actions, refer * to the $columns array below. * * The 'cb' column is treated differently than the rest. If including a checkbox * column in your table you must create a column_cb() method. If you don't need * to bulk actions or checkboxes, simply leave the 'cb' entry out of your array. * * @return array An associative array containing column information: 'slugs'=>'Visible Titles' **************************************************************************@see WP_List_Table::::single_row_columns() */ function get_columns() { return [ 'boardid' => __( 'boardid', 'wpforo' ), 'title' => __( 'title', 'wpforo' ), 'slug' => __( 'slug', 'wpforo' ), 'pageid' => __( 'pageid', 'wpforo' ), 'locale' => __( 'locale', 'wpforo' ), 'is_standalone' => __( 'is standalone', 'wpforo' ), 'status' => __( 'enabled', 'wpforo' ), ]; } /** ************************************************************************ * REQUIRED! This is where you prepare your data for display. This method will * usually be used to query the database, sort and filter the data, and generally * get it ready to be displayed. At a minimum, we should set $this->items and * $this->set_pagination_args(), although the following properties and methods * are frequently interacted with here... * * @uses $this->_column_headers * @uses $this->items * @uses $this->get_columns() * @uses $this->get_sortable_columns() * @uses $this->get_pagenum() * @uses $this->set_pagination_args() **************************************************************************/ function prepare_items() { /** * REQUIRED. Now we need to define our column headers. This includes a complete * array of columns to be displayed (slugs & titles), a list of columns * to keep hidden, and a list of columns that are sortable. Each of these * can be defined in another method (as we've done here) before being * used to build the value for our _column_headers property. */ $columns = $this->get_columns(); $hidden = []; $sortable = $this->get_sortable_columns(); /** * REQUIRED. Finally, we build an array to be used by the class for column * headers. The $this->_column_headers property takes an array which contains * 3 other arrays. One for all columns, one for hidden columns, and one * for sortable columns. */ $this->_column_headers = [ $columns, $hidden, $sortable ]; /** * REQUIRED. Now we can add our *sorted* data to the items' property, where * it can be used by the rest of the class. */ $this->items = WPF()->board->get_boards(); } }