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