PluginProbe
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts / 2.1.91
Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts v2.1.91
2.7.6 2.7.5 2.7.4 trunk 1.3 2.0.4 2.0.6 2.1.91 2.2.4 2.2.7 2.2.9 2.3.1 2.3.10 2.4.10 2.4.2 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.6.0 2.6.1 2.7.0 2.7.1 All 27 releases
insert-php / includes / class.plugin.php

class.plugin.php in Woody Code Snippets – Insert PHP, CSS, JS, and Header/Footer Scripts 2.1.91, at includes/class.plugin.php

158 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PHP snippets plugin base
4 * @author Webcraftic <wordpress.webraftic@gmail.com>
5 * @copyright (c) 19.02.2018, Webcraftic
6 * @version 1.0
7 */
8
9 // Exit if accessed directly
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 }
13
14 if ( ! class_exists( 'WINP_Plugin' ) ) {
15
16 class WINP_Plugin extends Wbcr_Factory410_Plugin {
17
18 /**
19 * @var Wbcr_Factory410_Plugin
20 */
21 private static $app;
22
23 /**
24 * @param string $plugin_path
25 * @param array $data
26 *
27 * @throws Exception
28 */
29 public function __construct( $plugin_path, $data ) {
30 parent::__construct( $plugin_path, $data );
31
32 self::$app = $this;
33
34 self::app()->setTextDomain( 'insert-php', WINP_PLUGIN_DIR );
35 $this->setModules();
36
37 $this->globalScripts();
38
39 if ( is_admin() ) {
40 $this->initActivation();
41 $this->adminScripts();
42
43 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
44 require( WINP_PLUGIN_DIR . '/admin/ajax/ajax.php' );
45 }
46 }
47 }
48
49 /**
50 * @return WINP_Plugin
51 */
52 public static function app() {
53 return self::$app;
54 }
55
56 /**
57 * @return bool
58 */
59 public function currentUserCan() {
60 return current_user_can( 'manage_options' );
61 }
62
63
64 /**
65 * Get Execute_Snippet object
66 *
67 * @return WINP_Execute_Snippet
68 */
69 public function getExecuteObject() {
70 require_once( WINP_PLUGIN_DIR . '/includes/class.execute.snippet.php' );
71
72 return new WINP_Execute_Snippet();
73 }
74
75 protected function setModules() {
76 $this->load( array(
77 array( 'libs/factory/bootstrap', 'factory_bootstrap_410', 'admin' ),
78 array( 'libs/factory/forms', 'factory_forms_411', 'admin' ),
79 array( 'libs/factory/pages', 'factory_pages_411', 'admin' ),
80 array( 'libs/factory/types', 'factory_types_405' ),
81 array( 'libs/factory/taxonomies', 'factory_taxonomies_325' ),
82 array( 'libs/factory/metaboxes', 'factory_metaboxes_404', 'admin' ),
83 array( 'libs/factory/viewtables', 'factory_viewtables_405', 'admin' ),
84 array( 'libs/factory/shortcodes', 'factory_shortcodes_325', 'all' ),
85 array( 'libs/factory/notices', 'factory_notices_408', 'admin' )
86 ) );
87 }
88
89 protected function initActivation() {
90 include_once( WINP_PLUGIN_DIR . '/admin/activation.php' );
91 $this->registerActivation( 'WINP_Activation' );
92 }
93
94 private function registerPages() {
95 $this->registerPage( 'WINP_NewItemPage', WINP_PLUGIN_DIR . '/admin/pages/new-item.php' );
96 $this->registerPage( 'WINP_ImportPage', WINP_PLUGIN_DIR . '/admin/pages/import.php' );
97 $this->registerPage( 'WINP_SettingsPage', WINP_PLUGIN_DIR . '/admin/pages/settings.php' );
98 $this->registerPage( 'WINP_AboutPage', WINP_PLUGIN_DIR . '/admin/pages/about.php' );
99 }
100
101 private function registerTypes() {
102 $this->registerType( 'WSC_TasksItemType', WINP_PLUGIN_DIR . '/admin/types/snippets-post-types.php' );
103
104 require_once( WINP_PLUGIN_DIR . '/admin/types/snippets-taxonomy.php' );
105 Wbcr_FactoryTaxonomies325::register( 'WINP_SnippetsTaxonomy', $this );
106 }
107
108 private function register_shortcodes() {
109 $is_cron = WINP_Helper::doing_cron();
110 $is_rest = WINP_Helper::doing_rest_api();
111
112 if ( ! ( isset( $_GET['action'] ) && $_GET['action'] == 'edit' && is_admin() ) && ! $is_cron && ! $is_rest ) {
113 require_once( WINP_PLUGIN_DIR . '/includes/shortcodes/shortcodes.php' );
114 require_once( WINP_PLUGIN_DIR . '/includes/shortcodes/shortcode-php.php' );
115 require_once( WINP_PLUGIN_DIR . '/includes/shortcodes/shortcode-text.php' );
116 require_once( WINP_PLUGIN_DIR . '/includes/shortcodes/shortcode-universal.php' );
117
118 Wbcr_FactoryShortcodes325::register( 'WINP_SnippetShortcodePhp', $this );
119 Wbcr_FactoryShortcodes325::register( 'WINP_SnippetShortcodeText', $this );
120 Wbcr_FactoryShortcodes325::register( 'WINP_SnippetShortcodeUniversal', $this );
121 }
122 }
123
124
125 private function globalScripts() {
126 $this->registerGutenberg();
127 $this->getExecuteObject()->registerHooks();
128 $this->register_shortcodes();
129
130 require_once( WINP_PLUGIN_DIR . '/admin/boot.php' );
131 }
132
133 private function adminScripts() {
134 require_once( WINP_PLUGIN_DIR . '/admin/includes/class.snippets.viewtable.php' );
135 require_once( WINP_PLUGIN_DIR . '/admin/includes/class.filter.snippet.php' );
136 require_once( WINP_PLUGIN_DIR . '/admin/includes/class.export.snippet.php' );
137 require_once( WINP_PLUGIN_DIR . '/admin/includes/class.import.snippet.php' );
138 require_once( WINP_PLUGIN_DIR . '/admin/includes/class.notices.php' );
139
140 $this->registerTypes();
141 $this->registerPages();
142
143 new WINP_Filter_List();
144 new WINP_Export_Snippet();
145 new WINP_Import_Snippet();
146 new WINP_WarningNotices();
147 }
148
149 /**
150 * Register Gutenberg related scripts.
151 */
152 private function registerGutenberg() {
153 require_once( WINP_PLUGIN_DIR . '/admin/includes/class.gutenberg.snippet.php' );
154
155 new WINP_Gutenberg_Snippet();
156 }
157 }
158 }