From 8b4004e0e4f70185f58dbd148ef3fb4ce77f9874 Mon Sep 17 00:00:00 2001 From: denisbaranov Date: Mon, 1 Oct 2018 18:35:59 +0300 Subject: [PATCH 01/11] Additional search filters for members helpscout#24541 Member Directory filter shortcode and search bar on paginated pages --- includes/admin/templates/directory/search.php | 11 ++++++++- includes/class-config.php | 1 + includes/core/um-filters-members.php | 23 +++++++++++++++---- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/includes/admin/templates/directory/search.php b/includes/admin/templates/directory/search.php index fa33f47c..1b1a3189 100644 --- a/includes/admin/templates/directory/search.php +++ b/includes/admin/templates/directory/search.php @@ -78,6 +78,15 @@ 'add_text' => __( 'Add New Custom Field','ultimate-member' ), 'show_default_number' => 1, ), + array( + 'id' => '_um_search_filters', + 'type' => 'text', + 'label' => __( 'Additional search filters', 'ultimate-member' ), + 'tooltip' => __( 'Additional search filters like URL parameters' ), + 'value' => UM()->query()->get_meta_value('_um_search_filters', null, '' ), + 'conditional' => array( '_um_search', '=', 1 ), + 'placeholder' => 'field1=val1&field2=val2' + ), array( 'id' => '_um_directory_header', 'type' => 'text', @@ -104,6 +113,6 @@ ) ) ) )->render_form(); ?> - +
\ No newline at end of file diff --git a/includes/class-config.php b/includes/class-config.php index e05eb15b..e6ee9b7d 100644 --- a/includes/class-config.php +++ b/includes/class-config.php @@ -149,6 +149,7 @@ if ( ! class_exists( 'um\Config' ) ) { '_um_profile_photo' => '1', '_um_cover_photos' => '1', '_um_show_name' => '1', + '_um_search_filters' => '', '_um_directory_header' => __('{total_users} Members','ultimate-member'), '_um_directory_header_single' => __('{total_users} Member','ultimate-member'), '_um_directory_no_users' => __('We are sorry. We cannot find any users who match your search criteria.','ultimate-member'), diff --git a/includes/core/um-filters-members.php b/includes/core/um-filters-members.php index 52285d33..bcb88071 100644 --- a/includes/core/um-filters-members.php +++ b/includes/core/um-filters-members.php @@ -100,6 +100,8 @@ add_filter( 'um_prepare_user_query_args', 'um_remove_special_users_from_list', 9 /** * Adds search parameters * + * @hooked 'um_prepare_user_query_args' + * * @param $query_args * @param $args * @@ -108,10 +110,21 @@ add_filter( 'um_prepare_user_query_args', 'um_remove_special_users_from_list', 9 function um_add_search_to_query( $query_args, $args ){ extract( $args ); + if( !empty( $args['search_filters'] ) ){ + $_REQUEST['um_search'] = 1; + } + if ( isset( $_REQUEST['um_search'] ) ) { $query = UM()->permalinks()->get_query_array(); + if( !empty( $args['search_filters'] ) ){ + parse_str( $args['search_filters'], $search_filters ); + if( $search_filters && is_array( $search_filters ) ){ + $query = array_merge( $search_filters, $query ); + } + } + // if searching if ( isset( $query['search'] ) ) { $query_args['search'] = '*' . um_filter_search( $query['search'] ) . '*'; @@ -154,7 +167,7 @@ function um_add_search_to_query( $query_args, $args ){ ) ); if ( in_array( $filter_data['attrs']['type'], $types ) ) { - + $arr_meta_query = array( array( 'key' => $field, @@ -383,7 +396,7 @@ function um_prepare_user_query_args( $query_args, $args ) { $sortby = str_replace('_asc','',$sortby); $order = 'ASC'; } - + $query_args['orderby'] = $sortby; } @@ -469,14 +482,14 @@ function um_modify_sortby_randomly( $query ) { if( isset( $_SESSION['seed'] ) ) { $seed = $_SESSION['seed']; } - + // Set new seed if none exists if ( ! $seed ) { $seed = rand(); $_SESSION['seed'] = $seed; } - + $query->query_orderby = 'ORDER by RAND('. $seed.')'; } @@ -498,7 +511,7 @@ function um_prepare_user_results_array( $result ) { } else { $result['no_users'] = 0; } - + return $result; } add_filter( 'um_prepare_user_results_array', 'um_prepare_user_results_array', 50, 2 ); From c2269048275b247277166d9d94b641939f772dd6 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 2 Oct 2018 09:23:18 +0300 Subject: [PATCH 02/11] - fixed PHPDoc for Groups extension; --- includes/class-init.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/class-init.php b/includes/class-init.php index 1de8286a..28aba1b7 100644 --- a/includes/class-init.php +++ b/includes/class-init.php @@ -31,6 +31,7 @@ if ( ! class_exists( 'UM' ) ) { * @method UM_Private_Content_API Private_Content_API() * @method UM_User_Location_API User_Location_API() * @method UM_Photos_API Photos_API() + * @method UM_Groups Groups() * */ final class UM extends UM_Functions { From 1fb0ed23091ed504ce0848a82faeae184d4c8431 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 2 Oct 2018 09:26:06 +0300 Subject: [PATCH 03/11] - changed time for first activation review notice; --- includes/admin/core/class-admin-notices.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/admin/core/class-admin-notices.php b/includes/admin/core/class-admin-notices.php index 5f6c5aa6..24850135 100644 --- a/includes/admin/core/class-admin-notices.php +++ b/includes/admin/core/class-admin-notices.php @@ -631,7 +631,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) { return; } - if ( $first_activation_date + MONTH_IN_SECONDS > time() ) { + if ( $first_activation_date + 2*WEEK_IN_SECONDS > time() ) { return; } From 7b9f26d6cf2cd31424615527a75f9b99bf3ec9fc Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 2 Oct 2018 12:25:22 +0300 Subject: [PATCH 04/11] - changed readme; --- readme.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 30c7cb7d..820502d6 100644 --- a/readme.txt +++ b/readme.txt @@ -58,6 +58,8 @@ Ultimate Member has a range of extensions that allow you to extend the power of * [Notices](https://ultimatemember.com/extensions/notices/) - Alert users to important information using conditional notices * [Profile Completeness](https://ultimatemember.com/extensions/profile-completeness/) - Encourage or force users to complete their profiles with the profile completeness extension * [Friends](https://ultimatemember.com/extensions/friends/) - Allows users to become friends by sending & accepting/rejecting friend requests +* [User Photos](https://ultimatemember.com/extensions/user-photos/) - Allow users to upload photos to their profile +* [Groups](https://ultimatemember.com/extensions/groups/) - Allow users to create and join groups around shared topics, interests etc. = Free Extensions = @@ -131,10 +133,11 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = -= 2.0.26: September 18, 2018 = += 2.0.26: October 2, 2018 = * Enhancements: - New files/images downloading process + - Added dependencies with User Photos and Groups extensions * Bugfixes: - File/Image email placeholders after registration form submitting From 48800351adc8f0e2005346631cce6c9ad2d52ecc Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 2 Oct 2018 13:05:13 +0300 Subject: [PATCH 05/11] - changed translate file; --- includes/admin/core/class-admin-enqueue.php | 2 +- includes/core/um-filters-members.php | 8 +- languages/ultimate-member-en_US.po | 298 ++++++++++---------- 3 files changed, 158 insertions(+), 150 deletions(-) diff --git a/includes/admin/core/class-admin-enqueue.php b/includes/admin/core/class-admin-enqueue.php index 2c0ebe5d..127154b0 100644 --- a/includes/admin/core/class-admin-enqueue.php +++ b/includes/admin/core/class-admin-enqueue.php @@ -57,7 +57,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Enqueue' ) ) { * Load js for Add/Edit User form */ function load_role_wrapper() { - wp_register_script( 'um_admin_role_wrapper', $this->js_url . 'um-admin-role-wrapper.js', '', '', true ); + wp_register_script( 'um_admin_role_wrapper', $this->js_url . 'um-admin-role-wrapper.js', '', ultimatemember_version, true ); wp_enqueue_script( 'um_admin_role_wrapper' ); $localize_roles_data = get_option( 'um_roles' ); diff --git a/includes/core/um-filters-members.php b/includes/core/um-filters-members.php index bcb88071..537e25d1 100644 --- a/includes/core/um-filters-members.php +++ b/includes/core/um-filters-members.php @@ -107,10 +107,10 @@ add_filter( 'um_prepare_user_query_args', 'um_remove_special_users_from_list', 9 * * @return mixed|void */ -function um_add_search_to_query( $query_args, $args ){ +function um_add_search_to_query( $query_args, $args ) { extract( $args ); - if( !empty( $args['search_filters'] ) ){ + if ( ! empty( $args['search_filters'] ) ) { $_REQUEST['um_search'] = 1; } @@ -118,9 +118,9 @@ function um_add_search_to_query( $query_args, $args ){ $query = UM()->permalinks()->get_query_array(); - if( !empty( $args['search_filters'] ) ){ + if ( ! empty( $args['search_filters'] ) ) { parse_str( $args['search_filters'], $search_filters ); - if( $search_filters && is_array( $search_filters ) ){ + if ( $search_filters && is_array( $search_filters ) ) { $query = array_merge( $search_filters, $query ); } } diff --git a/languages/ultimate-member-en_US.po b/languages/ultimate-member-en_US.po index 5985ef14..719f37d4 100644 --- a/languages/ultimate-member-en_US.po +++ b/languages/ultimate-member-en_US.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Ultimate Member\n" -"POT-Creation-Date: 2018-09-18 09:44+0300\n" -"PO-Revision-Date: 2018-09-18 09:45+0300\n" +"POT-Creation-Date: 2018-10-02 13:01+0300\n" +"PO-Revision-Date: 2018-10-02 13:01+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: en_US\n" @@ -94,62 +94,62 @@ msgstr "" msgid "Reset all rules" msgstr "" -#: includes/admin/core/class-admin-builder.php:402 -#: includes/admin/core/class-admin-builder.php:472 +#: includes/admin/core/class-admin-builder.php:401 +#: includes/admin/core/class-admin-builder.php:471 #: includes/admin/core/class-admin-dragdrop.php:161 msgid "Add Row" msgstr "" -#: includes/admin/core/class-admin-builder.php:403 -#: includes/admin/core/class-admin-builder.php:473 +#: includes/admin/core/class-admin-builder.php:402 +#: includes/admin/core/class-admin-builder.php:472 #: includes/admin/core/class-admin-dragdrop.php:162 msgid "Edit Row" msgstr "" -#: includes/admin/core/class-admin-builder.php:476 +#: includes/admin/core/class-admin-builder.php:475 #: includes/admin/core/class-admin-dragdrop.php:164 #: includes/admin/core/class-admin-dragdrop.php:178 #: includes/admin/core/class-admin-dragdrop.php:203 msgid "Delete Row" msgstr "" -#: includes/admin/core/class-admin-builder.php:610 -#: includes/admin/core/class-admin-builder.php:764 -#: includes/core/class-fields.php:4034 +#: includes/admin/core/class-admin-builder.php:609 +#: includes/admin/core/class-admin-builder.php:763 +#: includes/core/class-fields.php:4026 msgid "Please login as administrator" msgstr "" -#: includes/admin/core/class-admin-builder.php:830 +#: includes/admin/core/class-admin-builder.php:827 msgid "Search Icons..." msgstr "" -#: includes/admin/core/class-admin-builder.php:851 +#: includes/admin/core/class-admin-builder.php:847 msgid "Setup New Field" msgstr "" -#: includes/admin/core/class-admin-builder.php:867 +#: includes/admin/core/class-admin-builder.php:863 msgid "Predefined Fields" msgstr "" -#: includes/admin/core/class-admin-builder.php:878 +#: includes/admin/core/class-admin-builder.php:874 #: includes/core/class-builtin.php:1308 msgid "None" msgstr "" -#: includes/admin/core/class-admin-builder.php:882 +#: includes/admin/core/class-admin-builder.php:878 msgid "Custom Fields" msgstr "" -#: includes/admin/core/class-admin-builder.php:893 +#: includes/admin/core/class-admin-builder.php:889 msgid "You did not create any custom fields" msgstr "" -#: includes/admin/core/class-admin-builder.php:925 -#: includes/admin/core/class-admin-builder.php:999 +#: includes/admin/core/class-admin-builder.php:920 +#: includes/admin/core/class-admin-builder.php:992 msgid "This field type is not setup correcty." msgstr "" -#: includes/admin/core/class-admin-builder.php:1146 +#: includes/admin/core/class-admin-builder.php:1137 #: includes/core/class-form.php:153 includes/core/class-form.php:326 #: includes/core/class-password.php:518 msgid "This is not possible for security reasons." @@ -188,10 +188,10 @@ msgstr "" #: includes/admin/core/class-admin-enqueue.php:127 #: includes/admin/core/class-admin-enqueue.php:161 -#: includes/admin/core/class-admin-forms.php:814 -#: includes/admin/core/class-admin-forms.php:828 -#: includes/admin/core/class-admin-forms.php:933 -#: includes/admin/core/class-admin-forms.php:942 +#: includes/admin/core/class-admin-forms.php:813 +#: includes/admin/core/class-admin-forms.php:827 +#: includes/admin/core/class-admin-forms.php:932 +#: includes/admin/core/class-admin-forms.php:941 #: includes/admin/core/class-admin-notices.php:430 #: includes/core/um-actions-profile.php:553 msgid "Remove" @@ -199,7 +199,7 @@ msgstr "" #: includes/admin/core/class-admin-enqueue.php:128 #: includes/admin/core/class-admin-enqueue.php:162 -#: includes/admin/core/class-admin-forms.php:1010 +#: includes/admin/core/class-admin-forms.php:1009 msgid "Select" msgstr "" @@ -215,11 +215,11 @@ msgstr "" msgid "No Icon" msgstr "" -#: includes/admin/core/class-admin-forms.php:987 +#: includes/admin/core/class-admin-forms.php:986 msgid "Select media" msgstr "" -#: includes/admin/core/class-admin-forms.php:1011 +#: includes/admin/core/class-admin-forms.php:1010 msgid "Clear" msgstr "" @@ -1534,7 +1534,7 @@ msgid "" msgstr "" #: includes/admin/core/class-admin-settings.php:338 -#: includes/class-config.php:134 includes/class-config.php:738 +#: includes/class-config.php:134 includes/class-config.php:739 #: includes/core/class-account.php:90 msgid "Account" msgstr "" @@ -2482,7 +2482,7 @@ msgid "UM Action" msgstr "" #: includes/admin/core/class-admin-users.php:116 -#: includes/core/class-fields.php:2276 +#: includes/core/class-fields.php:2271 msgid "Apply" msgstr "" @@ -3129,44 +3129,52 @@ msgid "Choose field(s) to enable in search" msgstr "" #: includes/admin/templates/directory/search.php:84 -msgid "Results Text" +msgid "Additional search filters" msgstr "" #: includes/admin/templates/directory/search.php:85 +msgid "Additional search filters like URL parameters" +msgstr "" + +#: includes/admin/templates/directory/search.php:93 +msgid "Results Text" +msgstr "" + +#: includes/admin/templates/directory/search.php:94 msgid "" "Customize the search result text . e.g. Found 3,000 Members. Leave this " "blank to not show result text" msgstr "" -#: includes/admin/templates/directory/search.php:86 -#: includes/class-config.php:152 includes/class-config.php:247 +#: includes/admin/templates/directory/search.php:95 +#: includes/class-config.php:153 includes/class-config.php:248 msgid "{total_users} Members" msgstr "" -#: includes/admin/templates/directory/search.php:92 +#: includes/admin/templates/directory/search.php:101 msgid "Single Result Text" msgstr "" -#: includes/admin/templates/directory/search.php:93 +#: includes/admin/templates/directory/search.php:102 msgid "Same as above but in case of 1 user found only" msgstr "" -#: includes/admin/templates/directory/search.php:94 -#: includes/class-config.php:153 includes/class-config.php:248 +#: includes/admin/templates/directory/search.php:103 +#: includes/class-config.php:154 includes/class-config.php:249 msgid "{total_users} Member" msgstr "" -#: includes/admin/templates/directory/search.php:100 +#: includes/admin/templates/directory/search.php:109 msgid "Custom text if no users were found" msgstr "" -#: includes/admin/templates/directory/search.php:101 +#: includes/admin/templates/directory/search.php:110 msgid "" "This is the text that is displayed if no users are found during a search" msgstr "" -#: includes/admin/templates/directory/search.php:102 -#: includes/class-config.php:154 +#: includes/admin/templates/directory/search.php:111 +#: includes/class-config.php:155 msgid "We are sorry. We cannot find any users who match your search criteria." msgstr "" @@ -3518,7 +3526,7 @@ msgstr "" #: includes/admin/templates/modal/dynamic_new_group.php:14 #: includes/admin/templates/modal/fonticons.php:11 #: includes/admin/templates/role/publish.php:24 -#: includes/core/class-fields.php:2277 includes/core/class-fields.php:2367 +#: includes/core/class-fields.php:2272 includes/core/class-fields.php:2362 #: includes/core/um-actions-profile.php:554 #: includes/core/um-actions-profile.php:693 #: includes/core/um-actions-profile.php:726 @@ -3867,145 +3875,145 @@ msgstr "" msgid "Check All" msgstr "" -#: includes/class-config.php:129 includes/class-config.php:733 +#: includes/class-config.php:129 includes/class-config.php:734 msgid "User" msgstr "" -#: includes/class-config.php:130 includes/class-config.php:234 -#: includes/class-config.php:240 includes/class-config.php:734 +#: includes/class-config.php:130 includes/class-config.php:235 +#: includes/class-config.php:241 includes/class-config.php:735 msgid "Login" msgstr "" -#: includes/class-config.php:131 includes/class-config.php:232 -#: includes/class-config.php:244 includes/class-config.php:735 +#: includes/class-config.php:131 includes/class-config.php:233 +#: includes/class-config.php:245 includes/class-config.php:736 msgid "Register" msgstr "" -#: includes/class-config.php:132 includes/class-config.php:736 +#: includes/class-config.php:132 includes/class-config.php:737 msgid "Members" msgstr "" -#: includes/class-config.php:133 includes/class-config.php:737 +#: includes/class-config.php:133 includes/class-config.php:738 #: includes/core/um-actions-profile.php:1079 #: includes/core/um-actions-user.php:15 msgid "Logout" msgstr "" -#: includes/class-config.php:135 includes/class-config.php:739 +#: includes/class-config.php:135 includes/class-config.php:740 msgid "Password Reset" msgstr "" -#: includes/class-config.php:307 +#: includes/class-config.php:308 msgid "Account Welcome Email" msgstr "" -#: includes/class-config.php:318 +#: includes/class-config.php:319 msgid "" "Whether to send the user an email when his account is automatically approved" msgstr "" -#: includes/class-config.php:324 +#: includes/class-config.php:325 msgid "Account Activation Email" msgstr "" -#: includes/class-config.php:332 +#: includes/class-config.php:333 msgid "" "Whether to send the user an email when his account needs e-mail activation" msgstr "" -#: includes/class-config.php:337 +#: includes/class-config.php:338 msgid "Your account is pending review" msgstr "" -#: includes/class-config.php:345 +#: includes/class-config.php:346 msgid "Whether to send the user an email when his account needs admin review" msgstr "" -#: includes/class-config.php:350 +#: includes/class-config.php:351 msgid "Account Approved Email" msgstr "" -#: includes/class-config.php:362 +#: includes/class-config.php:363 msgid "Whether to send the user an email when his account is approved" msgstr "" -#: includes/class-config.php:367 +#: includes/class-config.php:368 msgid "Account Rejected Email" msgstr "" -#: includes/class-config.php:374 +#: includes/class-config.php:375 msgid "Whether to send the user an email when his account is rejected" msgstr "" -#: includes/class-config.php:379 +#: includes/class-config.php:380 msgid "Account Deactivated Email" msgstr "" -#: includes/class-config.php:386 +#: includes/class-config.php:387 msgid "Whether to send the user an email when his account is deactivated" msgstr "" -#: includes/class-config.php:392 +#: includes/class-config.php:393 msgid "Account Deleted Email" msgstr "" -#: includes/class-config.php:399 +#: includes/class-config.php:400 msgid "Whether to send the user an email when his account is deleted" msgstr "" -#: includes/class-config.php:405 +#: includes/class-config.php:406 msgid "Password Reset Email" msgstr "" -#: includes/class-config.php:413 +#: includes/class-config.php:414 msgid "" "Whether to send an email when users changed their password (Recommended, " "please keep on)" msgstr "" -#: includes/class-config.php:419 +#: includes/class-config.php:420 msgid "Password Changed Email" msgstr "" -#: includes/class-config.php:426 +#: includes/class-config.php:427 msgid "" "Whether to send the user an email when he request to reset password " "(Recommended, please keep on)" msgstr "" -#: includes/class-config.php:432 +#: includes/class-config.php:433 msgid "Account Updated Email" msgstr "" -#: includes/class-config.php:439 +#: includes/class-config.php:440 msgid "Whether to send the user an email when he updated their account" msgstr "" -#: includes/class-config.php:445 +#: includes/class-config.php:446 msgid "New User Notification" msgstr "" -#: includes/class-config.php:451 +#: includes/class-config.php:452 msgid "Whether to receive notification when a new user account is approved" msgstr "" -#: includes/class-config.php:457 +#: includes/class-config.php:458 msgid "Account Needs Review Notification" msgstr "" -#: includes/class-config.php:464 +#: includes/class-config.php:465 msgid "Whether to receive notification when an account needs admin review" msgstr "" -#: includes/class-config.php:469 +#: includes/class-config.php:470 msgid "Account Deletion Notification" msgstr "" -#: includes/class-config.php:472 +#: includes/class-config.php:473 msgid "Whether to receive notification when an account is deleted" msgstr "" -#: includes/class-config.php:495 +#: includes/class-config.php:496 msgid "" "Are you sure you want to delete your account? This will erase all of your " "account data from the site. To delete your account enter your password below" @@ -4045,7 +4053,7 @@ msgstr "" msgid "Correct folder name is \"%s\"" msgstr "" -#: includes/class-init.php:159 includes/class-init.php:168 +#: includes/class-init.php:160 includes/class-init.php:169 msgid "Cheatin’ huh?" msgstr "" @@ -6236,116 +6244,116 @@ msgstr "" msgid "Add translation to %s" msgstr "" -#: includes/core/class-fields.php:1160 +#: includes/core/class-fields.php:1155 msgid "Custom Field" msgstr "" -#: includes/core/class-fields.php:1457 +#: includes/core/class-fields.php:1452 msgid "Please upload a valid image!" msgstr "" -#: includes/core/class-fields.php:1464 includes/core/class-fields.php:1485 +#: includes/core/class-fields.php:1459 includes/core/class-fields.php:1480 msgid "Upload" msgstr "" -#: includes/core/class-fields.php:1465 +#: includes/core/class-fields.php:1460 msgid "Sorry this is not a valid image." msgstr "" -#: includes/core/class-fields.php:1466 +#: includes/core/class-fields.php:1461 msgid "This image is too large!" msgstr "" -#: includes/core/class-fields.php:1467 +#: includes/core/class-fields.php:1462 msgid "This image is too small!" msgstr "" -#: includes/core/class-fields.php:1468 +#: includes/core/class-fields.php:1463 msgid "You can only upload one image" msgstr "" -#: includes/core/class-fields.php:1935 +#: includes/core/class-fields.php:1930 msgid "Current Password" msgstr "" -#: includes/core/class-fields.php:1964 +#: includes/core/class-fields.php:1959 msgid "New Password" msgstr "" -#: includes/core/class-fields.php:1996 +#: includes/core/class-fields.php:1991 #, php-format msgid "Confirm %s" msgstr "" -#: includes/core/class-fields.php:2231 +#: includes/core/class-fields.php:2226 msgid "Upload Photo" msgstr "" -#: includes/core/class-fields.php:2252 includes/core/class-fields.php:2276 +#: includes/core/class-fields.php:2247 includes/core/class-fields.php:2271 #: includes/core/um-actions-profile.php:724 msgid "Change photo" msgstr "" -#: includes/core/class-fields.php:2276 includes/core/class-fields.php:2366 +#: includes/core/class-fields.php:2271 includes/core/class-fields.php:2361 msgid "Processing..." msgstr "" -#: includes/core/class-fields.php:2298 +#: includes/core/class-fields.php:2293 msgid "Upload File" msgstr "" -#: includes/core/class-fields.php:2333 includes/core/um-filters-fields.php:230 +#: includes/core/class-fields.php:2328 includes/core/um-filters-fields.php:230 msgid "This file has been removed." msgstr "" -#: includes/core/class-fields.php:2336 includes/core/class-fields.php:2366 +#: includes/core/class-fields.php:2331 includes/core/class-fields.php:2361 msgid "Change file" msgstr "" -#: includes/core/class-fields.php:2366 +#: includes/core/class-fields.php:2361 msgid "Save" msgstr "" -#: includes/core/class-fields.php:3792 +#: includes/core/class-fields.php:3784 #, php-format msgid "" "Your profile is looking a little empty. Why not add some " "information!" msgstr "" -#: includes/core/class-fields.php:3794 +#: includes/core/class-fields.php:3786 msgid "This user has not added any information to their profile yet." msgstr "" -#: includes/core/class-files.php:241 +#: includes/core/class-files.php:239 msgid "Invalid parameters" msgstr "" -#: includes/core/class-files.php:246 +#: includes/core/class-files.php:244 msgid "Invalid coordinates" msgstr "" -#: includes/core/class-files.php:251 +#: includes/core/class-files.php:249 msgid "Invalid file ownership" msgstr "" -#: includes/core/class-files.php:304 +#: includes/core/class-files.php:302 msgid "Invalid nonce" msgstr "" -#: includes/core/class-files.php:324 includes/core/class-files.php:409 +#: includes/core/class-files.php:322 includes/core/class-files.php:407 msgid "A theme or plugin compatibility issue" msgstr "" -#: includes/core/class-files.php:952 +#: includes/core/class-files.php:950 msgid "Ultimate Member: Not a valid temp file" msgstr "" -#: includes/core/class-files.php:1080 +#: includes/core/class-files.php:1078 msgid "Invalid user ID: " msgstr "" -#: includes/core/class-files.php:1089 includes/core/class-files.php:1117 +#: includes/core/class-files.php:1087 includes/core/class-files.php:1115 msgid "Unauthorized to do this attempt." msgstr "" @@ -6381,7 +6389,7 @@ msgid "Your password must contain less than 30 characters" msgstr "" #: includes/core/class-password.php:536 includes/core/um-actions-account.php:62 -#: includes/core/um-actions-form.php:470 +#: includes/core/um-actions-form.php:476 msgid "" "Your password must contain at least one lowercase letter, one capital letter " "and one number" @@ -6391,7 +6399,7 @@ msgstr "" msgid "You must confirm your new password" msgstr "" -#: includes/core/class-password.php:546 includes/core/um-actions-form.php:479 +#: includes/core/class-password.php:546 includes/core/um-actions-form.php:485 msgid "Your passwords do not match" msgstr "" @@ -6515,7 +6523,7 @@ msgstr "" msgid "You are already registered" msgstr "" -#: includes/core/class-shortcodes.php:759 +#: includes/core/class-shortcodes.php:760 msgid "Default Template" msgstr "" @@ -6620,136 +6628,136 @@ msgstr "" msgid "You are not allowed to use this word as your username." msgstr "" -#: includes/core/um-actions-form.php:276 includes/core/um-actions-form.php:388 -#: includes/core/um-actions-form.php:392 includes/core/um-actions-form.php:396 +#: includes/core/um-actions-form.php:276 includes/core/um-actions-form.php:394 +#: includes/core/um-actions-form.php:398 includes/core/um-actions-form.php:402 #, php-format msgid "%s is required." msgstr "" -#: includes/core/um-actions-form.php:401 +#: includes/core/um-actions-form.php:407 msgid "Please specify account type." msgstr "" -#: includes/core/um-actions-form.php:433 +#: includes/core/um-actions-form.php:439 msgid "This field is required" msgstr "" -#: includes/core/um-actions-form.php:435 +#: includes/core/um-actions-form.php:441 #, php-format msgid "%s is required" msgstr "" -#: includes/core/um-actions-form.php:442 +#: includes/core/um-actions-form.php:448 #, php-format msgid "You are only allowed to enter a maximum of %s words" msgstr "" -#: includes/core/um-actions-form.php:448 +#: includes/core/um-actions-form.php:454 #, php-format msgid "Your %s must contain at least %s characters" msgstr "" -#: includes/core/um-actions-form.php:454 +#: includes/core/um-actions-form.php:460 #, php-format msgid "Your %s must contain less than %s characters" msgstr "" -#: includes/core/um-actions-form.php:463 +#: includes/core/um-actions-form.php:469 msgid "You can not use HTML tags here" msgstr "" -#: includes/core/um-actions-form.php:476 +#: includes/core/um-actions-form.php:482 msgid "Please confirm your password" msgstr "" -#: includes/core/um-actions-form.php:485 -#, php-format -msgid "Please select at least %s choices" -msgstr "" - #: includes/core/um-actions-form.php:491 #, php-format -msgid "You can only select up to %s choices" +msgid "Please select at least %s choices" msgstr "" #: includes/core/um-actions-form.php:497 #, php-format -msgid "Minimum number limit is %s" +msgid "You can only select up to %s choices" msgstr "" #: includes/core/um-actions-form.php:503 #, php-format +msgid "Minimum number limit is %s" +msgstr "" + +#: includes/core/um-actions-form.php:509 +#, php-format msgid "Maximum number limit is %s" msgstr "" -#: includes/core/um-actions-form.php:539 +#: includes/core/um-actions-form.php:545 msgid "Please enter numbers only in this field" msgstr "" -#: includes/core/um-actions-form.php:545 +#: includes/core/um-actions-form.php:551 msgid "Please enter a valid phone number" msgstr "" -#: includes/core/um-actions-form.php:551 includes/core/um-actions-form.php:557 -#: includes/core/um-actions-form.php:563 includes/core/um-actions-form.php:569 -#: includes/core/um-actions-form.php:575 includes/core/um-actions-form.php:581 -#: includes/core/um-actions-form.php:587 includes/core/um-actions-form.php:593 -#: includes/core/um-actions-form.php:605 +#: includes/core/um-actions-form.php:557 includes/core/um-actions-form.php:563 +#: includes/core/um-actions-form.php:569 includes/core/um-actions-form.php:575 +#: includes/core/um-actions-form.php:581 includes/core/um-actions-form.php:587 +#: includes/core/um-actions-form.php:593 includes/core/um-actions-form.php:599 +#: includes/core/um-actions-form.php:611 #, php-format msgid "Please enter a valid %s username or profile URL" msgstr "" -#: includes/core/um-actions-form.php:599 +#: includes/core/um-actions-form.php:605 msgid "Please enter a valid URL" msgstr "" -#: includes/core/um-actions-form.php:612 includes/core/um-actions-form.php:626 +#: includes/core/um-actions-form.php:618 includes/core/um-actions-form.php:632 msgid "You must provide a username" msgstr "" -#: includes/core/um-actions-form.php:614 includes/core/um-actions-form.php:628 +#: includes/core/um-actions-form.php:620 includes/core/um-actions-form.php:634 msgid "Your username is already taken" msgstr "" -#: includes/core/um-actions-form.php:616 +#: includes/core/um-actions-form.php:622 msgid "Username cannot be an email" msgstr "" -#: includes/core/um-actions-form.php:618 includes/core/um-actions-form.php:632 +#: includes/core/um-actions-form.php:624 includes/core/um-actions-form.php:638 msgid "Your username contains invalid characters" msgstr "" -#: includes/core/um-actions-form.php:630 includes/core/um-actions-form.php:652 -#: includes/core/um-actions-form.php:654 includes/core/um-actions-form.php:666 -#: includes/core/um-actions-form.php:673 +#: includes/core/um-actions-form.php:636 includes/core/um-actions-form.php:658 +#: includes/core/um-actions-form.php:660 includes/core/um-actions-form.php:672 +#: includes/core/um-actions-form.php:679 msgid "This email is already linked to an existing account" msgstr "" -#: includes/core/um-actions-form.php:650 +#: includes/core/um-actions-form.php:656 msgid "You must provide your email" msgstr "" -#: includes/core/um-actions-form.php:656 includes/core/um-actions-form.php:664 +#: includes/core/um-actions-form.php:662 includes/core/um-actions-form.php:670 msgid "This is not a valid email" msgstr "" -#: includes/core/um-actions-form.php:658 +#: includes/core/um-actions-form.php:664 msgid "Your email contains invalid characters" msgstr "" -#: includes/core/um-actions-form.php:698 +#: includes/core/um-actions-form.php:704 msgid "You must provide a unique value" msgstr "" -#: includes/core/um-actions-form.php:708 +#: includes/core/um-actions-form.php:714 msgid "You must provide alphabetic letters" msgstr "" -#: includes/core/um-actions-form.php:718 +#: includes/core/um-actions-form.php:724 msgid "You must provide lowercase letters." msgstr "" -#: includes/core/um-actions-form.php:737 +#: includes/core/um-actions-form.php:743 #, php-format msgid "Your user description must contain less than %s characters" msgstr "" From 432a1c67414dc2eb9b83189dd9097102ff7904fa Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Tue, 2 Oct 2018 21:50:07 +0300 Subject: [PATCH 06/11] - fixed PHP errors --- includes/core/class-files.php | 17 +++++++++-------- languages/ultimate-member-en_US.po | 20 ++++++++++---------- readme.txt | 5 +++++ ultimate-member.php | 2 +- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/includes/core/class-files.php b/includes/core/class-files.php index 8a655e54..1d393632 100644 --- a/includes/core/class-files.php +++ b/includes/core/class-files.php @@ -100,18 +100,19 @@ if ( ! class_exists( 'um\core\Files' ) ) { return false; } - if ( empty( get_query_var( 'um_form' ) ) ) { + $query_form = get_query_var( 'um_form' ); + if ( empty( $query_form ) ) { return false; } $form_id = get_query_var( 'um_form' ); - - if ( empty( get_query_var( 'um_field' ) ) ) { + $query_field = get_query_var( 'um_field' ); + if ( empty( $query_field ) ) { return false; } $field_key = urldecode( get_query_var( 'um_field' ) ); - - if ( empty( get_query_var( 'um_user' ) ) ) { + $query_user = get_query_var( 'um_user' ); + if ( empty( $query_user ) ) { return false; } @@ -121,9 +122,9 @@ if ( ! class_exists( 'um\core\Files' ) ) { if ( empty( $user ) || is_wp_error( $user ) ) { return false; } - - if ( empty( get_query_var( 'um_verify' ) ) || - ! wp_verify_nonce( get_query_var( 'um_verify' ), $user_id . $form_id . 'um-download-nonce' ) ) { + $query_verify = get_query_var( 'um_verify' ); + if ( empty( $query_verify ) || + ! wp_verify_nonce( $query_verify, $user_id . $form_id . 'um-download-nonce' ) ) { return false; } diff --git a/languages/ultimate-member-en_US.po b/languages/ultimate-member-en_US.po index 719f37d4..3f280f7b 100644 --- a/languages/ultimate-member-en_US.po +++ b/languages/ultimate-member-en_US.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Ultimate Member\n" -"POT-Creation-Date: 2018-10-02 13:01+0300\n" -"PO-Revision-Date: 2018-10-02 13:01+0300\n" +"POT-Creation-Date: 2018-10-02 21:48+0300\n" +"PO-Revision-Date: 2018-10-02 21:48+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: en_US\n" @@ -6325,35 +6325,35 @@ msgstr "" msgid "This user has not added any information to their profile yet." msgstr "" -#: includes/core/class-files.php:239 +#: includes/core/class-files.php:240 msgid "Invalid parameters" msgstr "" -#: includes/core/class-files.php:244 +#: includes/core/class-files.php:245 msgid "Invalid coordinates" msgstr "" -#: includes/core/class-files.php:249 +#: includes/core/class-files.php:250 msgid "Invalid file ownership" msgstr "" -#: includes/core/class-files.php:302 +#: includes/core/class-files.php:303 msgid "Invalid nonce" msgstr "" -#: includes/core/class-files.php:322 includes/core/class-files.php:407 +#: includes/core/class-files.php:323 includes/core/class-files.php:408 msgid "A theme or plugin compatibility issue" msgstr "" -#: includes/core/class-files.php:950 +#: includes/core/class-files.php:951 msgid "Ultimate Member: Not a valid temp file" msgstr "" -#: includes/core/class-files.php:1078 +#: includes/core/class-files.php:1079 msgid "Invalid user ID: " msgstr "" -#: includes/core/class-files.php:1087 includes/core/class-files.php:1115 +#: includes/core/class-files.php:1088 includes/core/class-files.php:1116 msgid "Unauthorized to do this attempt." msgstr "" diff --git a/readme.txt b/readme.txt index 820502d6..ff2ed2ec 100644 --- a/readme.txt +++ b/readme.txt @@ -133,6 +133,11 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = += 2.0.27: October 2, 2018 = + +* Bugfixes: + - Fixed files class + = 2.0.26: October 2, 2018 = * Enhancements: diff --git a/ultimate-member.php b/ultimate-member.php index c9777126..16ef060a 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.26 +Version: 2.0.27 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From bb4aff7ee330ecd5d0286327f570ef07aac452e2 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 4 Oct 2018 16:50:47 +0300 Subject: [PATCH 07/11] - fixed multisite file/image download; --- README.md | 4 +- includes/core/class-fields.php | 7 ++ includes/core/class-files.php | 24 +++++- includes/core/um-actions-login.php | 41 +++++---- includes/core/um-actions-profile.php | 8 +- includes/core/um-actions-register.php | 6 +- includes/core/um-filters-fields.php | 46 ++++++++++- includes/um-short-functions.php | 115 ++++++++++++++++++++------ readme.txt | 2 +- 9 files changed, 197 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 442a24b9..83db873b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl | Latest Version |Requires at least|Stable Tag| | :------------: |:------------:|:------------:| -| 2.0.25 | WordPress 4.9 or higher| 2.0.25 | +| 2.0.27 | WordPress 4.9 or higher| 2.0.27 | Features of the plugin include: @@ -48,7 +48,7 @@ GNU Version 2 or Any Later Version Releases ==================== -[Official Release Version: 2.0.25](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.25). +[Official Release Version: 2.0.27](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.27). [Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases). diff --git a/includes/core/class-fields.php b/includes/core/class-fields.php index 9a266eff..bcfc29f6 100644 --- a/includes/core/class-fields.php +++ b/includes/core/class-fields.php @@ -2313,6 +2313,13 @@ if ( ! class_exists( 'um\core\Fields' ) ) { } else { $file_url = UM()->files()->get_download_link( $this->set_id, $key, um_user( 'ID' ) ); $file_dir = UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $this->field_value( $key, $default, $data ); + + if ( ! file_exists( $file_dir ) ) { + if ( is_multisite() ) { + //multisite fix for old customers + $file_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $file_dir ); + } + } } if ( file_exists( $file_dir ) ) { diff --git a/includes/core/class-files.php b/includes/core/class-files.php index 1d393632..6d01a50c 100644 --- a/includes/core/class-files.php +++ b/includes/core/class-files.php @@ -161,11 +161,19 @@ if ( ! class_exists( 'um\core\Files' ) ) { */ function image_download( $user_id, $field_key, $field_value ) { $file_path = UM()->uploader()->get_upload_base_dir() . $user_id . DIRECTORY_SEPARATOR . $field_value; + if ( ! file_exists( $file_path ) ) { + if ( is_multisite() ) { + //multisite fix for old customers + $file_path = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $file_path ); + } + } + $file_info = get_user_meta( $user_id, $field_key . "_metadata", true ); + $pathinfo = pathinfo( $file_path ); $size = filesize( $file_path ); - $originalname = $file_info['original_name']; - $type = $file_info['type']; + $originalname = ! empty( $file_info['original_name'] ) ? $file_info['original_name'] : $pathinfo['basename']; + $type = ! empty( $file_info['type'] ) ? $file_info['type'] : $pathinfo['extension']; header('Content-Description: File Transfer'); header('Content-Type: ' . $type ); @@ -187,11 +195,19 @@ if ( ! class_exists( 'um\core\Files' ) ) { */ function file_download( $user_id, $field_key, $field_value ) { $file_path = UM()->uploader()->get_upload_base_dir() . $user_id . DIRECTORY_SEPARATOR . $field_value; + if ( ! file_exists( $file_path ) ) { + if ( is_multisite() ) { + //multisite fix for old customers + $file_path = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $file_path ); + } + } + $file_info = get_user_meta( $user_id, $field_key . "_metadata", true ); + $pathinfo = pathinfo( $file_path ); $size = filesize( $file_path ); - $originalname = $file_info['original_name']; - $type = $file_info['type']; + $originalname = ! empty( $file_info['original_name'] ) ? $file_info['original_name'] : $pathinfo['basename']; + $type = ! empty( $file_info['type'] ) ? $file_info['type'] : $pathinfo['extension']; header('Content-Description: File Transfer'); header('Content-Type: ' . $type ); diff --git a/includes/core/um-actions-login.php b/includes/core/um-actions-login.php index 2e4b28b2..7c4c7fc1 100644 --- a/includes/core/um-actions-login.php +++ b/includes/core/um-actions-login.php @@ -47,16 +47,18 @@ function um_submit_form_errors_hook_login( $args ) { $user_name = $args['user_login']; } - if ( !username_exists( $user_name ) ) { + /*if ( !username_exists( $user_name ) ) { if ( $is_email ) { UM()->form()->add_error( $field, __(' Sorry, we can\'t find an account with that email address','ultimate-member') ); } else { UM()->form()->add_error( $field, __(' Sorry, we can\'t find an account with that username','ultimate-member') ); } } else { - if ( $args['user_password'] == '' ) { - UM()->form()->add_error( 'user_password', __('Please enter your password','ultimate-member') ); - } + + }*/ + + if ( $args['user_password'] == '' ) { + UM()->form()->add_error( 'user_password', __('Please enter your password','ultimate-member') ); } $user = get_user_by( 'login', $user_name ); @@ -100,26 +102,29 @@ add_action( 'um_submit_form_errors_hook_login', 'um_submit_form_errors_hook_logi */ function um_display_login_errors( $args ) { $error = ''; - - if( UM()->form()->count_errors() > 0 ) { + + if ( UM()->form()->count_errors() > 0 ) { $errors = UM()->form()->errors; // hook for other plugins to display error $error_keys = array_keys( $errors ); - } + } - if( isset( $args['custom_fields'] ) ){ - $custom_fields = $args['custom_fields']; - } + if ( isset( $args['custom_fields'] ) ) { + $custom_fields = $args['custom_fields']; + } - if( ! empty( $error_keys ) && ! empty( $custom_fields ) ){ - foreach( $error_keys as $error ){ - if( trim( $error ) && ! isset( $custom_fields[ $error ] ) && ! empty( $errors[ $error ] ) ){ - $error_message = apply_filters( 'login_errors', $errors[ $error ] ); - echo '

' . $error_message . '

'; + if ( ! empty( $error_keys ) && ! empty( $custom_fields ) ) { + foreach ( $error_keys as $error ) { + if ( trim( $error ) && ! isset( $custom_fields[ $error ] ) && ! empty( $errors[ $error ] ) ) { + $error_message = apply_filters( 'login_errors', $errors[ $error ], $error ); + if ( empty( $error_message ) ) { + return; } + echo '

' . $error_message . '

'; } } } +} add_action( 'um_before_login_fields', 'um_display_login_errors' ); @@ -421,12 +426,12 @@ function um_add_submit_button_to_login( $args ) { -
-
+
+
-
+
diff --git a/includes/core/um-actions-profile.php b/includes/core/um-actions-profile.php index 30b89ac6..51f05672 100644 --- a/includes/core/um-actions-profile.php +++ b/includes/core/um-actions-profile.php @@ -1195,15 +1195,15 @@ function um_add_submit_button_to_profile( $args ) { -
-
+
-
diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php index bd5d0b72..3e163100 100644 --- a/includes/core/um-actions-register.php +++ b/includes/core/um-actions-register.php @@ -585,12 +585,12 @@ function um_add_submit_button_to_register( $args ) { -
-
+
+
-
+
diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php index 243c34d0..9f422e20 100644 --- a/includes/core/um-filters-fields.php +++ b/includes/core/um-filters-fields.php @@ -226,7 +226,20 @@ function um_profile_field_filter_hook__file( $value, $data ) { $file_type = wp_check_filetype( $value ); $uri = UM()->files()->get_download_link( UM()->fields()->set_id, $data['metakey'], um_user( 'ID' ) ); + $removed = false; if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) { + if ( is_multisite() ) { + //multisite fix for old customers + $file_path = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ); + if ( ! file_exists( $file_path ) ) { + $removed = true; + } + } else { + $removed = true; + } + } + + if ( $removed ) { $value = __( 'This file has been removed.', 'ultimate-member' ); } else { $file_info = um_user( $data['metakey'] . "_metadata" ); @@ -260,11 +273,24 @@ function um_profile_field_filter_hook__image( $value, $data ) { $uri = UM()->files()->get_download_link( UM()->fields()->set_id, $data['metakey'], um_user( 'ID' ) ); $title = ( isset( $data['title'] ) ) ? $data['title'] : __( 'Untitled photo', 'ultimate-member' ); + $removed = false; + if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) { + if ( is_multisite() ) { + //multisite fix for old customers + $file_path = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ); + if ( ! file_exists( $file_path ) ) { + $removed = true; + } + } else { + $removed = true; + } + } + // if value is an image tag if( preg_match( '/\' . esc_attr( $title ) . '
'; - } else if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $value ) ) { + } else if ( ! $removed ) { $value = '
' . esc_attr( $title ) . '
'; } else { $value = ''; @@ -637,6 +663,24 @@ function um_profile_field_filter_xss_validation( $value, $data, $type = '' ) { add_filter( 'um_profile_field_filter_hook__','um_profile_field_filter_xss_validation', 10, 3 ); +/** + * Trim All form POST submitted data + * + * @param $post_form + * @param $mode + * + * @return mixed + */ +function um_submit_form_data_trim_fields( $post_form, $mode ) { + foreach ( $post_form as &$field ) { + $field = trim( $field ); + } + + return $post_form; +} +add_filter( 'um_submit_form_data', 'um_submit_form_data_trim_fields', 9, 2 ); + + /** * add role_select and role_radio to the $post_form * It is necessary for that if on these fields the conditional logic diff --git a/includes/um-short-functions.php b/includes/um-short-functions.php index ad591cdd..18da3bdb 100644 --- a/includes/um-short-functions.php +++ b/includes/um-short-functions.php @@ -556,10 +556,19 @@ function um_user_submitted_registration( $style = false ) { if ( UM()->fields()->get_field_type( $k ) == 'image' || UM()->fields()->get_field_type( $k ) == 'file' ) { $file = basename( $v ); $filedata = get_user_meta( um_user( 'ID' ), $k . "_metadata", true ); + + $baseurl = UM()->uploader()->get_upload_base_url(); + if ( ! file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . $file ) ) { + if ( is_multisite() ) { + //multisite fix for old customers + $baseurl = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $baseurl ); + } + } + if ( ! empty( $filedata['original_name'] ) ) { - $v = '' . $filedata['original_name'] . ''; + $v = '' . $filedata['original_name'] . ''; } else { - $v = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . '/' . $file; + $v = $baseurl . um_user( 'ID' ) . '/' . $file; } } @@ -1659,8 +1668,27 @@ function um_closest_num( $array, $number ) { */ function um_get_cover_uri( $image, $attrs ) { $uri = false; + $uri_common = false; $ext = '.' . pathinfo( $image, PATHINFO_EXTENSION ); + if ( is_multisite() ) { + //multisite fix for old customers + $multisite_fix_dir = UM()->uploader()->get_upload_base_dir(); + $multisite_fix_url = UM()->uploader()->get_upload_base_url(); + $multisite_fix_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $multisite_fix_dir ); + $multisite_fix_url = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $multisite_fix_url ); + + if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' ); + } + + if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}x{$attrs}{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}x{$attrs}{$ext}?". current_time( 'timestamp' ); + } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' ); + } + } + if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo{$ext}" ) ) { $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo{$ext}?" . current_time( 'timestamp' ); } @@ -1670,6 +1698,11 @@ function um_get_cover_uri( $image, $attrs ) { } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "cover_photo-{$attrs}{$ext}" ) ) { $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/cover_photo-{$attrs}{$ext}?" . current_time( 'timestamp' ); } + + if ( ! empty( $uri_common ) && empty( $uri ) ) { + $uri = $uri_common; + } + return $uri; } @@ -1699,8 +1732,64 @@ function um_get_avatar_url( $get_avatar ) { */ function um_get_avatar_uri( $image, $attrs ) { $uri = false; + $uri_common = false; $find = false; $ext = '.' . pathinfo( $image, PATHINFO_EXTENSION ); + + if ( is_multisite() ) { + //multisite fix for old customers + $multisite_fix_dir = UM()->uploader()->get_upload_base_dir(); + $multisite_fix_url = UM()->uploader()->get_upload_base_url(); + $multisite_fix_dir = str_replace( DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . get_current_blog_id() . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $multisite_fix_dir ); + $multisite_fix_url = str_replace( '/sites/' . get_current_blog_id() . '/', '/', $multisite_fix_url ); + + if ( $attrs == 'original' && file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo{$ext}"; + } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}"; + } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}"; + } else { + $sizes = UM()->options()->get( 'photo_thumb_sizes' ); + if ( is_array( $sizes ) ) { + $find = um_closest_num( $sizes, $attrs ); + } + + if ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}"; + } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}"; + } elseif ( file_exists( $multisite_fix_dir . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) { + $uri_common = $multisite_fix_url . um_user( 'ID' ) . "/profile_photo{$ext}"; + } + } + } + + if ( $attrs == 'original' && file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) { + $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}"; + } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) { + $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}"; + } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) { + $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}"; + } else { + $sizes = UM()->options()->get( 'photo_thumb_sizes' ); + if ( is_array( $sizes ) ) { + $find = um_closest_num( $sizes, $attrs ); + } + + if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) { + $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}"; + } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) { + $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}"; + } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) { + $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}"; + } + } + + if ( ! empty( $uri_common ) && empty( $uri ) ) { + $uri = $uri_common; + } + /** * UM hook * @@ -1723,30 +1812,10 @@ function um_get_avatar_uri( $image, $attrs ) { * ?> */ $cache_time = apply_filters( 'um_filter_avatar_cache_time', current_time( 'timestamp' ), um_user( 'ID' ) ); - if ( $attrs == 'original' && file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) { - $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}"; - } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}x{$attrs}{$ext}" ) ) { - $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}x{$attrs}{$ext}"; - } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$attrs}{$ext}" ) ) { - $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$attrs}{$ext}"; - } else { - $sizes = UM()->options()->get( 'photo_thumb_sizes' ); - if ( is_array( $sizes ) ) { - $find = um_closest_num( $sizes, $attrs ); - } - - if ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}x{$find}{$ext}" ) ) { - $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}x{$find}{$ext}"; - } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo-{$find}{$ext}" ) ) { - $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo-{$find}{$ext}"; - } elseif ( file_exists( UM()->uploader()->get_upload_base_dir() . um_user( 'ID' ) . DIRECTORY_SEPARATOR . "profile_photo{$ext}" ) ) { - $uri = UM()->uploader()->get_upload_base_url() . um_user( 'ID' ) . "/profile_photo{$ext}"; - } - } - if ( ! empty( $cache_time ) ) { $uri .= "?{$cache_time}"; } + return $uri; } diff --git a/readme.txt b/readme.txt index ff2ed2ec..aecb8e95 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Donate link: Tags: community, member, membership, user-profile, user-registration Requires at least: 4.7 Tested up to: 4.9 -Stable tag: 2.0.26 +Stable tag: 2.0.27 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt From 8b09a914950743da08666ebb8f8b81e6a01f0104 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Thu, 4 Oct 2018 18:46:03 +0300 Subject: [PATCH 08/11] - fixed submitted info; - fixed approve user notification; --- includes/core/class-user.php | 10 ++++++---- includes/core/um-filters-fields.php | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/includes/core/class-user.php b/includes/core/class-user.php index f8b58e98..30ab7290 100644 --- a/includes/core/class-user.php +++ b/includes/core/class-user.php @@ -1214,12 +1214,14 @@ if ( ! class_exists( 'um\core\User' ) ) { ?> * */ - function approve() { + function approve( $repeat = true ) { $user_id = um_user('ID'); - $status = get_user_meta( $user_id, 'account_status', true ); - if ( 'approved' === $status ) { - return; + if ( ! $repeat ) { + $status = get_user_meta( $user_id, 'account_status', true ); + if ( 'approved' === $status ) { + return; + } } delete_option( "um_cache_userdata_{$user_id}" ); diff --git a/includes/core/um-filters-fields.php b/includes/core/um-filters-fields.php index 9f422e20..d0018551 100644 --- a/includes/core/um-filters-fields.php +++ b/includes/core/um-filters-fields.php @@ -672,8 +672,10 @@ add_filter( 'um_profile_field_filter_hook__','um_profile_field_filter_xss_valida * @return mixed */ function um_submit_form_data_trim_fields( $post_form, $mode ) { - foreach ( $post_form as &$field ) { - $field = trim( $field ); + foreach ( $post_form as $key => $field ) { + if ( is_string( $field ) ) { + $post_form[ $key ] = trim( $field ); + } } return $post_form; From 846e9b3b5ac7af3360d7a8ba633955eca5733a9f Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Fri, 5 Oct 2018 10:18:03 +0300 Subject: [PATCH 09/11] - prepare 2.0.28 release; --- README.md | 4 +- languages/ultimate-member-en_US.po | 62 +++++++++++++----------------- readme.txt | 12 +++++- ultimate-member.php | 2 +- 4 files changed, 41 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 83db873b..e5ba1c68 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl | Latest Version |Requires at least|Stable Tag| | :------------: |:------------:|:------------:| -| 2.0.27 | WordPress 4.9 or higher| 2.0.27 | +| 2.0.28 | WordPress 4.9 or higher| 2.0.28 | Features of the plugin include: @@ -48,7 +48,7 @@ GNU Version 2 or Any Later Version Releases ==================== -[Official Release Version: 2.0.27](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.27). +[Official Release Version: 2.0.28](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.28). [Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases). diff --git a/languages/ultimate-member-en_US.po b/languages/ultimate-member-en_US.po index 3f280f7b..bcab794e 100644 --- a/languages/ultimate-member-en_US.po +++ b/languages/ultimate-member-en_US.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Ultimate Member\n" -"POT-Creation-Date: 2018-10-02 21:48+0300\n" -"PO-Revision-Date: 2018-10-02 21:48+0300\n" +"POT-Creation-Date: 2018-10-05 10:16+0300\n" +"PO-Revision-Date: 2018-10-05 10:16+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: en_US\n" @@ -115,7 +115,7 @@ msgstr "" #: includes/admin/core/class-admin-builder.php:609 #: includes/admin/core/class-admin-builder.php:763 -#: includes/core/class-fields.php:4026 +#: includes/core/class-fields.php:4033 msgid "Please login as administrator" msgstr "" @@ -3526,7 +3526,7 @@ msgstr "" #: includes/admin/templates/modal/dynamic_new_group.php:14 #: includes/admin/templates/modal/fonticons.php:11 #: includes/admin/templates/role/publish.php:24 -#: includes/core/class-fields.php:2272 includes/core/class-fields.php:2362 +#: includes/core/class-fields.php:2272 includes/core/class-fields.php:2369 #: includes/core/um-actions-profile.php:554 #: includes/core/um-actions-profile.php:693 #: includes/core/um-actions-profile.php:726 @@ -4165,7 +4165,7 @@ msgstr "" msgid "You must add a shortcode to the content area" msgstr "" -#: includes/core/class-builtin.php:663 includes/core/class-user.php:1536 +#: includes/core/class-builtin.php:663 includes/core/class-user.php:1538 msgid "Only me" msgstr "" @@ -6294,7 +6294,7 @@ msgstr "" msgid "Change photo" msgstr "" -#: includes/core/class-fields.php:2271 includes/core/class-fields.php:2361 +#: includes/core/class-fields.php:2271 includes/core/class-fields.php:2368 msgid "Processing..." msgstr "" @@ -6302,58 +6302,58 @@ msgstr "" msgid "Upload File" msgstr "" -#: includes/core/class-fields.php:2328 includes/core/um-filters-fields.php:230 +#: includes/core/class-fields.php:2335 includes/core/um-filters-fields.php:243 msgid "This file has been removed." msgstr "" -#: includes/core/class-fields.php:2331 includes/core/class-fields.php:2361 +#: includes/core/class-fields.php:2338 includes/core/class-fields.php:2368 msgid "Change file" msgstr "" -#: includes/core/class-fields.php:2361 +#: includes/core/class-fields.php:2368 msgid "Save" msgstr "" -#: includes/core/class-fields.php:3784 +#: includes/core/class-fields.php:3791 #, php-format msgid "" "Your profile is looking a little empty. Why not add some " "information!" msgstr "" -#: includes/core/class-fields.php:3786 +#: includes/core/class-fields.php:3793 msgid "This user has not added any information to their profile yet." msgstr "" -#: includes/core/class-files.php:240 +#: includes/core/class-files.php:256 msgid "Invalid parameters" msgstr "" -#: includes/core/class-files.php:245 +#: includes/core/class-files.php:261 msgid "Invalid coordinates" msgstr "" -#: includes/core/class-files.php:250 +#: includes/core/class-files.php:266 msgid "Invalid file ownership" msgstr "" -#: includes/core/class-files.php:303 +#: includes/core/class-files.php:319 msgid "Invalid nonce" msgstr "" -#: includes/core/class-files.php:323 includes/core/class-files.php:408 +#: includes/core/class-files.php:339 includes/core/class-files.php:424 msgid "A theme or plugin compatibility issue" msgstr "" -#: includes/core/class-files.php:951 +#: includes/core/class-files.php:967 msgid "Ultimate Member: Not a valid temp file" msgstr "" -#: includes/core/class-files.php:1079 +#: includes/core/class-files.php:1095 msgid "Invalid user ID: " msgstr "" -#: includes/core/class-files.php:1088 includes/core/class-files.php:1116 +#: includes/core/class-files.php:1104 includes/core/class-files.php:1132 msgid "Unauthorized to do this attempt." msgstr "" @@ -6778,31 +6778,23 @@ msgstr "" msgid "Please enter your email" msgstr "" -#: includes/core/um-actions-login.php:52 -msgid " Sorry, we can't find an account with that email address" -msgstr "" - -#: includes/core/um-actions-login.php:54 -msgid " Sorry, we can't find an account with that username" -msgstr "" - -#: includes/core/um-actions-login.php:58 +#: includes/core/um-actions-login.php:61 msgid "Please enter your password" msgstr "" -#: includes/core/um-actions-login.php:66 +#: includes/core/um-actions-login.php:68 msgid "Password is incorrect. Please try again." msgstr "" -#: includes/core/um-actions-login.php:194 +#: includes/core/um-actions-login.php:199 msgid "This action has been prevented for security measures." msgstr "" -#: includes/core/um-actions-login.php:418 +#: includes/core/um-actions-login.php:423 msgid "Keep me signed in" msgstr "" -#: includes/core/um-actions-login.php:453 +#: includes/core/um-actions-login.php:458 msgid "Forgot your password?" msgstr "" @@ -6952,7 +6944,7 @@ msgstr "" msgid "Last login: %s" msgstr "" -#: includes/core/um-filters-fields.php:261 +#: includes/core/um-filters-fields.php:274 msgid "Untitled photo" msgstr "" @@ -6977,11 +6969,11 @@ msgstr "" msgid "Login as this user" msgstr "" -#: includes/um-short-functions.php:571 +#: includes/um-short-functions.php:580 msgid "date submitted" msgstr "" -#: includes/um-short-functions.php:577 +#: includes/um-short-functions.php:586 msgid "(empty)" msgstr "" diff --git a/readme.txt b/readme.txt index aecb8e95..b6559a30 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Donate link: Tags: community, member, membership, user-profile, user-registration Requires at least: 4.7 Tested up to: 4.9 -Stable tag: 2.0.27 +Stable tag: 2.0.28 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -133,6 +133,16 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = += 2.0.28: October 5, 2018 = + +* Bugfixes: + - Fixed Email notifications + - Fixed Download files/images for multisites + - Fixed Profile/Cover image for multisites + - Fixed XSS vulnerabilities (detected by @Serhack) + - Fixed trim fields on submit forms + - Fixed submitted info + = 2.0.27: October 2, 2018 = * Bugfixes: diff --git a/ultimate-member.php b/ultimate-member.php index 16ef060a..44386e18 100644 --- a/ultimate-member.php +++ b/ultimate-member.php @@ -3,7 +3,7 @@ Plugin Name: Ultimate Member Plugin URI: http://ultimatemember.com/ Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress -Version: 2.0.27 +Version: 2.0.28 Author: Ultimate Member Author URI: http://ultimatemember.com/ Text Domain: ultimate-member From b4c2ff15dd4832a3cfacc8f2b96c80739e396697 Mon Sep 17 00:00:00 2001 From: nikitozzzzzzz Date: Mon, 8 Oct 2018 23:36:05 +0300 Subject: [PATCH 10/11] - fixed User Profile posts pagination; - 2.0.29 release; --- README.md | 6 +- assets/js/um-scripts.js | 81 +++++++++++++------ assets/js/um-scripts.min.js | 2 +- includes/core/class-ajax-common.php | 3 + includes/core/class-shortcodes.php | 3 - includes/core/class-user-posts.php | 121 +++++++++++++++++++++------- languages/ultimate-member-en_US.po | 34 ++++---- readme.txt | 7 +- templates/profile/posts-single.php | 64 ++++++++------- templates/profile/posts.php | 72 ++++++++--------- ultimate-member.php | 2 +- 11 files changed, 246 insertions(+), 149 deletions(-) diff --git a/README.md b/README.md index e5ba1c68..87dccf71 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl | Latest Version |Requires at least|Stable Tag| | :------------: |:------------:|:------------:| -| 2.0.28 | WordPress 4.9 or higher| 2.0.28 | +| 2.0.29 | WordPress 4.9 or higher| 2.0.29 | Features of the plugin include: @@ -48,9 +48,7 @@ GNU Version 2 or Any Later Version Releases ==================== -[Official Release Version: 2.0.28](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.28). - -[Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases). +[Official Release Version: 2.0.29](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.29). Changelog ==================== diff --git a/assets/js/um-scripts.js b/assets/js/um-scripts.js index df13cd0e..0be9ab66 100644 --- a/assets/js/um-scripts.js +++ b/assets/js/um-scripts.js @@ -241,31 +241,62 @@ jQuery(document).ready(function() { return false; }); - jQuery(document).on('click', '.um-ajax-paginate', function(e){ - e.preventDefault(); - var parent = jQuery(this).parent(); - parent.addClass('loading'); - var args = jQuery(this).data('args'); - var hook = jQuery(this).data('hook'); - var container = jQuery(this).parents('.um').find('.um-ajax-items'); - jQuery.ajax({ - url: wp.ajax.settings.url, - type: 'post', - data: { - action: 'um_ajax_paginate', - hook: hook, - args: args - }, - complete: function(){ - parent.removeClass('loading'); - }, - success: function(data){ - parent.remove(); - container.append( data ); - } - }); - return false; - }); + + jQuery( document.body ).on( 'click', '.um-ajax-paginate', function(e) { + e.preventDefault(); + + var obj = jQuery(this); + var parent = jQuery(this).parent(); + parent.addClass( 'loading' ); + + var hook = jQuery(this).data('hook'); + if ( 'um_load_posts' === hook ) { + var pages = jQuery(this).data('pages')*1; + var next_page = jQuery(this).data('page')*1 + 1; + + jQuery.ajax({ + url: wp.ajax.settings.url, + type: 'post', + data: { + action: 'um_ajax_paginate_posts', + author: jQuery(this).data('author'), + page: next_page + }, + complete: function() { + parent.removeClass( 'loading' ); + }, + success: function( data ) { + parent.before( data ); + if ( next_page === pages ) { + parent.remove(); + } else { + obj.data( 'page', next_page ); + } + } + }); + } else { + var args = jQuery(this).data('args'); + var container = jQuery(this).parents('.um').find('.um-ajax-items'); + + jQuery.ajax({ + url: wp.ajax.settings.url, + type: 'post', + data: { + action: 'um_ajax_paginate', + hook: hook, + args: args + }, + complete: function() { + parent.removeClass( 'loading' ); + }, + success: function(data){ + parent.remove(); + container.append( data ); + } + }); + } + }); + jQuery(document).on('click', '.um-ajax-action', function(e){ e.preventDefault(); diff --git a/assets/js/um-scripts.min.js b/assets/js/um-scripts.min.js index f2de24a3..82a00880 100644 --- a/assets/js/um-scripts.min.js +++ b/assets/js/um-scripts.min.js @@ -1 +1 @@ -jQuery(document).ready(function(){jQuery(document).on("click",".um-dropdown a",function(e){return!1}),jQuery(document).on("click",".um-dropdown a.real_url",function(e){window.location=jQuery(this).attr("href")}),jQuery(document).on("click",".um-trigger-menu-on-click",function(e){return jQuery(".um-dropdown").hide(),menu=jQuery(this).find(".um-dropdown"),menu.show(),!1}),jQuery(document).on("click",".um-dropdown-hide",function(e){UM_hide_menus()}),jQuery(document).on("click","a.um-manual-trigger",function(){var e=jQuery(this).attr("data-child"),t=jQuery(this).attr("data-parent");jQuery(this).parents(t).find(e).trigger("click")}),jQuery(".um-tip-n").tipsy({gravity:"n",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-w").tipsy({gravity:"w",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-e").tipsy({gravity:"e",opacity:1,live:"a.live",offset:3}),jQuery(".um-tip-s").tipsy({gravity:"s",opacity:1,live:"a.live",offset:3}),jQuery(document).on("change",".um-field-area input[type=radio]",function(){var e=jQuery(this).parents(".um-field-area"),t=jQuery(this).parents("label");e.find(".um-field-radio").removeClass("active"),e.find(".um-field-radio").find("i").removeAttr("class").addClass("um-icon-android-radio-button-off"),t.addClass("active"),t.find("i").removeAttr("class").addClass("um-icon-android-radio-button-on")}),jQuery(document).on("change",".um-field-area input[type=checkbox]",function(){jQuery(this).parents(".um-field-area");var e=jQuery(this).parents("label");e.hasClass("active")?(e.removeClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline-blank")):(e.addClass("active"),e.find("i").removeAttr("class").addClass("um-icon-android-checkbox-outline"))}),jQuery(".um-datepicker").each(function(){if(elem=jQuery(this),""!=elem.attr("data-disabled_weekdays"))var e=JSON.parse(elem.attr("data-disabled_weekdays"));else e=!1;var t=elem.attr("data-years"),a=elem.attr("data-date_min"),i=elem.attr("data-date_max"),r=a.split(","),n=i.split(","),u=r.length?new Date(r):null,o=r.length?new Date(n):null;if(u&&"Invalid Date"==u.toString()&&3==r.length){var d=r[1]+"/"+r[2]+"/"+r[0];u=new Date(Date.parse(d))}if(o&&"Invalid Date"==o.toString()&&3==n.length){var s=n[1]+"/"+n[2]+"/"+n[0];o=new Date(Date.parse(s))}elem.pickadate({selectYears:t,min:u,max:o,disable:e,format:elem.attr("data-format"),formatSubmit:"yyyy/mm/dd",hiddenName:!0,onOpen:function(){elem.blur()},onClose:function(){elem.blur()}})}),jQuery(".um-timepicker").each(function(){elem=jQuery(this),elem.pickatime({format:elem.attr("data-format"),interval:parseInt(elem.attr("data-intervals")),formatSubmit:"HH:i",hiddenName:!0,onOpen:function(){elem.blur()},onClose:function(){elem.blur()}})}),jQuery(".um-rating").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,click:function(e,t){live_field=this.id,live_value=e,um_conditional()}}),jQuery(".um-rating-readonly").um_raty({half:!1,starType:"i",number:function(){return jQuery(this).attr("data-number")},score:function(){return jQuery(this).attr("data-score")},scoreName:function(){return jQuery(this).attr("data-key")},hints:!1,readOnly:!0}),jQuery(document).on("click",".um .um-single-image-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=jQuery(this).parents(".um-field").find(".um-single-image-preview img").attr("src");return t.find(".um-single-image-preview img").attr("src",""),t.find(".um-single-image-preview").hide(),t.find(".um-btn-auto-width").html("Upload"),t.find("input[type=hidden]").val("empty_file"),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:a}}),!1}),jQuery(document).on("click",".um .um-single-file-preview a.cancel",function(e){e.preventDefault();var t=jQuery(this).parents(".um-field"),a=jQuery(this).parents(".um-field").find(".um-single-fileinfo a").attr("href");return t.find(".um-single-file-preview").hide(),t.find(".um-btn-auto-width").html("Upload"),t.find("input[type=hidden]").val("empty_file"),jQuery.ajax({url:wp.ajax.settings.url,type:"post",data:{action:"um_remove_file",src:a}}),!1}),jQuery(".um-s1,.um-s2").css({display:"block"}),jQuery(".um-s1").select2({allowClear:!0}),jQuery(".um-s2").select2({allowClear:!1,minimumResultsForSearch:10}),jQuery(document).on("click",".um-field-group-head:not(.disabled)",function(){var e=jQuery(this).parents(".um-field-group"),t=e.data("max_entries");e.find(".um-field-group-body").is(":hidden")?e.find(".um-field-group-body").show():e.find(".um-field-group-body:first").clone().appendTo(e),increase_id=0,e.find(".um-field-group-body").each(function(){increase_id++,jQuery(this).find("input").each(function(){var e=jQuery(this);e.attr("id",e.data("key")+"-"+increase_id),e.attr("name",e.data("key")+"-"+increase_id),e.parent().parent().find("label").attr("for",e.data("key")+"-"+increase_id)})}),0profile(), 'ajax_delete_profile_photo' ) ); add_action( 'wp_ajax_um_delete_cover_photo', array( UM()->profile(), 'ajax_delete_cover_photo' ) ); + add_action( 'wp_ajax_um_ajax_paginate', array( UM()->query(), 'ajax_paginate' ) ); + add_action( 'wp_ajax_um_ajax_paginate_posts', array( UM()->user_posts(), 'load_posts' ) ); + add_action( 'wp_ajax_um_muted_action', array( UM()->form(), 'ajax_muted_action' ) ); add_action( 'wp_ajax_um_remove_file', array( UM()->files(), 'ajax_remove_file' ) ); diff --git a/includes/core/class-shortcodes.php b/includes/core/class-shortcodes.php index aadc3e80..0a0c01b3 100644 --- a/includes/core/class-shortcodes.php +++ b/includes/core/class-shortcodes.php @@ -272,14 +272,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) { $file = um_path . "templates/{$tpl}.php"; $theme_file = get_stylesheet_directory() . "/ultimate-member/templates/{$tpl}.php"; - - if ( file_exists( $theme_file ) ) { $file = $theme_file; } if ( file_exists( $file ) ) { - include $file; } } diff --git a/includes/core/class-user-posts.php b/includes/core/class-user-posts.php index 4ec2686b..24ec6f76 100644 --- a/includes/core/class-user-posts.php +++ b/includes/core/class-user-posts.php @@ -20,32 +20,109 @@ if ( ! class_exists( 'um\core\User_posts' ) ) { add_action( 'um_profile_content_posts', array( &$this, 'add_posts' ) ); add_action( 'um_profile_content_comments', array( &$this, 'add_comments' ) ); - add_action( 'um_ajax_load_posts__um_load_posts', array( &$this, 'load_posts' ) ); - add_action( 'um_ajax_load_posts__um_load_comments', array( &$this, 'load_comments' ) ); + add_action( 'um_ajax_load_posts__um_load_comments', array( &$this, 'load_comments' ), 10, 1 ); + } + + + /** + * Add posts + */ + function add_posts() { + + $args = array( + 'post_type' => 'post', + 'posts_per_page' => 10, + 'offset' => 0, + 'author' => um_get_requested_user(), + 'post_status' => array( 'publish' ) + ); + + /** + * UM hook + * + * @type filter + * @title um_profile_query_make_posts + * @description Some changes of WP_Query Posts Tab + * @input_vars + * [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ + $args = apply_filters( 'um_profile_query_make_posts', $args ); + $posts = get_posts( $args ); + + $count_posts = wp_count_posts(); + $count_posts = ! empty( $count_posts->publish ) ? $count_posts->publish : 0; + + UM()->shortcodes()->set_args = array( 'posts' => $posts, 'count_posts' => $count_posts ); + UM()->shortcodes()->load_template( 'profile/posts' ); + } + + + /** + * Add comments + */ + function add_comments() { + UM()->shortcodes()->load_template( 'profile/comments' ); } /** * Dynamic load of posts * - * @param array $args */ - function load_posts( $args ) { - $array = explode(',', $args ); - $post_type = $array[0]; - $posts_per_page = $array[1]; - $offset = $array[2]; - $author = $array[3]; + function load_posts() { + $author = ! empty( $_POST['author'] ) ? $_POST['author'] : get_current_user_id(); + $page = ! empty( $_POST['page'] ) ? $_POST['page'] : 0; - $offset_n = $posts_per_page + $offset; + $args = array( + 'post_type' => 'post', + 'posts_per_page' => 10, + 'offset' => ( $page - 1 ) * 10, + 'author' => $author, + 'post_status' => array( 'publish' ) + ); - UM()->shortcodes()->modified_args = "$post_type,$posts_per_page,$offset_n,$author"; + /** + * UM hook + * + * @type filter + * @title um_profile_query_make_posts + * @description Some changes of WP_Query Posts Tab + * @input_vars + * [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}] + * @change_log + * ["Since: 2.0"] + * @usage + * + * @example + * + */ + $args = apply_filters( 'um_profile_query_make_posts', $args ); + $posts = get_posts( $args ); - UM()->shortcodes()->loop = UM()->query()->make("post_type=$post_type&posts_per_page=$posts_per_page&offset=$offset&author=$author"); - - UM()->shortcodes()->load_template('profile/posts-single'); + UM()->shortcodes()->set_args = array( 'posts' => $posts ); + UM()->shortcodes()->load_template( 'profile/posts' ); + wp_die(); } + /** * Dynamic load of comments * @@ -68,22 +145,6 @@ if ( ! class_exists( 'um\core\User_posts' ) ) { } - /** - * Add posts - */ - function add_posts() { - UM()->shortcodes()->load_template( 'profile/posts' ); - } - - - /** - * Add comments - */ - function add_comments() { - UM()->shortcodes()->load_template( 'profile/comments' ); - } - - /** * Count posts by type * diff --git a/languages/ultimate-member-en_US.po b/languages/ultimate-member-en_US.po index bcab794e..48622378 100644 --- a/languages/ultimate-member-en_US.po +++ b/languages/ultimate-member-en_US.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: Ultimate Member\n" -"POT-Creation-Date: 2018-10-05 10:16+0300\n" -"PO-Revision-Date: 2018-10-05 10:16+0300\n" +"POT-Creation-Date: 2018-10-08 23:32+0300\n" +"PO-Revision-Date: 2018-10-08 23:32+0300\n" "Last-Translator: \n" "Language-Team: \n" "Language: en_US\n" @@ -6513,17 +6513,17 @@ msgstr "" msgid "Wrong nonce" msgstr "" -#: includes/core/class-shortcodes.php:358 +#: includes/core/class-shortcodes.php:355 msgid "" "This content has been restricted to logged in users only. Please login to view this content." msgstr "" -#: includes/core/class-shortcodes.php:518 +#: includes/core/class-shortcodes.php:515 msgid "You are already registered" msgstr "" -#: includes/core/class-shortcodes.php:760 +#: includes/core/class-shortcodes.php:757 msgid "Default Template" msgstr "" @@ -7043,37 +7043,37 @@ msgstr "" msgid "This user has not made any comments." msgstr "" -#: templates/profile/posts-single.php:16 +#: templates/profile/posts-single.php:21 #, php-format msgid "%s ago" msgstr "" -#: templates/profile/posts-single.php:17 +#: templates/profile/posts-single.php:24 msgid "in" msgstr "" -#: templates/profile/posts-single.php:18 +#: templates/profile/posts-single.php:30 msgid "no comments" msgstr "" -#: templates/profile/posts-single.php:18 +#: templates/profile/posts-single.php:32 +#, php-format +msgid "%s comments" +msgstr "" + +#: templates/profile/posts-single.php:34 msgid "1 comment" msgstr "" -#: templates/profile/posts-single.php:18 -#, php-format -msgid "% comments" -msgstr "" - -#: templates/profile/posts-single.php:27 templates/profile/posts.php:35 +#: templates/profile/posts.php:21 msgid "load more posts" msgstr "" -#: templates/profile/posts.php:43 +#: templates/profile/posts.php:32 msgid "You have not created any posts." msgstr "" -#: templates/profile/posts.php:43 +#: templates/profile/posts.php:32 msgid "This user has not created any posts." msgstr "" diff --git a/readme.txt b/readme.txt index b6559a30..4a3feed2 100644 --- a/readme.txt +++ b/readme.txt @@ -6,7 +6,7 @@ Donate link: Tags: community, member, membership, user-profile, user-registration Requires at least: 4.7 Tested up to: 4.9 -Stable tag: 2.0.28 +Stable tag: 2.0.29 License: GNU Version 2 or Any Later Version License URI: http://www.gnu.org/licenses/gpl-3.0.txt @@ -133,6 +133,11 @@ The plugin works with popular caching plugins by automatically excluding Ultimat = Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin = += 2.0.29: October 8, 2018 = + +* Bugfixes: + - Fixed User Profile Posts pagination + = 2.0.28: October 5, 2018 = * Bugfixes: diff --git a/templates/profile/posts-single.php b/templates/profile/posts-single.php index a2d94511..e7b31c75 100644 --- a/templates/profile/posts-single.php +++ b/templates/profile/posts-single.php @@ -1,30 +1,40 @@ - shortcodes()->loop->have_posts()) { UM()->shortcodes()->loop->the_post(); $post_id = get_the_ID(); ?> +
+ -
- - - - -
- - - -
- - : - -
+ ID ) ) { + $image_id = get_post_thumbnail_id( $post->ID ); + $image_url = wp_get_attachment_image_src( $image_id, 'full', true ); ?> + + - + - - shortcodes()->modified_args) && UM()->shortcodes()->loop->have_posts() && UM()->shortcodes()->loop->found_posts >= 10 ) { ?> - -
- -
- - \ No newline at end of file + +
+ + ID ), current_time( 'timestamp' ) ) ); ?> + + + : ID ); ?> + + + ID ); + + if ( $num_comments == 0 ) { + $comments = __( 'no comments', 'ultimate-member' ); + } elseif ( $num_comments > 1 ) { + $comments = sprintf( __( '%s comments', 'ultimate-member' ), $num_comments ); + } else { + $comments = __( '1 comment', 'ultimate-member' ); + } ?> + + + +
+
\ No newline at end of file diff --git a/templates/profile/posts.php b/templates/profile/posts.php index dd720abf..6b13e9fb 100644 --- a/templates/profile/posts.php +++ b/templates/profile/posts.php @@ -1,45 +1,37 @@ -query()->make('post_type=post&posts_per_page=10&offset=0&author=' . um_get_requested_user() ); +shortcodes()->set_args = array( 'post' => $post ); + UM()->shortcodes()->load_template( 'profile/posts-single' ); + } + } +} else { + if ( ! empty( $posts ) ) { ?> +
-/** - * UM hook - * - * @type filter - * @title um_profile_query_make_posts - * @description Some changes of WP_Query Posts Tab - * @input_vars - * [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}] - * @change_log - * ["Since: 2.0"] - * @usage - * - * @example - * - */ -UM()->shortcodes()->loop = apply_filters( 'um_profile_query_make_posts', $query_posts ); + shortcodes()->set_args = array( 'post' => $post ); + UM()->shortcodes()->load_template( 'profile/posts-single' ); + } -if ( UM()->shortcodes()->loop->have_posts() ) { + if ( $count_posts > 10 ) { ?> +
+ + + +
+ - UM()->shortcodes()->load_template( 'profile/posts-single' ); ?> - -
- - shortcodes()->loop->found_posts >= 10 ) { ?> - -
- -
+
- -
- - + -
- - \ No newline at end of file +
+ + + +
+ + Date: Tue, 16 Oct 2018 10:34:14 +0300 Subject: [PATCH 11/11] - added extensions to the list; --- includes/admin/templates/extensions.php | 16 +++++++++++++++- readme.txt | 4 ++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/includes/admin/templates/extensions.php b/includes/admin/templates/extensions.php index e0da08cb..c3755722 100644 --- a/includes/admin/templates/extensions.php +++ b/includes/admin/templates/extensions.php @@ -117,7 +117,21 @@ $premium['private-content'] = array( 'url' => 'https://ultimatemember.com/extensions/private-content/', 'image' => 'https://ultimatemember.com/wp-content/uploads/bb-plugin/cache/private-content-page-circle.png', 'name' => 'Private Content', - 'desc' => 'With the private content extension you can provide logged in users with content that only they can access and view', + 'desc' => 'Display private content to logged in users that only they can access', +); + +$premium['groups'] = array( + 'url' => 'https://ultimatemember.com/extensions/groups/', + 'image' => 'https://ultimatemember.com/wp-content/uploads/edd/2018/10/groupimage.png', + 'name' => 'Groups', + 'desc' => 'Allow users to create and join groups around shared topics, interests etc.', +); + +$premium['user-photos'] = array( + 'url' => 'https://ultimatemember.com/extensions/user-photos/', + 'image' => 'https://ultimatemember.com/wp-content/uploads/edd/2018/06/User-Photos.png', + 'name' => 'User Photos', + 'desc' => 'Allow users to upload photos to their profile', ); diff --git a/readme.txt b/readme.txt index 4a3feed2..d75a3723 100644 --- a/readme.txt +++ b/readme.txt @@ -67,6 +67,10 @@ Ultimate Member has a range of extensions that allow you to extend the power of * [Google reCAPTCHA](https://ultimatemember.com/extensions/google-recaptcha/) - Stop bots on your registration & login forms with Google reCAPTCHA * [Online Users](https://ultimatemember.com/extensions/online-users/) - Display what users are online with this extension += Theme = + +Our official [theme](https://ultimatemember.com/theme/) is purpose built for websites that have logged in and out users. The [theme](https://ultimatemember.com/theme/) has deep integration with Ultimate Member plugin and the extensions, different header designs for logged-in/out users and works alongside the Beaver Builder and Elementor page builders. + = Development * Translations = If you're a developer and would like to contribute to the source code of the plugin you can do so via our [GitHub Repository](https://github.com/ultimatemember/ultimatemember).