PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.3
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.3
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / includes / class-userswp.php

class-userswp.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.3, at includes/class-userswp.php

956 lines 34.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 * @since 1.0.0
10 * @author GeoDirectory Team <info@wpgeodirectory.com>
11 */
12 final class UsersWP {
13
14 public $profile;
15 public $forms;
16 public $notices;
17 /**
18 * The current version of the plugin.
19 *
20 * @since 1.0.0
21 * @access protected
22 * @var string $version The current version of the plugin.
23 */
24 protected $version;
25 protected $i18n;
26 protected $templates;
27 protected $meta;
28 protected $pages;
29 protected $files;
30 protected $shortcodes;
31 protected $assets;
32 protected $admin;
33 protected $menus;
34 protected $form_builder;
35 protected $ajax;
36 protected $tools;
37 protected $tables;
38
39 /**
40 * Define the core functionality of the plugin.
41 *
42 * Set the plugin name and the plugin version that can be used throughout the plugin.
43 * Load the dependencies, define the locale, and set the hooks for the admin area and
44 * the public-facing side of the site.
45 *
46 * @since 1.0.0
47 */
48 public function __construct() {
49
50 $this->plugin_name = USERSWP_NAME;
51 $this->version = USERSWP_VERSION;
52
53
54 $this->load_dependencies();
55 $this->init_hooks();
56
57 $this->meta = new UsersWP_Meta();
58 $this->pages = new UsersWP_Pages();
59 $this->profile = new UsersWP_Profile();
60 $this->forms = new UsersWP_Forms();
61 $this->templates = new UsersWP_Templates();
62 $this->notices = new UsersWP_Notices();
63 $this->assets = new UsersWP_Public();
64 $this->form_builder = new UsersWP_Form_Builder();
65 $this->menus = new UsersWP_Menus();
66 $this->tools = new UsersWP_Tools();
67 $this->tables = new UsersWP_Tables();
68 $this->admin = new UsersWP_Admin();
69 $this->admin_menus = new UsersWP_Admin_Menus();
70 $this->ajax = new UsersWP_Ajax();
71 $this->files = new UsersWP_Files();
72 $this->notifications = new UsersWP_Notifications();
73
74 // actions and filters
75 $this->load_assets_actions_and_filters( $this->assets );
76 $this->load_meta_actions_and_filters( $this->meta );
77 $this->load_files_actions_and_filters( $this->files );
78 $this->load_forms_actions_and_filters( $this->forms );
79 $this->load_notices_actions_and_filters( $this->notices );
80 $this->load_pages_actions_and_filters( $this->pages );
81 $this->load_profile_actions_and_filters( $this->profile );
82 $this->load_tables_actions_and_filters( $this->tables );
83 $this->load_templates_actions_and_filters( $this->templates );
84 $this->load_tools_actions_and_filters( $this->tools );
85 $this->load_notifications_actions_and_filters( $this->notifications );
86
87 //admin
88 $this->load_form_builder_actions_and_filters( $this->form_builder );
89 $this->load_menus_actions_and_filters( $this->menus );
90
91 }
92
93 /**
94 * Load the required dependencies for this plugin.
95 *
96 * @since 1.0.0
97 * @access private
98 */
99 private function load_dependencies() {
100 global $uwp_options;
101
102 if ( ! function_exists( 'is_plugin_active' ) ) {
103 /**
104 * Load all plugin functions from WordPress.
105 */
106 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
107 }
108
109 require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/functions.php';
110
111 $uwp_options = uwp_get_settings();
112
113 require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-font-awesome-settings.php';
114
115 require_once( dirname( dirname( __FILE__ ) ) . '/upgrade.php' );
116
117 /**
118 * The class responsible for activation functionality
119 * of the plugin.
120 */
121 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-activator.php';
122
123 /**
124 * The libraries required.
125 */
126 require_once dirname( dirname( __FILE__ ) ) . '/vendor/autoload.php';
127
128 /**
129 * Contains functions for templates.
130 */
131 require_once( dirname( dirname( __FILE__ ) ) . '/includes/template-functions.php' );
132
133 /**
134 * The class responsible for sending emails
135 * of the plugin.
136 */
137 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-emails.php';
138
139 /**
140 * The class responsible for reading and updating meta
141 * of the plugin.
142 */
143 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-meta.php';
144
145 /**
146 * The class responsible for userswp dates
147 * of the plugin.
148 */
149 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-date.php';
150
151 /**
152 * The class responsible for userswp pages
153 * of the plugin.
154 */
155 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-pages.php';
156
157 /**
158 * The class responsible for uploading files
159 * of the plugin.
160 */
161 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-files.php';
162
163 /**
164 * The class responsible for defining form handler functionality
165 * of the plugin.
166 */
167 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-forms.php';
168
169 /**
170 * The class responsible for form validation
171 * of the plugin.
172 */
173 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-validation.php';
174
175 /**
176 * Country helpers
177 */
178 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-countries.php';
179
180 /**
181 * The class responsible for defining ajax handler functionality
182 * of the plugin.
183 */
184 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-ajax.php';
185
186 /**
187 * The class responsible for defining all shortcodes
188 */
189 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-templates.php';
190
191 /**
192 * The class responsible for defining profile content
193 */
194 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-profile.php';
195
196 /**
197 * The class responsible for defining all menus items.
198 */
199 require_once dirname( dirname( __FILE__ ) ) . '/admin/menus/class-checklist.php';
200
201 /**
202 * The class responsible for defining all menus in the admin area.
203 */
204 require_once dirname( dirname( __FILE__ ) ) . '/admin/menus/class-menus.php';
205
206 /**
207 * The class responsible for defining all actions that occur in the admin area.
208 */
209 require_once dirname( dirname( __FILE__ ) ) . '/admin/class-admin.php';
210
211 /**
212 * The class responsible for defining all actions that occur for setup wizard.
213 */
214 if ( isset( $_GET['page'] ) && 'uwp-setup' == $_GET['page'] ) {
215 require_once dirname( dirname( __FILE__ ) ) . '/admin/class-admin-setup-wizard.php';
216 }
217
218 /**
219 * The class responsible for defining all actions help screen.
220 */
221 require_once dirname( dirname( __FILE__ ) ) . '/admin/class-uwp-admin-help.php';
222
223 /**
224 * The class responsible for defining all menus in the admin area.
225 */
226 require_once dirname( dirname( __FILE__ ) ) . '/admin/class-uwp-admin-menus.php';
227
228 /**
229 * The class responsible for defining all admin area settings.
230 */
231 require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-settings.php';
232
233 /**
234 * The class responsible for default content.
235 */
236 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-uwp-defaults.php';
237
238 /**
239 * The class responsible for defining all actions that occur in the public-facing
240 * side of the site.
241 */
242 require_once dirname( dirname( __FILE__ ) ) . '/public/class-public.php';
243
244 /**
245 * The class responsible for table functions
246 */
247 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-tables.php';
248
249 /**
250 * The class responsible for admin settings functions
251 */
252 include_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-settings-page.php';
253
254 /**
255 * The class responsible for adding fields in forms
256 */
257 require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-formbuilder.php';
258
259 /**
260 * The class responsible for defining all admin area settings.
261 */
262 require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-settings-profile-tabs.php';
263
264 /**
265 * The class responsible for user sorting builder.
266 */
267 require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-settings-user-sorting.php';
268
269 /**
270 * The class responsible for adding tools functions
271 */
272 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-tools.php';
273
274 /**
275 * The class responsible for displaying notices
276 */
277 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-notices.php';
278
279 /**
280 * contents helpers files and functions.
281 */
282 require_once( dirname( dirname( __FILE__ ) ) . '/includes/helpers.php' );
283
284 /**
285 * The class for login widget.
286 */
287 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/login.php' );
288
289 /**
290 * The class for register widget.
291 */
292 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/register.php' );
293
294 /**
295 * The class for forgot password widget.
296 */
297 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/forgot.php' );
298
299 /**
300 * The class for reset password widget.
301 */
302 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/reset.php' );
303
304 /**
305 * The class for change password widget.
306 */
307 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/change.php' );
308
309 /**
310 * The class for users widget.
311 */
312 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users.php' );
313
314 /**
315 * The class for users item widget.
316 */
317 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users-item.php' );
318
319 /**
320 * The class for account widget.
321 */
322 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/account.php' );
323
324 /**
325 * The class for profile widget.
326 */
327 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile.php' );
328
329 /**
330 * The class for profile sections widget.
331 */
332 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile-section.php' );
333
334 /**
335 * The class profile header widget
336 */
337 require_once dirname( dirname( __FILE__ ) ) . '/widgets/profile-header.php';
338
339 /**
340 * The class for user title widget.
341 */
342 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-title.php' );
343
344 /**
345 * The class for user avatar widget.
346 */
347 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-avatar.php' );
348
349 /**
350 * The class for user post count widget.
351 */
352 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-post-counts.php' );
353
354 /**
355 * The class for user cover widget.
356 */
357 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-cover.php' );
358
359 /**
360 * The class for profile social fields widget.
361 */
362 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile-social.php' );
363
364 /**
365 * The class for profile action buttons fields widget.
366 */
367 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile-actions.php' );
368
369 /**
370 * The class for profile buttons fields widget.
371 */
372 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-actions.php' );
373
374 /**
375 * The class for profile content widget.
376 */
377 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/profile-tabs.php' );
378
379 /**
380 * The class for user meta widget.
381 */
382 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-meta.php' );
383
384 /**
385 * The class for users search widget.
386 */
387 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users-search.php' );
388
389 /**
390 * The class for user list sorting widget.
391 */
392 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users-loop-actions.php' );
393
394 /**
395 * The class for users list widget.
396 */
397 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/users-loop.php' );
398
399 /**
400 * The class for output location widget.
401 */
402 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/output-location.php' );
403
404 /**
405 * The class for author box widget.
406 */
407 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/authorbox.php' );
408
409 /**
410 * The class for user badge widget.
411 */
412 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/user-badge.php' );
413
414 /**
415 * The class for button group widget.
416 */
417 require_once( dirname( dirname( __FILE__ ) ) . '/widgets/button-group.php' );
418
419 /**
420 * The class responsible for displaying notices
421 */
422 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-import-export.php';
423
424 /**
425 * The class responsible for displaying notices
426 */
427 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-user-notifications.php';
428
429 /**
430 * The class responsible for account handling
431 */
432 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-account.php';
433
434 /**
435 * The class responsible for adding tools functions
436 */
437 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-status.php';
438
439 /**
440 * The class responsible for extensions screen functions on admin side
441 */
442 require_once dirname( dirname( __FILE__ ) ) . '/includes/libraries/class-ayecode-addons.php';
443
444 /**
445 * The class responsible for extensions screen functions on admin side
446 */
447 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-addons.php';
448
449 /**
450 * The file is responsible for defining deprecated functions.
451 */
452 require_once dirname( dirname( __FILE__ ) ) . '/includes/deprecated-functions.php';
453
454 /**
455 * The class responsible for privacy policy functions
456 */
457 require_once dirname( dirname( __FILE__ ) ) . '/includes/abstract-uwp-privacy.php';
458 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-uwp-privacy.php';
459
460 /**
461 * The class responsible for SEO functions
462 */
463 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-uwp-seo.php';
464
465 /**
466 * The class responsible for compatibility with other themes and plugins
467 */
468 require_once dirname( dirname( __FILE__ ) ) . '/includes/class-uwp-compatibility.php';
469
470 if ( is_plugin_active( 'uwp_geodirectory/uwp_geodirectory.php' ) ) {
471 deactivate_plugins( 'uwp_geodirectory/uwp_geodirectory.php' );
472 }
473
474 if ( is_plugin_active( 'geodirectory/geodirectory.php' ) || class_exists( 'GeoDirectory' ) ) {
475 /**
476 * The class responsible for displaying notices
477 *
478 * @since 1.0.12
479 */
480 require_once dirname( dirname( __FILE__ ) ) . '/includes/libraries/class-geodirectory-plugin.php';
481 }
482
483 if ( class_exists( 'WPInv_Plugin' ) ) {
484 /**
485 * The class responsible for displaying notices
486 *
487 * @since 1.0.12
488 */
489 require_once dirname( dirname( __FILE__ ) ) . '/includes/libraries/class-invoicing-plugin.php';
490 }
491 }
492
493 /**
494 * Hook into actions and filters.
495 */
496 private function init_hooks() {
497 register_activation_hook( USERSWP_PLUGIN_FILE, array( 'UsersWP_Activator', 'activate' ) );
498 add_action( 'admin_init', array( 'UsersWP_Activator', 'automatic_upgrade' ) );
499 add_action( 'init', array( 'UsersWP_Activator', 'init_background_updater' ), 5 );
500 add_action( 'widgets_init', array( $this, 'register_widgets' ) );
501 add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
502 add_action( 'uwp_flush_rewrite_rules', array( $this, 'flush_rewrite_rules' ) );
503 add_action( 'uwp_language_file_add_string', array( $this, 'register_string' ), 10, 1 );
504 add_action( 'after_setup_theme', array( $this, 'hide_admin_bar' ));
505 }
506
507 /**
508 * Actions for assets
509 *
510 * @param $instance
511 */
512 public function load_assets_actions_and_filters( $instance ) {
513 add_action( 'wp_enqueue_scripts', array( $instance, 'enqueue_styles' ) );
514 add_action( 'wp_enqueue_scripts', array( $instance, 'enqueue_scripts' ) );
515 }
516
517 /**
518 * Actions for meta data
519 *
520 * @param $instance
521 */
522 public function load_meta_actions_and_filters( $instance ) {
523 add_action( 'user_register', array( $instance, 'sync_usermeta' ), 10, 1 );
524 add_action( 'delete_user', array( $instance, 'delete_usermeta_for_user' ), 10, 1 );
525 add_action( 'remove_user_from_blog', array( $instance, 'remove_user_from_blog' ), 10, 2 );
526 add_action( 'wp_login', array( $instance, 'save_user_ip_on_login' ), 10, 2 );
527 add_filter( 'uwp_before_extra_fields_save', array( $instance, 'save_user_ip_on_register' ), 10, 3 );
528 add_filter( 'uwp_update_usermeta', array( $instance, 'modify_datepicker_value_on_update' ), 10, 3 );
529 add_filter( 'uwp_get_usermeta', array( $instance, 'modify_datepicker_value_on_get' ), 10, 4 );
530 add_action( 'get_user_metadata', array( $instance, 'dynamically_add_user_meta' ), 10, 4 );
531 }
532
533 public function load_files_actions_and_filters( $instance ) {
534 if ( $instance->doing_upload() ) {
535 add_filter( 'wp_handle_upload_prefilter', array( $instance, 'wp_media_restrict_file_types' ) );
536 }
537 add_filter( 'uwp_get_max_upload_size', array( $instance, 'uwp_modify_get_max_upload_size' ), 10, 2 );
538 }
539
540 /**
541 * Actions for forms
542 *
543 * @param $instance
544 */
545 public function load_forms_actions_and_filters( $instance ) {
546
547 // login
548 add_action( 'wp_ajax_nopriv_uwp_ajax_login_form', array( $instance, 'ajax_login_form' ) );
549 add_action( 'wp_ajax_nopriv_uwp_ajax_login', array( $instance, 'process_login' ) );
550 add_action( 'wp_ajax_nopriv_uwp_ajax_login_process_2fa', array( $instance, 'process_login_2fa' ) );
551
552 // register
553 add_action( 'wp_ajax_nopriv_uwp_ajax_register_form', array( $instance, 'ajax_register_form' ) );
554 add_action( 'wp_ajax_nopriv_uwp_ajax_register', array( $instance, 'process_register' ) );
555
556 // forgot
557 add_action( 'wp_ajax_nopriv_uwp_ajax_forgot_password_form', array( $instance, 'ajax_forgot_password_form' ) );
558 add_action( 'wp_ajax_nopriv_uwp_ajax_forgot_password', array( $instance, 'process_forgot' ) );
559
560 // general
561 add_action( 'init', array( $instance, 'init_notices' ), 1 );
562 add_action( 'uwp_loaded', array( $instance, 'handler' ) );
563 add_action( 'init', array( $instance, 'privacy_submit_handler' ) );
564 add_action( 'uwp_template_display_notices', array( $instance, 'display_notices' ), 10, 1 );
565 add_action( 'wp_ajax_uwp_upload_file_remove', array( $instance, 'upload_file_remove' ) );
566 //User search form
567 add_action( 'personal_options_update', array( $instance, 'update_profile_extra_admin_edit' ), 10, 1 );
568 add_action( 'edit_user_profile_update', array( $instance, 'update_profile_extra_admin_edit' ), 10, 1 );
569 add_action( 'user_edit_form_tag', array( $instance, 'add_multipart_to_admin_edit_form' ) );
570 add_action( 'template_redirect', array( $instance, 'process_login' ) );
571 add_action( 'template_redirect', array( $instance, 'process_register' ) );
572 add_action( 'template_redirect', array( $instance, 'process_account' ) );
573 add_action( 'template_redirect', array( $instance, 'process_forgot' ) );
574 add_action( 'template_redirect', array( $instance, 'process_change' ) );
575 add_action( 'template_redirect', array( $instance, 'process_reset' ) );
576
577 // Forms
578 add_filter( 'uwp_form_input_html_datepicker', array( $instance, 'form_input_datepicker' ), 10, 4 );
579 add_filter( 'uwp_form_input_html_time', array( $instance, 'form_input_time' ), 10, 4 );
580 add_filter( 'uwp_form_input_html_select', array( $instance, 'form_input_select' ), 10, 4 );
581 add_filter( 'uwp_form_input_html_multiselect', array( $instance, 'form_input_multiselect' ), 10, 4 );
582 add_filter( 'uwp_form_input_html_text', array( $instance, 'form_input_text' ), 10, 4 );
583 add_filter( 'uwp_form_input_html_textarea', array( $instance, 'form_input_textarea' ), 10, 4 );
584 add_filter( 'uwp_form_input_html_editor', array( $instance, 'form_input_editor' ), 10, 4 );
585 add_filter( 'uwp_form_input_html_fieldset', array( $instance, 'form_input_fieldset' ), 10, 4 );
586 add_filter( 'uwp_form_input_html_file', array( $instance, 'form_input_file' ), 10, 4 );
587 add_filter( 'uwp_form_input_html_checkbox', array( $instance, 'form_input_checkbox' ), 10, 4 );
588 add_filter( 'uwp_form_input_html_radio', array( $instance, 'form_input_radio' ), 10, 4 );
589 add_filter( 'uwp_form_input_html_url', array( $instance, 'form_input_url' ), 10, 4 );
590 add_filter( 'uwp_form_input_html_email', array( $instance, 'form_input_email' ), 10, 4 );
591 add_filter( 'uwp_form_input_html_password', array( $instance, 'form_input_password' ), 10, 4 );
592 add_filter( 'uwp_form_input_html_checkbox_register_gdpr', array(
593 $instance,
594 'form_input_register_gdpr'
595 ), 10, 4 );
596 add_filter( 'uwp_form_input_html_checkbox_register_tos', array( $instance, 'form_input_register_tos' ), 10, 4 );
597 // Country select
598 add_filter( 'uwp_form_input_html_select_uwp_country', array( $instance, 'form_input_select_country' ), 10, 4 );
599 add_filter( 'uwp_form_input_html_phone', array( $instance, 'form_input_phone' ), 10, 4 );
600 add_filter( 'uwp_form_input_email_email_after', array( $instance, 'register_confirm_email_field' ), 10, 4 );
601 add_filter( 'uwp_form_input_password_password_after', array(
602 $instance,
603 'register_confirm_password_field'
604 ), 10, 4 );
605 add_filter( 'uwp_form_input_html_custom_html', array( $instance, 'form_custom_html' ), 10, 4 );
606
607 // Emails
608 add_filter( 'uwp_send_mail_form_fields', array( $instance, 'init_mail_form_fields' ), 10, 4 );
609 }
610
611 /**
612 * Actions for notices
613 *
614 * @param $instance
615 */
616 public function load_notices_actions_and_filters( $instance ) {
617 add_action( 'uwp_template_display_notices', array( $instance, 'display_registration_disabled_notice' ) );
618 add_action( 'uwp_template_display_notices', array( $instance, 'form_notice_by_key' ) );
619 add_action( 'admin_notices', array( $instance, 'show_admin_notices' ) );
620 add_action( 'admin_notices', array( $instance, 'try_bootstrap' ) );
621 add_action( 'admin_notices', array( $instance, 'yoast_user_archives_disabled' ) );
622 }
623
624 /**
625 * Actions for pages
626 *
627 * @param $instance
628 */
629 public function load_pages_actions_and_filters( $instance ) {
630 add_action( 'wpmu_new_blog', array( $instance, 'wpmu_generate_default_pages_on_new_site' ), 10, 1 );
631 add_filter( 'display_post_states', array( $instance, 'add_display_post_states' ), 10, 2 );
632 }
633
634 /**
635 * Actions for user profile
636 *
637 * @param $instance
638 */
639 public function load_profile_actions_and_filters( $instance ) {
640 add_action( 'template_redirect', array( $instance, 'redirect_author_page' ), 10, 2 );
641 //profile page
642 add_filter( 'query_vars', array( $instance, 'profile_query_vars' ), 10, 1 );
643 add_action( 'init', array( $instance, 'rewrite_profile_link' ), 10, 1 );
644 add_filter( 'author_link', array( $instance, 'get_author_link' ), 11, 2 );
645 add_filter( 'edit_profile_url', array( $instance, 'modify_admin_bar_edit_profile_url' ), 10, 3 );
646 add_filter( 'the_title', array( $instance, 'modify_profile_page_title' ), 10, 2 );
647 add_filter( 'get_comment_author_link', array( $instance, 'get_comment_author_link' ), 10, 2 );
648 add_action( 'uwp_user_title', array( $instance, 'get_profile_title' ), 10, 2 );
649 add_action( 'uwp_profile_social', array( $instance, 'get_profile_social' ), 10, 2 );
650 add_filter( 'get_avatar_url', array( $instance, 'get_avatar_url' ), 99, 2 );
651
652 // Popup and crop functions
653 add_filter( 'ajax_query_attachments_args', array( $instance, 'restrict_attachment_display' ) );
654 add_action( 'uwp_handle_file_upload_error_checks', array(
655 $instance,
656 'handle_file_upload_error_checks'
657 ), 10, 4 );
658 add_action( 'wp_ajax_uwp_avatar_banner_upload', array( $instance, 'ajax_avatar_banner_upload' ) );
659 add_action( 'wp_ajax_uwp_ajax_image_crop_popup_form', array( $instance, 'ajax_image_crop_popup_form' ) );
660 add_action( 'wp_ajax_uwp_ajax_profile_image_remove', array( $instance, 'ajax_profile_image_remove' ) );
661 add_action( 'wp_head', array( $instance, 'define_ajaxurl' ) );
662 add_action( 'uwp_profile_header', array( $instance, 'image_crop_init' ), 10, 1 );
663 add_action( 'uwp_admin_profile_edit', array( $instance, 'image_crop_init' ), 10, 1 );
664
665 // Profile Tabs
666 add_action( 'uwp_profile_more_info_tab_content', array( $instance, 'get_profile_more_info' ), 10, 1 );
667 add_action( 'uwp_profile_posts_tab_content', array( $instance, 'get_profile_posts' ), 10, 1 );
668 add_action( 'uwp_profile_comments_tab_content', array( $instance, 'get_profile_comments' ), 10, 1 );
669 add_action( 'uwp_profile_user-comments_tab_content', array( $instance, 'get_profile_user_comments' ), 10, 1 );
670
671 // Profile Pagination
672 add_action( 'uwp_profile_pagination', array( $instance, 'get_profile_pagination' ) );
673
674 // Profile title
675 add_action( 'uwp_profile_after_title', array( $instance, 'edit_profile_button' ), 10, 1 );
676
677 // Users
678 add_action( 'uwp_output_location', array( $instance, 'show_output_location_data' ), 10, 2 );
679 add_action( 'wpdiscuz_profile_url', array( $instance, 'wpdiscuz_profile_url' ), 10, 2 );
680
681 // User, allow subscribers to upload profile and banner pictures
682 add_filter( 'plupload_default_params', array( $instance, 'add_uwp_plupload_param' ), 10, 1 );
683 add_filter( 'user_has_cap', array( $instance, 'allow_all_users_profile_uploads' ), 10, 4 );
684 }
685
686 /**
687 * Actions for database tables
688 *
689 * @param $instance
690 */
691 public function load_tables_actions_and_filters( $instance ) {
692 add_filter( 'wpmu_drop_tables', array( $instance, 'drop_tables_on_delete_blog' ) );
693 }
694
695 /**
696 * Actions for templates
697 *
698 * @param $instance
699 */
700 public function load_templates_actions_and_filters( $instance ) {
701
702 add_action( 'template_redirect', array( $instance, 'change_default_password_redirect' ) );
703 add_action( 'uwp_template_fields', array( $instance, 'template_fields' ), 10, 2 );
704 add_action( 'uwp_template_fields', array( $instance, 'template_extra_fields' ), 10, 2 );
705 add_action( 'uwp_account_form_display', array( $instance, 'privacy_edit_form_display' ), 10, 1 );
706 add_action( 'wp_logout', array( $instance, 'logout_redirect' ) );
707 add_action( 'init', array( $instance, 'wp_login_redirect' ) );
708 add_action( 'init', array( $instance, 'wp_register_redirect' ) );
709 // Redirect functions
710 add_action( 'template_redirect', array( $instance, 'profile_redirect' ), 10 );
711 add_action( 'template_redirect', array( $instance, 'access_checks' ), 20 );
712 add_action( 'wp', array( $instance, 'redirect_templates_sub_pages' ) );
713 add_action( 'wp_login', array( $instance, 'unconfirmed_login_redirect' ), 10, 2 );
714
715 add_filter( 'wp_setup_nav_menu_item', array( $instance, 'setup_nav_menu_item' ), 10, 1 );
716 add_filter( 'the_content', array( $instance, 'author_page_content' ), 10, 1 );
717 add_filter( 'the_content', array( $instance, 'author_box_page_content' ), 10, 1 );
718 add_filter( 'the_content', array( $instance, 'setup_singular_page_content' ), 10, 1 );
719 add_filter( 'body_class', array( $instance, 'add_body_class' ), 10, 1 );
720
721 // filter the login and register url
722 add_filter( 'login_url', array( $instance, 'wp_login_url' ), 10, 3 );
723 add_filter( 'register_url', array( $instance, 'wp_register_url' ), 10, 1 );
724 add_filter( 'lostpassword_url', array( $instance, 'wp_lostpassword_url' ), 10, 1 );
725
726 // Oxygen plugin
727 if ( defined( 'CT_VERSION' ) ) {
728 add_filter( 'uwp_get_template', array( $instance, 'oxygen_override_template' ), 11, 5 );
729 }
730
731 }
732
733 /**
734 * Actions for tools
735 *
736 * @param $instance
737 */
738 public function load_tools_actions_and_filters( $instance ) {
739 add_action( 'uwp_admin_sub_menus', array( $instance, 'uwp_add_admin_tools_sub_menu' ), 100, 1 );
740 add_action( 'uwp_tools_settings_main_tab_content', array( $instance, 'uwp_tools_main_tab_content' ) );
741 add_action( 'wp_ajax_uwp_process_diagnosis', array( $instance, 'uwp_process_diagnosis_ajax' ) );
742 }
743
744 /**
745 * Actions for notifications
746 *
747 * @param $instance
748 */
749 public function load_notifications_actions_and_filters( $instance ) {
750 add_action( 'uwp_account_form_display', array( $instance, 'user_notifications_form_front' ), 10, 1 );
751 add_action( 'init', array( $instance, 'notification_submit_handler' ) );
752 }
753
754 /**
755 * Actions for form builder
756 *
757 * @param $instance
758 */
759 public function load_form_builder_actions_and_filters( $instance ) {
760 // Actions
761 add_action( 'uwp_manage_available_fields_predefined', array(
762 $instance,
763 'manage_available_fields_predefined'
764 ) );
765 add_action( 'uwp_manage_available_fields_custom', array( $instance, 'manage_available_fields_custom' ) );
766 add_action( 'uwp_manage_available_fields', array( $instance, 'manage_available_fields' ) );
767 add_action( 'uwp_manage_selected_fields', array( $instance, 'manage_selected_fields' ) );
768 add_action( 'uwp_admin_extra_custom_fields', array( $instance, 'advance_admin_custom_fields' ), 10, 2 );
769
770 add_filter( 'uwp_before_form_builder_content', array( $instance, 'multiple_registration_form' ) );
771 add_filter( 'uwp_before_available_fields', array( $instance, 'display_before_available_fields' ) );
772
773 add_action( 'wp_ajax_uwp_ajax_register_action', array( $instance, 'register_ajax_handler' ) );
774 add_action( 'wp_ajax_uwp_ajax_action', array( $instance, 'create_field' ) );
775 add_action( 'uwp_form_builder_tabs_content', array( $instance, 'uwp_form_builder' ) );
776
777 // Filters
778 add_filter( 'uwp_builder_extra_fields_multiselect', array( $instance, 'builder_extra_fields_smr' ), 10, 4 );
779 add_filter( 'uwp_builder_extra_fields_select', array( $instance, 'builder_extra_fields_smr' ), 10, 4 );
780 add_filter( 'uwp_builder_extra_fields_radio', array( $instance, 'builder_extra_fields_smr' ), 10, 4 );
781 add_filter( 'uwp_builder_extra_fields_datepicker', array(
782 $instance,
783 'builder_extra_fields_datepicker'
784 ), 10, 4 );
785 add_filter( 'uwp_builder_extra_fields_password', array( $instance, 'builder_extra_fields_password' ), 10, 4 );
786 add_filter( 'uwp_builder_extra_fields_email', array( $instance, 'builder_extra_fields_email' ), 10, 4 );
787 add_filter( 'uwp_builder_extra_fields_file', array( $instance, 'builder_extra_fields_file' ), 10, 4 );
788 add_filter( 'uwp_builder_data_type_text', array( $instance, 'builder_data_type_text' ), 10, 4 );
789 add_filter( 'uwp_form_builder_available_fields_head', array(
790 $instance,
791 'register_available_fields_head'
792 ), 10, 2 );
793 add_filter( 'uwp_form_builder_available_fields_note', array(
794 $instance,
795 'register_available_fields_note'
796 ), 10, 2 );
797 add_filter( 'uwp_form_builder_selected_fields_head', array(
798 $instance,
799 'register_selected_fields_head'
800 ), 10, 2 );
801 add_filter( 'uwp_form_builder_selected_fields_note', array(
802 $instance,
803 'register_selected_fields_note'
804 ), 10, 2 );
805 // htmlvar not needed for taxonomy
806 add_filter( 'uwp_builder_htmlvar_name_taxonomy', array( $instance, 'return_empty_string' ), 10, 4 );
807 // default_value not needed for textarea, html, file, fieldset
808 add_filter( 'uwp_builder_default_value_textarea', array( $instance, 'return_empty_string' ), 10, 4 );
809 add_filter( 'uwp_builder_default_value_html', array( $instance, 'return_empty_string' ), 10, 4 );
810 add_filter( 'uwp_builder_default_value_file', array( $instance, 'return_empty_string' ), 10, 4 );
811 add_filter( 'uwp_builder_default_value_fieldset', array( $instance, 'return_empty_string' ), 10, 4 );
812 // is_required not needed for fieldset
813 add_filter( 'uwp_builder_is_required_fieldset', array( $instance, 'return_empty_string' ), 10, 4 );
814 add_filter( 'uwp_builder_required_msg_fieldset', array( $instance, 'return_empty_string' ), 10, 4 );
815 // field_icon not needed for fieldset
816 add_filter( 'uwp_builder_css_class_fieldset', array( $instance, 'return_empty_string' ), 10, 4 );
817 // filters for which is_public not required
818 add_filter( 'uwp_builder_is_public_password', array( $instance, 'return_empty_string' ), 10, 4 );
819 add_filter( 'uwp_builder_validation_pattern_text', array( $instance, 'validation_pattern' ), 10, 4 );
820 add_filter( 'uwp_builder_validation_pattern_email', array( $instance, 'validation_pattern' ), 10, 4 );
821 add_filter( 'uwp_builder_validation_pattern_phone', array( $instance, 'validation_pattern' ), 10, 4 );
822 add_filter( 'uwp_builder_validation_pattern_url', array( $instance, 'validation_pattern' ), 10, 4 );
823 }
824
825 /**
826 * Actions for admin menus
827 *
828 * @param $instance
829 */
830 public function load_menus_actions_and_filters( $instance ) {
831 add_action( 'load-nav-menus.php', array( $instance, 'users_wp_admin_menu_metabox' ) );
832 add_action( 'admin_bar_menu', array( $instance, 'admin_bar_menu' ), 51 );
833 }
834
835 /**
836 * Registers an individual text string for WPML translation.
837 *
838 * @since 1.2.2
839 *
840 * @param string $string The string that needs to be translated.
841 * @param string $domain The plugin domain. Default userswp.
842 * @param string $name The name of the string which helps to know what's being translated.
843 */
844 public static function register_string( $string, $domain = 'userswp', $name = '' ) {
845 do_action( 'wpml_register_single_string', $domain, $name, $string );
846 }
847
848 /**
849 * Register widgets
850 *
851 */
852 public function register_widgets() {
853 global $pagenow;
854
855 $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
856
857 if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
858 // don't initiate in these conditions.
859 }else{
860
861 $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
862 $widgets = $this->get_widgets();
863
864 if( !empty($widgets) ){
865 foreach ( $widgets as $widget ) {
866 if(!in_array($widget,$exclude)){
867 // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
868 if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
869 register_widget( $widget );
870 } else {
871 new $widget();
872 }
873 }
874 }
875 }
876 }
877 }
878
879 public function get_widgets(){
880 $widgets = array(
881 'UWP_Register_Widget',
882 'UWP_Forgot_Widget',
883 'UWP_Login_Widget',
884 'UWP_Change_Widget',
885 'UWP_Reset_Widget',
886 'UWP_Users_Widget',
887 'UWP_Users_Item_Widget',
888 'UWP_Account_Widget',
889 'UWP_Profile_Widget',
890 'UWP_Profile_Header_Widget',
891 'UWP_Profile_Social_Widget',
892 'UWP_Profile_Tabs_Widget',
893 'UWP_Profile_Actions_Widget',
894 'UWP_Profile_Section_Widget',
895 'UWP_User_Title_Widget',
896 'UWP_User_Avatar_Widget',
897 'UWP_User_Cover_Widget',
898 'UWP_User_Post_Counts_Widget',
899 'UWP_User_Meta_Widget',
900 'UWP_Users_Search_Widget',
901 'UWP_Users_Loop_Actions',
902 'UWP_Users_Loop_Widget',
903 'UWP_User_Actions_Widget',
904 'UWP_Output_Location_Widget',
905 'UWP_Author_Box_Widget',
906 'UWP_Button_Group_Widget',
907 'UWP_User_Badge_Widget',
908 );
909
910 return apply_filters('uwp_get_widgets', $widgets );
911 }
912
913 /**
914 * Load the plugin text domain for translation.
915 *
916 * @since 1.0.0
917 * @package userswp
918 * @return void
919 */
920 public function load_plugin_textdomain() {
921
922 load_plugin_textdomain( 'userswp', false, basename( dirname( dirname( __FILE__ ) ) ) . '/languages' );
923
924 do_action( 'uwp_loaded' );
925
926 }
927
928 /**
929 * Flush rewrite rules.
930 *
931 * @return void
932 */
933 public function flush_rewrite_rules() {
934 flush_rewrite_rules();
935 }
936
937 /**
938 * Hide admin bar based on settings.
939 */
940 public function hide_admin_bar(){
941
942 $is_hidden = false;
943 if(is_user_logged_in()){
944 $user = get_userdata(get_current_user_id());
945
946 if($user && isset($user->roles[0])){
947 $user_role = $user->roles[0];
948 $is_hidden = uwp_get_option( 'hide_admin_bar_'.$user_role );
949 }
950 }
951
952 if($is_hidden){
953 show_admin_bar(false);
954 }
955 }
956 }