Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/essential-addons-for-elementor-lite/essential_adons_elementor.php
+++ b/essential-addons-for-elementor-lite/essential_adons_elementor.php
@@ -4,7 +4,7 @@
* Description: The Essential plugin you install after Elementor! Packed with 100+ stunning elements like Data Table, Event Calendar, Filterable Gallery, WooCommerce.
* Plugin URI: https://essential-addons.com/
* Author: WPDeveloper
- * Version: 6.8.9
+ * Version: 6.8.10
* Author URI: https://wpdeveloper.com/
* Text Domain: essential-addons-for-elementor-lite
* Domain Path: /languages
@@ -12,8 +12,8 @@
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*
* WC tested up to: 10.8
- * Elementor tested up to: 4.1
- * Elementor Pro tested up to: 4.1
+ * Elementor tested up to: 4.4
+ * Elementor Pro tested up to: 4.4
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -29,7 +29,7 @@
define( 'EAEL_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'EAEL_PLUGIN_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) );
define( 'EAEL_PLUGIN_URL', trailingslashit( plugins_url( '/', __FILE__ ) ) );
-define( 'EAEL_PLUGIN_VERSION', '6.8.9' );
+define( 'EAEL_PLUGIN_VERSION', '6.8.10' );
// The dashboard renders tabs other plugins add through eael/admin/dashboard/menu.
define( 'EAEL_DASHBOARD_PANELS', true );
define( 'EAEL_ASSET_PATH', wp_upload_dir()['basedir'] . '/essential-addons-elementor' );
--- a/essential-addons-for-elementor-lite/includes/Classes/Asset_Builder.php
+++ b/essential-addons-for-elementor-lite/includes/Classes/Asset_Builder.php
@@ -28,6 +28,14 @@
protected $custom_js = '';
/**
+ * How many bytes of $custom_js have already been handed to the eael-general
+ * handle by enqueue_inline_js(); the rest is printed the legacy way.
+ *
+ * @var int
+ */
+ protected $inline_js_offset = 0;
+
+ /**
* @var string
*/
protected $css_strings = '';
@@ -103,6 +111,7 @@
* Load Hook
*/
protected function init_hook() {
+ add_action( 'wp_footer', [ $this, 'enqueue_inline_js' ], 9 );
add_action( 'wp_footer', [ $this, 'add_inline_js' ], 100 );
add_action( 'wp_footer', [ $this, 'add_inline_css' ], 15 );
add_action( 'after_delete_post', [ $this, 'delete_cache_data' ] );
@@ -278,19 +287,65 @@
}
/**
+ * enqueue_inline_js
+ * Hand the combined "Internal" JS to the jQuery-dependent eael-general handle.
+ */
+ public function enqueue_inline_js() {
+ // Front end only: the editor preview iframe keeps the self-contained print below,
+ // and nothing to attach means nothing to do.
+ if ( $this->is_edit_mode() || ! $this->custom_js ) {
+ return;
+ }
+
+ // Attach the combined "Internal" JS to the already-enqueued, jQuery-dependent
+ // `eael-general` handle instead of echoing a raw <script> with no declared
+ // dependency. WordPress then prints it after jQuery, and JS delay/optimization
+ // plugins (e.g. WP Rocket "Delay JavaScript Execution") keep the two together
+ // rather than letting the blob run before jQuery exists and throw
+ // "jQuery is not defined", which silently breaks every widget later in the blob
+ // (#1038). Runs at wp_footer:9, before footer scripts print at :20.
+ if ( ! wp_script_is( 'eael-general', 'enqueued' ) || wp_script_is( 'eael-general', 'done' ) ) {
+ return;
+ }
+
+ wp_add_inline_script( 'eael-general', $this->custom_js, 'after' );
+ $this->inline_js_offset = strlen( $this->custom_js );
+ }
+
+ /**
* add_inline_js
* Load inline js data
*/
public function add_inline_js() {
- if ( $this->is_edit_mode() || $this->is_preview_mode() ) {
- if ( $this->custom_js ) {
+ if ( ! $this->custom_js ) {
+ return;
+ }
- // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- printf( '<script>%1$s</script>', 'var localize =' . wp_json_encode( $this->localize_objects ) );
- // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- printf( '<script id="eael-inline-js">%s</script>', $this->custom_js );
- }
+ // Editor preview iframe (?elementor-preview): no optimization plugins run there,
+ // so keep the original self-contained inline print, including its own localize
+ // object (the front end already localizes `eael-general`).
+ if ( $this->is_edit_mode() ) {
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ printf( '<script>%1$s</script>', 'var localize =' . wp_json_encode( $this->localize_objects ) );
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ printf( '<script id="eael-inline-js">%s</script>', $this->custom_js );
+ return;
+ }
+
+ if ( ! $this->is_preview_mode() ) {
+ return;
+ }
+
+ // Front end: enqueue_inline_js() already handed everything accumulated up to
+ // wp_footer:9 to the eael-general handle. Print only whatever arrived afterwards
+ // (rare — e.g. a Theme Builder footer rendered later) the legacy way so those
+ // late widgets keep working.
+ $remainder = (string) substr( $this->custom_js, $this->inline_js_offset );
+
+ if ( '' !== $remainder ) {
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ printf( '<script id="eael-inline-js">%s</script>', $remainder );
}
}
--- a/essential-addons-for-elementor-lite/includes/Classes/Helper.php
+++ b/essential-addons-for-elementor-lite/includes/Classes/Helper.php
@@ -1087,6 +1087,30 @@
return $options;
}
+ /**
+ * Point the Post Grid "Terms From" setting at the taxonomy the selected source uses.
+ *
+ * A custom post type keeps its taxonomy in its own `eael_cve_proof_terms` control,
+ * and products use product_cat / product_tag. The first render and Load More both
+ * run this, so the cards Load More adds show the same terms as the first ones.
+ *
+ * @param array $settings Post Grid widget settings.
+ *
+ * @return array
+ */
+ public static function eael_post_grid_terms_settings( $settings ) {
+ $post_type = isset( $settings['post_type'] ) ? $settings['post_type'] : '';
+
+ if ( ! in_array( $post_type, [ 'post', 'page', 'product', 'by_id', 'source_dynamic' ] ) ) {
+ $settings['eael_post_terms'] = empty( $settings["eael_{$post_type}_terms"] ) ? '' : $settings["eael_{$post_type}_terms"];
+ } elseif ( 'product' === $post_type ) {
+ $terms_from = isset( $settings['eael_post_terms'] ) ? $settings['eael_post_terms'] : '';
+ $settings['eael_post_terms'] = 'category' === $terms_from ? 'product_cat' : ( 'tags' === $terms_from ? 'product_tag' : $terms_from );
+ }
+
+ return $settings;
+ }
+
public static function get_terms_as_list($term_type = 'category', $length = 1)
{
$terms = get_the_terms( get_the_ID(), $term_type );
--- a/essential-addons-for-elementor-lite/includes/Elements/Post_Grid.php
+++ b/essential-addons-for-elementor-lite/includes/Elements/Post_Grid.php
@@ -1780,11 +1780,7 @@
$args = HelperClass::get_query_args($settings);
$args = HelperClass::get_dynamic_args($settings, $args);
- if ( ! in_array( $settings['post_type'], [ 'post', 'page', 'product', 'by_id', 'source_dynamic' ] ) ) {
- $settings['eael_post_terms'] = empty( $settings["eael_{$settings['post_type']}_terms"] ) ? '' : $settings["eael_{$settings['post_type']}_terms"];
- } elseif ( $settings['post_type'] === 'product' ) {
- $settings['eael_post_terms'] = $settings['eael_post_terms'] === 'category' ? 'product_cat' : ( $settings['eael_post_terms'] === 'tags' ? 'product_tag' : $settings['eael_post_terms'] );
- }
+ $settings = HelperClass::eael_post_grid_terms_settings( $settings );
$link_settings = [
'image_link_nofollow' => $settings['image_link_nofollow'] ? 'rel="nofollow"' : '',
--- a/essential-addons-for-elementor-lite/includes/MegaMenu/Manager.php
+++ b/essential-addons-for-elementor-lite/includes/MegaMenu/Manager.php
@@ -200,10 +200,6 @@
public function ajax_template_preview() {
check_ajax_referer( 'essential-addons-elementor', 'security' );
- if ( ! current_user_can( 'edit_posts' ) ) {
- wp_send_json_error( [ 'message' => esc_html__( 'You are not allowed to preview templates.', 'essential-addons-for-elementor-lite' ) ], 403 );
- }
-
// The action is registered on every request — Bootstrap boots this feature
// without checking Elementor, and it cannot: `plugins_loaded` runs before
// `elementor/loaded`. So the dependency is asserted here instead, where it
@@ -225,6 +221,15 @@
// WPML compatibility, mirroring Frontend_Renderer::render_template_panel().
$template_id = apply_filters( 'wpml_object_id', $template_id, 'elementor_library', true ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
+ // Per-object capability check: the primitive `edit_posts` only asks whether the user
+ // can edit posts at all, not whether they may edit *this* template. Without the meta
+ // capability, any Contributor+ could preview the full HTML of a published template they
+ // neither own nor can access. `edit_post` enforces the same per-template rule WordPress
+ // uses for editing. (The Theme_Builder admin AJAX handlers already use this form.)
+ if ( ! current_user_can( 'edit_post', $template_id ) ) {
+ wp_send_json_error( [ 'message' => esc_html__( 'You are not allowed to preview templates.', 'essential-addons-for-elementor-lite' ) ], 403 );
+ }
+
if ( ! Helper::is_elementor_publish_template( $template_id ) ) {
wp_send_json_error( [ 'message' => esc_html__( 'Template not found.', 'essential-addons-for-elementor-lite' ) ], 404 );
}
--- a/essential-addons-for-elementor-lite/includes/Traits/Ajax_Handler.php
+++ b/essential-addons-for-elementor-lite/includes/Traits/Ajax_Handler.php
@@ -216,6 +216,9 @@
}
if ( $class == 'Essential_Addons_ElementorElementsPost_Grid' ) {
+ // Same "Terms From" mapping as Post_Grid::render(), so Load More cards show the same terms.
+ $settings = HelperClass::eael_post_grid_terms_settings( $settings );
+
$eael_lang_suffix = HelperClass::eael_lang_suffix( $page_id );
$settings['read_more_button_text'] = get_transient( 'eael_post_grid_read_more_button_text_' . $widget_id . $eael_lang_suffix );
$settings['excerpt_expanison_indicator'] = get_transient( 'eael_post_grid_excerpt_expanison_indicator_' . $widget_id . $eael_lang_suffix );
@@ -892,6 +895,16 @@
* @return array WC_Product_Query compatible arguments
*/
private function convert_pagination_args_to_wc_product_query( $args, $settings ) {
+ // The pagination / product-gallery requests that reach here are unsigned: $args is
+ // parsed straight from the visitor's own request and carries no server signature.
+ // Drop every meta query var so a visitor cannot filter products by arbitrary custom
+ // fields — a meta query can be used to read private meta (cost prices, supplier SKUs,
+ // other plugins' data) one guess at a time. This mirrors the removal that
+ // eael_restrict_unsigned_load_more_args() already performs for unsigned Load More.
+ foreach ( [ 'meta_query', 'meta_key', 'meta_value', 'meta_value_num', 'meta_compare', 'meta_compare_key', 'meta_type', 'meta_type_key' ] as $meta_key ) {
+ unset( $args[ $meta_key ] );
+ }
+
$wc_args = [
'paginate' => true,
'return' => 'objects',
@@ -968,6 +981,38 @@
// Set visibility
$wc_args['visibility'] = 'visible';
+ // Price / SKU sorting (and the best-selling / top-rated product filters) order by a
+ // product meta value, which needs a meta_key. That key was stripped from the client
+ // args at the top of this method — a visitor must not be able to sort or filter by an
+ // arbitrary private meta field. Re-derive it here from the widget's own saved settings
+ // (the trusted source), so the one legitimate case keeps working on page 2+ (#1048)
+ // while the security property holds. WC_Product_Query only honours a top-level meta_key
+ // for ordering, so set it directly rather than as a meta_query clause. The sort
+ // direction stays as the client requested for price/SKU; the two product filters pin
+ // their own order, matching Product_Grid / Woo_Product_Gallery query building.
+ $orderby_setting = isset( $settings['orderby'] ) ? $settings['orderby'] : '';
+ $filter_setting = isset( $settings['eael_product_grid_product_filter'] )
+ ? $settings['eael_product_grid_product_filter']
+ : ( isset( $settings['eael_product_gallery_product_filter'] ) ? $settings['eael_product_gallery_product_filter'] : '' );
+
+ if ( '_price' === $orderby_setting ) {
+ $wc_args['orderby'] = 'meta_value_num';
+ $wc_args['meta_key'] = '_price';
+ } elseif ( '_sku' === $orderby_setting ) {
+ $wc_args['orderby'] = 'meta_value';
+ $wc_args['meta_key'] = '_sku';
+ }
+
+ if ( 'best-selling-products' === $filter_setting ) {
+ $wc_args['orderby'] = 'meta_value_num';
+ $wc_args['meta_key'] = 'total_sales';
+ $wc_args['order'] = 'DESC';
+ } elseif ( 'top-products' === $filter_setting ) {
+ $wc_args['orderby'] = 'meta_value_num';
+ $wc_args['meta_key'] = '_wc_average_rating';
+ $wc_args['order'] = 'DESC';
+ }
+
return $wc_args;
}
--- a/essential-addons-for-elementor-lite/includes/Traits/Helper.php
+++ b/essential-addons-for-elementor-lite/includes/Traits/Helper.php
@@ -842,7 +842,16 @@
$widget_id = ! empty( $_POST['widget_id'] ) ? sanitize_text_field( wp_unslash( $_POST['widget_id'] ) ) : '';
$permalink = ! empty( $_POST['page_permalink'] ) ? sanitize_text_field( wp_unslash( $_POST['page_permalink'] ) ) : '';
$page_id = url_to_postid($permalink);
-
+
+ // The nonce checked above is minted by eael_get_token, which is handed out to anyone
+ // (logged in or not), so it proves nothing about the caller. Require edit rights:
+ // the only legitimate trigger is the "Clear" button inside the Elementor editor panel,
+ // whose users can always edit the page. Without this, any logged-in user (even a
+ // Subscriber) could force-clear a widget's cache repeatedly as a minor DoS.
+ if ( $page_id ? ! current_user_can( 'edit_post', $page_id ) : ! current_user_can( 'edit_posts' ) ) {
+ wp_send_json_error( [ 'message' => __( 'You are not allowed to clear this cache.', 'essential-addons-for-elementor-lite' ) ], 403 );
+ }
+
$settings = $this->eael_get_widget_settings($page_id, $widget_id);
$twitter_v2 = ! empty( $settings['eael_twitter_api_v2'] ) && 'yes' === $settings['eael_twitter_api_v2'] ? true : false;
--- a/essential-addons-for-elementor-lite/includes/Traits/Login_Registration.php
+++ b/essential-addons-for-elementor-lite/includes/Traits/Login_Registration.php
@@ -216,6 +216,23 @@
}
/**
+ * Keep an AJAX redirect target on this site.
+ *
+ * The non-AJAX login / register / password flows redirect with wp_safe_redirect(),
+ * which only allows same-host targets. The AJAX flow instead returns the URL to the
+ * browser in the JSON response for the front-end script to follow, so it must apply
+ * the same host allow-list here. Without it, a target derived from the Referer header
+ * (the "redirect to previous page" option) could send the user to an unrelated
+ * external site right after a successful submission.
+ *
+ * @param string $url Candidate redirect URL.
+ * @return string A same-host URL, or the site home when the target is off-site or empty.
+ */
+ protected function eael_lr_safe_redirect_url( $url ) {
+ return wp_validate_redirect( esc_url_raw( (string) $url ), home_url( '/' ) );
+ }
+
+ /**
* It logs the user in when the login form is submitted normally without AJAX.
*/
public function log_user_in() {
@@ -533,7 +550,7 @@
];
if ( ! empty( $custom_redirect_url ) ) {
- $data['redirect_to'] = esc_url_raw( $custom_redirect_url );
+ $data['redirect_to'] = $this->eael_lr_safe_redirect_url( $custom_redirect_url );
}
wp_send_json_success( $data );
}
@@ -664,6 +681,8 @@
$eael_custom_profile_fields = array_merge( $eael_custom_profile_fields_text, $eael_custom_profile_fields_image );
$eael_custom_profile_fields_image_keys = array_keys( $eael_custom_profile_fields_image );
+ // Image fields of this form whose upload passed the checks below.
+ $profile_images_to_save = [];
if( count($settings_register_fields) ){
foreach($settings_register_fields as $register_field){
@@ -683,8 +702,16 @@
}
if( isset( $register_field['field_type'] ) && in_array( $register_field['field_type'], $eael_custom_profile_fields_image_keys ) ){
+ $profile_image_key = $register_field['field_type'];
+ $profile_image_file = isset( $_FILES[ $profile_image_key ] ) && is_array( $_FILES[ $profile_image_key ] ) ? $_FILES[ $profile_image_key ] : []; //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
+ $profile_image_error = isset( $profile_image_file['error'] ) && is_numeric( $profile_image_file['error'] ) ? (int) $profile_image_file['error'] : UPLOAD_ERR_NO_FILE;
+
+ // No file chosen is fine here; any other upload error stops the registration.
+ if ( $profile_image_file && UPLOAD_ERR_NO_FILE !== $profile_image_error && UPLOAD_ERR_OK !== $profile_image_error ) {
+ $errors[ $profile_image_key ] = __( 'Sorry, this file could not be uploaded. Please try again.', 'essential-addons-for-elementor-lite' );
+ }
- if ( ! empty( $_FILES[ $register_field['field_type'] ] ) && ! empty( $_FILES[ $register_field['field_type'] ]["error"] ) && 4 !== $_FILES[ $register_field['field_type'] ]["error"] ) {
+ if ( $profile_image_file && UPLOAD_ERR_OK === $profile_image_error ) {
$custom_field_file_name = !empty( $_FILES[ $register_field['field_type'] ]["name"] ) ? sanitize_text_field( $_FILES[ $register_field['field_type'] ]["name"] ) : '';
$_custom_field_file_extension = explode( ".", $custom_field_file_name );
$custom_field_file_extension = end( $_custom_field_file_extension ); # extra () to prevent notice
@@ -692,7 +719,7 @@
$unsupported_extensions = ['svg', 'php', 'js', 'aiff', 'psd', 'exr', 'wma', 'sql', 'm2v', 'swf', 'py', 'java', 'json', 'html', 'yaml', 'css', 'rb', 'cpp', 'c', 'cs', 'swift', 'kt', 'go', 'ts'];
- if( ! empty ( $register_field['field_type_custom_image_extensions'] ) || in_array($custom_field_file_extension, $unsupported_extensions) ){
+ if( ! empty ( $register_field['field_type_custom_image_extensions'] ) || in_array( strtolower( $custom_field_file_extension ), $unsupported_extensions ) ){
$field_type_custom_image_extensions_trimmed = trim( sanitize_text_field( $register_field['field_type_custom_image_extensions'] ), ' ,nr x0B' );
$field_type_custom_image_extensions_array = array_unique( explode( ',', $field_type_custom_image_extensions_trimmed ) );
@@ -726,6 +753,16 @@
$errors[ $register_field['field_type'] ] = isset( $settings['field_type_custom_image_filename_length_error'] ) ? $settings['field_type_custom_image_filename_length_error'] : sprintf( __( 'Filename length exceeded. Maximum length is %d', 'essential-addons-for-elementor-lite' ), intval( $field_type_custom_image_filename_length ) );
}
}
+
+ // The file must really be an image of a type this field accepts, by its contents too.
+ if ( empty( $errors[ $profile_image_key ] ) && ! $this->eael_lr_is_profile_image( $profile_image_file ) ) {
+ $errors[ $profile_image_key ] = isset( $settings['field_type_custom_image_extensions_error'] ) ? $settings['field_type_custom_image_extensions_error'] : __( 'Sorry, you are not allowed to upload this file type.', 'essential-addons-for-elementor-lite' );
+ }
+
+ // Only a file that passed every check is saved after the user is created.
+ if ( empty( $errors[ $profile_image_key ] ) ) {
+ $profile_images_to_save[ $profile_image_key ] = true;
+ }
}
}
@@ -1100,8 +1137,17 @@
foreach( $eael_custom_profile_fields_image as $eael_custom_profile_field_image_key => $eael_custom_profile_field_value ){
self::$email_options[$eael_custom_profile_field_image_key] = '';
- if ( ! empty( $_FILES[ $eael_custom_profile_field_image_key ] ) ) {
- $attachment_id = media_handle_upload( $eael_custom_profile_field_image_key, 0, [ 'post_author' => $user_id ] );
+ // Only this form's image fields, and only files that passed the checks above.
+ if ( ! empty( $profile_images_to_save[ $eael_custom_profile_field_image_key ] ) ) {
+ $attachment_id = media_handle_upload(
+ $eael_custom_profile_field_image_key,
+ 0,
+ [ 'post_author' => $user_id ],
+ [
+ 'test_form' => false,
+ 'mimes' => $this->eael_lr_profile_image_mimes(),
+ ]
+ );
if ( ! is_wp_error( $attachment_id ) ) {
$eael_custom_profile_field_values[ $eael_custom_profile_field_image_key ] = sanitize_text_field( $attachment_id );
self::$email_options[ $eael_custom_profile_field_image_key ] = wp_get_attachment_image_url( sanitize_text_field( $attachment_id ) );
@@ -1207,7 +1253,7 @@
if ( $ajax ) {
if ( in_array( 'redirect', $register_actions ) && ! empty( $custom_redirect_url ) ) {
- $data['redirect_to'] = $custom_redirect_url;
+ $data['redirect_to'] = $this->eael_lr_safe_redirect_url( $custom_redirect_url );
}
wp_send_json_success( $data );
}
@@ -1222,7 +1268,7 @@
// custom redirect?
if ( $ajax ) {
if ( in_array( 'redirect', $register_actions ) && ! empty( $custom_redirect_url ) ) {
- $data['redirect_to'] = $custom_redirect_url;
+ $data['redirect_to'] = $this->eael_lr_safe_redirect_url( $custom_redirect_url );
}
wp_send_json_success( $data );
}
@@ -1431,7 +1477,7 @@
if ( $ajax ) {
if ( ! empty( $_POST['redirect_to'] ) ) {
- $data['redirect_to'] = esc_url_raw( $_POST['redirect_to'] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
+ $data['redirect_to'] = $this->eael_lr_safe_redirect_url( wp_unslash( $_POST['redirect_to'] ) ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
}
wp_send_json_success( $data );
} else {
@@ -1604,7 +1650,7 @@
if($ajax){
// $custom_redirect_url = ! empty( $settings['resetpassword_redirect_url']['url'] ) ? $settings['resetpassword_redirect_url']['url'] : '/';
if( ! empty( $_POST['resetpassword_redirect_to'] ) ){
- $data['redirect_to'] = esc_url_raw( $_POST['resetpassword_redirect_to'] ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
+ $data['redirect_to'] = $this->eael_lr_safe_redirect_url( wp_unslash( $_POST['resetpassword_redirect_to'] ) ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash
}
wp_send_json_success( $data );
@@ -2920,7 +2966,7 @@
}
if ( in_array( 'redirect', $register_actions, true ) && ! empty( $payload['redirect_url'] ) ) {
- $response['redirect_to'] = esc_url_raw( $payload['redirect_url'] );
+ $response['redirect_to'] = $this->eael_lr_safe_redirect_url( $payload['redirect_url'] );
}
return $response;
@@ -2967,7 +3013,7 @@
];
if ( ! empty( $payload['redirect_url'] ) ) {
- $response['redirect_to'] = esc_url_raw( $payload['redirect_url'] );
+ $response['redirect_to'] = $this->eael_lr_safe_redirect_url( $payload['redirect_url'] );
}
return $response;
@@ -3258,6 +3304,40 @@
return apply_filters( 'eael/login-register/wp-login-url', wp_login_url() );
}
+ /**
+ * Image types a custom profile image field accepts: the site's allowed
+ * image types, without SVG.
+ *
+ * @return array Extension pattern => MIME type, as get_allowed_mime_types() returns them.
+ */
+ public function eael_lr_profile_image_mimes() {
+ $mimes = [];
+ foreach ( get_allowed_mime_types() as $extensions => $mime ) {
+ if ( 0 === strpos( $mime, 'image/' ) && false === strpos( $mime, 'svg' ) ) {
+ $mimes[ $extensions ] = $mime;
+ }
+ }
+
+ return $mimes;
+ }
+
+ /**
+ * Whether an uploaded file is an image this field accepts, judged by its
+ * name and by its contents.
+ *
+ * @param array $file One entry of $_FILES.
+ * @return bool
+ */
+ public function eael_lr_is_profile_image( $file ) {
+ if ( empty( $file['tmp_name'] ) || empty( $file['name'] ) || ! is_string( $file['tmp_name'] ) || ! is_uploaded_file( $file['tmp_name'] ) ) {
+ return false;
+ }
+
+ $checked = wp_check_filetype_and_ext( $file['tmp_name'], sanitize_file_name( $file['name'] ), $this->eael_lr_profile_image_mimes() );
+
+ return ! empty( $checked['ext'] ) && ! empty( $checked['type'] ) && 0 === strpos( $checked['type'], 'image/' );
+ }
+
public function get_eael_custom_profile_fields( $type = 'text' ){
$eael_custom_profile_fields = [];
$custom_profile_fields_arr = [];