PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.13
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.13
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.13, at includes/class-userswp.php

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