| @@ -1,127 +1,51 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | 2 | /** |
| 4 | 3 | * The main plugin file for Posts Table with Search & Sort. |
| 5 | 4 | * |
| 5 | + * @package Barn2\posts-table-search-sort | |
| 6 | + * @author Barn2 Plugins <support@barn2.com> | |
| 7 | + * @license GPL-3.0 | |
| 8 | + * @copyright Barn2 Media Ltd | |
| 9 | + * | |
| 6 | 10 | * @wordpress-plugin |
| 7 | 11 | * Plugin Name: Posts Table with Search & Sort |
| 8 | 12 | * Plugin URI: https://wordpress.org/plugins/posts-data-table/ |
| 9 | - * Description: Provides a shortcode to show a list of your posts in an instantly searchable & sortable table. | |
| 10 | - * Version: 1.2 | |
| 11 | - * Author: Barn2 Media | |
| 12 | - * Author URI: https://barn2.co.uk | |
| 13 | + * Description: List your posts in an instantly searchable & sortable table. | |
| 14 | + * Version: 1.4.13 | |
| 15 | + * Author: Barn2 Plugins | |
| 16 | + * Author URI: https://barn2.com | |
| 13 | 17 | * Text Domain: posts-data-table |
| 14 | 18 | * Domain Path: /languages |
| 15 | 19 | * |
| 16 | - * Copyright: Barn2 Media Ltd | |
| 17 | - * License: GNU General Public License v3.0 | |
| 18 | - * License URI: https://www.gnu.org/licenses/gpl.html | |
| 20 | + * Requires at least: 6.1 | |
| 21 | + * Requires PHP: 7.4 | |
| 22 | + * | |
| 23 | + * Copyright: Barn2 Media Ltd | |
| 24 | + * License: GNU General Public License v3.0 | |
| 25 | + * License URI: https://www.gnu.org/licenses/gpl.html | |
| 19 | 26 | */ |
| 20 | 27 | |
| 21 | -namespace Barn2\Plugin\Posts_Table_Search_Sort { | |
| 28 | +namespace Barn2\Plugin\Posts_Table_Search_Sort; | |
| 22 | 29 | |
| 23 | - // Prevent direct file access | |
| 24 | - if ( ! defined( '\ABSPATH' ) ) { | |
| 25 | - exit; | |
| 26 | - } | |
| 30 | +// Prevent direct file access | |
| 31 | +if ( ! defined( '\ABSPATH' ) ) { | |
| 32 | + exit; | |
| 33 | +} | |
| 27 | 34 | |
| 28 | - use Barn2\Lib\Util; | |
| 35 | +const PLUGIN_VERSION = '1.4.13'; | |
| 36 | +const PLUGIN_FILE = __FILE__; | |
| 29 | 37 | |
| 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 | +// Autoloader. | |
| 39 | +require_once __DIR__ . '/vendor/autoload.php'; | |
| 38 | 40 | |
| 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(); | |
| 41 | +/** | |
| 42 | + * Helper function to access the shared plugin instance. | |
| 43 | + * | |
| 44 | + * @return Plugin | |
| 45 | + */ | |
| 46 | +function posts_table_search_sort() { | |
| 47 | + return Plugin_Factory::create( PLUGIN_FILE, PLUGIN_VERSION ); | |
| 117 | 48 | } |
| 118 | 49 | |
| 119 | -namespace { | |
| 120 | - | |
| 121 | - if ( ! function_exists( 'posts_table_search_sort' ) ) { | |
| 122 | - | |
| 123 | - function posts_table_search_sort() { | |
| 124 | - return \Barn2\Plugin\Posts_Table_Search_Sort\Plugin::instance(); | |
| 125 | - } | |
| 126 | - } | |
| 127 | -} | |
| 50 | +// Load the plugin. | |
| 51 | +posts_table_search_sort()->register(); | |