diff --git a/.gitattributes b/.gitattributes
index 71b1dede..2477d8cd 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -28,6 +28,7 @@
/assets/libs/fontawesome/scss export-ignore
/docs export-ignore
/tests export-ignore
+/blocks-src export-ignore
# Files
/.bowerrc export-ignore
diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml
new file mode 100644
index 00000000..ab6245a4
--- /dev/null
+++ b/.github/workflows/build-release.yml
@@ -0,0 +1,68 @@
+name: Build Release
+
+on:
+ push:
+ branches:
+ - master
+
+permissions:
+ contents: write
+
+jobs:
+ generate-translations:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: WordPress .pot File Generator
+ uses: iamdharmesh/action-wordpress-pot-generator@main
+ with:
+ destination_path: './languages'
+ slug: 'ultimate-member'
+ text_domain: 'ultimate-member'
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ build:
+ needs: generate-translations
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install PHP
+ uses: "shivammathur/setup-php@v2"
+ with:
+ php-version: "latest"
+ - name: Install Composer Dependencies
+ run: |
+ composer install --no-progress --no-dev --optimize-autoloader --ignore-platform-req=ext-exif --ignore-platform-req=ext-gd --ignore-platform-req=ext-tidy
+ - name: Commit files
+ run: |
+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
+ git config --local user.name "github-actions[bot]"
+ git rm .bowerrc
+ git rm .editorconfig
+ git rm .gitignore
+ git rm .jshintrc
+ git rm .travis.yml
+ 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 package-lock.json
+ git rm phpcs.xml
+ git rm phpdoc.dist.xml
+ git rm webpack.mix.js
+ git rm -r .github
+ git rm -r docs
+ git rm -r blocks-src
+ git rm -r tests
+ git add vendor/\*
+ git add includes/lib/action-scheduler/\*
+ git commit -a -m "Composer Installed. Cleared release repo."
+ - name: Push changes
+ uses: ad-m/github-push-action@master
+ with:
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+ branch: releases
+ repository: ultimatemember/ultimatemember
+ force: true
diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml
deleted file mode 100644
index 0505af0a..00000000
--- a/.github/workflows/translations.yml
+++ /dev/null
@@ -1,20 +0,0 @@
-name: Generate POT file
-
-on:
- push:
- branches:
- - master
-
-jobs:
- WP_Generate_POT_File:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v2
- - name: WordPress .pot File Generator
- uses: iamdharmesh/action-wordpress-pot-generator@main
- with:
- destination_path: './languages'
- slug: 'ultimate-member'
- text_domain: 'ultimate-member'
- env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.gitignore b/.gitignore
index a7597b20..95969446 100644
--- a/.gitignore
+++ b/.gitignore
@@ -220,6 +220,7 @@ assets/vendor/
package-lock.json
.idea/
composer.lock
+includes/lib/action-scheduler/
# exclude Composer installation
composer.phar
diff --git a/.wordpress-org/blueprints/blueprint.json b/.wordpress-org/blueprints/blueprint.json
index 9f87ac24..0860d56d 100644
--- a/.wordpress-org/blueprints/blueprint.json
+++ b/.wordpress-org/blueprints/blueprint.json
@@ -15,7 +15,7 @@
"step": "installPlugin",
"pluginZipFile": {
"resource": "url",
- "url": "https:\/\/downloads.wordpress.org\/plugin\/ultimate-member.2.8.9.zip"
+ "url": "https:\/\/downloads.wordpress.org\/plugin\/ultimate-member.2.9.0.zip"
},
"options": {
"activate": true
diff --git a/README.md b/README.md
index 720f7e42..11318199 100644
--- a/README.md
+++ b/README.md
@@ -44,7 +44,7 @@ GNU Version 2 or Any Later Version
### IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSION 2.6.7 PATCHES SECURITY PRIVILEGE ESCALATION VULNERABILITY. PLEASE SEE [THIS ARTICLE](https://docs.ultimatemember.com/article/1866-security-incident-update-and-recommended-actions) FOR MORE INFORMATION
-[Official Release Version: 2.8.9](https://github.com/ultimatemember/ultimatemember/releases/tag/2.8.9).
+[Official Release Version: 2.9.0](https://github.com/ultimatemember/ultimatemember/releases/tag/2.9.0).
## Changelog
diff --git a/assets/css/admin/users.css b/assets/css/admin/users.css
index f4d527c3..22277fd8 100644
--- a/assets/css/admin/users.css
+++ b/assets/css/admin/users.css
@@ -1,15 +1,18 @@
-.um-admin.users-php .um_account_status {
+.um-admin.users-php .um-filter-by-status {
+ padding: 0 8px 0 0;
+}
+.um-admin.users-php .um_account_status:not(.hidden) {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
flex-wrap: nowrap;
}
-.um-admin.users-php .um_account_status span {
+.um-admin.users-php .um_account_status:not(.hidden) span {
margin: 0 0 2px 0;
padding: 0;
}
-.um-admin.users-php .um_account_status ul {
+.um-admin.users-php .um_account_status:not(.hidden) ul {
display: flex;
flex-direction: row;
justify-content: flex-start;
@@ -20,14 +23,14 @@
margin: 0 0 4px 0;
padding: 0;
}
-.um-admin.users-php .um_account_status ul li {
+.um-admin.users-php .um_account_status:not(.hidden) ul li {
margin: 0;
padding: 0;
}
-.um-admin.users-php .um_account_status ul li a.um-set-status-rejected, .um-admin.users-php .um_account_status ul li a.um-deactivate-user {
+.um-admin.users-php .um_account_status:not(.hidden) ul li a.um-set-status-rejected, .um-admin.users-php .um_account_status:not(.hidden) ul li a.um-deactivate-user {
color: #b32d2e;
}
-.um-admin.users-php .um_account_status ul li a.um-set-status-rejected:active, .um-admin.users-php .um_account_status ul li a.um-set-status-rejected:hover, .um-admin.users-php .um_account_status ul li a.um-deactivate-user:active, .um-admin.users-php .um_account_status ul li a.um-deactivate-user:hover {
+.um-admin.users-php .um_account_status:not(.hidden) ul li a.um-set-status-rejected:active, .um-admin.users-php .um_account_status:not(.hidden) ul li a.um-set-status-rejected:hover, .um-admin.users-php .um_account_status:not(.hidden) ul li a.um-deactivate-user:active, .um-admin.users-php .um_account_status:not(.hidden) ul li a.um-deactivate-user:hover {
color: #b32d2e;
}
diff --git a/assets/css/admin/users.min.css b/assets/css/admin/users.min.css
index 1efe0289..df30e148 100644
--- a/assets/css/admin/users.min.css
+++ b/assets/css/admin/users.min.css
@@ -1 +1 @@
-.um-admin.users-php .um_account_status{display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;flex-wrap:nowrap}.um-admin.users-php .um_account_status span{margin:0 0 2px 0;padding:0}.um-admin.users-php .um_account_status ul{display:flex;flex-direction:row;justify-content:flex-start;align-items:baseline;flex-wrap:wrap;column-gap:4px;row-gap:0;margin:0 0 4px 0;padding:0}.um-admin.users-php .um_account_status ul li{margin:0;padding:0}.um-admin.users-php .um_account_status ul li a.um-deactivate-user,.um-admin.users-php .um_account_status ul li a.um-set-status-rejected{color:#b32d2e}.um-admin.users-php .um_account_status ul li a.um-deactivate-user:active,.um-admin.users-php .um_account_status ul li a.um-deactivate-user:hover,.um-admin.users-php .um_account_status ul li a.um-set-status-rejected:active,.um-admin.users-php .um_account_status ul li a.um-set-status-rejected:hover{color:#b32d2e}.um-admin.users-php .subsubsub li.subsep{display:block;visibility:hidden;height:0}.um-admin-modal .um-admin-infobox label{font-weight:700;display:block;color:#333;cursor:default}.um-admin-modal .um-admin-infobox p{color:#666;padding-top:15px}.um-admin-modal .um-admin-infobox>p:not(:first-child){border-top:1px solid #e5e5e5}.um-admin-modal .um-admin-infobox>p:first-child{margin-top:0;padding-top:0}.um-admin-modal .um-admin-infobox>.um-row>p{border-top:1px solid #e5e5e5}.um-admin-modal .um-admin-infobox>.um-row>p:last-child{margin-bottom:0}#UM_preview_registration .um-admin-modal-foot{display:none}
\ No newline at end of file
+.um-admin.users-php .um-filter-by-status{padding:0 8px 0 0}.um-admin.users-php .um_account_status:not(.hidden){display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;flex-wrap:nowrap}.um-admin.users-php .um_account_status:not(.hidden) span{margin:0 0 2px 0;padding:0}.um-admin.users-php .um_account_status:not(.hidden) ul{display:flex;flex-direction:row;justify-content:flex-start;align-items:baseline;flex-wrap:wrap;column-gap:4px;row-gap:0;margin:0 0 4px 0;padding:0}.um-admin.users-php .um_account_status:not(.hidden) ul li{margin:0;padding:0}.um-admin.users-php .um_account_status:not(.hidden) ul li a.um-deactivate-user,.um-admin.users-php .um_account_status:not(.hidden) ul li a.um-set-status-rejected{color:#b32d2e}.um-admin.users-php .um_account_status:not(.hidden) ul li a.um-deactivate-user:active,.um-admin.users-php .um_account_status:not(.hidden) ul li a.um-deactivate-user:hover,.um-admin.users-php .um_account_status:not(.hidden) ul li a.um-set-status-rejected:active,.um-admin.users-php .um_account_status:not(.hidden) ul li a.um-set-status-rejected:hover{color:#b32d2e}.um-admin.users-php .subsubsub li.subsep{display:block;visibility:hidden;height:0}.um-admin-modal .um-admin-infobox label{font-weight:700;display:block;color:#333;cursor:default}.um-admin-modal .um-admin-infobox p{color:#666;padding-top:15px}.um-admin-modal .um-admin-infobox>p:not(:first-child){border-top:1px solid #e5e5e5}.um-admin-modal .um-admin-infobox>p:first-child{margin-top:0;padding-top:0}.um-admin-modal .um-admin-infobox>.um-row>p{border-top:1px solid #e5e5e5}.um-admin-modal .um-admin-infobox>.um-row>p:last-child{margin-bottom:0}#UM_preview_registration .um-admin-modal-foot{display:none}
\ No newline at end of file
diff --git a/assets/css/admin/users.sass b/assets/css/admin/users.sass
index 09b3756e..405e040b 100644
--- a/assets/css/admin/users.sass
+++ b/assets/css/admin/users.sass
@@ -2,7 +2,9 @@
@import "mixins"
.#{$prefix}admin.users-php
- .um_account_status
+ .um-filter-by-status
+ padding: 0 8px 0 0
+ .um_account_status:not(.hidden)
+flex( column, flex-start, stretch, nowrap )
span
margin: 0 0 2px 0
diff --git a/blocks-src/um-account/block.json b/blocks-src/um-account/block.json
new file mode 100644
index 00000000..8a5c803d
--- /dev/null
+++ b/blocks-src/um-account/block.json
@@ -0,0 +1,15 @@
+{
+ "apiVersion": 2,
+ "name": "um-block/um-account",
+ "title": "Account",
+ "description": "Displaying the account page of the current user",
+ "icon": "id",
+ "category": "um-blocks",
+ "attributes": {
+ "tab": {
+ "type": "string"
+ }
+ },
+ "editorScript": "file:./src/index.js",
+ "textdomain": "ultimate-member"
+}
diff --git a/blocks-src/um-account/src/index.js b/blocks-src/um-account/src/index.js
new file mode 100644
index 00000000..18345342
--- /dev/null
+++ b/blocks-src/um-account/src/index.js
@@ -0,0 +1,81 @@
+import { registerBlockType } from '@wordpress/blocks';
+import ServerSideRender from '@wordpress/server-side-render';
+import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
+import { PanelBody, SelectControl } from "@wordpress/components";
+import { useMemo, useCallback } from '@wordpress/element';
+
+registerBlockType('um-block/um-account', {
+ edit: function (props) {
+ const { attributes, setAttributes } = props;
+ const { tab } = attributes;
+ const blockProps = useBlockProps();
+
+ const options = useMemo(() => {
+ const option = [{ label: wp.i18n.__('All', 'ultimate-member'), value: 'all' }];
+ for (const key in um_account_settings) {
+ if (um_account_settings.hasOwnProperty(key) && um_account_settings[key]['enabled']) {
+ option.push({
+ label: um_account_settings[key]['label'],
+ value: key
+ });
+ }
+ }
+ return option;
+ }, []);
+
+ const onTabChange = useCallback((value) => {
+ setAttributes({ tab: value });
+ const shortcode = `[ultimatemember_account${value !== 'all' ? ` tab="${value}"` : ''}]`;
+ setAttributes({ content: shortcode });
+ }, [setAttributes]);
+
+ return (
+
+ );
+ },
+
+ save: () => null
+});
+
+jQuery(window).on( 'load', function($) {
+ let observer = new MutationObserver(function(mutations) {
+ mutations.forEach(function(mutation) {
+
+ jQuery(mutation.addedNodes).find('.um.um-account').each(function() {
+ let current_tab = jQuery(this).find('.um-account-main').attr('data-current_tab');
+ let wrapper = document.querySelector('.um-form');
+
+ if ( current_tab ) {
+ jQuery(this).find('.um-account-tab[data-tab="'+current_tab+'"]').show();
+ jQuery(this).find('.um-account-tab:not(:visible)').find( 'input, select, textarea' ).not( ':disabled' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
+ um_responsive();
+ }
+
+ if (wrapper) {
+ wrapper.addEventListener('click', (event) => {
+ if (event.target !== wrapper) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ });
+ }
+ });
+ });
+ });
+
+ observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});
+});
diff --git a/blocks-src/um-forms/block.json b/blocks-src/um-forms/block.json
new file mode 100644
index 00000000..2d5dce4a
--- /dev/null
+++ b/blocks-src/um-forms/block.json
@@ -0,0 +1,15 @@
+{
+ "apiVersion": 2,
+ "name": "um-block/um-forms",
+ "title": "Form",
+ "description": "Choose display form",
+ "icon": "forms",
+ "category": "um-blocks",
+ "attributes": {
+ "form_id": {
+ "type": "integer"
+ }
+ },
+ "editorScript": "file:./src/index.js",
+ "textdomain": "ultimate-member"
+}
diff --git a/blocks-src/um-forms/src/index.js b/blocks-src/um-forms/src/index.js
new file mode 100644
index 00000000..5c7852e2
--- /dev/null
+++ b/blocks-src/um-forms/src/index.js
@@ -0,0 +1,74 @@
+import { useSelect } from '@wordpress/data';
+import { PanelBody, SelectControl, Spinner } from '@wordpress/components';
+import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
+import ServerSideRender from '@wordpress/server-side-render';
+import { registerBlockType } from '@wordpress/blocks';
+import { useMemo } from '@wordpress/element';
+
+registerBlockType('um-block/um-forms', {
+ edit: function (props) {
+ const blockProps = useBlockProps();
+ const { attributes, setAttributes } = props;
+ const { form_id } = attributes;
+
+ const posts = useSelect(
+ (select) => select('core').getEntityRecords('postType', 'um_form', { per_page: -1, _fields: ['id', 'title'] }),
+ []
+ );
+
+ const options = useMemo(() => {
+ if (!posts) {
+ return [{ label: wp.i18n.__('Loading...', 'ultimate-member'), value: '' }];
+ }
+ if (posts.length === 0) {
+ return [{ label: wp.i18n.__('No forms found.', 'ultimate-member'), value: '' }];
+ }
+ return [{ label: wp.i18n.__('Select Form', 'ultimate-member'), value: '' }].concat(
+ posts.map((post) => ({ label: post.title.rendered, value: post.id }))
+ );
+ }, [posts]);
+
+ const onFormChange = (value) => setAttributes({ form_id: value });
+
+ return (
+
+ );
+ },
+
+ save: () => null
+});
+
+jQuery(window).on( 'load', function($) {
+ let observer = new MutationObserver(function(mutations) {
+ mutations.forEach(function(mutation) {
+
+ jQuery(mutation.addedNodes).find('.um-form').each(function() {
+ let wrapper = document.querySelector('.um-form');
+
+ if (wrapper) {
+ wrapper.addEventListener('click', (event) => {
+ if (event.target !== wrapper) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ });
+ }
+ });
+ });
+ });
+
+ observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});
+});
diff --git a/blocks-src/um-member-directories/block.json b/blocks-src/um-member-directories/block.json
new file mode 100644
index 00000000..cdffceea
--- /dev/null
+++ b/blocks-src/um-member-directories/block.json
@@ -0,0 +1,15 @@
+{
+ "apiVersion": 2,
+ "name": "um-block/um-member-directories",
+ "title": "Member Directory",
+ "description": "Choose display directory",
+ "icon": "groups",
+ "category": "um-blocks",
+ "attributes": {
+ "member_id": {
+ "type": "integer"
+ }
+ },
+ "editorScript": "file:./src/index.js",
+ "textdomain": "ultimate-member"
+}
diff --git a/blocks-src/um-member-directories/src/index.js b/blocks-src/um-member-directories/src/index.js
new file mode 100644
index 00000000..c5415fff
--- /dev/null
+++ b/blocks-src/um-member-directories/src/index.js
@@ -0,0 +1,107 @@
+import { useSelect } from '@wordpress/data';
+import { PanelBody, SelectControl, Spinner } from '@wordpress/components';
+import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
+import ServerSideRender from '@wordpress/server-side-render';
+import { registerBlockType } from "@wordpress/blocks";
+import { useMemo } from '@wordpress/element';
+
+registerBlockType('um-block/um-member-directories', {
+ edit: function (props) {
+ const blockProps = useBlockProps();
+ const { attributes, setAttributes } = props;
+ const { member_id } = attributes;
+
+ const posts = useSelect((select) => {
+ return select('core').getEntityRecords('postType', 'um_directory', {
+ per_page: -1,
+ _fields: ['id', 'title']
+ });
+ }, []);
+
+ const options = useMemo(() => {
+ if (!posts) {
+ return [{ label: wp.i18n.__('Loading...', 'ultimate-member'), value: '' }];
+ }
+ if (posts.length === 0) {
+ return [{ label: wp.i18n.__('No posts found.', 'ultimate-member'), value: '' }];
+ }
+ return [{ label: wp.i18n.__('Select Directory', 'ultimate-member'), value: '' }].concat(
+ posts.map((post) => ({
+ label: post.title.rendered,
+ value: post.id
+ }))
+ );
+ }, [posts]);
+
+ const onMemberIdChange = (value) => setAttributes({ member_id: value });
+
+ if (!posts) {
+ return (
+
+
+ {wp.i18n.__('Loading...', 'ultimate-member')}
+
+ );
+ }
+
+ return (
+
+ );
+ },
+
+ save: () => null
+});
+
+jQuery(window).on( 'load', function($) {
+ let observer = new MutationObserver(function(mutations) {
+ mutations.forEach(function(mutation) {
+
+ jQuery(mutation.addedNodes).find('.um.um-directory').each(function() {
+ let wrapper = document.querySelector('.um-directory');
+ let directory = jQuery(this);
+ um_ajax_get_members( directory );
+ um_slider_filter_init( directory );
+ um_datepicker_filter_init( directory );
+ um_timepicker_filter_init( directory );
+
+ if (wrapper) {
+ wrapper.addEventListener('click', (event) => {
+ if (event.target !== wrapper) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ });
+ }
+ });
+ jQuery(mutation.addedNodes).find('.um-member').each(function() {
+ let wrapper = document.querySelector('.um-member');
+ let directory = jQuery(this).parent();
+ UM_Member_Grid(directory);
+
+ if (wrapper) {
+ wrapper.addEventListener('click', (event) => {
+ if (event.target !== wrapper) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ });
+ }
+ });
+ });
+ });
+
+ observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});
+});
diff --git a/blocks-src/um-password-reset/block.json b/blocks-src/um-password-reset/block.json
new file mode 100644
index 00000000..2e1548c2
--- /dev/null
+++ b/blocks-src/um-password-reset/block.json
@@ -0,0 +1,10 @@
+{
+ "apiVersion": 2,
+ "name": "um-block/um-password-reset",
+ "title": "Password Reset",
+ "description": "Displaying the password reset form",
+ "icon": "unlock",
+ "category": "um-blocks",
+ "editorScript": "file:./src/index.js",
+ "textdomain": "ultimate-member"
+}
diff --git a/blocks-src/um-password-reset/src/index.js b/blocks-src/um-password-reset/src/index.js
new file mode 100644
index 00000000..74e89369
--- /dev/null
+++ b/blocks-src/um-password-reset/src/index.js
@@ -0,0 +1,17 @@
+import { registerBlockType } from '@wordpress/blocks';
+import ServerSideRender from '@wordpress/server-side-render';
+import { useBlockProps } from '@wordpress/block-editor';
+
+registerBlockType('um-block/um-password-reset', {
+ edit: function () {
+ const blockProps = useBlockProps();
+
+ return (
+
+
+
+ );
+ },
+
+ save: () => null
+});
diff --git a/changelog.txt b/changelog.txt
index 27e5aa73..49946b34 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,5 +1,21 @@
== Changelog ==
+= 2.9.0 November 12, 2024 =
+
+* Enhancements:
+
+ - Added: Action Scheduler (version 3.8.1) for email sending. More info is [here](https://actionscheduler.org/)
+ - Added: Supporting new `wp_register_block_metadata_collection()` function for registering WP Blocks
+
+* Bugfixes:
+
+ - Fixed: `ajax_image_upload()` and `ajax_resize_image()` handlers vulnerability. CVE ID: CVE-2024-10528
+ - Fixed: Disabling user status column wp-admin > Users screen
+ - Fixed: User status filter on wp-admin > Users on mobile devices
+ - Fixed: Extra unwrapping of the WP Editor field's value
+
+* Cached and optimized/minified assets(JS/CSS) must be flushed/re-generated after upgrade
+
= 2.8.9 October 14, 2024 =
* Enhancements:
diff --git a/composer.json b/composer.json
index 53cd7340..b46c44db 100644
--- a/composer.json
+++ b/composer.json
@@ -9,7 +9,8 @@
"config": {
"allow-plugins": {
"symfony/flex": true,
- "dealerdirect/phpcodesniffer-composer-installer": true
+ "dealerdirect/phpcodesniffer-composer-installer": true,
+ "composer/installers": true
}
},
"require": {
@@ -22,7 +23,8 @@
"ext-curl": "*",
"ext-iconv": "*",
"ext-tidy": "*",
- "woocommerce/action-scheduler": "3.2.1"
+ "composer/installers": "^2.3",
+ "woocommerce/action-scheduler": "3.8.1"
},
"require-dev": {
"roave/security-advisories": "dev-latest",
@@ -36,7 +38,7 @@
},
"extra": {
"installer-paths": {
- "vendor/{$vendor}/{$name}/": ["woocommerce/action-scheduler"]
+ "includes/lib/{$name}/": ["woocommerce/action-scheduler"]
}
}
}
diff --git a/includes/action-scheduler/class-init.php b/includes/action-scheduler/class-init.php
new file mode 100644
index 00000000..7850e81c
--- /dev/null
+++ b/includes/action-scheduler/class-init.php
@@ -0,0 +1,299 @@
+can_be_active() ) {
+ UM()->admin()->notices()->add_notice(
+ 'um-action-scheduler',
+ array(
+ '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 ) . '
',
+ )
+ );
+ } else {
+ add_filter( 'um_settings_structure', array( $this, 'add_setting' ) );
+
+ if ( UM()->options()->get( 'enable_action_scheduler' ) ) {
+ $this->enabled = true;
+ }
+ }
+ }
+
+ /**
+ * Adds the Action Scheduler setting to Ultimate Member feature settings
+ *
+ * @param array $settings
+ *
+ * @return array
+ */
+ public function add_setting( $settings ) {
+ $settings['advanced']['sections']['features']['form_sections']['features']['fields'][] = array(
+ 'id' => 'enable_action_scheduler',
+ 'type' => 'checkbox',
+ 'label' => __( 'Action Scheduler', 'ultimate-member' ),
+ 'checkbox_label' => __( 'Enable Action Scheduler', 'ultimate-member' ),
+ 'description' => __( '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', 'ultimate-member' ),
+ );
+
+ return $settings;
+ }
+
+ /**
+ * Verifies whether WooCommerce is installed and activated,
+ * and checks for the existence of the WooCommerce Action Scheduler file.
+ *
+ * @return bool
+ */
+ public function verify_wc_action_scheduler() {
+ if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
+ return false;
+ }
+
+ $action_scheduler_file = WP_PLUGIN_DIR . '/woocommerce/packages/action-scheduler/action-scheduler.php';
+
+ return file_exists( $action_scheduler_file );
+ }
+
+ /**
+ * Tries to load Action Scheduler from Ultimate Member if file exists
+ *
+ * @return bool
+ */
+ public function load_library() {
+ if ( file_exists( $this->lib_path ) ) {
+ require_once $this->lib_path;
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Checks whenever Action Scheduler can be active
+ *
+ * @return bool
+ */
+ public function can_be_active() {
+ return $this->verify_wc_action_scheduler() || $this->load_library();
+ }
+
+ /**
+ * Enqueue an action to run one time, as soon as possible.
+ * If Action Scheduler is disabled then do_action_ref_array is called to run action right away.
+ *
+ * @param string $hook Required. Name of the action hook.
+ * @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.
+ *
+ * @return int Еhe action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log
+ */
+ public function enqueue_async_action( $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
+ if ( $this->enabled ) {
+ $group = $this->set_group( $group );
+ return as_enqueue_async_action( $hook, $args, $group, $unique, $priority );
+ }
+
+ do_action_ref_array( $hook, $args );
+ return 0;
+ }
+
+ /**
+ * Schedule an action to run one time at some defined point in the future.
+ *
+ * @param int $timestamp Required. The Unix timestamp representing the date you want the action to run.
+ * @param string $hook Required. Name of the action hook.
+ * @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.)
+ *
+ * @return int The action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log.
+ */
+ public function schedule_single_action( $timestamp, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
+ if ( $this->enabled ) {
+ $group = $this->set_group( $group );
+ return as_schedule_single_action( $timestamp, $hook, $args, $group, $unique, $priority );
+ }
+
+ do_action_ref_array( $hook, $args );
+ return 0;
+ }
+
+ /**
+ * Schedule an action to run repeatedly with a specified interval in seconds.
+ *
+ * @param int $timestamp Required. The Unix timestamp representing the date you want the action to run.
+ * @param int $interval_in_seconds Required. How long to wait between runs.
+ * @param string $hook Required. Name of the action hook.
+ * @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.
+ *
+ * @return int The action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log.
+ */
+ public function schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
+ $group = $this->set_group( $group );
+
+ return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group, $unique, $priority );
+ }
+
+ /**
+ * Schedule an action that recurs on a cron-like schedule.
+ *
+ * If execution of a cron-like action is delayed, the next attempt will still be scheduled according to the provided cron expression.
+ *
+ * @param int $timestamp Required. The Unix timestamp representing the date you want the action to run.
+ * @param string $schedule Required. A cron-like schedule string, see http://en.wikipedia.org/wiki/Cron.
+ * @param string $hook Required Name of the action hook.
+ * @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.
+ *
+ * @return int The action’s ID. Zero if there was an error scheduling the action. The error will be sent to error_log.
+ */
+ public function schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '', $unique = false, $priority = 10 ) {
+ $group = $this->set_group( $group );
+
+ return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group, $unique, $priority );
+ }
+
+ /**
+ * Cancel the next occurrence of a scheduled action.
+ *
+ * @param string $hook Required. Name of the action hook.
+ * @param array $args Arguments passed to callbacks when the hook triggers. Default: array().
+ * @param string $group The group the job is assigned to. Default: ''.
+ *
+ * @return int|null The scheduled action ID if a scheduled action was found, or null if no matching action found.
+ */
+ public function unschedule_action( $hook, $args = array(), $group = '' ) {
+ $group = $this->set_group( $group );
+
+ return as_unschedule_action( $hook, $args, $group );
+ }
+
+ /**
+ * Cancel all occurrences of a scheduled action.
+ *
+ * @param string $hook The hook that the job will trigger.
+ * @param array $args Args that would have been passed to the job.
+ * @param string $group The group the job is assigned to.
+ */
+ public function unschedule_all_actions( $hook, $args = array(), $group = '' ) {
+ $group = $this->set_group( $group );
+
+ as_unschedule_all_actions( $hook, $args, $group );
+ }
+
+ /**
+ * Returns the next timestamp for a scheduled action.
+ *
+ * @param string $hook Required. Name of the action hook. Default: none.
+ * @param array $args Arguments passed to callbacks when the hook triggers. Default: array().
+ * @param string $group The group the job is assigned to. Default: ''.
+ *
+ * @return int|bool The timestamp for the next occurrence of a pending scheduled action, true for an async or in-progress action or false if there is no matching action.
+ */
+ public function next_scheduled_action( $hook, $args = array(), $group = '' ) {
+ $group = $this->set_group( $group );
+
+ return as_next_scheduled_action( $hook, $args, $group );
+ }
+
+ /**
+ * Check if there is a scheduled action in the queue, but more efficiently than as_next_scheduled_action().
+ * It’s recommended to use this function when you need to know whether a specific action is currently scheduled.
+ *
+ * @param string $hook Required. Name of the action hook. Default: none.
+ * @param array $args Arguments passed to callbacks when the hook triggers. Default: array().
+ * @param string $group The group the job is assigned to. Default: ''.
+ *
+ * @return bool True if a matching action is pending or in-progress, false otherwise.
+ */
+ public function has_scheduled_action( $hook, $args = array(), $group = '' ) {
+ $group = $this->set_group( $group );
+
+ return as_has_scheduled_action( $hook, $args, $group );
+ }
+
+ /**
+ * @param array $args Arguments to search and filter results by. Possible arguments, with their default values:
+ * 'hook' => '' - the name of the action that will be triggered
+ * 'args' => NULL - the args array that will be passed with the action
+ * 'date' => NULL - the scheduled date of the action. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime().
+ * 'date_compare' => '<=' - operator for testing “date”. accepted values are ‘!=’, ‘>’, ‘>=’, ‘<’, ‘<=’, ‘=’
+ * 'modified' => NULL - the date the action was last updated. Expects a DateTime object, a unix timestamp, or a string that can parsed with strtotime().
+ * 'modified_compare' => '<=' - operator for testing “modified”. accepted values are ‘!=’, ‘>’, ‘>=’, ‘<’, ‘<=’, ‘=’
+ * 'group' => '' - the group the action belongs to
+ * 'status' => '' - ActionScheduler_Store::STATUS_COMPLETE or ActionScheduler_Store::STATUS_PENDING
+ * 'claimed' => NULL - TRUE to find claimed actions, FALSE to find unclaimed actions, a string to find a specific claim ID
+ * 'per_page' => 5 - Number of results to return
+ * 'offset' => 0
+ * 'orderby' => 'date' - accepted values are ‘hook’, ‘group’, ‘modified’, or ‘date’
+ * 'order' => 'ASC'
+ *
+ * @param string $return_format The format in which to return the scheduled actions: 'OBJECT', 'ARRAY_A', or 'ids'. Default: 'OBJECT'.
+ *
+ * @return array Array of action rows matching the criteria specified with $args.
+ */
+ public function get_scheduled_actions( $args, $return_format = 'OBJECT' ) {
+ if ( ! empty( $args['group'] ) ) {
+ $args['group'] = $this->set_group( $args['group'] );
+ }
+ return as_get_scheduled_actions( $args, $return_format );
+ }
+
+ public function set_group( $group ) {
+ if ( empty( $group ) ) {
+ return $this->default_group;
+ }
+
+ return $this->default_group . '_' . $group;
+ }
+ }
+}
diff --git a/includes/admin/class-users-columns.php b/includes/admin/class-users-columns.php
index d6d3c22b..81165829 100644
--- a/includes/admin/class-users-columns.php
+++ b/includes/admin/class-users-columns.php
@@ -360,7 +360,7 @@ if ( ! class_exists( 'um\admin\Users_Columns' ) ) {
$statuses = $this->get_statuses_filter_options();
?>
-
+
diff --git a/includes/admin/core/class-admin-settings.php b/includes/admin/core/class-admin-settings.php
index 6b58b35c..d8373b9f 100644
--- a/includes/admin/core/class-admin-settings.php
+++ b/includes/admin/core/class-admin-settings.php
@@ -543,7 +543,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'size' => 'medium',
),
array(
- 'id' => 'a$access_fieldsccess_redirect',
+ 'id' => 'access_redirect',
'type' => 'text',
'label' => __( 'Custom Redirect URL', 'ultimate-member' ),
'description' => __( 'A logged out user will be redirected to this url If he is not permitted to access the site.', 'ultimate-member' ),
@@ -1005,6 +1005,9 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
'enable_blocks' => array(
'sanitize' => 'bool',
),
+ 'enable_action_scheduler' => array(
+ 'sanitize' => 'bool',
+ ),
'rest_api_version' => array(
'sanitize' => 'text',
),
diff --git a/includes/admin/core/list-tables/emails-list-table.php b/includes/admin/core/list-tables/emails-list-table.php
index 0321b934..87bcc5c3 100644
--- a/includes/admin/core/list-tables/emails-list-table.php
+++ b/includes/admin/core/list-tables/emails-list-table.php
@@ -14,7 +14,7 @@ if ( ! empty( $_GET['_wp_http_referer'] ) ) {
}
if ( ! class_exists( 'WP_List_Table' ) ) {
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
diff --git a/includes/admin/core/packages/2.1.3-beta3/functions.php b/includes/admin/core/packages/2.1.3-beta3/functions.php
index 9609ce10..7f5de7f1 100644
--- a/includes/admin/core/packages/2.1.3-beta3/functions.php
+++ b/includes/admin/core/packages/2.1.3-beta3/functions.php
@@ -140,7 +140,7 @@ KEY meta_key_indx (um_key),
KEY meta_value_indx (um_value(191))
) $charset_collate;";
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql );
update_option( 'um_last_version_upgrade', '2.1.3-beta3' );
diff --git a/includes/blocks/blocks-manifest.php b/includes/blocks/blocks-manifest.php
new file mode 100644
index 00000000..7bfc80cd
--- /dev/null
+++ b/includes/blocks/blocks-manifest.php
@@ -0,0 +1,59 @@
+ array(
+ 'apiVersion' => 2,
+ 'name' => 'um-block/um-account',
+ 'title' => 'Account',
+ 'description' => 'Displaying the account page of the current user',
+ 'icon' => 'id',
+ 'category' => 'um-blocks',
+ 'attributes' => array(
+ 'tab' => array(
+ 'type' => 'string'
+ )
+ ),
+ 'editorScript' => 'file:./src/index.js',
+ 'textdomain' => 'ultimate-member'
+ ),
+ 'um-forms' => array(
+ 'apiVersion' => 2,
+ 'name' => 'um-block/um-forms',
+ 'title' => 'Form',
+ 'description' => 'Choose display form',
+ 'icon' => 'forms',
+ 'category' => 'um-blocks',
+ 'attributes' => array(
+ 'form_id' => array(
+ 'type' => 'integer'
+ )
+ ),
+ 'editorScript' => 'file:./src/index.js',
+ 'textdomain' => 'ultimate-member'
+ ),
+ 'um-member-directories' => array(
+ 'apiVersion' => 2,
+ 'name' => 'um-block/um-member-directories',
+ 'title' => 'Member Directory',
+ 'description' => 'Choose display directory',
+ 'icon' => 'groups',
+ 'category' => 'um-blocks',
+ 'attributes' => array(
+ 'member_id' => array(
+ 'type' => 'integer'
+ )
+ ),
+ 'editorScript' => 'file:./src/index.js',
+ 'textdomain' => 'ultimate-member'
+ ),
+ 'um-password-reset' => array(
+ 'apiVersion' => 2,
+ 'name' => 'um-block/um-password-reset',
+ 'title' => 'Password Reset',
+ 'description' => 'Displaying the password reset form',
+ 'icon' => 'unlock',
+ 'category' => 'um-blocks',
+ 'editorScript' => 'file:./src/index.js',
+ 'textdomain' => 'ultimate-member'
+ )
+);
diff --git a/includes/blocks/um-account/block.json b/includes/blocks/um-account/block.json
index 2085aec7..b95c89b9 100644
--- a/includes/blocks/um-account/block.json
+++ b/includes/blocks/um-account/block.json
@@ -10,6 +10,6 @@
"type": "string"
}
},
- "editorScript": "file:./build/index.js",
+ "editorScript": "file:./src/index.js",
"textdomain": "ultimate-member"
-}
+}
\ No newline at end of file
diff --git a/includes/blocks/um-account/build/index.asset.php b/includes/blocks/um-account/build/index.asset.php
deleted file mode 100644
index cf48a0d1..00000000
--- a/includes/blocks/um-account/build/index.asset.php
+++ /dev/null
@@ -1 +0,0 @@
- array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-server-side-render'), 'version' => '98a99fd44cd9deb95734');
diff --git a/includes/blocks/um-account/build/index.js b/includes/blocks/um-account/build/index.js
deleted file mode 100644
index d8d1e5fe..00000000
--- a/includes/blocks/um-account/build/index.js
+++ /dev/null
@@ -1 +0,0 @@
-(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var a in n)t.o(n,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:n[a]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wp.element,n=window.wp.blocks,a=window.wp.serverSideRender;var o=t.n(a);const u=window.wp.blockEditor,r=window.wp.components;(0,n.registerBlockType)("um-block/um-account",{edit:function(t){let{tab:n,setAttributes:a}=t.attributes;const c=(0,u.useBlockProps)();return(0,e.createElement)("div",c,(0,e.createElement)(o(),{block:"um-block/um-account",attributes:t.attributes}),(0,e.createElement)(u.InspectorControls,null,(0,e.createElement)(r.PanelBody,{title:wp.i18n.__("Account Tab","ultimate-member")},(0,e.createElement)(r.SelectControl,{label:wp.i18n.__("Select Tab","ultimate-member"),className:"um_select_account_tab",value:n,options:function(){var t=[];for(var e in t.push({label:wp.i18n.__("All","ultimate-member"),value:"all"}),um_account_settings)um_account_settings.hasOwnProperty(e)&&um_account_settings[e].enabled&&t.push({label:um_account_settings[e].label,value:e});return t}(),style:{height:"35px",lineHeight:"20px",padding:"0 7px"},onChange:e=>{t.setAttributes({tab:e}),function(e){var n="[ultimatemember_account";"all"!==e&&(n=n+' tab="'+e+'"'),n+="]",t.setAttributes({content:n})}(e)}}))))},save:function(t){return null}}),jQuery(window).on("load",(function(t){new MutationObserver((function(t){t.forEach((function(t){jQuery(t.addedNodes).find(".um.um-account").each((function(){var t=jQuery(this).find(".um-account-main").attr("data-current_tab");t&&(jQuery(this).find('.um-account-tab[data-tab="'+t+'"]').show(),jQuery(this).find(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),um_responsive(),um_modal_responsive())}))}))})).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})}))})();
\ No newline at end of file
diff --git a/includes/blocks/um-account/src/index.asset.php b/includes/blocks/um-account/src/index.asset.php
new file mode 100644
index 00000000..0b7c5e12
--- /dev/null
+++ b/includes/blocks/um-account/src/index.asset.php
@@ -0,0 +1 @@
+ array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-element', 'wp-server-side-render'), 'version' => 'a9e99ac324b1bd5538e3');
diff --git a/includes/blocks/um-account/src/index.js b/includes/blocks/um-account/src/index.js
index cb62aee3..bab6a5f8 100644
--- a/includes/blocks/um-account/src/index.js
+++ b/includes/blocks/um-account/src/index.js
@@ -1,88 +1 @@
-import { registerBlockType } from '@wordpress/blocks';
-import ServerSideRender from '@wordpress/server-side-render';
-import {InspectorControls, useBlockProps} from '@wordpress/block-editor';
-import {PanelBody, SelectControl} from "@wordpress/components";
-
-registerBlockType('um-block/um-account', {
- edit: function (props) {
- let { tab, setAttributes } = props.attributes;
- const blockProps = useBlockProps();
-
- function get_options() {
- var option = [];
-
- option.push( { label: wp.i18n.__( 'All', 'ultimate-member' ), value: 'all' } );
-
- for ( var key in um_account_settings ) {
- if ( um_account_settings.hasOwnProperty( key ) && um_account_settings[ key ]['enabled'] ) {
- option.push(
- {
- label: um_account_settings[ key ]['label'],
- value: key
- }
- )
- }
- }
-
- return option;
- }
-
- function umShortcode( value ) {
-
- var shortcode = '[ultimatemember_account';
-
- if ( value !== 'all' ) {
- shortcode = shortcode + ' tab="' + value + '"';
- }
-
- shortcode = shortcode + ']';
-
- props.setAttributes({ content: shortcode });
- }
-
- return (
-
-
-
-
- {
- props.setAttributes({ tab: value });
- umShortcode(value);
- }}
- />
-
-
-
- );
-
- },
- save: function save(props) {
- return null;
- }
-});
-
-jQuery(window).on( 'load', function($) {
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
-
- jQuery(mutation.addedNodes).find('.um.um-account').each(function() {
- var current_tab = jQuery(this).find('.um-account-main').attr('data-current_tab');
-
- if ( current_tab ) {
- jQuery(this).find('.um-account-tab[data-tab="'+current_tab+'"]').show();
- jQuery(this).find('.um-account-tab:not(:visible)').find( 'input, select, textarea' ).not( ':disabled' ).addClass('um_account_inactive').prop( 'disabled', true ).attr( 'disabled', true );
- um_responsive();
- // um_modal_responsive();
- }
- });
- });
- });
-
- observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});
-});
+(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},d:(e,n)=>{for(var a in n)t.o(n,a)&&!t.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:n[a]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)};const e=window.wp.blocks,n=window.wp.serverSideRender;var a=t.n(n);const o=window.wp.blockEditor,c=window.wp.components,u=window.wp.element,i=window.ReactJSXRuntime;(0,e.registerBlockType)("um-block/um-account",{edit:function(t){const{attributes:e,setAttributes:n}=t,{tab:r}=e,s=(0,o.useBlockProps)(),l=(0,u.useMemo)((()=>{const t=[{label:wp.i18n.__("All","ultimate-member"),value:"all"}];for(const e in um_account_settings)um_account_settings.hasOwnProperty(e)&&um_account_settings[e].enabled&&t.push({label:um_account_settings[e].label,value:e});return t}),[]),d=(0,u.useCallback)((t=>{n({tab:t}),n({content:`[ultimatemember_account${"all"!==t?` tab="${t}"`:""}]`})}),[n]);return(0,i.jsxs)("div",{...s,children:[(0,i.jsx)(a(),{block:"um-block/um-account",attributes:e}),(0,i.jsx)(o.InspectorControls,{children:(0,i.jsx)(c.PanelBody,{title:wp.i18n.__("Account Tab","ultimate-member"),children:(0,i.jsx)(c.SelectControl,{label:wp.i18n.__("Select Tab","ultimate-member"),className:"um_select_account_tab",value:r,options:l,style:{height:"35px",lineHeight:"20px",padding:"0 7px"},onChange:d})})})]})},save:()=>null}),jQuery(window).on("load",(function(t){new MutationObserver((function(t){t.forEach((function(t){jQuery(t.addedNodes).find(".um.um-account").each((function(){let t=jQuery(this).find(".um-account-main").attr("data-current_tab"),e=document.querySelector(".um-form");t&&(jQuery(this).find('.um-account-tab[data-tab="'+t+'"]').show(),jQuery(this).find(".um-account-tab:not(:visible)").find("input, select, textarea").not(":disabled").addClass("um_account_inactive").prop("disabled",!0).attr("disabled",!0),um_responsive()),e&&e.addEventListener("click",(t=>{t.target!==e&&(t.preventDefault(),t.stopPropagation())}))}))}))})).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})}))})();
\ No newline at end of file
diff --git a/includes/blocks/um-forms/block.json b/includes/blocks/um-forms/block.json
index 563f7399..b6acee9f 100644
--- a/includes/blocks/um-forms/block.json
+++ b/includes/blocks/um-forms/block.json
@@ -10,6 +10,6 @@
"type": "integer"
}
},
- "editorScript": "file:./build/index.js",
+ "editorScript": "file:./src/index.js",
"textdomain": "ultimate-member"
-}
+}
\ No newline at end of file
diff --git a/includes/blocks/um-forms/build/index.asset.php b/includes/blocks/um-forms/build/index.asset.php
deleted file mode 100644
index 6ef4166a..00000000
--- a/includes/blocks/um-forms/build/index.asset.php
+++ /dev/null
@@ -1 +0,0 @@
- array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-server-side-render'), 'version' => '9dc130f3a0af7db5d679');
diff --git a/includes/blocks/um-forms/build/index.js b/includes/blocks/um-forms/build/index.js
deleted file mode 100644
index eaaac6a4..00000000
--- a/includes/blocks/um-forms/build/index.js
+++ /dev/null
@@ -1 +0,0 @@
-(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,r=window.wp.data,n=window.wp.components,l=window.wp.blockEditor,o=window.wp.serverSideRender;var i=e.n(o);(0,window.wp.blocks.registerBlockType)("um-block/um-forms",{edit:function(e){let{form_id:o,setAttributes:a}=e.attributes;const s=(0,l.useBlockProps)(),m=(0,r.useSelect)((e=>e("core").getEntityRecords("postType","um_form",{per_page:-1,_fields:["id","title"]})));if(!m)return(0,t.createElement)("p",null,(0,t.createElement)(n.Spinner,null),wp.i18n.__("Loading...","ultimate-member"));if(0===m.length)return"No forms found.";let c=[{id:"",title:""}].concat(m).map((e=>({label:e.title.rendered,value:e.id})));return(0,t.createElement)("div",s,(0,t.createElement)(i(),{block:"um-block/um-forms",attributes:e.attributes}),(0,t.createElement)(l.InspectorControls,null,(0,t.createElement)(n.PanelBody,{title:wp.i18n.__("Select Forms","ultimate-member")},(0,t.createElement)(n.SelectControl,{label:wp.i18n.__("Select Forms","ultimate-member"),className:"um_select_forms",value:o,options:c,style:{height:"35px",lineHeight:"20px",padding:"0 7px"},onChange:t=>{e.setAttributes({form_id:t})}}))))},save:function(e){return null}})})();
\ No newline at end of file
diff --git a/includes/blocks/um-forms/src/index.asset.php b/includes/blocks/um-forms/src/index.asset.php
new file mode 100644
index 00000000..2bb40790
--- /dev/null
+++ b/includes/blocks/um-forms/src/index.asset.php
@@ -0,0 +1 @@
+ array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-server-side-render'), 'version' => 'cf4974d44ac78244494c');
diff --git a/includes/blocks/um-forms/src/index.js b/includes/blocks/um-forms/src/index.js
index 27cc2418..285e5656 100644
--- a/includes/blocks/um-forms/src/index.js
+++ b/includes/blocks/um-forms/src/index.js
@@ -1,91 +1 @@
-import { useSelect } from '@wordpress/data';
-import { PanelBody, SelectControl, Spinner } from '@wordpress/components';
-import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
-import ServerSideRender from '@wordpress/server-side-render';
-import { registerBlockType } from "@wordpress/blocks";
-
-registerBlockType('um-block/um-forms', {
- edit: function (props) {
- let { form_id, setAttributes } = props.attributes;
- const blockProps = useBlockProps();
- const posts = useSelect((select) => {
- return select('core').getEntityRecords('postType', 'um_form', {
- per_page: -1,
- _fields: ['id', 'title']
- });
- });
-
- if (!posts) {
- return (
-
-
- {wp.i18n.__('Loading...', 'ultimate-member')}
-
- );
- }
-
- if (posts.length === 0) {
- return 'No forms found.';
- }
-
- function get_option( posts ) {
- var option = [];
-
- posts.map( function( post ) {
- option.push(
- {
- label: post.title.rendered,
- value: post.id
- }
- );
- });
-
- return option;
- }
-
- function umShortcode( value ) {
-
- var shortcode = '';
-
- if (value !== undefined && value !== '') {
- shortcode = '[ultimatemember form_id="' + value + '"]';
- }
-
- return shortcode;
- }
-
- let posts_data = [{ id: '', title: '' }].concat(posts);
-
- let get_post = posts_data.map((post) => {
- return {
- label: post.title.rendered,
- value: post.id
- };
- });
-
- return (
-
-
-
-
- {
- props.setAttributes({ form_id: value });
- umShortcode(value);
- }}
- />
-
-
-
- );
-
- },
- save: function save(props) {
- return null;
- }
-});
+(()=>{"use strict";var e={n:t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.data,o=window.wp.components,r=window.wp.blockEditor,n=window.wp.serverSideRender;var l=e.n(n);const i=window.wp.blocks,a=window.wp.element,s=window.ReactJSXRuntime;(0,i.registerBlockType)("um-block/um-forms",{edit:function(e){const n=(0,r.useBlockProps)(),{attributes:i,setAttributes:u}=e,{form_id:c}=i,d=(0,t.useSelect)((e=>e("core").getEntityRecords("postType","um_form",{per_page:-1,_fields:["id","title"]})),[]),m=(0,a.useMemo)((()=>d?0===d.length?[{label:wp.i18n.__("No forms found.","ultimate-member"),value:""}]:[{label:wp.i18n.__("Select Form","ultimate-member"),value:""}].concat(d.map((e=>({label:e.title.rendered,value:e.id})))):[{label:wp.i18n.__("Loading...","ultimate-member"),value:""}]),[d]);return(0,s.jsxs)("div",{...n,children:[(0,s.jsx)(l(),{block:"um-block/um-forms",attributes:i}),(0,s.jsx)(r.InspectorControls,{children:(0,s.jsx)(o.PanelBody,{title:wp.i18n.__("Select Forms","ultimate-member"),children:(0,s.jsx)(o.SelectControl,{label:wp.i18n.__("Select Forms","ultimate-member"),className:"um_select_forms",value:c,options:m,onChange:e=>u({form_id:e})})})})]})},save:()=>null}),jQuery(window).on("load",(function(e){new MutationObserver((function(e){e.forEach((function(e){jQuery(e.addedNodes).find(".um-form").each((function(){let e=document.querySelector(".um-form");e&&e.addEventListener("click",(t=>{t.target!==e&&(t.preventDefault(),t.stopPropagation())}))}))}))})).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})}))})();
\ No newline at end of file
diff --git a/includes/blocks/um-member-directories/block.json b/includes/blocks/um-member-directories/block.json
index ddaabf37..46492735 100644
--- a/includes/blocks/um-member-directories/block.json
+++ b/includes/blocks/um-member-directories/block.json
@@ -10,6 +10,6 @@
"type": "integer"
}
},
- "editorScript": "file:./build/index.js",
+ "editorScript": "file:./src/index.js",
"textdomain": "ultimate-member"
-}
+}
\ No newline at end of file
diff --git a/includes/blocks/um-member-directories/build/index.asset.php b/includes/blocks/um-member-directories/build/index.asset.php
deleted file mode 100644
index 83e8be83..00000000
--- a/includes/blocks/um-member-directories/build/index.asset.php
+++ /dev/null
@@ -1 +0,0 @@
- array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-server-side-render'), 'version' => '5b1a8ec016836a5c26cd');
diff --git a/includes/blocks/um-member-directories/build/index.js b/includes/blocks/um-member-directories/build/index.js
deleted file mode 100644
index 7492c2d3..00000000
--- a/includes/blocks/um-member-directories/build/index.js
+++ /dev/null
@@ -1 +0,0 @@
-(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.React,r=window.wp.data,i=window.wp.components,n=window.wp.blockEditor,o=window.wp.serverSideRender;var l=e.n(o);(0,window.wp.blocks.registerBlockType)("um-block/um-member-directories",{edit:function(e){let{member_id:o,setAttributes:a}=e.attributes;const c=(0,n.useBlockProps)(),u=(0,r.useSelect)((e=>e("core").getEntityRecords("postType","um_directory",{per_page:-1,_fields:["id","title"]})));if(!u)return(0,t.createElement)("p",null,(0,t.createElement)(i.Spinner,null),wp.i18n.__("Loading...","ultimate-member"));if(0===u.length)return"No posts found.";let d=[{id:"",title:""}].concat(u).map((e=>({label:e.title.rendered,value:e.id})));return(0,t.createElement)("div",{...c},(0,t.createElement)(l(),{block:"um-block/um-member-directories",attributes:e.attributes}),(0,t.createElement)(n.InspectorControls,null,(0,t.createElement)(i.PanelBody,{title:wp.i18n.__("Select Directories","ultimate-member")},(0,t.createElement)(i.SelectControl,{label:wp.i18n.__("Select Directories","ultimate-member"),className:"um_select_directory",value:o,options:d,style:{height:"35px",lineHeight:"20px",padding:"0 7px"},onChange:t=>{e.setAttributes({member_id:t})}}))))},save:function(e){return null}}),jQuery(window).on("load",(function(e){new MutationObserver((function(e){e.forEach((function(e){jQuery(e.addedNodes).find(".um.um-directory").each((function(){var e=jQuery(this);um_ajax_get_members(e),um_slider_filter_init(e),um_datepicker_filter_init(e),um_timepicker_filter_init(e)})),jQuery(e.addedNodes).find(".um-member").each((function(){var e=jQuery(this).parent();UM_Member_Grid(e)}))}))})).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})}))})();
\ No newline at end of file
diff --git a/includes/blocks/um-member-directories/src/index.asset.php b/includes/blocks/um-member-directories/src/index.asset.php
new file mode 100644
index 00000000..7ac488fc
--- /dev/null
+++ b/includes/blocks/um-member-directories/src/index.asset.php
@@ -0,0 +1 @@
+ array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-server-side-render'), 'version' => 'cced871823424b7be338');
diff --git a/includes/blocks/um-member-directories/src/index.js b/includes/blocks/um-member-directories/src/index.js
index 41e606b3..38fffc0c 100644
--- a/includes/blocks/um-member-directories/src/index.js
+++ b/includes/blocks/um-member-directories/src/index.js
@@ -1,112 +1 @@
-import { useSelect } from '@wordpress/data';
-import { PanelBody, SelectControl, Spinner } from '@wordpress/components';
-import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
-import ServerSideRender from '@wordpress/server-side-render';
-import { registerBlockType } from "@wordpress/blocks";
-
-registerBlockType('um-block/um-member-directories', {
- edit: function (props) {
- let { member_id, setAttributes } = props.attributes;
- const blockProps = useBlockProps();
- const posts = useSelect((select) => {
- return select('core').getEntityRecords('postType', 'um_directory', {
- per_page: -1,
- _fields: ['id', 'title']
- });
- });
-
- if (!posts) {
- return (
-
-
- {wp.i18n.__('Loading...', 'ultimate-member')}
-
- );
- }
-
- if (posts.length === 0) {
- return 'No posts found.';
- }
-
- function get_option( posts ) {
- var option = [];
-
- posts.map( function( post ) {
- option.push(
- {
- label: post.title.rendered,
- value: post.id
- }
- );
- });
-
- return option;
- }
-
- function umShortcode( value ) {
-
- var shortcode = '';
-
- if (value !== undefined && value !== '') {
- shortcode = '[ultimatemember form_id="' + value + '"]';
- }
-
- return shortcode;
- }
-
- let posts_data = [{ id: '', title: '' }].concat(posts);
-
- let get_post = posts_data.map((post) => {
- return {
- label: post.title.rendered,
- value: post.id
- };
- });
-
- return (
-
-
-
-
- {
- props.setAttributes({ member_id: value });
- umShortcode(value);
- }}
- />
-
-
-
- );
-
- },
- save: function save(props) {
- return null;
- }
-});
-
-jQuery(window).on( 'load', function($) {
- var observer = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
-
- jQuery(mutation.addedNodes).find('.um.um-directory').each(function() {
- var directory = jQuery(this);
- um_ajax_get_members( directory );
- um_slider_filter_init( directory );
- um_datepicker_filter_init( directory );
- um_timepicker_filter_init( directory );
- });
- jQuery(mutation.addedNodes).find('.um-member').each(function() {
- var directory = jQuery(this).parent();
- UM_Member_Grid(directory);
- });
- });
- });
-
- observer.observe(document, {attributes: false, childList: true, characterData: false, subtree:true});
-});
+(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.data,r=window.wp.components,i=window.wp.blockEditor,n=window.wp.serverSideRender;var o=e.n(n);const l=window.wp.blocks,a=window.wp.element,c=window.ReactJSXRuntime;(0,l.registerBlockType)("um-block/um-member-directories",{edit:function(e){const n=(0,i.useBlockProps)(),{attributes:l,setAttributes:d}=e,{member_id:u}=l,m=(0,t.useSelect)((e=>e("core").getEntityRecords("postType","um_directory",{per_page:-1,_fields:["id","title"]})),[]),s=(0,a.useMemo)((()=>m?0===m.length?[{label:wp.i18n.__("No posts found.","ultimate-member"),value:""}]:[{label:wp.i18n.__("Select Directory","ultimate-member"),value:""}].concat(m.map((e=>({label:e.title.rendered,value:e.id})))):[{label:wp.i18n.__("Loading...","ultimate-member"),value:""}]),[m]);return m?(0,c.jsxs)("div",{...n,children:[(0,c.jsx)(o(),{block:"um-block/um-member-directories",attributes:l}),(0,c.jsx)(i.InspectorControls,{children:(0,c.jsx)(r.PanelBody,{title:wp.i18n.__("Select Directories","ultimate-member"),children:(0,c.jsx)(r.SelectControl,{label:wp.i18n.__("Select Directories","ultimate-member"),className:"um_select_directory",value:u,options:s,onChange:e=>d({member_id:e})})})})]}):(0,c.jsxs)("p",{children:[(0,c.jsx)(r.Spinner,{}),wp.i18n.__("Loading...","ultimate-member")]})},save:()=>null}),jQuery(window).on("load",(function(e){new MutationObserver((function(e){e.forEach((function(e){jQuery(e.addedNodes).find(".um.um-directory").each((function(){let e=document.querySelector(".um-directory"),t=jQuery(this);um_ajax_get_members(t),um_slider_filter_init(t),um_datepicker_filter_init(t),um_timepicker_filter_init(t),e&&e.addEventListener("click",(t=>{t.target!==e&&(t.preventDefault(),t.stopPropagation())}))})),jQuery(e.addedNodes).find(".um-member").each((function(){let e=document.querySelector(".um-member"),t=jQuery(this).parent();UM_Member_Grid(t),e&&e.addEventListener("click",(t=>{t.target!==e&&(t.preventDefault(),t.stopPropagation())}))}))}))})).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})}))})();
\ No newline at end of file
diff --git a/includes/blocks/um-password-reset/block.json b/includes/blocks/um-password-reset/block.json
index f73a45ee..e9ba86f6 100644
--- a/includes/blocks/um-password-reset/block.json
+++ b/includes/blocks/um-password-reset/block.json
@@ -5,6 +5,6 @@
"description": "Displaying the password reset form",
"icon": "unlock",
"category": "um-blocks",
- "editorScript": "file:./build/index.js",
+ "editorScript": "file:./src/index.js",
"textdomain": "ultimate-member"
-}
+}
\ No newline at end of file
diff --git a/includes/blocks/um-password-reset/build/index.asset.php b/includes/blocks/um-password-reset/build/index.asset.php
deleted file mode 100644
index 75ba44e5..00000000
--- a/includes/blocks/um-password-reset/build/index.asset.php
+++ /dev/null
@@ -1 +0,0 @@
- array('wp-block-editor', 'wp-blocks', 'wp-element', 'wp-server-side-render'), 'version' => '95e8fe2695e681505871');
diff --git a/includes/blocks/um-password-reset/build/index.js b/includes/blocks/um-password-reset/build/index.js
deleted file mode 100644
index 5f96959e..00000000
--- a/includes/blocks/um-password-reset/build/index.js
+++ /dev/null
@@ -1 +0,0 @@
-(()=>{"use strict";var e={n:r=>{var o=r&&r.__esModule?()=>r.default:()=>r;return e.d(o,{a:o}),o},d:(r,o)=>{for(var t in o)e.o(o,t)&&!e.o(r,t)&&Object.defineProperty(r,t,{enumerable:!0,get:o[t]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r)};const r=window.wp.element,o=window.wp.blocks,t=window.wp.serverSideRender;var n=e.n(t);const s=window.wp.blockEditor;(0,o.registerBlockType)("um-block/um-password-reset",{edit:function(e){const o=(0,s.useBlockProps)();return(0,r.createElement)("div",o,(0,r.createElement)(n(),{block:"um-block/um-password-reset"}))},save:function(e){return null}})})();
\ No newline at end of file
diff --git a/includes/blocks/um-password-reset/src/index.asset.php b/includes/blocks/um-password-reset/src/index.asset.php
new file mode 100644
index 00000000..4cf5f6d3
--- /dev/null
+++ b/includes/blocks/um-password-reset/src/index.asset.php
@@ -0,0 +1 @@
+ array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-server-side-render'), 'version' => 'd1e8ad89d47a20d3414b');
diff --git a/includes/blocks/um-password-reset/src/index.js b/includes/blocks/um-password-reset/src/index.js
index 56ab795b..32865158 100644
--- a/includes/blocks/um-password-reset/src/index.js
+++ b/includes/blocks/um-password-reset/src/index.js
@@ -1,19 +1 @@
-import { registerBlockType } from '@wordpress/blocks';
-import ServerSideRender from '@wordpress/server-side-render';
-import { useBlockProps } from '@wordpress/block-editor';
-
-registerBlockType('um-block/um-password-reset', {
- edit: function (props) {
- const blockProps = useBlockProps();
-
- return (
-
-
-
- );
-
- },
- save: function save(props) {
- return null;
- }
-});
+(()=>{"use strict";var e={n:o=>{var r=o&&o.__esModule?()=>o.default:()=>o;return e.d(r,{a:r}),r},d:(o,r)=>{for(var t in r)e.o(r,t)&&!e.o(o,t)&&Object.defineProperty(o,t,{enumerable:!0,get:r[t]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o)};const o=window.wp.blocks,r=window.wp.serverSideRender;var t=e.n(r);const n=window.wp.blockEditor,s=window.ReactJSXRuntime;(0,o.registerBlockType)("um-block/um-password-reset",{edit:function(){const e=(0,n.useBlockProps)();return(0,s.jsx)("div",{...e,children:(0,s.jsx)(t(),{block:"um-block/um-password-reset"})})},save:()=>null})})();
\ No newline at end of file
diff --git a/includes/class-config.php b/includes/class-config.php
index 5391f9c1..547e3772 100644
--- a/includes/class-config.php
+++ b/includes/class-config.php
@@ -732,6 +732,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'secure_notify_admins_banned_accounts__interval' => 'instant',
'secure_allowed_redirect_hosts' => '',
'delete_comments' => false,
+ 'enable_action_scheduler' => false,
);
add_filter( 'um_get_tabs_from_config', '__return_true' );
diff --git a/includes/class-init.php b/includes/class-init.php
index 471886dc..b498a084 100644
--- a/includes/class-init.php
+++ b/includes/class-init.php
@@ -1,4 +1,5 @@
maybe_action_scheduler();
+
$this->common()->includes();
+
$this->access();
if ( $this->is_request( 'ajax' ) ) {
@@ -1439,6 +1443,19 @@ if ( ! class_exists( 'UM' ) ) {
return $this->classes['multisite'];
}
+ /**
+ * Maybe include and init Action Scheduler.
+ *
+ * @since 2.9.0
+ *
+ * @return um\action_scheduler\Init
+ */
+ public function maybe_action_scheduler() {
+ if ( empty( $this->classes['action_scheduler'] ) ) {
+ $this->classes['action_scheduler'] = new um\action_scheduler\Init();
+ }
+ return $this->classes['action_scheduler'];
+ }
/**
* Include files with hooked filters/actions
diff --git a/includes/common/actions/class-emails.php b/includes/common/actions/class-emails.php
new file mode 100644
index 00000000..abb5def9
--- /dev/null
+++ b/includes/common/actions/class-emails.php
@@ -0,0 +1,38 @@
+mail()->send( $user_email, $template, $args );
+ }
+ }
+}
diff --git a/includes/common/class-init.php b/includes/common/class-init.php
index 63540a46..73cf4805 100644
--- a/includes/common/class-init.php
+++ b/includes/common/class-init.php
@@ -20,6 +20,8 @@ if ( ! class_exists( 'um\common\Init' ) ) {
* @used-by \UM::includes()
*/
public function includes() {
+ $this->actions();
+
$this->cpt()->hooks();
$this->screen();
$this->secure()->hooks();
@@ -28,6 +30,18 @@ if ( ! class_exists( 'um\common\Init' ) ) {
$this->users()->hooks();
}
+ /**
+ * Init actions that can be scheduled via Action Scheduler.
+ *
+ * @since 2.9.0
+ */
+ private function actions() {
+ if ( empty( UM()->classes['um\common\actions\emails'] ) ) {
+ UM()->classes['um\common\actions\emails'] = new actions\Emails();
+ }
+ // Other classes init here as soon as possible.
+ }
+
/**
* @since 2.6.8
*
diff --git a/includes/common/class-secure.php b/includes/common/class-secure.php
index 65396d7e..e23b0139 100644
--- a/includes/common/class-secure.php
+++ b/includes/common/class-secure.php
@@ -113,16 +113,19 @@ if ( ! class_exists( 'um\common\Secure' ) ) {
$emails = um_multi_admin_email();
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
- UM()->mail()->send(
- $email,
- 'suspicious-activity',
+ UM()->maybe_action_scheduler()->enqueue_async_action(
+ 'um_dispatch_email',
array(
- 'admin' => true,
- 'tags' => array(
- '{banned_profile_links}',
- ),
- 'tags_replace' => array(
- $banned_profile_links,
+ $email,
+ 'suspicious-activity',
+ array(
+ 'admin' => true,
+ 'tags' => array(
+ '{banned_profile_links}',
+ ),
+ 'tags_replace' => array(
+ $banned_profile_links,
+ ),
),
)
);
diff --git a/includes/common/class-users.php b/includes/common/class-users.php
index 9884efa8..57fdebc3 100644
--- a/includes/common/class-users.php
+++ b/includes/common/class-users.php
@@ -388,7 +388,7 @@ class Users {
add_filter( 'um_template_tags_patterns_hook', array( UM()->user(), 'add_activation_placeholder' ) );
add_filter( 'um_template_tags_replaces_hook', array( UM()->user(), 'add_activation_replace_placeholder' ) );
- UM()->mail()->send( $userdata->user_email, 'checkmail_email' );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $userdata->user_email, 'checkmail_email' ) );
um_fetch_user( $current_user_id );
/**
@@ -456,7 +456,7 @@ class Users {
$this->reset_activation_link( $user_id );
$userdata = get_userdata( $user_id );
- UM()->mail()->send( $userdata->user_email, 'inactive_email' );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $userdata->user_email, 'inactive_email' ) );
/**
* Fires after User has been deactivated.
@@ -528,7 +528,7 @@ class Users {
$this->reset_activation_link( $user_id );
$userdata = get_userdata( $user_id );
- UM()->mail()->send( $userdata->user_email, 'rejected_email' );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $userdata->user_email, 'rejected_email' ) );
/**
* Fires after User has been rejected.
@@ -606,7 +606,7 @@ class Users {
$this->reset_activation_link( $user_id );
$userdata = get_userdata( $user_id );
- UM()->mail()->send( $userdata->user_email, 'pending_email' );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $userdata->user_email, 'pending_email' ) );
/**
* Fires after User has been set as pending admin review.
@@ -697,7 +697,7 @@ class Users {
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ) );
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ) );
- UM()->mail()->send( $userdata->user_email, $email_slug );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $userdata->user_email, $email_slug ) );
um_fetch_user( $current_user_id );
/**
@@ -774,7 +774,7 @@ class Users {
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ) );
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ) );
- UM()->mail()->send( $userdata->user_email, 'welcome_email' );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $userdata->user_email, 'welcome_email' ) );
um_fetch_user( $current_user_id );
diff --git a/includes/core/class-ajax-common.php b/includes/core/class-ajax-common.php
index be2abe0d..9517db0a 100644
--- a/includes/core/class-ajax-common.php
+++ b/includes/core/class-ajax-common.php
@@ -49,13 +49,13 @@ if ( ! class_exists( 'um\core\AJAX_Common' ) ) {
add_action( 'wp_ajax_um_remove_file', array( UM()->files(), 'ajax_remove_file' ) );
add_action( 'wp_ajax_nopriv_um_remove_file', array( UM()->files(), 'ajax_remove_file' ) );
- add_action( 'wp_ajax_nopriv_um_fileupload', array( UM()->files(), 'ajax_file_upload' ) );
+ add_action( 'wp_ajax_nopriv_um_fileupload', array( UM()->files(), 'ajax_file_upload' ) ); // Enabled files uploading on registration form.
add_action( 'wp_ajax_um_fileupload', array( UM()->files(), 'ajax_file_upload' ) );
- add_action( 'wp_ajax_nopriv_um_imageupload', array( UM()->files(), 'ajax_image_upload' ) );
+ add_action( 'wp_ajax_nopriv_um_imageupload', array( UM()->files(), 'ajax_image_upload' ) ); // Enabled image uploading on registration form.
add_action( 'wp_ajax_um_imageupload', array( UM()->files(), 'ajax_image_upload' ) );
- add_action( 'wp_ajax_nopriv_um_resize_image', array( UM()->files(), 'ajax_resize_image' ) );
+ add_action( 'wp_ajax_nopriv_um_resize_image', array( UM()->files(), 'ajax_resize_image' ) ); // Enabled image resize on registration form.
add_action( 'wp_ajax_um_resize_image', array( UM()->files(), 'ajax_resize_image' ) );
add_action( 'wp_ajax_nopriv_um_get_members', array( UM()->member_directory(), 'ajax_get_members' ) );
diff --git a/includes/core/class-blocks.php b/includes/core/class-blocks.php
index 8e76e467..25b2cf9d 100644
--- a/includes/core/class-blocks.php
+++ b/includes/core/class-blocks.php
@@ -17,7 +17,7 @@ if ( ! class_exists( 'um\core\Blocks' ) ) {
* Blocks constructor.
*/
public function __construct() {
- add_action( 'init', array( &$this, 'block_editor_render' ) );
+ add_action( 'init', array( &$this, 'block_editor_render' ), 11 );
add_filter( 'block_type_metadata_settings', array( &$this, 'block_type_metadata_settings' ), 9999, 2 );
}
@@ -68,6 +68,7 @@ if ( ! class_exists( 'um\core\Blocks' ) ) {
* Register UM Blocks.
*
* @uses register_block_type_from_metadata()
+ * @uses wp_register_block_metadata_collection()
*/
public function block_editor_render() {
/**
@@ -99,6 +100,10 @@ if ( ! class_exists( 'um\core\Blocks' ) ) {
return;
}
+ if ( function_exists( 'wp_register_block_metadata_collection' ) ) {
+ wp_register_block_metadata_collection( UM_PATH . 'includes/blocks', UM_PATH . 'includes/blocks/blocks-manifest.php' );
+ }
+
$blocks = array(
'um-block/um-member-directories' => array(
'render_callback' => array( $this, 'member_directories_render' ),
diff --git a/includes/core/class-files.php b/includes/core/class-files.php
index 200849e5..00f7d16b 100644
--- a/includes/core/class-files.php
+++ b/includes/core/class-files.php
@@ -1,6 +1,8 @@
roles()->um_current_user_can( 'edit', $user_id ) ) {
+ wp_send_json_error( esc_js( __( 'You have no permission to edit this user', 'ultimate-member' ) ) );
+ }
- UM()->fields()->set_id = isset( $_POST['set_id'] ) ? absint( $_POST['set_id'] ) : null;
- UM()->fields()->set_mode = isset( $_POST['set_mode'] ) ? sanitize_text_field( $_POST['set_mode'] ) : null;
+ if ( $user_id && ! is_user_logged_in() ) {
+ wp_send_json_error( esc_js( __( 'Please login to edit this user', 'ultimate-member' ) ) );
+ }
- if ( 'register' !== UM()->fields()->set_mode && ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
- $ret['error'] = esc_js( __( 'You have no permission to edit this user', 'ultimate-member' ) );
- wp_send_json_error( $ret );
+ $form_id = isset( $_POST['set_id'] ) ? absint( $_POST['set_id'] ) : null;
+ $mode = isset( $_POST['set_mode'] ) ? sanitize_text_field( $_POST['set_mode'] ) : null;
+
+ UM()->fields()->set_id = $form_id;
+ UM()->fields()->set_mode = $mode;
+
+ if ( ! is_user_logged_in() && 'profile' === $mode ) {
+ wp_send_json_error( esc_js( __( 'You have no permission to edit user profile', 'ultimate-member' ) ) );
+ }
+
+ if ( null !== $user_id && 'register' === $mode ) {
+ wp_send_json_error( esc_js( __( 'User has to be empty on registration', 'ultimate-member' ) ) );
+ }
+
+ $form_post = get_post( $form_id );
+ // Invalid post ID. Maybe post doesn't exist.
+ if ( empty( $form_post ) ) {
+ wp_send_json_error( esc_js( __( 'Invalid form ID', 'ultimate-member' ) ) );
+ }
+
+ if ( 'um_form' !== $form_post->post_type ) {
+ wp_send_json_error( esc_js( __( 'Invalid form post type', 'ultimate-member' ) ) );
+ }
+
+ $form_status = get_post_status( $form_id );
+ if ( 'publish' !== $form_status ) {
+ wp_send_json_error( esc_js( __( 'Invalid form status', 'ultimate-member' ) ) );
+ }
+
+ $post_data = UM()->query()->post_data( $form_id );
+ if ( ! array_key_exists( 'mode', $post_data ) || $mode !== $post_data['mode'] ) {
+ wp_send_json_error( esc_js( __( 'Invalid form type', 'ultimate-member' ) ) );
+ }
+
+ // For profiles only.
+ if ( 'profile' === $mode && ! empty( $post_data['use_custom_settings'] ) && ! empty( $post_data['role'] ) ) {
+ // Option "Apply custom settings to this form". Option "Make this profile form role-specific".
+ // Show the first Profile Form with role selected, don't show profile forms below the page with other role-specific setting.
+ $current_user_roles = UM()->roles()->get_all_user_roles( $user_id );
+ if ( empty( $current_user_roles ) ) {
+ wp_send_json_error( esc_js( __( 'You have no permission to edit this user through this form', 'ultimate-member' ) ) );
+ }
+
+ if ( is_array( $post_data['role'] ) ) {
+ if ( ! count( array_intersect( $post_data['role'], $current_user_roles ) ) ) {
+ wp_send_json_error( esc_js( __( 'You have no permission to edit this user through this form', 'ultimate-member' ) ) );
+ }
+ } elseif ( ! in_array( $post_data['role'], $current_user_roles, true ) ) {
+ wp_send_json_error( esc_js( __( 'You have no permission to edit this user through this form', 'ultimate-member' ) ) );
+ }
+ }
+
+ $key = sanitize_text_field( $_REQUEST['key'] );
+
+ if ( ! array_key_exists( 'custom_fields', $post_data ) || empty( $post_data['custom_fields'] ) ) {
+ wp_send_json_error( esc_js( __( 'Invalid form fields', 'ultimate-member' ) ) );
+ }
+
+ $custom_fields = maybe_unserialize( $post_data['custom_fields'] );
+ if ( ! is_array( $custom_fields ) || ! array_key_exists( $key, $custom_fields ) ) {
+ if ( ! ( 'profile' === $mode && in_array( $key, array( 'cover_photo', 'profile_photo' ), true ) ) ) {
+ wp_send_json_error( esc_js( __( 'Invalid field metakey', 'ultimate-member' ) ) );
+ }
+ }
+
+ if ( empty( $custom_fields[ $key ]['crop'] ) && ! in_array( $key, array( 'cover_photo', 'profile_photo' ), true ) ) {
+ 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' ) ) );
}
$src = esc_url_raw( $_REQUEST['src'] );
@@ -340,6 +412,8 @@ if ( ! class_exists( 'um\core\Files' ) ) {
wp_send_json_error( esc_js( __( 'Invalid file ownership', 'ultimate-member' ) ) );
}
+ $coord = sanitize_text_field( $_REQUEST['coord'] );
+
UM()->uploader()->replace_upload_dir = true;
$output = UM()->uploader()->resize_image( $image_path, $src, $key, $user_id, $coord );
@@ -354,166 +428,309 @@ if ( ! class_exists( 'um\core\Files' ) ) {
/**
* Image upload by AJAX
*
- * @throws \Exception
+ * @throws Exception
*/
- function ajax_image_upload() {
+ public function ajax_image_upload() {
$ret['error'] = null;
- $ret = array();
-
- $id = sanitize_text_field( $_POST['key'] );
- $timestamp = absint( $_POST['timestamp'] );
- $nonce = sanitize_text_field( $_POST['_wpnonce'] );
- $user_id = empty( $_POST['user_id'] ) ? get_current_user_id() : absint( $_POST['user_id'] );
-
- UM()->fields()->set_id = absint( $_POST['set_id'] );
- UM()->fields()->set_mode = sanitize_key( $_POST['set_mode'] );
-
- if ( UM()->fields()->set_mode != 'register' && ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
- $ret['error'] = __( 'You have no permission to edit this user', 'ultimate-member' );
- wp_send_json_error( $ret );
- }
+ $ret = array();
/**
- * UM hook
+ * Filters image upload checking nonce.
*
- * @type filter
- * @title um_image_upload_nonce
- * @description Change Image Upload nonce
- * @input_vars
- * [{"var":"$nonce","type":"bool","desc":"Nonce"}]
- * @change_log
- * ["Since: 2.0"]
- * @usage
- *
- * @example
- * Disable checking nonce on image upload.
+ * function my_image_upload_nonce( $verify_nonce ) {
* // your code here
- * return $nonce;
+ * $verify_nonce = false;
+ * return $verify_nonce;
* }
- * ?>
+ * add_filter( 'um_image_upload_nonce', 'my_image_upload_nonce' );
*/
$um_image_upload_nonce = apply_filters( 'um_image_upload_nonce', true );
-
if ( $um_image_upload_nonce ) {
+ $timestamp = absint( $_POST['timestamp'] );
+ $nonce = sanitize_text_field( $_POST['_wpnonce'] );
if ( ! wp_verify_nonce( $nonce, "um_upload_nonce-{$timestamp}" ) && is_user_logged_in() ) {
// This nonce is not valid.
- $ret['error'] = __( 'Invalid nonce', 'ultimate-member' );
+ $ret['error'] = esc_html__( 'Invalid nonce', 'ultimate-member' );
wp_send_json_error( $ret );
}
}
+ $user_id = empty( $_POST['user_id'] ) ? null : absint( $_POST['user_id'] );
+ if ( $user_id && is_user_logged_in() && ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ if ( $user_id && ! is_user_logged_in() ) {
+ $ret['error'] = esc_html__( 'Please login to edit this user', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ $form_id = absint( $_POST['set_id'] );
+ $mode = sanitize_key( $_POST['set_mode'] );
+
+ UM()->fields()->set_id = $form_id;
+ UM()->fields()->set_mode = $mode;
+
+ if ( ! is_user_logged_in() && 'profile' === $mode ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit user profile', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ if ( null !== $user_id && 'register' === $mode ) {
+ $ret['error'] = esc_html__( 'User has to be empty on registration', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ $form_post = get_post( $form_id );
+ // Invalid post ID. Maybe post doesn't exist.
+ if ( empty( $form_post ) ) {
+ $ret['error'] = esc_html__( 'Invalid form ID', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ if ( 'um_form' !== $form_post->post_type ) {
+ $ret['error'] = esc_html__( 'Invalid form post type', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ $form_status = get_post_status( $form_id );
+ if ( 'publish' !== $form_status ) {
+ $ret['error'] = esc_html__( 'Invalid form status', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ $post_data = UM()->query()->post_data( $form_id );
+ if ( ! array_key_exists( 'mode', $post_data ) || $mode !== $post_data['mode'] ) {
+ $ret['error'] = esc_html__( 'Invalid form type', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ // For profiles only.
+ if ( 'profile' === $mode && ! empty( $post_data['use_custom_settings'] ) && ! empty( $post_data['role'] ) ) {
+ // Option "Apply custom settings to this form". Option "Make this profile form role-specific".
+ // Show the first Profile Form with role selected, don't show profile forms below the page with other role-specific setting.
+ $current_user_roles = UM()->roles()->get_all_user_roles( $user_id );
+ if ( empty( $current_user_roles ) ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user through this form', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ if ( is_array( $post_data['role'] ) ) {
+ if ( ! count( array_intersect( $post_data['role'], $current_user_roles ) ) ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user through this form', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+ } elseif ( ! in_array( $post_data['role'], $current_user_roles, true ) ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user through this form', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+ }
+
+ $id = sanitize_text_field( $_POST['key'] );
+
+ if ( ! array_key_exists( 'custom_fields', $post_data ) || empty( $post_data['custom_fields'] ) ) {
+ $ret['error'] = esc_html__( 'Invalid form fields', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ $custom_fields = maybe_unserialize( $post_data['custom_fields'] );
+ if ( ! is_array( $custom_fields ) || ! array_key_exists( $id, $custom_fields ) ) {
+ if ( ! ( 'profile' === $mode && in_array( $id, array( 'cover_photo', 'profile_photo' ), true ) ) ) {
+ $ret['error'] = esc_html__( 'Invalid field metakey', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+ }
+
+ 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 ( isset( $_FILES[ $id ]['name'] ) ) {
-
if ( ! is_array( $_FILES[ $id ]['name'] ) ) {
-
UM()->uploader()->replace_upload_dir = true;
+
$uploaded = UM()->uploader()->upload_image( $_FILES[ $id ], $user_id, $id );
+
UM()->uploader()->replace_upload_dir = false;
+
if ( isset( $uploaded['error'] ) ) {
$ret['error'] = $uploaded['error'];
} else {
$ret[] = $uploaded['handle_upload'];
}
-
}
-
} else {
- $ret['error'] = __( 'A theme or plugin compatibility issue', 'ultimate-member' );
+ $ret['error'] = esc_html__( 'A theme or plugin compatibility issue', 'ultimate-member' );
}
+
wp_send_json_success( $ret );
}
-
/**
* File upload by AJAX
+ *
+ * @throws Exception
*/
- function ajax_file_upload() {
+ public function ajax_file_upload() {
$ret['error'] = null;
- $ret = array();
-
- /* commented for enable download files on registration form
- * if ( ! is_user_logged_in() ) {
- $ret['error'] = 'Invalid user';
- die( json_encode( $ret ) );
- }*/
-
- $nonce = sanitize_text_field( $_POST['_wpnonce'] );
- $id = sanitize_text_field( $_POST['key'] );
- $timestamp = absint( $_POST['timestamp'] );
-
- UM()->fields()->set_id = absint( $_POST['set_id'] );
- UM()->fields()->set_mode = sanitize_key( $_POST['set_mode'] );
+ $ret = array();
/**
- * UM hook
+ * Filters file upload checking nonce.
*
- * @type filter
- * @title um_file_upload_nonce
- * @description Change File Upload nonce
- * @input_vars
- * [{"var":"$nonce","type":"bool","desc":"Nonce"}]
- * @change_log
- * ["Since: 2.0"]
- * @usage
- *
- * @example
- * Disable checking nonce on file upload.
+ * function my_file_upload_nonce( $verify_nonce ) {
* // your code here
- * return $nonce;
+ * $verify_nonce = false;
+ * return $verify_nonce;
* }
- * ?>
+ * add_filter( 'um_file_upload_nonce', 'my_file_upload_nonce' );
*/
- $um_file_upload_nonce = apply_filters("um_file_upload_nonce", true );
+ $um_file_upload_nonce = apply_filters( 'um_file_upload_nonce', true );
+ if ( $um_file_upload_nonce ) {
+ $nonce = sanitize_text_field( $_POST['_wpnonce'] );
+ $timestamp = absint( $_POST['timestamp'] );
- if ( $um_file_upload_nonce ) {
- if ( ! wp_verify_nonce( $nonce, 'um_upload_nonce-'.$timestamp ) && is_user_logged_in() ) {
+ if ( ! wp_verify_nonce( $nonce, 'um_upload_nonce-' . $timestamp ) && is_user_logged_in() ) {
// This nonce is not valid.
- $ret['error'] = 'Invalid nonce';
+ $ret['error'] = esc_html__( 'Invalid nonce', 'ultimate-member' );
wp_send_json_error( $ret );
-
}
}
+ $user_id = empty( $_POST['user_id'] ) ? null : absint( $_POST['user_id'] );
+ if ( $user_id && is_user_logged_in() && ! UM()->roles()->um_current_user_can( 'edit', $user_id ) ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
- if( isset( $_FILES[ $id ]['name'] ) ) {
+ if ( $user_id && ! is_user_logged_in() ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
- if ( ! is_array( $_FILES[ $id ]['name'] ) ) {
+ $form_id = absint( $_POST['set_id'] );
+ $mode = sanitize_key( $_POST['set_mode'] );
- $user_id = absint( $_POST['user_id'] );
+ UM()->fields()->set_id = $form_id;
+ UM()->fields()->set_mode = $mode;
- UM()->uploader()->replace_upload_dir = true;
- $uploaded = UM()->uploader()->upload_file( $_FILES[ $id ], $user_id, $id );
- UM()->uploader()->replace_upload_dir = false;
- if ( isset( $uploaded['error'] ) ){
+ if ( ! is_user_logged_in() && 'profile' === $mode ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
- $ret['error'] = $uploaded['error'];
+ if ( null !== $user_id && 'register' === $mode ) {
+ $ret['error'] = esc_html__( 'User has to be empty on registration', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
- } else {
+ $form_post = get_post( $form_id );
+ // Invalid post ID. Maybe post doesn't exist.
+ if ( empty( $form_post ) ) {
+ $ret['error'] = esc_html__( 'Invalid form ID', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
- $uploaded_file = $uploaded['handle_upload'];
- $ret['url'] = $uploaded_file['file_info']['name'];
- $ret['icon'] = UM()->files()->get_fonticon_by_ext( $uploaded_file['file_info']['ext'] );
- $ret['icon_bg'] = UM()->files()->get_fonticon_bg_by_ext( $uploaded_file['file_info']['ext'] );
- $ret['filename'] = $uploaded_file['file_info']['basename'];
- $ret['original_name'] = $uploaded_file['file_info']['original_name'];
+ if ( 'um_form' !== $form_post->post_type ) {
+ $ret['error'] = esc_html__( 'Invalid form post type', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+ $form_status = get_post_status( $form_id );
+ if ( 'publish' !== $form_status ) {
+ $ret['error'] = esc_html__( 'Invalid form status', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ $post_data = UM()->query()->post_data( $form_id );
+ if ( ! array_key_exists( 'mode', $post_data ) || $mode !== $post_data['mode'] ) {
+ $ret['error'] = esc_html__( 'Invalid form type', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ // For profiles only.
+ if ( 'profile' === $mode && ! empty( $post_data['use_custom_settings'] ) && ! empty( $post_data['role'] ) ) {
+ // Option "Apply custom settings to this form". Option "Make this profile form role-specific".
+ // Show the first Profile Form with role selected, don't show profile forms below the page with other role-specific setting.
+ $current_user_roles = UM()->roles()->get_all_user_roles( $user_id );
+ if ( empty( $current_user_roles ) ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user through this form', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ if ( is_array( $post_data['role'] ) ) {
+ if ( ! count( array_intersect( $post_data['role'], $current_user_roles ) ) ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user through this form', 'ultimate-member' );
+ wp_send_json_error( $ret );
}
-
+ } elseif ( ! in_array( $post_data['role'], $current_user_roles, true ) ) {
+ $ret['error'] = esc_html__( 'You have no permission to edit this user through this form', 'ultimate-member' );
+ wp_send_json_error( $ret );
}
-
- } else {
- $ret['error'] = __('A theme or plugin compatibility issue','ultimate-member');
}
+ $id = sanitize_text_field( $_POST['key'] );
+
+ if ( ! array_key_exists( 'custom_fields', $post_data ) || empty( $post_data['custom_fields'] ) ) {
+ $ret['error'] = esc_html__( 'Invalid form fields', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ $custom_fields = maybe_unserialize( $post_data['custom_fields'] );
+ if ( ! is_array( $custom_fields ) || ! array_key_exists( $id, $custom_fields ) ) {
+ $ret['error'] = esc_html__( 'Invalid field metakey', 'ultimate-member' );
+ wp_send_json_error( $ret );
+ }
+
+ 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 ( isset( $_FILES[ $id ]['name'] ) ) {
+ if ( ! is_array( $_FILES[ $id ]['name'] ) ) {
+ UM()->uploader()->replace_upload_dir = true;
+
+ $uploaded = UM()->uploader()->upload_file( $_FILES[ $id ], $user_id, $id );
+
+ UM()->uploader()->replace_upload_dir = false;
+
+ if ( isset( $uploaded['error'] ) ) {
+ $ret['error'] = $uploaded['error'];
+ } else {
+ $uploaded_file = $uploaded['handle_upload'];
+ $ret['url'] = $uploaded_file['file_info']['name'];
+ $ret['icon'] = UM()->files()->get_fonticon_by_ext( $uploaded_file['file_info']['ext'] );
+ $ret['icon_bg'] = UM()->files()->get_fonticon_bg_by_ext( $uploaded_file['file_info']['ext'] );
+ $ret['filename'] = $uploaded_file['file_info']['basename'];
+ $ret['original_name'] = $uploaded_file['file_info']['original_name'];
+ }
+ }
+ } else {
+ $ret['error'] = esc_html__( 'A theme or plugin compatibility issue', 'ultimate-member' );
+ }
wp_send_json_success( $ret );
}
-
/**
* Allowed image types
*
diff --git a/includes/core/class-form.php b/includes/core/class-form.php
index fc2341b5..ad692d84 100644
--- a/includes/core/class-form.php
+++ b/includes/core/class-form.php
@@ -818,11 +818,6 @@ if ( ! class_exists( 'um\core\Form' ) ) {
case 'textarea':
if ( ! empty( $field['html'] ) || ( UM()->profile()->get_show_bio_key( $form ) === $k && UM()->options()->get( 'profile_show_html_bio' ) ) ) {
$form[ $k ] = html_entity_decode( $form[ $k ] ); // required because WP_Editor send sometimes encoded content.
- preg_match( '/^(.*?)<\/p>$/', $form[ $k ], $match ); // required because WP_Editor send content wrapped to
- if ( ! empty( $match[1] ) ) {
- $form[ $k ] = $match[1];
- }
-
$form[ $k ] = self::maybe_apply_tidy( $form[ $k ], $field );
$allowed_html = UM()->get_allowed_html( 'templates' );
@@ -963,11 +958,6 @@ if ( ! class_exists( 'um\core\Form' ) ) {
$field_exists = true;
if ( ! empty( $custom_fields[ $description_key ]['html'] ) && $bio_html ) {
$form[ $description_key ] = html_entity_decode( $form[ $description_key ] ); // required because WP_Editor send sometimes encoded content.
- preg_match( '/^(.*?)<\/p>$/', $form[ $description_key ], $match ); // required because WP_Editor send content wrapped to
- if ( ! empty( $match[1] ) ) {
- $form[ $description_key ] = $match[1];
- }
-
$form[ $description_key ] = self::maybe_apply_tidy( $form[ $description_key ], $custom_fields[ $description_key ] );
$allowed_html = UM()->get_allowed_html( 'templates' );
diff --git a/includes/core/class-plugin-updater.php b/includes/core/class-plugin-updater.php
index 5945d673..a4082b76 100644
--- a/includes/core/class-plugin-updater.php
+++ b/includes/core/class-plugin-updater.php
@@ -250,7 +250,7 @@ if ( ! class_exists( 'um\core\Plugin_Updater' ) ) {
return;
}
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
$api_params = array(
'edd_action' => 'check_licenses',
diff --git a/includes/core/class-uploader.php b/includes/core/class-uploader.php
index 9ef60e96..01d695da 100644
--- a/includes/core/class-uploader.php
+++ b/includes/core/class-uploader.php
@@ -3,6 +3,8 @@ namespace um\core;
// Exit if accessed directly
+use Exception;
+
if ( ! defined( 'ABSPATH' ) ) exit;
@@ -300,13 +302,13 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
* @since 2.0.22
*
* @return array
- * @throws \Exception
+ * @throws Exception
*/
public function upload_image( $uploadedfile, $user_id = null, $field_key = '', $upload_type = 'stream_photo' ) {
$response = array();
if ( ! function_exists( 'wp_handle_upload' ) ) {
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
+ require_once ABSPATH . 'wp-admin/includes/file.php';
}
if ( empty( $field_key ) ) {
@@ -323,7 +325,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$this->user_id = $user_id;
}
- if ( in_array( $field_key, array( 'profile_photo', 'cover_photo' ) ) ) {
+ if ( in_array( $field_key, array( 'profile_photo', 'cover_photo' ), true ) ) {
$this->upload_image_type = $field_key;
}
@@ -510,19 +512,20 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
/**
* Upload Files
*
+ * @since 2.0.22
+ *
* @param $uploadedfile
* @param int|null $user_id
* @param string $field_key
*
- * @since 2.0.22
- *
* @return array
+ * @throws Exception
*/
public function upload_file( $uploadedfile, $user_id = null, $field_key = '' ) {
$response = array();
if ( ! function_exists( 'wp_handle_upload' ) ) {
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
+ require_once ABSPATH . 'wp-admin/includes/file.php';
}
$this->field_key = $field_key;
@@ -535,19 +538,19 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$field_data = UM()->fields()->get_field( $field_key );
- $field_allowed_file_types = explode(",", $field_data['allowed_types'] );
+ $field_allowed_file_types = explode( ',', $field_data['allowed_types'] );
$allowed_file_mimes = array();
foreach ( $field_allowed_file_types as $a ) {
- $atype = wp_check_filetype( "test.{$a}" );
+ $atype = wp_check_filetype( "test.{$a}" );
$allowed_file_mimes[ $atype['ext'] ] = $atype['type'];
}
$upload_overrides = array(
- 'test_form' => false,
- 'mimes' => apply_filters( 'um_uploader_allowed_file_mimes', $allowed_file_mimes ),
- 'unique_filename_callback' => array( $this, 'unique_filename' ),
+ 'test_form' => false,
+ 'mimes' => apply_filters( 'um_uploader_allowed_file_mimes', $allowed_file_mimes ),
+ 'unique_filename_callback' => array( $this, 'unique_filename' ),
);
$upload_overrides = apply_filters( "um_file_upload_handler_overrides__{$field_key}", $upload_overrides );
@@ -556,9 +559,9 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
if ( isset( $movefile['error'] ) ) {
/*
- * Error generated by _wp_handle_upload()
- * @see _wp_handle_upload() in wp-admin/includes/file.php
- */
+ * Error generated by _wp_handle_upload()
+ * @see _wp_handle_upload() in wp-admin/includes/file.php
+ */
$response['error'] = $movefile['error'];
} else {
@@ -574,7 +577,6 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$movefile['file_info']['size'] = filesize( $movefile['file'] );
$movefile['file_info']['size_format'] = size_format( $movefile['file_info']['size'] );
-
/**
* UM hook
*
@@ -690,7 +692,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$error = null;
if ( ! function_exists( 'wp_get_image_editor' ) ) {
- require_once( ABSPATH . 'wp-admin/includes/media.php' );
+ require_once ABSPATH . 'wp-admin/includes/media.php';
}
$image = wp_get_image_editor( $file );
@@ -814,7 +816,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
$error = null;
if ( ! function_exists( 'wp_get_image_editor' ) ) {
- require_once( ABSPATH . 'wp-admin/includes/media.php' );
+ require_once ABSPATH . 'wp-admin/includes/media.php';
}
$file_type = wp_check_filetype( $file );
diff --git a/includes/core/class-user.php b/includes/core/class-user.php
index fae9ccf3..0a7a3f69 100644
--- a/includes/core/class-user.php
+++ b/includes/core/class-user.php
@@ -622,12 +622,15 @@ if ( ! class_exists( 'um\core\User' ) ) {
// send email notifications
if ( $this->send_mail_on_delete ) {
- UM()->mail()->send( um_user( 'user_email' ), 'deletion_email' );
+ $user_email = um_user( 'user_email' );
+ $template = 'deletion_email';
+
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $user_email, $template ) );
$emails = um_multi_admin_email();
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
- UM()->mail()->send( $email, 'notification_deletion', array( 'admin' => true ) );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $email, 'notification_deletion', array( 'admin' => true ) ) );
}
}
}
@@ -1517,7 +1520,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
add_filter( 'um_template_tags_patterns_hook', array( UM()->password(), 'add_placeholder' ), 10, 1 );
add_filter( 'um_template_tags_replaces_hook', array( UM()->password(), 'add_replace_placeholder' ), 10, 1 );
- UM()->mail()->send( $userdata->user_email, 'resetpw_email' );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $userdata->user_email, 'resetpw_email' ) );
}
@@ -1531,7 +1534,7 @@ if ( ! class_exists( 'um\core\User' ) ) {
um_fetch_user( $user_id );
}
- UM()->mail()->send( um_user( 'user_email' ), 'changedpw_email' );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( um_user( 'user_email' ), 'changedpw_email' ) );
if ( ! empty( $user_id ) ) {
um_reset_user();
diff --git a/includes/core/um-actions-account.php b/includes/core/um-actions-account.php
index eb7fcc8d..8d442810 100644
--- a/includes/core/um-actions-account.php
+++ b/includes/core/um-actions-account.php
@@ -593,7 +593,7 @@ function um_account_updated_notification( $user_id, $changed ) {
if ( 'password' !== $_POST['_um_account_tab'] || ! UM()->options()->get( 'changedpw_email_on' ) ) {
// Avoid email duplicates (account changed and password changed) on the password change tab.
um_fetch_user( $user_id );
- UM()->mail()->send( um_user( 'user_email' ), 'changedaccount_email' );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( um_user( 'user_email' ), 'changedaccount_email' ) );
}
// phpcs:enable WordPress.Security.NonceVerification
}
diff --git a/includes/core/um-actions-register.php b/includes/core/um-actions-register.php
index 74bcf169..65a931ab 100644
--- a/includes/core/um-actions-register.php
+++ b/includes/core/um-actions-register.php
@@ -120,9 +120,9 @@ function um_send_registration_notification( $user_id ) {
if ( ! empty( $emails ) ) {
foreach ( $emails as $email ) {
if ( 'pending' !== $registration_status ) {
- UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $email, 'notification_new_user', array( 'admin' => true ) ) );
} else {
- UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
+ UM()->maybe_action_scheduler()->enqueue_async_action( 'um_dispatch_email', array( $email, 'notification_review', array( 'admin' => true ) ) );
}
}
}
diff --git a/package.json b/package.json
index d08fe57d..a7c73a87 100644
--- a/package.json
+++ b/package.json
@@ -23,11 +23,9 @@
"scripts": {
"build:docs": "rm -rf docs/hooks/ && jsdoc -c hookdoc-conf.json",
"build": "npm-run-all build:*",
- "build:all-blocks": "npm-run-all --parallel build-block-*",
- "build-block-um-member-directories": "cd includes/blocks/um-member-directories && wp-scripts build src/index.js",
- "build-block-um-forms": "cd includes/blocks/um-forms && wp-scripts build src/index.js",
- "build-block-um-password-reset": "cd includes/blocks/um-password-reset && wp-scripts build src/index.js",
- "build-block-um-account": "cd includes/blocks/um-account && wp-scripts build src/index.js"
+ "build-blocks": "wp-scripts build --webpack-src-dir=blocks-src --output-path=includes/blocks",
+ "build-manifest": "wp-scripts build-blocks-manifest --input=includes/blocks --output=includes/blocks/blocks-manifest.php",
+ "build:all-blocks": "npm-run-all build-blocks build-manifest"
},
"engines": {
"node": ">= 0.10.0"
@@ -43,12 +41,12 @@
"jsdoc": "~4.0.2",
"wp-hookdoc": "^0.2.0",
"npm-run-all": "^4.1.5",
- "@wordpress/block-editor": "^11.5.0",
- "@wordpress/blocks": "^12.5.0",
- "@wordpress/components": "^23.5.0",
- "@wordpress/i18n": "^4.28.0",
- "@wordpress/scripts": "^25.5.1",
- "@wordpress/server-side-render": "^4.5.0"
+ "@wordpress/block-editor": "^14.5.0",
+ "@wordpress/blocks": "^13.10.0",
+ "@wordpress/components": "^28.10.0",
+ "@wordpress/i18n": "^5.10.0",
+ "@wordpress/scripts": "^30.3.0",
+ "@wordpress/server-side-render": "^5.10.0"
},
"dependencies": {
"react": "^18.2.0",
diff --git a/phpcs.xml b/phpcs.xml
index 7e29e70d..76067eb6 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -15,6 +15,8 @@
node_modules/*
documentor/*
\.idea/*
+ includes/blocks/*
+ blocks-src/*
diff --git a/readme.txt b/readme.txt
index 9c07f8f2..0e3811d0 100644
--- a/readme.txt
+++ b/readme.txt
@@ -5,8 +5,8 @@ Contributors: ultimatemember, champsupertramp, nsinelnikov
Tags: community, member, membership, user-profile, user-registration
Requires PHP: 5.6
Requires at least: 5.5
-Tested up to: 6.6
-Stable tag: 2.8.9
+Tested up to: 6.7
+Stable tag: 2.9.0
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -166,6 +166,22 @@ No specific extensions are needed. But we highly recommended keep active these P
IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSION 2.6.7 PATCHES SECURITY PRIVILEGE ESCALATION VULNERABILITY. PLEASE SEE [THIS ARTICLE](https://docs.ultimatemember.com/article/1866-security-incident-update-and-recommended-actions) FOR MORE INFORMATION
+= 2.9.0 2024-11-12 =
+
+**Enhancements**
+
+* Added: Action Scheduler (version 3.8.1) for email sending. More info is [here](https://actionscheduler.org/).
+* Added: Supporting new `wp_register_block_metadata_collection()` function for registering WP Blocks
+
+**Bugfixes**
+
+* Fixed: `ajax_image_upload()` and `ajax_resize_image()` handlers vulnerability. CVE ID: CVE-2024-10528
+* Fixed: Disabling user status column wp-admin > Users screen
+* Fixed: User status filter on wp-admin > Users on mobile devices
+* Fixed: Extra unwrapping of the WP Editor field's value
+
+**Cached and optimized/minified assets(JS/CSS) must be flushed/re-generated after upgrade**
+
= 2.8.9 2024-10-14 =
**Enhancements**
@@ -456,6 +472,9 @@ IMPORTANT: PLEASE UPDATE THE PLUGIN TO AT LEAST VERSION 2.6.7 IMMEDIATELY. VERSI
== Upgrade Notice ==
+= 2.9.0 =
+This version fixes a security related bug. Upgrade immediately.
+
= 2.8.7 =
This version fixes a security related bug. Upgrade immediately.
diff --git a/ultimate-member.php b/ultimate-member.php
index c18c607b..6369eb11 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.8.9
+ * Version: 2.9.0
* Author: Ultimate Member
* Author URI: http://ultimatemember.com/
* Text Domain: ultimate-member
@@ -17,7 +17,7 @@
defined( 'ABSPATH' ) || exit;
require_once ABSPATH . 'wp-admin/includes/plugin.php';
-$plugin_data = get_plugin_data( __FILE__ );
+$plugin_data = get_plugin_data( __FILE__, true, false );
// phpcs:disable Generic.NamingConventions.UpperCaseConstantName
define( 'um_url', plugin_dir_url( __FILE__ ) );