PluginProbe
Posts Table with Search & Sort / 1.4.0
Posts Table with Search & Sort v1.4.0
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 / src / Plugin.php

Plugin.php in Posts Table with Search & Sort 1.4.0, at src/Plugin.php

91 lines 2.2 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 use Barn2\Plugin\Posts_Table_Search_Sort\Admin\Settings_Page;
6 use Barn2\PTS_Lib\Plugin\Simple_Plugin;
7 use Barn2\PTS_Lib\Registerable;
8 use Barn2\PTS_Lib\Service_Provider;
9 use Barn2\PTS_Lib\Util;
10
11 /**
12 * The main plugin class.
13 *
14 * @package Barn2\posts-table-search-sort
15 * @author Barn2 Plugins <support@barn2.com>
16 * @license GPL-3.0
17 * @copyright Barn2 Media Ltd
18 */
19 class Plugin extends Simple_Plugin implements Registerable, Service_Provider {
20
21 const NAME = 'Posts Table with Search and Sort';
22 const ITEM_ID = 8006;
23
24 /**
25 * @var array $services
26 */
27 private $services;
28
29 /**
30 * Constructs and initializes an EDD VAT plugin instance.
31 *
32 * @param string $file The main plugin __FILE__
33 * @param string $version The current plugin version
34 */
35 public function __construct( $file = null, $version = '1.0' ) {
36 parent::__construct(
37 [
38 'id' => self::ITEM_ID,
39 'name' => self::NAME,
40 'version' => $version,
41 'file' => $file,
42 'settings_path' => 'options-general.php?page=' . Settings_Page::MENU_SLUG
43 ]
44 );
45
46 include_once plugin_dir_path( $file ) . 'src/deprecated.php';
47
48 // Services
49 $this->services['shortcode'] = new Table_Shortcode();
50 $this->services['scripts'] = new Frontend_Scripts( $this );
51 $this->services['setup_wizard'] = new Admin\Wizard\Setup_Wizard( $this );
52
53 // Admin only services
54 if ( Util::is_admin() ) {
55 $this->services['admin'] = new Admin\Admin_Controller( $this );
56 }
57 }
58
59 public function register() {
60 add_action( 'plugins_loaded', [ $this, 'maybe_load_plugin' ] );
61 }
62
63 public function maybe_load_plugin() {
64 // Don't load plugin if Pro version active
65 if ( class_exists( '\Posts_Table_Pro_Plugin' ) ) {
66 return;
67 }
68
69 add_action( 'init', [ $this, 'load_textdomain' ] );
70
71 Util::register_services( $this->services );
72 }
73
74 public function load_textdomain() {
75 load_plugin_textdomain( 'posts-data-table', false, $this->get_slug() . '/languages' );
76 }
77
78 public function get_service( $id ) {
79 if ( isset( $this->services[ $id ] ) ) {
80 return $this->services[ $id ];
81 }
82
83 return null;
84 }
85
86 public function get_services() {
87 return $this->services;
88 }
89
90 }
91