PluginProbe
Posts Table with Search & Sort / 1.2
Posts Table with Search & Sort v1.2
1.4.13 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 All 40 releases
← All changes | posts-data-table.php +106 -18 1.31.2 View file →
@@ -6,34 +6,122 @@
6 6 * @wordpress-plugin
7 7 * Plugin Name: Posts Table with Search & Sort
8 8 * Plugin URI: https://wordpress.org/plugins/posts-data-table/
9 9 * Description: Provides a shortcode to show a list of your posts in an instantly searchable & sortable table.
10 - * Version: 1.3
10 + * Version: 1.2
11 11 * Author: Barn2 Media
12 12 * Author URI: https://barn2.co.uk
13 13 * Text Domain: posts-data-table
14 14 * Domain Path: /languages
15 15 *
16 - * Copyright: Barn2 Media Ltd
17 - * License: GNU General Public License v3.0
18 - * License URI: https://www.gnu.org/licenses/gpl.html
16 + * Copyright: Barn2 Media Ltd
17 + * License: GNU General Public License v3.0
18 + * License URI: https://www.gnu.org/licenses/gpl.html
19 19 */
20 -namespace Barn2\Plugin\Posts_Table_Search_Sort;
21 20
22 -// Prevent direct file access
23 -if ( ! defined( '\ABSPATH' ) ) {
24 - exit;
21 +namespace Barn2\Plugin\Posts_Table_Search_Sort {
22 +
23 + // Prevent direct file access
24 + if ( ! defined( '\ABSPATH' ) ) {
25 + exit;
26 + }
27 +
28 + use Barn2\Lib\Util;
29 +
30 + /**
31 + * The main plugin class.
32 + *
33 + * @author Barn2 Media <info@barn2.co.uk>
34 + * @license GPL-3.0
35 + * @copyright Barn2 Media Ltd
36 + */
37 + final class Plugin {
38 +
39 + const VERSION = '1.2';
40 + const FILE = __FILE__;
41 +
42 + private $helpers;
43 +
44 + /**
45 + * The singleton instance
46 + */
47 + private static $_instance = null;
48 +
49 + public static function instance() {
50 + if ( is_null( self::$_instance ) ) {
51 + self::$_instance = new self();
52 + }
53 + return self::$_instance;
54 + }
55 +
56 + public function load() {
57 + add_action( 'plugins_loaded', array( $this, 'maybe_load_plugin' ) );
58 + }
59 +
60 + private function includes() {
61 + require_once __DIR__ . '/includes/lib/interface-attachable.php';
62 + require_once __DIR__ . '/includes/lib/class-util.php';
63 + require_once __DIR__ . '/includes/lib/class-wp-settings-api-helper.php';
64 +
65 + require_once __DIR__ . '/includes/class-settings.php';
66 + require_once __DIR__ . '/includes/class-simple-posts-table.php';
67 + require_once __DIR__ . '/includes/class-frontend-scripts.php';
68 + require_once __DIR__ . '/includes/class-table-shortcode.php';
69 + require_once __DIR__ . '/includes/deprecated.php';
70 +
71 + require_once __DIR__ . '/includes/admin/class-admin-controller.php';
72 + require_once __DIR__ . '/includes/admin/class-admin-settings-page.php';
73 + }
74 +
75 + private function define_constants() {
76 + define( 'PTSS_PLUGIN_BASENAME', plugin_basename( self::FILE ) );
77 + }
78 +
79 + public function maybe_load_plugin() {
80 + // Don't load plugin if Pro version active
81 + if ( class_exists( '\Posts_Table_Pro_Plugin' ) ) {
82 + return;
83 + }
84 +
85 + add_action( 'init', array( $this, 'init' ) );
86 + }
87 +
88 + public function init() {
89 + $this->includes();
90 + $this->define_constants();
91 + $this->load_textdomain();
92 +
93 + $this->helpers = array();
94 +
95 + if ( Util::is_admin() ) {
96 + $this->helpers['admin'] = new Admin_Controller();
97 + }
98 +
99 + if ( Util::is_front_end() ) {
100 + // Register the posts table shortcode
101 + $this->helpers['shortcode'] = new Table_Shortcode();
102 + $this->helpers['scripts'] = new Frontend_Scripts();
103 + }
104 +
105 + foreach ( $this->helpers as $attachable ) {
106 + $attachable->attach();
107 + }
108 + }
109 +
110 + private function load_textdomain() {
111 + load_plugin_textdomain( 'posts-data-table', false, dirname( plugin_basename( self::FILE ) ) . '/languages' );
112 + }
113 + }
114 +
115 + // Load the plugin
116 + Plugin::instance()->load();
25 117 }
26 118
27 -const PLUGIN_VERSION = '1.3';
28 -const PLUGIN_FILE = __FILE__;
119 +namespace {
29 120
30 -// Autoloader.
31 -require_once plugin_dir_path( __FILE__ ) . 'autoloader.php';
121 + if ( ! function_exists( 'posts_table_search_sort' ) ) {
32 122
33 -// Helper function to access the shared plugin instance.
34 -function posts_table_search_sort() {
35 - return Plugin_Factory::create( PLUGIN_FILE, PLUGIN_VERSION );
123 + function posts_table_search_sort() {
124 + return \Barn2\Plugin\Posts_Table_Search_Sort\Plugin::instance();
125 + }
126 + }
36 127 }
37 -
38 -// Load the plugin.
39 -posts_table_search_sort()->register();