| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* This class handles the posts table shortcode registration. |
| 5 |
* |
| 6 |
* @package Posts_Data_Table |
| 7 |
* @author Barn2 Media <info@barn2.co.uk> |
| 8 |
* @license GPL-3.0 |
| 9 |
* @link https://barn2.co.uk |
| 10 |
* @copyright 2016-2017 Barn2 Media Ltd |
| 11 |
*/ |
| 12 |
// Prevent direct file access |
| 13 |
if ( !defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
class Posts_Data_Table_Shortcode { |
| 18 |
|
| 19 |
private $shortcode = 'posts_data_table'; |
| 20 |
|
| 21 |
public function __construct() { |
| 22 |
// Register shortcode |
| 23 |
add_shortcode( $this->shortcode, array( $this, 'shortcode' ) ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Handles our posts data table shortcode. |
| 28 |
* |
| 29 |
* @param array $atts The shortcode attributes specified by the user. |
| 30 |
* @param string $content The content between the open and close shortcode tags (not used) |
| 31 |
* @return string The shortcode output |
| 32 |
*/ |
| 33 |
public function shortcode( $atts, $content = '' ) { |
| 34 |
// Parse attributes |
| 35 |
$atts = shortcode_atts( Posts_Data_Table_Simple::$default_args, $atts, $this->shortcode ); |
| 36 |
|
| 37 |
// Create table and return output |
| 38 |
$table = new Posts_Data_Table_Simple(); |
| 39 |
return $table->get_table( $atts ); |
| 40 |
} |
| 41 |
|
| 42 |
} |