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

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

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