PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.11
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.11
1.2.73 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 All 173 releases
← All changes | includes/class-userswp.php +61 -68 1.2.631.2.11 View file →
@@ -48,8 +48,9 @@
48 48 *
49 49 * @since 1.0.0
50 50 */
51 51 public function __construct() {
52 +
52 53 $this->plugin_name = USERSWP_NAME;
53 54 $this->version = USERSWP_VERSION;
54 55
55 56
@@ -88,8 +89,9 @@
88 89
89 90 //admin
90 91 $this->load_form_builder_actions_and_filters( $this->form_builder );
91 92 $this->load_menus_actions_and_filters( $this->menus );
93 +
92 94 }
93 95
94 96 /**
95 97 * Load the required dependencies for this plugin.
@@ -257,18 +259,8 @@
257 259 */
258 260 require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-formbuilder.php';
259 261
260 262 /**
261 - * The class responsible for adding admin table listing
262 - */
263 - require_once dirname ( dirname ( __FILE__ ) ) . '/admin/tables/class-user-types-table.php';
264 -
265 - /**
266 - * The class responsible for adding user types
267 - */
268 - require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-user-types.php';
269 -
270 - /**
271 263 * The class responsible for defining all admin area settings.
272 264 */
273 265 require_once dirname( dirname( __FILE__ ) ) . '/admin/settings/class-uwp-settings-profile-tabs.php';
274 266
@@ -508,9 +500,9 @@
508 500 register_activation_hook( USERSWP_PLUGIN_FILE, array( 'UsersWP_Activator', 'activate' ) );
509 501 add_action( 'admin_init', array( 'UsersWP_Activator', 'automatic_upgrade' ) );
510 502 add_action( 'init', array( 'UsersWP_Activator', 'init_background_updater' ), 5 );
511 503 add_action( 'widgets_init', array( $this, 'register_widgets' ) );
512 - add_action( 'plugins_loaded', array( $this, 'load_plugin_textdomain' ) );
504 + add_action( 'init', array( $this, 'load_plugin_textdomain' ) );
513 505 add_action( 'uwp_flush_rewrite_rules', array( $this, 'flush_rewrite_rules' ) );
514 506 add_action( 'uwp_language_file_add_string', array( $this, 'register_string' ), 10, 1 );
515 507 add_action( 'after_setup_theme', array( $this, 'hide_admin_bar' ));
516 508 }
@@ -538,10 +530,8 @@
538 530 add_filter( 'uwp_before_extra_fields_save', array( $instance, 'save_user_ip_on_register' ), 10, 3 );
539 531 add_filter( 'uwp_update_usermeta', array( $instance, 'modify_datepicker_value_on_update' ), 10, 3 );
540 532 add_filter( 'uwp_get_usermeta', array( $instance, 'modify_datepicker_value_on_get' ), 10, 4 );
541 533 add_action( 'get_user_metadata', array( $instance, 'dynamically_add_user_meta' ), 10, 4 );
542 - // enqueue select2 on auth pages.
543 - add_filter( 'aui_is_conditional_select2', array( $this, 'enqueue_select2_on_auth_pages'), 10, 1 );
544 534 }
545 535
546 536 public function load_files_actions_and_filters( $instance ) {
547 537 if ( $instance->doing_upload() ) {
@@ -555,8 +545,9 @@
555 545 *
556 546 * @param $instance
557 547 */
558 548 public function load_forms_actions_and_filters( $instance ) {
549 +
559 550 // login
560 551 add_action( 'wp_ajax_nopriv_uwp_ajax_login_form', array( $instance, 'ajax_login_form' ) );
561 552 add_action( 'wp_ajax_nopriv_uwp_ajax_login', array( $instance, 'process_login' ) );
562 553 add_action( 'wp_ajax_nopriv_uwp_ajax_login_process_2fa', array( $instance, 'process_login_2fa' ) );
@@ -570,9 +561,9 @@
570 561 add_action( 'wp_ajax_nopriv_uwp_ajax_forgot_password', array( $instance, 'process_forgot' ) );
571 562
572 563 // general
573 564 add_action( 'init', array( $instance, 'init_notices' ), 1 );
574 - add_action( 'init', array( $instance, 'handler' ), 11 );
565 + add_action( 'uwp_loaded', array( $instance, 'handler' ) );
575 566 add_action( 'init', array( $instance, 'privacy_submit_handler' ) );
576 567 add_action( 'uwp_template_display_notices', array( $instance, 'display_notices' ), 10, 1 );
577 568 add_action( 'wp_ajax_uwp_upload_file_remove', array( $instance, 'upload_file_remove' ) );
578 569 //User search form
@@ -600,15 +591,21 @@
600 591 add_filter( 'uwp_form_input_html_radio', array( $instance, 'form_input_radio' ), 10, 4 );
601 592 add_filter( 'uwp_form_input_html_url', array( $instance, 'form_input_url' ), 10, 4 );
602 593 add_filter( 'uwp_form_input_html_email', array( $instance, 'form_input_email' ), 10, 4 );
603 594 add_filter( 'uwp_form_input_html_password', array( $instance, 'form_input_password' ), 10, 4 );
604 - add_filter( 'uwp_form_input_html_checkbox_register_gdpr', array( $instance, 'form_input_register_gdpr' ), 10, 4 );
595 + add_filter( 'uwp_form_input_html_checkbox_register_gdpr', array(
596 + $instance,
597 + 'form_input_register_gdpr'
598 + ), 10, 4 );
605 599 add_filter( 'uwp_form_input_html_checkbox_register_tos', array( $instance, 'form_input_register_tos' ), 10, 4 );
606 600 // Country select
607 601 add_filter( 'uwp_form_input_html_select_uwp_country', array( $instance, 'form_input_select_country' ), 10, 4 );
608 602 add_filter( 'uwp_form_input_html_phone', array( $instance, 'form_input_phone' ), 10, 4 );
609 603 add_filter( 'uwp_form_input_email_email_after', array( $instance, 'register_confirm_email_field' ), 10, 4 );
610 - add_filter( 'uwp_form_input_password_password_after', array( $instance, 'register_confirm_password_field' ), 10, 4 );
604 + add_filter( 'uwp_form_input_password_password_after', array(
605 + $instance,
606 + 'register_confirm_password_field'
607 + ), 10, 4 );
611 608 add_filter( 'uwp_form_input_html_custom_html', array( $instance, 'form_custom_html' ), 10, 4 );
612 609 add_filter( 'uwp_form_input_html_select_uwp_language', array( $instance, 'form_input_uwp_language' ), 10, 4 );
613 610
614 611 // Emails
@@ -645,9 +642,9 @@
645 642 * @param $instance
646 643 */
647 644 public function load_profile_actions_and_filters( $instance ) {
648 645 add_action( 'template_redirect', array( $instance, 'redirect_author_page' ), 10, 2 );
649 - // Profile page
646 + //profile page
650 647 add_filter( 'query_vars', array( $instance, 'profile_query_vars' ), 10, 1 );
651 648 add_action( 'init', array( $instance, 'rewrite_profile_link' ), 10, 1 );
652 649 add_filter( 'author_link', array( $instance, 'get_author_link' ), 11, 2 );
653 650 add_filter( 'edit_profile_url', array( $instance, 'modify_admin_bar_edit_profile_url' ), 10, 3 );
@@ -658,9 +655,12 @@
658 655 add_filter( 'get_avatar_url', array( $instance, 'get_avatar_url' ), 99, 2 );
659 656
660 657 // Popup and crop functions
661 658 add_filter( 'ajax_query_attachments_args', array( $instance, 'restrict_attachment_display' ) );
662 - add_action( 'uwp_handle_file_upload_error_checks', array( $instance, 'handle_file_upload_error_checks' ), 10, 4 );
659 + add_action( 'uwp_handle_file_upload_error_checks', array(
660 + $instance,
661 + 'handle_file_upload_error_checks'
662 + ), 10, 4 );
663 663 add_action( 'wp_ajax_uwp_avatar_banner_upload', array( $instance, 'ajax_avatar_banner_upload' ) );
664 664 add_action( 'wp_ajax_uwp_ajax_image_crop_popup_form', array( $instance, 'ajax_image_crop_popup_form' ) );
665 665 add_action( 'wp_ajax_uwp_ajax_profile_image_remove', array( $instance, 'ajax_profile_image_remove' ) );
666 666 add_action( 'wp_head', array( $instance, 'define_ajaxurl' ) );
@@ -702,8 +702,9 @@
702 702 *
703 703 * @param $instance
704 704 */
705 705 public function load_templates_actions_and_filters( $instance ) {
706 +
706 707 add_action( 'template_redirect', array( $instance, 'change_default_password_redirect' ) );
707 708 add_action( 'uwp_template_fields', array( $instance, 'template_fields' ), 10, 2 );
708 709 add_action( 'uwp_template_fields', array( $instance, 'template_extra_fields' ), 10, 2 );
709 710 add_action( 'uwp_account_form_display', array( $instance, 'privacy_edit_form_display' ), 10, 1 );
@@ -719,12 +720,11 @@
719 720 add_filter( 'wp_setup_nav_menu_item', array( $instance, 'setup_nav_menu_item' ), 10, 1 );
720 721 add_filter( 'the_content', array( $instance, 'author_page_content' ), 10, 1 );
721 722 add_filter( 'the_content', array( $instance, 'author_box_page_content' ), 10, 1 );
722 723 add_filter( 'the_content', array( $instance, 'setup_singular_page_content' ), 10, 1 );
723 - add_filter( 'the_content', array( $instance, 'set_the_content_hook' ), 5, 1 );
724 724 add_filter( 'body_class', array( $instance, 'add_body_class' ), 10, 1 );
725 725
726 - // Filter the login and register url
726 + // filter the login and register url
727 727 add_filter( 'login_url', array( $instance, 'wp_login_url' ), 10, 3 );
728 728 add_filter( 'register_url', array( $instance, 'wp_register_url' ), 10, 1 );
729 729 add_filter( 'lostpassword_url', array( $instance, 'wp_lostpassword_url' ), 10, 1 );
730 730
@@ -731,8 +731,9 @@
731 731 // Oxygen plugin
732 732 if ( defined( 'CT_VERSION' ) ) {
733 733 add_filter( 'uwp_get_template', array( $instance, 'oxygen_override_template' ), 11, 5 );
734 734 }
735 +
735 736 }
736 737
737 738 /**
738 739 * Actions for tools
@@ -761,9 +762,12 @@
761 762 * @param $instance
762 763 */
763 764 public function load_form_builder_actions_and_filters( $instance ) {
764 765 // Actions
765 - add_action( 'uwp_manage_available_fields_predefined', array( $instance, 'manage_available_fields_predefined' ) );
766 + add_action( 'uwp_manage_available_fields_predefined', array(
767 + $instance,
768 + 'manage_available_fields_predefined'
769 + ) );
766 770 add_action( 'uwp_manage_available_fields_custom', array( $instance, 'manage_available_fields_custom' ) );
767 771 add_action( 'uwp_manage_available_fields', array( $instance, 'manage_available_fields' ) );
768 772 add_action( 'uwp_manage_selected_fields', array( $instance, 'manage_selected_fields' ) );
769 773 add_action( 'uwp_admin_extra_custom_fields', array( $instance, 'advance_admin_custom_fields' ), 10, 2 );
@@ -778,17 +782,32 @@
778 782 // Filters
779 783 add_filter( 'uwp_builder_extra_fields_multiselect', array( $instance, 'builder_extra_fields_smr' ), 10, 4 );
780 784 add_filter( 'uwp_builder_extra_fields_select', array( $instance, 'builder_extra_fields_smr' ), 10, 4 );
781 785 add_filter( 'uwp_builder_extra_fields_radio', array( $instance, 'builder_extra_fields_smr' ), 10, 4 );
782 - add_filter( 'uwp_builder_extra_fields_datepicker', array( $instance, 'builder_extra_fields_datepicker' ), 10, 4 );
786 + add_filter( 'uwp_builder_extra_fields_datepicker', array(
787 + $instance,
788 + 'builder_extra_fields_datepicker'
789 + ), 10, 4 );
783 790 add_filter( 'uwp_builder_extra_fields_password', array( $instance, 'builder_extra_fields_password' ), 10, 4 );
784 791 add_filter( 'uwp_builder_extra_fields_email', array( $instance, 'builder_extra_fields_email' ), 10, 4 );
785 792 add_filter( 'uwp_builder_extra_fields_file', array( $instance, 'builder_extra_fields_file' ), 10, 4 );
786 793 add_filter( 'uwp_builder_data_type_text', array( $instance, 'builder_data_type_text' ), 10, 4 );
787 - add_filter( 'uwp_form_builder_available_fields_head', array( $instance, 'register_available_fields_head' ), 10, 2 );
788 - add_filter( 'uwp_form_builder_available_fields_note', array( $instance, 'register_available_fields_note' ), 10, 2 );
789 - add_filter( 'uwp_form_builder_selected_fields_head', array( $instance, 'register_selected_fields_head' ), 10, 2 );
790 - add_filter( 'uwp_form_builder_selected_fields_note', array( $instance, 'register_selected_fields_note' ), 10, 2 );
794 + add_filter( 'uwp_form_builder_available_fields_head', array(
795 + $instance,
796 + 'register_available_fields_head'
797 + ), 10, 2 );
798 + add_filter( 'uwp_form_builder_available_fields_note', array(
799 + $instance,
800 + 'register_available_fields_note'
801 + ), 10, 2 );
802 + add_filter( 'uwp_form_builder_selected_fields_head', array(
803 + $instance,
804 + 'register_selected_fields_head'
805 + ), 10, 2 );
806 + add_filter( 'uwp_form_builder_selected_fields_note', array(
807 + $instance,
808 + 'register_selected_fields_note'
809 + ), 10, 2 );
791 810 // htmlvar not needed for taxonomy
792 811 add_filter( 'uwp_builder_htmlvar_name_taxonomy', array( $instance, 'return_empty_string' ), 10, 4 );
793 812 // default_value not needed for textarea, html, file, fieldset
794 813 add_filter( 'uwp_builder_default_value_textarea', array( $instance, 'return_empty_string' ), 10, 4 );
@@ -837,19 +856,20 @@
837 856 */
838 857 public function register_widgets() {
839 858 global $pagenow;
840 859
841 - $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
860 + $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
842 861
843 - if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
844 - // Don't initiate in these conditions.
845 - } else {
846 - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
862 + if ( is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
863 + // don't initiate in these conditions.
864 + }else{
865 +
866 + $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
847 867 $widgets = $this->get_widgets();
848 868
849 - if ( ! empty( $widgets ) ) {
869 + if( !empty($widgets) ){
850 870 foreach ( $widgets as $widget ) {
851 - if ( ! in_array( $widget, $exclude ) ) {
871 + if(!in_array($widget,$exclude)){
852 872 // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
853 873 if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
854 874 register_widget( $widget );
855 875 } else {
@@ -902,40 +922,13 @@
902 922 * @package userswp
903 923 * @return void
904 924 */
905 925 public function load_plugin_textdomain() {
906 - // Determines the current locale.
907 - if ( function_exists( 'determine_locale' ) ) {
908 - $locale = determine_locale();
909 - } else if ( function_exists( 'get_user_locale' ) ) {
910 - $locale = get_user_locale();
911 - } else {
912 - $locale = get_locale();
913 - }
914 926
915 - /**
916 - * Filter the locale to use for translations.
917 - */
918 - $locale = apply_filters( 'plugin_locale', $locale, 'userswp' );
927 + load_plugin_textdomain( 'userswp', false, basename( dirname( dirname( __FILE__ ) ) ) . '/languages' );
919 928
920 - unload_textdomain( 'userswp', true );
921 - load_textdomain( 'userswp', WP_LANG_DIR . '/userswp/userswp-' . $locale . '.mo' );
922 - load_plugin_textdomain( 'userswp', false, plugin_basename( dirname( USERSWP_PLUGIN_FILE ) ) . '/languages/' );
923 -
924 929 do_action( 'uwp_loaded' );
925 - }
926 930
927 - /**
928 - * Ensure Select2 is enqueued in auth pages only if not already done.
929 - *
930 - * @return void
931 - *
932 - * @since 1.2.29
933 - */
934 - public function enqueue_select2_on_auth_pages() {
935 - if ( ! wp_script_is( 'select2', 'enqueued' ) ) {
936 - wp_enqueue_script( 'select2' );
937 - }
938 931 }
939 932
940 933 /**
941 934 * Flush rewrite rules.
@@ -948,21 +941,21 @@
948 941
949 942 /**
950 943 * Hide admin bar based on settings.
951 944 */
952 - public function hide_admin_bar() {
945 + public function hide_admin_bar(){
946 +
953 947 $is_hidden = false;
948 + if(is_user_logged_in()){
949 + $user = get_userdata(get_current_user_id());
954 950
955 - if ( is_user_logged_in() ) {
956 - $user = get_userdata( (int) get_current_user_id() );
957 -
958 - if ( ! empty( $user ) && isset( $user->roles[0] ) ) {
951 + if($user && isset($user->roles[0])){
959 952 $user_role = $user->roles[0];
960 953 $is_hidden = uwp_get_option( 'hide_admin_bar_'.$user_role );
961 954 }
962 955 }
963 956
964 - if ( $is_hidden ) {
965 - show_admin_bar( false );
957 + if($is_hidden){
958 + show_admin_bar(false);
966 959 }
967 960 }
968 961 }