PluginProbe
Disable Comments & Delete All Comments / 1.3.0
Disable Comments & Delete All Comments v1.3.0
1.3.3 1.3.2 trunk 1.0.0 1.0.4 1.0.5 1.0.8 1.0.9 1.1.1 1.1.3 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.3.0 1.3.1
comments-plus / includes / class-plugin.php

class-plugin.php in Disable Comments & Delete All Comments 1.3.0, at includes/class-plugin.php

135 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Plugin class
9 *
10 * @author Alex Kovalev <alex.kovalevv@gmail.com>
11 * @copyright (c) 19.02.2018, Webcraftic
12 */
13 class WCM_Plugin extends Wbcr_Factory480_Plugin {
14
15 /**
16 * @see self::app()
17 * @var Wbcr_Factory480_Plugin
18 */
19 private static $app;
20
21 /**
22 * @since 3.1.0
23 * @var array
24 */
25 private $plugin_data;
26
27 /**
28 * Конструктор
29 *
30 * Применяет конструктор родительского класса и записывает экземпляр текущего класса в свойство $app.
31 * Подробнее о свойстве $app см. self::app()
32 *
33 * @param string $plugin_path
34 * @param array $data
35 *
36 * @throws Exception
37 */
38 public function __construct( $plugin_path, $data ) {
39 parent::__construct( $plugin_path, $data );
40
41 self::$app = $this;
42 $this->plugin_data = $data;
43
44 $this->global_scripts();
45
46 if ( is_admin() ) {
47 $this->admin_scripts();
48 }
49
50 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
51
52 // Wordpress 6.7 fix
53 add_action( 'init', function () {
54 if ( is_admin() ) {
55 $this->register_pages();
56 }
57 } );
58
59 add_filter( 'themeisle_sdk_products', array( __CLASS__, 'register_sdk' ) );
60 }
61
62 /**
63 * Register product into SDK.
64 *
65 * @param array $products All products.
66 *
67 * @return array Registered product.
68 */
69 public static function register_sdk( $products ) {
70 $products[] = WCM_PLUGIN_FILE;
71
72 return $products;
73 }
74
75 /**
76 * Статический метод для быстрого доступа к интерфейсу плагина.
77 *
78 * Позволяет разработчику глобально получить доступ к экземпляру класса плагина в любом месте
79 * плагина, но при этом разработчик не может вносить изменения в основной класс плагина.
80 *
81 * Используется для получения настроек плагина, информации о плагине, для доступа к вспомогательным
82 * классам.
83 *
84 * @return \Wbcr_Factory480_Plugin|\WCM_Plugin
85 */
86 public static function app() {
87 return self::$app;
88 }
89
90 /**
91 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
92 * @throws \Exception
93 */
94 public function plugins_loaded() {
95
96 }
97
98 /**
99 * Регистрирует классы страниц в плагине
100 *
101 * Мы указываем плагину, где найти файлы страниц и какое имя у и�
102 класса. Чтобы плагин
103 * выполнил подключение классов страниц. После регистрации, страницы будут доступные по url
104 * и в меню боковой панели администратора. Регистрируемые страницы будут связаны с текущим плагином
105 * все операции выполняемые внутри классов страниц, имеют отношение только текущему плагину.
106 *
107 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
108 * @throws \Exception
109 */
110 private function register_pages() {
111 $admin_path = WCM_PLUGIN_DIR . '/admin/pages';
112
113 self::app()->registerPage( 'WbcrCmp_CommentsPage', $admin_path . '/class-page-comments.php' );
114 self::app()->registerPage( 'WbcrCmp_DeleteCommentsPage', $admin_path . '/class-page-delete-comments.php' );
115 }
116
117 /**
118 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
119 */
120 private function admin_scripts() {
121 require( WCM_PLUGIN_DIR . '/admin/boot.php' );
122 }
123
124 /**
125 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
126 */
127 private function global_scripts() {
128 require( WCM_PLUGIN_DIR . '/includes/boot.php' );
129 require( WCM_PLUGIN_DIR . '/includes/classes/class-configurate-comments.php' );
130
131 new WbcrCmp_ConfigComments( self::$app );
132 }
133 }
134
135