PluginProbe
Posts Table with Search & Sort / 1.4.13
Posts Table with Search & Sort v1.4.13
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 +36 -109 1.11.4.13 View file →
@@ -1,124 +1,51 @@
1 1 <?php
2 -
3 2 /**
4 3 * The main plugin file for Posts Table with Search & Sort.
5 4 *
6 - * @package Posts_Data_Table
7 - * @author Barn2 Media <info@barn2.co.uk>
8 - * @license GPLv3
9 - * @link http://barn2.co.uk
10 - * @copyright 2016-2017 Barn2 Media Ltd
5 + * @package Barn2\posts-table-search-sort
6 + * @author Barn2 Plugins <support@barn2.com>
7 + * @license GPL-3.0
8 + * @copyright Barn2 Media Ltd
11 9 *
12 10 * @wordpress-plugin
13 - * Plugin Name: Posts Table with Search & Sort
14 - * Description: Provides a shortcode to show a list of your posts in an instantly searchable & sortable table.
15 - * Version: 1.1
16 - * Author: Barn2 Media
17 - * Author URI: https://barn2.co.uk
18 - * Text Domain: posts-data-table
19 - * Domain Path: /languages
20 - * License: GNU General Public License v3.0
21 - * License URI: http://www.gnu.org/licenses/gpl-3.0.html
11 + * Plugin Name: Posts Table with Search & Sort
12 + * Plugin URI: https://wordpress.org/plugins/posts-data-table/
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
17 + * Text Domain: posts-data-table
18 + * Domain Path: /languages
19 + *
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
22 26 */
27 +
28 +namespace Barn2\Plugin\Posts_Table_Search_Sort;
29 +
23 30 // Prevent direct file access
24 -if ( !defined( 'ABSPATH' ) ) {
31 +if ( ! defined( '\ABSPATH' ) ) {
25 32 exit;
26 33 }
27 34
28 -// Current version of this plugin
29 -define( 'POSTS_DATA_TABLE_VERSION', '1.1' );
35 +const PLUGIN_VERSION = '1.4.13';
36 +const PLUGIN_FILE = __FILE__;
30 37
31 -class Posts_Data_Table_Plugin {
38 +// Autoloader.
39 +require_once __DIR__ . '/vendor/autoload.php';
32 40
33 - public function __construct() {
34 - $this->includes();
35 -
36 - add_action( 'plugins_loaded', array( $this, 'maybe_load_plugin' ) );
37 - add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_settings_link' ) );
38 - }
39 -
40 - private function includes() {
41 - $includes = plugin_dir_path( __FILE__ ) . 'includes/';
42 -
43 - require_once $includes . 'class-posts-data-table-simple.php';
44 - require_once $includes . 'class-posts-data-table-shortcode.php';
45 - }
46 -
47 - public function maybe_load_plugin() {
48 - // Don't init plugin if Pro version exists
49 - if ( class_exists( 'Posts_Table_Pro_Plugin' ) ) {
50 - return;
51 - }
52 -
53 - // Load the text domain - should go on 'plugins_loaded' hook
54 - $this->load_textdomain();
55 -
56 - add_action( 'init', array( $this, 'init' ) );
57 - }
58 -
59 - public function load_textdomain() {
60 - load_plugin_textdomain( 'posts-data-table', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
61 - }
62 -
63 - public function init() {
64 - new Posts_Data_Table_Shortcode();
65 -
66 - // Register styles and scripts
67 - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) );
68 - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
69 - }
70 -
71 - public function register_styles() {
72 - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : 'min.';
73 -
74 - wp_enqueue_style( 'jquery-data-tables', plugins_url( 'assets/css/datatables.min.css', __FILE__ ), array(), '1.10.15' );
75 - wp_enqueue_style( 'posts-data-table', plugins_url( "assets/css/posts-data-table.{$suffix}css", __FILE__ ), array( 'jquery-data-tables' ), POSTS_DATA_TABLE_VERSION );
76 - }
77 -
78 - public function register_scripts() {
79 - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : 'min.';
80 -
81 - wp_enqueue_script( 'jquery-data-tables', plugins_url( "assets/js/datatables.{$suffix}js", __FILE__ ), array( 'jquery' ), '1.10.15', true );
82 - wp_enqueue_script( 'posts-data-table', plugins_url( "assets/js/posts-data-table.{$suffix}js", __FILE__ ), array( 'jquery-data-tables' ), POSTS_DATA_TABLE_VERSION, true );
83 -
84 - $locale = get_locale();
85 - $supported_locales = $this->get_supported_locales();
86 -
87 - // Add language file to script if locale is supported (English file is not added as this is the default language)
88 - if ( array_key_exists( $locale, $supported_locales ) ) {
89 - wp_localize_script( 'posts-data-table', 'posts_data_table', array(
90 - 'langurl' => $supported_locales[$locale]
91 - ) );
92 - }
93 - }
94 -
95 - public function add_plugin_settings_link( $links ) {
96 - $links[] = sprintf( '<a href="%1$s" target="_blank">%2$s</a>', esc_url( 'https://barn2.co.uk/wordpress-plugins/posts-table-pro/' ), __( 'Pro Version', 'posts-data-table' ) );
97 - return $links;
98 - }
99 -
100 - /**
101 - * Returns an array of locales supported by the plugin.
102 - * The array returned uses the locale as the array key mapped to the URL of the corresponding translation file.
103 - *
104 - * @return array The supported locales
105 - */
106 - private function get_supported_locales() {
107 - $lang_file_base_url = plugins_url( 'languages/data-tables/', __FILE__ );
108 -
109 - return array(
110 - 'es_ES' => $lang_file_base_url . 'Spanish.json',
111 - 'fr_FR' => $lang_file_base_url . 'French.json',
112 - 'fr_BE' => $lang_file_base_url . 'French.json',
113 - 'fr_CA' => $lang_file_base_url . 'French.json',
114 - 'de_DE' => $lang_file_base_url . 'German.json',
115 - 'de_CH' => $lang_file_base_url . 'German.json',
116 - 'el' => $lang_file_base_url . 'Greek.json',
117 - 'el_EL' => $lang_file_base_url . 'Greek.json',
118 - );
119 - }
120 -
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 );
121 48 }
122 -// end class
123 49
124 -$posts_data_table = new Posts_Data_Table_Plugin();
50 +// Load the plugin.
51 +posts_table_search_sort()->register();