| 1 |
<?php |
| 2 |
namespace Barn2\Plugin\Posts_Table_Search_Sort; |
| 3 |
|
| 4 |
use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Registerable; |
| 5 |
use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Service\Standard_Service; |
| 6 |
|
| 7 |
/** |
| 8 |
* This class handles the posts table shortcode registration. |
| 9 |
* |
| 10 |
* @package Barn2\posts-table-search-sort |
| 11 |
* @author Barn2 Plugins <support@barn2.com> |
| 12 |
* @license GPL-3.0 |
| 13 |
* @copyright Barn2 Media Ltd |
| 14 |
*/ |
| 15 |
class Table_Shortcode implements Registerable, Standard_Service { |
| 16 |
|
| 17 |
const SHORTCODE = 'posts_table'; |
| 18 |
|
| 19 |
public function register() { |
| 20 |
add_shortcode( self::SHORTCODE, [ $this, 'do_shortcode' ] ); |
| 21 |
add_shortcode( 'posts_data_table', [ $this, 'do_shortcode' ] ); // back compat: support old shortcode |
| 22 |
} |
| 23 |
|
| 24 |
/** |
| 25 |
* Handles our posts data table shortcode. |
| 26 |
* |
| 27 |
* @param array $atts The shortcode attributes specified by the user. |
| 28 |
* @param string $content The content between the open and close shortcode tags (not used) |
| 29 |
* @return string The shortcode output |
| 30 |
*/ |
| 31 |
public function do_shortcode( $atts, $content = '' ) { |
| 32 |
// Parse attributes |
| 33 |
$atts = shortcode_atts( Simple_Posts_Table::get_defaults(), $atts, self::SHORTCODE ); |
| 34 |
|
| 35 |
// Create table and return output |
| 36 |
$table = new Simple_Posts_Table(); |
| 37 |
return $table->get_table( $atts ); |
| 38 |
} |
| 39 |
|
| 40 |
} |
| 41 |
|