2017 © Pedro Peláez
 

library wptables

A fluent implementation of WordPress WP List Table for WP Bones

image

wpbones/wptables

A fluent implementation of WordPress WP List Table for WP Bones

  • Saturday, February 11, 2017
  • by gfazioli
  • Repository
  • 1 Watchers
  • 1 Stars
  • 56 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 4 % Grown

The README.md

WP Tables for WP Bones

[![Latest Stable Version](https://poser.pugx.org/wpbones/wptables/v/stable?style=for-the-badge)](https://packagist.org/packages/wpbones/wptables)   [![Latest Unstable Version](https://poser.pugx.org/wpbones/wptables/v/unstable?style=for-the-badge)](https://packagist.org/packages/wpbones/wptables)   [![Total Downloads](https://poser.pugx.org/wpbones/wptables/downloads?style=for-the-badge)](https://packagist.org/packages/wpbones/wptables)   [![License](https://poser.pugx.org/wpbones/wptables/license?style=for-the-badge)](https://packagist.org/packages/wpbones/wptables)   [![Monthly Downloads](https://poser.pugx.org/wpbones/wptables/d/monthly?style=for-the-badge)](https://packagist.org/packages/wpbones/wptables)

, (*1)

images, (*2)

A fluent implementation of WordPress WP List Table for WP Bones, (*3)

Requirements

This package works with a WordPress plugin written with WP Bones framework library., (*4)

Installation

You can install third party packages by using:, (*5)

```sh copy php bones require wpbones/wptables, (*6)


I advise to use this command instead of `composer require` because doing this an automatic renaming will done. You can use composer to install this package: ```sh copy composer require wpbones/wptables

You may also to add "wpbones/wptables": "^1.0" in the composer.json file of your plugin:, (*7)

```json copy filename="composer.json" {4} "require": { "php": ">=7.4", "wpbones/wpbones": "~0.8", "wpbones/wptables": "~1.0" },, (*8)


and run ```sh copy composer install

How to

You can use WP Tables either like subclass or like fluent class instance., (*9)

Subclassing

As subclass class instance you may create a your own class as show below:, (*10)

```php copy <?php, (*11)

namespace WPKirk\Http\Controllers;, (*12)

use WPKirk\WPTables\Html\WPTable;, (*13)

class ExampleTable extends WPTable {, (*14)

protected $name = 'Discos';, (*15)

public function getColumnsAttribute() { return [ 'id' => 'Name', 'description' => 'Description', ]; }, (*16)

public function getItems( $args = [] ) {, (*17)

$fake = [];

for( $i = 0; $i < 20; $i++ ) {
  $fake[] = [
    'id' => "Example {$i}",
    'description' => 'Some description...'
  ];
}

return $fake;

} }, (*18)


In your view controller you have to use the `load` method in order to register the screen options: ```php copy ... public function load() { ExampleTable::registerScreenOption(); } public function index() { $table = new ExampleTable(); return WPKirk() ->view( 'dashboard.table' ) ->with( 'table', $table ); } ...

In your ExampleTable you may override:, (*19)


public function getCheckBoxValueAttribute( $item ) { return $item[ 'my_colum' ]; } // or public function getCheckBoxColumnNameAttribute() { return 'my_colum'; }

This will be the value used in the checkbox value., (*20)

Fluent

If you like use the WPTable as fluent instance, you have to set the columns twice., (*21)

```php copy ... public function loadFluentExample() { WPTable::name( 'Books' ) ->columns( [ 'id' => 'Name', 'description' => 'Description', ] ) ->screenOptionLabel( 'Rows' ) ->registerScreenOption(); }, (*22)

public function indexFluentExample() {, (*23)

$items = [];

for ( $i = 0; $i < 20; $i++ ) {
  $items[] = [
    'id'          => "Book {$i}",
    'description' => 'Some description...',
  ];
}

$table = WPTable::name( 'Books' )
                ->singular( 'Book' )
                ->plural( 'Books' )
                ->columns(
                  [
                    'id'          => 'Name',
                    'description' => 'Description',
                  ]
                )
                ->setItems( $items );

return WPKirk()
  ->view( 'dashboard.table' )
  ->with( 'table', $table );

}, (*24)

```, (*25)

The Versions

11/02 2017

dev-master

9999999-dev https://github.com/wpbones/wptables

A fluent implementation of WordPress WP List Table for WP Bones

  Sources   Download

MIT

wp bones wp table

11/02 2017

dev-develop

dev-develop https://github.com/wpbones/wptables

A fluent implementation of WordPress WP List Table for WP Bones

  Sources   Download

MIT

wp bones wp table

07/01 2017

1.0.2

1.0.2.0 https://github.com/wpbones/wptables

A fluent implementation of WordPress WP List Table for WP Bones

  Sources   Download

MIT

wp bones wp table

28/12 2016

1.0.1

1.0.1.0 https://github.com/wpbones/wptables

A fluent implementation of WordPress WP List Table for WP Bones

  Sources   Download

MIT

wp bones wp table

27/12 2016

1.0.0

1.0.0.0 https://github.com/wpbones/wptables

A fluent implementation of WordPress WP List Table for WP Bones

  Sources   Download

MIT

wp bones wp table