PluginProbe
Posts Table with Search & Sort / 1.4.11
Posts Table with Search & Sort v1.4.11
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 | src/Frontend_Scripts.php +61 -52 1.3.21.4.11 View file →
@@ -1,77 +1,86 @@
1 1 <?php
2 +
2 3 namespace Barn2\Plugin\Posts_Table_Search_Sort;
3 4
4 -use Barn2\PTS_Lib\Util,
5 - Barn2\PTS_Lib\Registerable,
6 - Barn2\PTS_Lib\Plugin\Plugin,
7 - Barn2\PTS_Lib\Service;
5 +use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Plugin\Plugin;
6 +use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Registerable;
7 +use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Service\Standard_Service;
8 +use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Util;
8 9
9 10 /**
10 11 * Registers the frontend styles and scripts for the post tables.
11 12 *
12 13 * @package Barn2\posts-table-search-sort
13 - * @author Barn2 Plugins <support@barn2.co.uk>
14 + * @author Barn2 Plugins <support@barn2.com>
14 15 * @license GPL-3.0
15 16 * @copyright Barn2 Media Ltd
16 17 */
17 -class Frontend_Scripts implements Registerable, Service {
18 +class Frontend_Scripts implements Registerable, Standard_Service {
18 19
19 - const DATATABLES_VERSION = '1.10.21';
20 + const DATATABLES_VERSION = '1.11.3';
20 21
21 - private $plugin;
22 + private $plugin;
22 23
23 - public function __construct( Plugin $plugin ) {
24 - $this->plugin = $plugin;
25 - }
24 + public function __construct( Plugin $plugin ) {
25 + $this->plugin = $plugin;
26 + }
26 27
27 - public function register() {
28 - add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) );
29 - add_action( 'wp_enqueue_scripts', array( $this, 'register_scripts' ) );
30 - }
28 + public function register() {
29 + add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ] );
30 + add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ] );
31 + }
31 32
32 - public function register_styles() {
33 - $suffix = Util::get_script_suffix();
33 + public function register_styles() {
34 + $suffix = Util::get_script_suffix();
34 35
35 - wp_register_style( 'jquery-data-tables', plugins_url( 'assets/js/datatables/datatables.min.css', $this->plugin->get_file() ), array(), self::DATATABLES_VERSION );
36 - wp_register_style( 'posts-data-table', plugins_url( "assets/css/posts-data-table{$suffix}.css", $this->plugin->get_file() ), array( 'jquery-data-tables' ), $this->plugin->get_version() );
37 - }
36 + wp_register_style( 'jquery-datatables-pss', plugins_url( 'assets/js/datatables/datatables.min.css', $this->plugin->get_file() ), [], self::DATATABLES_VERSION );
37 + wp_register_style( 'posts-data-table', plugins_url( "assets/css/posts-data-table-main.css", $this->plugin->get_file() ), [ 'jquery-datatables-pss' ], $this->plugin->get_version() );
38 + }
38 39
39 - public function register_scripts() {
40 - $suffix = Util::get_script_suffix();
40 + public function register_scripts() {
41 + $suffix = Util::get_script_suffix();
41 42
42 - wp_register_script( 'jquery-data-tables', plugins_url( "assets/js/datatables/datatables.min.js", $this->plugin->get_file() ), array( 'jquery' ), self::DATATABLES_VERSION, true );
43 - wp_register_script( 'posts-data-table', plugins_url( "assets/js/posts-data-table{$suffix}.js", $this->plugin->get_file() ), array( 'jquery-data-tables' ), $this->plugin->get_version(), true );
43 + wp_register_script( 'jquery-datatables-pss', plugins_url( "assets/js/datatables/datatables{$suffix}.js", $this->plugin->get_file() ), [ 'jquery' ], self::DATATABLES_VERSION, true );
44 + wp_register_script( 'posts-data-table', plugins_url( "assets/js/posts-data-table-main.js", $this->plugin->get_file() ), [ 'jquery', 'jquery-datatables-pss' ], $this->plugin->get_version(), true );
44 45
45 - $locale = get_locale();
46 - $supported_locales = $this->get_supported_locales();
46 + $locale = get_locale();
47 + $supported_locales = $this->get_supported_locales();
47 48
48 - // Add language file to script if locale is supported (English file is not added as this is the default language)
49 - if ( array_key_exists( $locale, $supported_locales ) ) {
50 - wp_localize_script( 'posts-data-table', 'posts_data_table', array(
51 - 'langurl' => $supported_locales[$locale]
52 - ) );
53 - }
54 - }
49 + // Add language file to script if locale is supported (English file is not added as this is the default language)
50 + if ( array_key_exists( $locale, $supported_locales ) ) {
51 + wp_localize_script(
52 + 'posts-data-table',
53 + 'posts_data_table',
54 + [
55 + 'langurl' => $supported_locales[ $locale ]
56 + ]
57 + );
58 + }
59 + }
55 60
56 - /**
57 - * Returns an array of locales supported by the plugin.
58 - * The array returned uses the locale as the array key mapped to the URL of the corresponding translation file.
59 - *
60 - * @return array The supported locales
61 - */
62 - private function get_supported_locales() {
63 - $lang_file_base_url = plugins_url( 'languages/data-tables/', $this->plugin->get_file() );
61 + /**
62 + * Returns an array of locales supported by the plugin.
63 + * The array returned uses the locale as the array key mapped to the URL of the corresponding translation file.
64 + *
65 + * @return array The supported locales
66 + */
67 + private function get_supported_locales() {
68 + $lang_file_base_url = plugins_url( 'languages/data-tables/', $this->plugin->get_file() );
64 69
65 - return apply_filters( 'posts_data_table_supported_languages', array(
66 - 'es_ES' => $lang_file_base_url . 'Spanish.json',
67 - 'fr_FR' => $lang_file_base_url . 'French.json',
68 - 'fr_BE' => $lang_file_base_url . 'French.json',
69 - 'fr_CA' => $lang_file_base_url . 'French.json',
70 - 'de_DE' => $lang_file_base_url . 'German.json',
71 - 'de_CH' => $lang_file_base_url . 'German.json',
72 - 'el' => $lang_file_base_url . 'Greek.json',
73 - 'el_EL' => $lang_file_base_url . 'Greek.json',
74 - ) );
75 - }
70 + return apply_filters(
71 + 'posts_data_table_supported_languages',
72 + [
73 + 'es_ES' => $lang_file_base_url . 'Spanish.json',
74 + 'fr_FR' => $lang_file_base_url . 'French.json',
75 + 'fr_BE' => $lang_file_base_url . 'French.json',
76 + 'fr_CA' => $lang_file_base_url . 'French.json',
77 + 'de_DE' => $lang_file_base_url . 'German.json',
78 + 'de_CH' => $lang_file_base_url . 'German.json',
79 + 'el' => $lang_file_base_url . 'Greek.json',
80 + 'el_EL' => $lang_file_base_url . 'Greek.json',
81 + 'zh_TW' => $lang_file_base_url . 'Taiwan.json',
82 + ]
83 + );
84 + }
76 85
77 86 }