# posts-data-table/1.4.13/src/Table_Shortcode.php

Posts Table with Search &amp; Sort, version 1.4.13. 41 lines.

- Page: https://pluginprobe.com/plugins/posts-data-table/1.4.13/code/src/Table_Shortcode.php
- Raw: https://pluginprobe.com/plugins/posts-data-table/1.4.13/raw/src/Table_Shortcode.php
- Modified: 2024-06-05T08:32:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/posts-data-table/1.4.13/code/src/Table_Shortcode.php#L10-L20`.

```php
<?php
namespace Barn2\Plugin\Posts_Table_Search_Sort;

use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Registerable;
use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Service\Standard_Service;

/**
 * This class handles the posts table shortcode registration.
 *
 * @package   Barn2\posts-table-search-sort
 * @author    Barn2 Plugins <support@barn2.com>
 * @license   GPL-3.0
 * @copyright Barn2 Media Ltd
 */
class Table_Shortcode implements Registerable, Standard_Service {

	const SHORTCODE = 'posts_table';

	public function register() {
		add_shortcode( self::SHORTCODE, [ $this, 'do_shortcode' ] );
		add_shortcode( 'posts_data_table', [ $this, 'do_shortcode' ] ); // back compat: support old shortcode
	}

	/**
	 * Handles our posts data table shortcode.
	 *
	 * @param array $atts The shortcode attributes specified by the user.
	 * @param string $content The content between the open and close shortcode tags (not used)
	 * @return string The shortcode output
	 */
	public function do_shortcode( $atts, $content = '' ) {
		// Parse attributes
		$atts = shortcode_atts( Simple_Posts_Table::get_defaults(), $atts, self::SHORTCODE );

		// Create table and return output
		$table = new Simple_Posts_Table();
		return $table->get_table( $atts );
	}

}

```
