diff --git a/.gitattributes b/.gitattributes index 2477d8cd..16eee259 100644 --- a/.gitattributes +++ b/.gitattributes @@ -26,9 +26,10 @@ /.github export-ignore /assets/sass export-ignore /assets/libs/fontawesome/scss export-ignore -/docs export-ignore -/tests export-ignore /blocks-src export-ignore +/docs export-ignore +/node_modules export-ignore +/tests export-ignore # Files /.bowerrc export-ignore @@ -43,6 +44,7 @@ /hookdoc-conf.json export-ignore /manifest.json export-ignore /package.json export-ignore +/package-lock.json export-ignore /phpcs.xml export-ignore /phpdoc.dist.xml export-ignore /README.md export-ignore diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index da8ae0db..bea312ac 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -45,14 +45,10 @@ jobs: git rm bower.json git rm composer.json git rm gulpfile.js - git rm hookdoc-conf.json git rm manifest.json - git rm package.json git rm phpcs.xml git rm phpdoc.dist.xml - git rm -r .github git rm -r docs - git rm -r blocks-src git rm -r tests git add includes/lib/action-scheduler/\* git commit -a -m "Composer Installed. Cleared release repo." diff --git a/includes/action-scheduler/class-init.php b/includes/action-scheduler/class-init.php index 7850e81c..e3f55f36 100644 --- a/includes/action-scheduler/class-init.php +++ b/includes/action-scheduler/class-init.php @@ -45,7 +45,7 @@ if ( ! class_exists( 'um\action_scheduler\Init' ) ) { UM()->admin()->notices()->add_notice( 'um-action-scheduler', array( - 'class' => 'notice-warning is-dismissible', + 'class' => 'notice-warning is-dismissible', // translators: %1$s - Plugin name, %1$s - Plugin Version 'message' => '

' . sprintf( __( '%1$s %2$s The file needed to enable the Action Scheduler is missing. The plugin will continue to function as it did before, but without the new benefits offered by the Action Scheduler.', 'ultimate-member' ), UM_PLUGIN_NAME, UM_VERSION ) . '

', ) @@ -55,6 +55,7 @@ if ( ! class_exists( 'um\action_scheduler\Init' ) ) { if ( UM()->options()->get( 'enable_action_scheduler' ) ) { $this->enabled = true; + $this->load_library( true ); } } } @@ -97,11 +98,15 @@ if ( ! class_exists( 'um\action_scheduler\Init' ) ) { /** * Tries to load Action Scheduler from Ultimate Member if file exists * + * @param bool $force + * * @return bool */ - public function load_library() { + public function load_library( $force = false ) { if ( file_exists( $this->lib_path ) ) { - require_once $this->lib_path; + if ( $force ) { + require_once $this->lib_path; + } return true; } @@ -148,7 +153,7 @@ if ( ! class_exists( 'um\action_scheduler\Init' ) ) { * @param array $args Arguments to pass to callbacks when the hook triggers. Default: array() * @param string $group The group to assign this job to. Default: ''. * @param bool $unique Whether the action should be unique. Default: false. - * @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255.) + * @param int $priority Lower values take precedence over higher values. Defaults to 10, with acceptable values falling in the range 0-255. * * @return int The action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log. */ diff --git a/includes/core/class-files.php b/includes/core/class-files.php index 00f7d16b..8f5389cc 100644 --- a/includes/core/class-files.php +++ b/includes/core/class-files.php @@ -402,8 +402,22 @@ if ( ! class_exists( 'um\core\Files' ) ) { wp_send_json_error( esc_js( __( 'This field doesn\'t support image crop', 'ultimate-member' ) ) ); } - if ( 'profile' === $mode && ! um_can_edit_field( $custom_fields[ $key ] ) ) { - wp_send_json_error( esc_js( __( 'You have no permission to edit this field', 'ultimate-member' ) ) ); + if ( 'profile' === $mode ) { + if ( in_array( $key, array( 'cover_photo', 'profile_photo' ), true ) ) { + if ( 'profile_photo' === $key ) { + $disable_photo_uploader = empty( $post_data['use_custom_settings'] ) ? UM()->options()->get( 'disable_profile_photo_upload' ) : $post_data['disable_photo_upload']; + if ( $disable_photo_uploader ) { + wp_send_json_error( esc_js( __( 'You have no permission to edit this field', 'ultimate-member' ) ) ); + } + } else { + $cover_enabled_uploader = empty( $post_data['use_custom_settings'] ) ? UM()->options()->get( 'profile_cover_enabled' ) : $post_data['cover_enabled']; + if ( ! $cover_enabled_uploader ) { + wp_send_json_error( esc_js( __( 'You have no permission to edit this field', 'ultimate-member' ) ) ); + } + } + } elseif ( ! um_can_edit_field( $custom_fields[ $key ] ) ) { + wp_send_json_error( esc_js( __( 'You have no permission to edit this field', 'ultimate-member' ) ) ); + } } $src = esc_url_raw( $_REQUEST['src'] ); @@ -550,9 +564,25 @@ if ( ! class_exists( 'um\core\Files' ) ) { } } - if ( 'profile' === $mode && ! um_can_edit_field( $custom_fields[ $id ] ) ) { - $ret['error'] = esc_html__( 'You have no permission to edit this field', 'ultimate-member' ); - wp_send_json_error( $ret ); + if ( 'profile' === $mode ) { + if ( in_array( $id, array( 'cover_photo', 'profile_photo' ), true ) ) { + if ( 'profile_photo' === $id ) { + $disable_photo_uploader = empty( $post_data['use_custom_settings'] ) ? UM()->options()->get( 'disable_profile_photo_upload' ) : $post_data['disable_photo_upload']; + if ( $disable_photo_uploader ) { + $ret['error'] = esc_html__( 'You have no permission to edit this field', 'ultimate-member' ); + wp_send_json_error( $ret ); + } + } else { + $cover_enabled_uploader = empty( $post_data['use_custom_settings'] ) ? UM()->options()->get( 'profile_cover_enabled' ) : $post_data['cover_enabled']; + if ( ! $cover_enabled_uploader ) { + $ret['error'] = esc_html__( 'You have no permission to edit this field', 'ultimate-member' ); + wp_send_json_error( $ret ); + } + } + } elseif ( ! um_can_edit_field( $custom_fields[ $id ] ) ) { + $ret['error'] = esc_html__( 'You have no permission to edit this field', 'ultimate-member' ); + wp_send_json_error( $ret ); + } } if ( isset( $_FILES[ $id ]['name'] ) ) { diff --git a/languages/ultimate-member.pot b/languages/ultimate-member.pot index be5f872d..bb583e30 100644 --- a/languages/ultimate-member.pot +++ b/languages/ultimate-member.pot @@ -9,7 +9,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-11-11T12:43:50+00:00\n" +"POT-Creation-Date: 2024-11-12T20:23:40+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.11.0\n" "X-Domain: ultimate-member\n" @@ -40,15 +40,15 @@ msgstr "" msgid "%1$s %2$s The file needed to enable the Action Scheduler is missing. The plugin will continue to function as it did before, but without the new benefits offered by the Action Scheduler." msgstr "" -#: includes/action-scheduler/class-init.php:73 +#: includes/action-scheduler/class-init.php:74 msgid "Action Scheduler" msgstr "" -#: includes/action-scheduler/class-init.php:74 +#: includes/action-scheduler/class-init.php:75 msgid "Enable Action Scheduler" msgstr "" -#: includes/action-scheduler/class-init.php:75 +#: includes/action-scheduler/class-init.php:76 msgid "Check this box if you want to use the Ultimate Member action scheduler. By enabling it, certain tasks like sending system emails will be scheduled to run at optimal times, which can help reduce the load on your server" msgstr "" @@ -9446,10 +9446,10 @@ msgstr "" #: includes/core/class-files.php:294 #: includes/core/class-files.php:329 -#: includes/core/class-files.php:468 -#: includes/core/class-files.php:620 -#: includes/core/class-files.php:625 -#: includes/core/class-files.php:636 +#: includes/core/class-files.php:482 +#: includes/core/class-files.php:650 +#: includes/core/class-files.php:655 +#: includes/core/class-files.php:666 msgid "You have no permission to edit this user" msgstr "" @@ -9466,66 +9466,66 @@ msgid "Invalid coordinates" msgstr "" #: includes/core/class-files.php:333 -#: includes/core/class-files.php:473 +#: includes/core/class-files.php:487 msgid "Please login to edit this user" msgstr "" #: includes/core/class-files.php:343 -#: includes/core/class-files.php:484 +#: includes/core/class-files.php:498 msgid "You have no permission to edit user profile" msgstr "" #: includes/core/class-files.php:347 -#: includes/core/class-files.php:489 -#: includes/core/class-files.php:641 +#: includes/core/class-files.php:503 +#: includes/core/class-files.php:671 msgid "User has to be empty on registration" msgstr "" #: includes/core/class-files.php:353 -#: includes/core/class-files.php:496 -#: includes/core/class-files.php:648 +#: includes/core/class-files.php:510 +#: includes/core/class-files.php:678 msgid "Invalid form ID" msgstr "" #: includes/core/class-files.php:357 -#: includes/core/class-files.php:501 -#: includes/core/class-files.php:653 +#: includes/core/class-files.php:515 +#: includes/core/class-files.php:683 msgid "Invalid form post type" msgstr "" #: includes/core/class-files.php:362 -#: includes/core/class-files.php:507 -#: includes/core/class-files.php:659 +#: includes/core/class-files.php:521 +#: includes/core/class-files.php:689 msgid "Invalid form status" msgstr "" #: includes/core/class-files.php:367 -#: includes/core/class-files.php:513 -#: includes/core/class-files.php:665 +#: includes/core/class-files.php:527 +#: includes/core/class-files.php:695 msgid "Invalid form type" msgstr "" #: includes/core/class-files.php:376 #: includes/core/class-files.php:381 #: includes/core/class-files.php:384 -#: includes/core/class-files.php:523 -#: includes/core/class-files.php:529 -#: includes/core/class-files.php:533 -#: includes/core/class-files.php:675 -#: includes/core/class-files.php:681 -#: includes/core/class-files.php:685 +#: includes/core/class-files.php:537 +#: includes/core/class-files.php:543 +#: includes/core/class-files.php:547 +#: includes/core/class-files.php:705 +#: includes/core/class-files.php:711 +#: includes/core/class-files.php:715 msgid "You have no permission to edit this user through this form" msgstr "" #: includes/core/class-files.php:391 -#: includes/core/class-files.php:541 -#: includes/core/class-files.php:693 +#: includes/core/class-files.php:555 +#: includes/core/class-files.php:723 msgid "Invalid form fields" msgstr "" #: includes/core/class-files.php:397 -#: includes/core/class-files.php:548 -#: includes/core/class-files.php:699 +#: includes/core/class-files.php:562 +#: includes/core/class-files.php:729 msgid "Invalid field metakey" msgstr "" @@ -9533,27 +9533,31 @@ msgstr "" msgid "This field doesn't support image crop" msgstr "" -#: includes/core/class-files.php:406 -#: includes/core/class-files.php:554 -#: includes/core/class-files.php:704 +#: includes/core/class-files.php:410 +#: includes/core/class-files.php:415 +#: includes/core/class-files.php:419 +#: includes/core/class-files.php:572 +#: includes/core/class-files.php:578 +#: includes/core/class-files.php:583 +#: includes/core/class-files.php:734 msgid "You have no permission to edit this field" msgstr "" -#: includes/core/class-files.php:412 +#: includes/core/class-files.php:426 msgid "Invalid file ownership" msgstr "" -#: includes/core/class-files.php:461 -#: includes/core/class-files.php:613 +#: includes/core/class-files.php:475 +#: includes/core/class-files.php:643 msgid "Invalid nonce" msgstr "" -#: includes/core/class-files.php:573 -#: includes/core/class-files.php:728 +#: includes/core/class-files.php:603 +#: includes/core/class-files.php:758 msgid "A theme or plugin compatibility issue" msgstr "" -#: includes/core/class-files.php:1501 +#: includes/core/class-files.php:1531 msgid "Original size" msgstr ""