PluginProbe
WP Directory Kit / 1.1.0
WP Directory Kit v1.1.0
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.1.0, at includes/class-wpdirectorykit.php

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