PluginProbe
WP Directory Kit / 1.4.8
WP Directory Kit v1.4.8
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 1.4.0 1.4.1 All 35 releases
wpdirectorykit / includes / class-wpdirectorykit.php

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

362 lines 10.0 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 <dev@listing-themes.com>
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 $this->loader = new Wpdirectorykit_Loader();
168 //global $Winter_MVC;
169
170 }
171
172 private function load_frameworks()
173 {
174 global $Winter_MVC_WDK;
175
176 if(empty($Winter_MVC_WDK))
177 {
178 $Winter_MVC_WDK = new MVC_Loader(plugin_dir_path( __FILE__ ).'../');
179 }
180 else
181 {
182 $Winter_MVC_WDK->plugin_directory = plugin_dir_path( __FILE__ ).'../';
183 }
184
185 $Winter_MVC_WDK->load_helper('basic');
186 }
187
188
189 /**
190 * Define the locale for this plugin for internationalization.
191 *
192 * Uses the Wpdirectorykit_i18n class in order to set the domain and to register the hook
193 * with WordPress.
194 *
195 * @since 1.0.0
196 * @access private
197 */
198 private function set_locale() {
199
200 $plugin_i18n = new Wpdirectorykit_i18n();
201
202 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
203
204 }
205
206 /**
207 * Register all of the hooks related to the admin area functionality
208 * of the plugin.
209 *
210 * @since 1.0.0
211 * @access private
212 */
213 private function define_admin_hooks() {
214
215 $plugin_admin = new Wpdirectorykit_Admin( $this->get_plugin_name(), $this->get_version() );
216
217 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
218 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
219
220 /**
221 * Adding Plugin Admin Menu
222 */
223 $this->loader->add_action(
224 'admin_menu',
225 $plugin_admin,
226 'plugin_menu'
227 );
228
229 $this->loader->add_action(
230 'wp_ajax_wdk_admin_action',
231 $plugin_admin,
232 'ajax_admin'
233 );
234
235 }
236
237 /**
238 * Register all of the hooks related to the public-facing functionality
239 * of the plugin.
240 *
241 * @since 1.0.0
242 * @access private
243 */
244 private function define_public_hooks() {
245
246 $plugin_public = new Wpdirectorykit_Public( $this->get_plugin_name(), $this->get_version() );
247
248 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
249 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
250
251
252 $this->loader->add_action(
253 'wp_ajax_wdk_public_action',
254 $plugin_public,
255 'ajax_public'
256 );
257
258 $this->loader->add_action(
259 'wp_ajax_nopriv_wdk_public_action',
260 $plugin_public,
261 'ajax_public'
262 );
263 }
264
265 /**
266 * Run the loader to execute all of the hooks with WordPress.
267 *
268 * @since 1.0.0
269 */
270 public function run() {
271 $this->loader->run();
272 }
273
274 /**
275 * The name of the plugin used to uniquely identify it within the context of
276 * WordPress and to define internationalization functionality.
277 *
278 * @since 1.0.0
279 * @return string The name of the plugin.
280 */
281 public function get_plugin_name() {
282 return $this->plugin_name;
283 }
284
285 /**
286 * The reference to the class that orchestrates the hooks with the plugin.
287 *
288 * @since 1.0.0
289 * @return Wpdirectorykit_Loader Orchestrates the hooks of the plugin.
290 */
291 public function get_loader() {
292 return $this->loader;
293 }
294
295 /**
296 * Retrieve the version number of the plugin.
297 *
298 * @since 1.0.0
299 * @return string The version number of the plugin.
300 */
301 public function get_version() {
302 return $this->version;
303 }
304
305 public function define_plugins_upgrade_hooks()
306 {
307 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-wpdirectorykit-activator.php';
308
309 $this->loader->add_action( 'plugins_loaded', 'Wpdirectorykit_Activator', 'plugins_loaded' );
310
311 //$Winter_MVC_WDK = new MVC_Loader(plugin_dir_path( __FILE__ ).'../');
312 //$Winter_MVC_WDK->load_helper('basic');
313
314 /*
315 $this->loader->add_action(
316 'wp_ajax_nopriv_activitytime_action',
317 $this,
318 'activitytime_action'
319 );
320
321 $this->loader->add_action(
322 'wp_ajax_activitytime_action',
323 $this,
324 'activitytime_action'
325 );
326
327 $this->loader->add_action(
328 'wp_ajax_activitytime_mvc_action',
329 $this,
330 'activitytime_mvc_action'
331 );*/
332
333 }
334
335 public function define_shortcode_hooks()
336 {
337 //require(plugin_dir_path( dirname( __FILE__ ) ) . 'shortcodes/xxx.php');
338
339 }
340
341 public function define_widget_hooks()
342 {
343 //require(plugin_dir_path( dirname( __FILE__ ) ) . 'widgets/xxx.php');
344
345 }
346
347 public function define_filter_hooks()
348 {
349 $this->loader->add_filter( 'ajax_query_attachments_args', $this, 'show_current_user_attachments' );
350 }
351
352 function show_current_user_attachments( $query ) {
353 $user_id = get_current_user_id();
354 if ( $user_id && !current_user_can('activate_plugins') && !current_user_can('edit_others_posts
355 ') ) {
356 $query['author'] = $user_id;
357 }
358 return $query;
359 }
360
361 }
362