PluginProbe
Posts Table with Search & Sort / 1.2
Posts Table with Search & Sort v1.2
trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2 1.3 1.3.1 1.3.1-v2 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 All 39 releases
posts-data-table / includes / class-table-shortcode.php

class-table-shortcode.php in Posts Table with Search & Sort 1.2, at includes/class-table-shortcode.php

42 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Barn2\Plugin\Posts_Table_Search_Sort;
4
5 // Prevent direct file access
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 /**
11 * This class handles the posts table shortcode registration.
12 *
13 * @author Barn2 Media <info@barn2.co.uk>
14 * @license GPL-3.0
15 * @copyright Barn2 Media Ltd
16 */
17 class Table_Shortcode implements \Barn2\Lib\Attachable {
18
19 const SHORTCODE = 'posts_table';
20
21 public function attach() {
22 add_shortcode( self::SHORTCODE, array( $this, 'do_shortcode' ) );
23 add_shortcode( 'posts_data_table', array( $this, 'do_shortcode' ) ); // back compat: support old 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 do_shortcode( $atts, $content = '' ) {
34 // Parse attributes
35 $atts = shortcode_atts( Simple_Posts_Table::get_defaults(), $atts, self::SHORTCODE );
36
37 // Create table and return output
38 $table = new Simple_Posts_Table();
39 return $table->get_table( $atts );
40 }
41 }
42