PluginProbe
Disable Comments & Delete All Comments / 1.1.3
Disable Comments & Delete All Comments v1.1.3
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.1.3, at includes/class-plugin.php

116 lines 3.7 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_Factory446_Plugin {
14
15 /**
16 * @see self::app()
17 * @var Wbcr_Factory446_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
53 /**
54 * Статический метод для быстрого доступа к интерфейсу плагина.
55 *
56 * Позволяет разработчику глобально получить доступ к экземпляру класса плагина в любом месте
57 * плагина, но при этом разработчик не может вносить изменения в основной класс плагина.
58 *
59 * Используется для получения настроек плагина, информации о плагине, для доступа к вспомогательным
60 * классам.
61 *
62 * @return \Wbcr_Factory446_Plugin|\WCM_Plugin
63 */
64 public static function app() {
65 return self::$app;
66 }
67
68 /**
69 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
70 * @throws \Exception
71 */
72 public function plugins_loaded() {
73 if ( is_admin() ) {
74 $this->register_pages();
75 }
76 }
77
78 /**
79 * Регистрирует классы страниц в плагине
80 *
81 * Мы указываем плагину, где найти файлы страниц и какое имя у и�
82 класса. Чтобы плагин
83 * выполнил подключение классов страниц. После регистрации, страницы будут доступные по url
84 * и в меню боковой панели администратора. Регистрируемые страницы будут связаны с текущим плагином
85 * все операции выполняемые внутри классов страниц, имеют отношение только текущему плагину.
86 *
87 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
88 * @throws \Exception
89 */
90 private function register_pages() {
91 $admin_path = WCM_PLUGIN_DIR . '/admin/pages';
92
93 self::app()->registerPage( 'WbcrCmp_CommentsPage', $admin_path . '/class-page-comments.php' );
94 self::app()->registerPage( 'WbcrCmp_DeleteCommentsPage', $admin_path . '/class-page-delete-comments.php' );
95 self::app()->registerPage( 'WbcrCmp_MoreFeaturesPage', $admin_path . '/class-page-more-features.php' );
96 }
97
98 /**
99 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
100 */
101 private function admin_scripts() {
102 require( WCM_PLUGIN_DIR . '/admin/boot.php' );
103 }
104
105 /**
106 * @author Alexander Kovalev <alex.kovalevv@gmail.com>
107 */
108 private function global_scripts() {
109 require( WCM_PLUGIN_DIR . '/includes/boot.php' );
110 require( WCM_PLUGIN_DIR . '/includes/classes/class-configurate-comments.php' );
111
112 new WbcrCmp_ConfigComments( self::$app );
113 }
114 }
115
116