PluginProbe
WP Directory Kit / 1.5.5
WP Directory Kit v1.5.5
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / includes / class-wpdirectorykit.php

class-wpdirectorykit.php in WP Directory Kit 1.5.5, at includes/class-wpdirectorykit.php

365 lines 10.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link listing-themes.com
10 * @since 1.0.0
11 *
12 * @package Wpdirectorykit
13 * @subpackage Wpdirectorykit/includes
14 */
15
16 /**
17 * The core plugin class.
18 *
19 * This is used to define internationalization, admin-specific hooks, and
20 * public-facing site hooks.
21 *
22 * Also maintains the unique identifier of this plugin as well as the current
23 * version of the plugin.
24 *
25 * @since 1.0.0
26 * @package Wpdirectorykit
27 * @subpackage Wpdirectorykit/includes
28 * @author listing-themes.com <[email protected]>
29 */
30
31 if ( ! defined( 'ABSPATH' ) ) {
32 exit; // Exit if accessed directly.
33 }
34 class Wpdirectorykit {
35
36 /**
37 * The loader that's responsible for maintaining and registering all hooks that power
38 * the plugin.
39 *
40 * @since 1.0.0
41 * @access protected
42 * @var Wpdirectorykit_Loader $loader Maintains and registers all hooks for the plugin.
43 */
44 protected $loader;
45
46 /**
47 * The unique identifier of this plugin.
48 *
49 * @since 1.0.0
50 * @access protected
51 * @var string $plugin_name The string used to uniquely identify this plugin.
52 */
53 protected $plugin_name;
54
55 /**
56 * The current version of the plugin.
57 *
58 * @since 1.0.0
59 * @access protected
60 * @var string $version The current version of the plugin.
61 */
62 protected $version;
63
64 /**
65 * Define the core functionality of the plugin.
66 *
67 * Set the plugin name and the plugin version that can be used throughout the plugin.
68 * Load the dependencies, define the locale, and set the hooks for the admin area and
69 * the public-facing side of the site.
70 *
71 * @since 1.0.0
72 */
73 public function __construct() {
74 if ( defined( 'WPDIRECTORYKIT_VERSION' ) ) {
75 $this->version = WPDIRECTORYKIT_VERSION;
76 } else {
77 $this->version = '1.0.0';
78 }
79 $this->plugin_name = 'wpdirectorykit';
80
81 $this->load_dependencies();
82 $this->set_locale();
83 $this->define_admin_hooks();
84 $this->define_public_hooks();
85
86 $this->load_frameworks();
87 $this->define_plugins_upgrade_hooks();
88 $this->define_shortcode_hooks();
89 $this->define_widget_hooks();
90 $this->define_filter_hooks();
91 }
92
93 /**
94 * Load the required dependencies for this plugin.
95 *
96 * Include the following files that make up the plugin:
97 *
98 * - Wpdirectorykit_Loader. Orchestrates the hooks of the plugin.
99 * - Wpdirectorykit_i18n. Defines internationalization functionality.
100 * - Wpdirectorykit_Admin. Defines all hooks for the admin area.
101 * - Wpdirectorykit_Public. Defines all hooks for the public side of the site.
102 *
103 * Create an instance of the loader which will be used to register the hooks
104 * with WordPress.
105 *
106 * @since 1.0.0
107 * @access private
108 */
109 private function load_dependencies() {
110
111 /**
112 * The class responsible for orchestrating the actions and filters of the
113 * core plugin.
114 */
115 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpdirectorykit-loader.php';
116
117 /**
118 * The class responsible for defining internationalization functionality
119 * of the plugin.
120 */
121 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpdirectorykit-i18n.php';
122
123 // Class asking for plugin review after some time
124 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpdirectorykit-review-request.php';
125
126 /**
127 * The class responsible for defining all actions that occur in the admin area.
128 */
129 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-wpdirectorykit-admin.php';
130
131 /**
132 * The class responsible for defining all actions that occur in the public-facing
133 * side of the site.
134 */
135 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-wpdirectorykit-public.php';
136
137 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'tgm-pa/configuration.php';
138
139 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'filters.php';
140
141 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'actions.php';
142
143 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'custom_post_type.php';
144
145 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'custom_user_roles.php';
146
147 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'custom_user_fields.php';
148
149 // Load Winter MVC core
150 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'vendor/Winter_MVC/init.php';
151
152 // Shortcodes
153 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'shortcodes/shortcodes-init.php';
154
155 // Dash Widgets
156 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'dash-widgets/dash-widgets-init.php';
157
158 // Widgets
159 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'widgets/widgets-init.php';
160
161 // Load Elementor Elements
162 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'elementor-elements/elementor-init.php';
163
164 // Load Blocks
165 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'blocks/blocks-init.php';
166
167 // Load Blocks
168 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'rest_api.php';
169
170 $this->loader = new Wpdirectorykit_Loader();
171 //global $Winter_MVC;
172
173 }
174
175 private function load_frameworks()
176 {
177 global $Winter_MVC_WDK;
178
179 if(empty($Winter_MVC_WDK))
180 {
181 $Winter_MVC_WDK = new MVC_Loader(plugin_dir_path( __FILE__ ).'../');
182 }
183 else
184 {
185 $Winter_MVC_WDK->plugin_directory = plugin_dir_path( __FILE__ ).'../';
186 }
187
188 $Winter_MVC_WDK->load_helper('basic');
189 }
190
191
192 /**
193 * Define the locale for this plugin for internationalization.
194 *
195 * Uses the Wpdirectorykit_i18n class in order to set the domain and to register the hook
196 * with WordPress.
197 *
198 * @since 1.0.0
199 * @access private
200 */
201 private function set_locale() {
202
203 $plugin_i18n = new Wpdirectorykit_i18n();
204
205 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
206
207 }
208
209 /**
210 * Register all of the hooks related to the admin area functionality
211 * of the plugin.
212 *
213 * @since 1.0.0
214 * @access private
215 */
216 private function define_admin_hooks() {
217
218 $plugin_admin = new Wpdirectorykit_Admin( $this->get_plugin_name(), $this->get_version() );
219
220 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
221 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
222
223 /**
224 * Adding Plugin Admin Menu
225 */
226 $this->loader->add_action(
227 'admin_menu',
228 $plugin_admin,
229 'plugin_menu'
230 );
231
232 $this->loader->add_action(
233 'wp_ajax_wdk_admin_action',
234 $plugin_admin,
235 'ajax_admin'
236 );
237
238 }
239
240 /**
241 * Register all of the hooks related to the public-facing functionality
242 * of the plugin.
243 *
244 * @since 1.0.0
245 * @access private
246 */
247 private function define_public_hooks() {
248
249 $plugin_public = new Wpdirectorykit_Public( $this->get_plugin_name(), $this->get_version() );
250
251 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
252 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
253
254
255 $this->loader->add_action(
256 'wp_ajax_wdk_public_action',
257 $plugin_public,
258 'ajax_public'
259 );
260
261 $this->loader->add_action(
262 'wp_ajax_nopriv_wdk_public_action',
263 $plugin_public,
264 'ajax_public'
265 );
266 }
267
268 /**
269 * Run the loader to execute all of the hooks with WordPress.
270 *
271 * @since 1.0.0
272 */
273 public function run() {
274 $this->loader->run();
275 }
276
277 /**
278 * The name of the plugin used to uniquely identify it within the context of
279 * WordPress and to define internationalization functionality.
280 *
281 * @since 1.0.0
282 * @return string The name of the plugin.
283 */
284 public function get_plugin_name() {
285 return $this->plugin_name;
286 }
287
288 /**
289 * The reference to the class that orchestrates the hooks with the plugin.
290 *
291 * @since 1.0.0
292 * @return Wpdirectorykit_Loader Orchestrates the hooks of the plugin.
293 */
294 public function get_loader() {
295 return $this->loader;
296 }
297
298 /**
299 * Retrieve the version number of the plugin.
300 *
301 * @since 1.0.0
302 * @return string The version number of the plugin.
303 */
304 public function get_version() {
305 return $this->version;
306 }
307
308 public function define_plugins_upgrade_hooks()
309 {
310 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpdirectorykit-activator.php';
311
312 $this->loader->add_action( 'plugins_loaded', 'Wpdirectorykit_Activator', 'plugins_loaded' );
313
314 //$Winter_MVC_WDK = new MVC_Loader(plugin_dir_path( __FILE__ ).'../');
315 //$Winter_MVC_WDK->load_helper('basic');
316
317 /*
318 $this->loader->add_action(
319 'wp_ajax_nopriv_activitytime_action',
320 $this,
321 'activitytime_action'
322 );
323
324 $this->loader->add_action(
325 'wp_ajax_activitytime_action',
326 $this,
327 'activitytime_action'
328 );
329
330 $this->loader->add_action(
331 'wp_ajax_activitytime_mvc_action',
332 $this,
333 'activitytime_mvc_action'
334 );*/
335
336 }
337
338 public function define_shortcode_hooks()
339 {
340 //require(plugin_dir_path( dirname( __FILE__ ) ) . 'shortcodes/xxx.php');
341
342 }
343
344 public function define_widget_hooks()
345 {
346 //require(plugin_dir_path( dirname( __FILE__ ) ) . 'widgets/xxx.php');
347
348 }
349
350 public function define_filter_hooks()
351 {
352 $this->loader->add_filter( 'ajax_query_attachments_args', $this, 'show_current_user_attachments' );
353 }
354
355 function show_current_user_attachments( $query ) {
356 $user_id = get_current_user_id();
357 if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts
358 ') ) {
359 $query['author'] = $user_id;
360 }
361 return $query;
362 }
363
364 }
365