Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/profile-builder/admin/advanced-settings/includes/forms/confirm-user-email-change.php
+++ b/profile-builder/admin/advanced-settings/includes/forms/confirm-user-email-change.php
@@ -185,7 +185,7 @@
$change_request_message = sprintf( __('Someone requested to change the email address for your account.<br/>If this was a mistake, just ignore this email and nothing will happen.<br/>To update your account email address to the one requested (%1$s), visit the following link: %2$s', 'profile-builder'), esc_html( $new_user_email['new_email'] ),'<a href="'.esc_url( $confirmation_url ).'">Change email address!</a>' );
$change_request_message = apply_filters( 'wppb_user_email_change_request_notification_content', $change_request_message, $current_user, $confirmation_url );
- wppb_mail($new_email,$change_request_subject,$change_request_message);
+ wppb_mail( $new_email, $change_request_subject, $change_request_message, '', 'email_user_update_email' );
// set transient
$transient_key = wppb_toolbox_email_change_request_transient_key( $current_user->ID, $new_email );
--- a/profile-builder/admin/plugin-optin/view-plugin-optin.php
+++ b/profile-builder/admin/plugin-optin/view-plugin-optin.php
@@ -9,7 +9,7 @@
<div class="wppb-optin-page__content">
<div class="wppb-optin-page__top">
- <img class="wppb-option-page__logo-wordpress" src="<?php echo esc_attr( WPPB_PLUGIN_URL . '/assets/images/plugin_optin_logo_wordpress.png') ?>">
+ <img class="wppb-option-page__logo-wordpress" src="<?php echo esc_attr( WPPB_PLUGIN_URL . 'assets/images/plugin_optin_logo_wordpress.png') ?>">
<span class="wppb-optin-page__extra-icon dashicons dashicons-plus"></span>
--- a/profile-builder/assets/misc/gutenberg/block-content-restriction/block-content-restriction.php
+++ b/profile-builder/assets/misc/gutenberg/block-content-restriction/block-content-restriction.php
@@ -27,6 +27,50 @@
}
add_filter( 'render_block', 'wppb_render_blocks', 10, 2 );
+// excerpt_remove_blocks() renders only the leaves of wrapper blocks, so render_block never runs for a restricted wrapper
+add_filter( 'content_pagination', 'wppb_hide_restricted_blocks_from_excerpt', 999, 2 );
+function wppb_hide_restricted_blocks_from_excerpt( $pages, $post ) {
+ if ( !doing_filter( 'get_the_excerpt' ) ) {
+ return $pages;
+ }
+
+ foreach ( $pages as $index => $page ) {
+ if ( strpos( $page, 'wppbContentRestriction' ) === false ) {
+ continue;
+ }
+
+ $stripped = false;
+ $blocks = wppb_strip_hidden_blocks_content( parse_blocks( $page ), $stripped );
+
+ if ( $stripped ) {
+ $pages[ $index ] = serialize_blocks( $blocks );
+ }
+ }
+
+ return $pages;
+}
+
+function wppb_strip_hidden_blocks_content( $blocks, &$stripped ) {
+ foreach ( $blocks as $index => $block ) {
+ if ( wppb_is_block_hidden( $block ) ) {
+ $blocks[ $index ]['innerBlocks'] = array();
+ $blocks[ $index ]['innerHTML'] = '';
+ $blocks[ $index ]['innerContent'] = array();
+ $stripped = true;
+ } elseif ( !empty( $block['innerBlocks'] ) ) {
+ $blocks[ $index ]['innerBlocks'] = wppb_strip_hidden_blocks_content( $block['innerBlocks'], $stripped );
+ }
+ }
+
+ return $blocks;
+}
+
+function wppb_is_block_hidden( $block ) {
+ $visibility_probe = 'wppb-block-visibility-probe';
+
+ return strpos( wppb_render_blocks( $visibility_probe, $block ), $visibility_probe ) === false;
+}
+
/**
* Adds the `wppbContentRestriction` attribute to all blocks
--- a/profile-builder/features/content-restriction/class-elementor-content-restriction.php
+++ b/profile-builder/features/content-restriction/class-elementor-content-restriction.php
@@ -49,6 +49,12 @@
// Disable Element Cache when Content Restriction rules are setup for an element
add_filter( 'elementor/element/is_dynamic_content', array( $this, 'are_content_restriction_rules_setup' ), 20, 3 );
+
+ // Auto-excerpts read the plain-text copy of every element that Elementor saves in post_content
+ add_filter( 'content_pagination', array( $this, 'excerpt_pages_without_hidden_elements' ), 999, 2 );
+
+ // Paid Member Subscriptions rebuilds the same plain-text copy, so both plugins share one hide check and the last rebuild keeps both restrictions
+ add_filter( 'cozmoslabs_elementor_excerpt_hide_element', array( $this, 'hide_element_from_excerpt' ), 10, 2 );
}
/**
@@ -355,8 +361,17 @@
public function are_content_restriction_rules_setup( $is_dynamic_content, $data, $element ){
+ if( $this->has_restriction_rules( $data ) )
+ return true;
+
+ return $is_dynamic_content;
+
+ }
+
+ private function has_restriction_rules( $data ){
+
if( empty( $data['settings'] ) )
- return $is_dynamic_content;
+ return false;
if( isset( $data['settings']['wppb_restriction_loggedin_users'] ) && $data['settings']['wppb_restriction_loggedin_users'] == 'yes' )
return true;
@@ -367,8 +382,67 @@
if( isset( $data['settings']['wppb_restriction_user_roles'] ) && !empty( $data['settings']['wppb_restriction_user_roles'] ) )
return true;
- return $is_dynamic_content;
+ return false;
+
+ }
+
+ public function excerpt_pages_without_hidden_elements( $pages, $post ) {
+ if( !doing_filter( 'get_the_excerpt' ) )
+ return $pages;
+
+ $elementor_data = get_post_meta( $post->ID, '_elementor_data', true );
+
+ if( is_string( $elementor_data ) && strpos( $elementor_data, 'wppb_restriction_' ) === false )
+ return $pages;
+
+ $document = ElementorPlugin::$instance->documents->get( $post->ID );
+
+ if( !$document || !$document->is_built_with_elementor() )
+ return $pages;
+
+ $removed = false;
+ $elements = $this->remove_hidden_elements( $document->get_elements_data(), $removed );
+
+ if( !$removed )
+ return $pages;
+
+ // Same parsing mode Elementor uses when it saves the plain-text copy
+ $dynamic_tags = ElementorPlugin::$instance->dynamic_tags;
+ $parsing_mode = $dynamic_tags->get_parsing_mode();
+ $dynamic_tags->set_parsing_mode( ElementorCoreDynamicTagsManager::MODE_REMOVE );
+
+ $plain_text = ElementorPlugin::$instance->db->get_plain_text_from_data( $elements );
+
+ $dynamic_tags->set_parsing_mode( $parsing_mode );
+
+ return array( $plain_text );
+ }
+
+ public function hide_element_from_excerpt( $hide, $element_data ) {
+ if( $hide || !$this->has_restriction_rules( $element_data ) )
+ return $hide;
+
+ $element = ElementorPlugin::$instance->elements_manager->create_element_instance( $element_data );
+
+ return !$element || $this->is_hidden( $element );
+ }
+
+ private function remove_hidden_elements( $elements, &$removed ) {
+ $kept = array();
+
+ foreach( $elements as $element_data ) {
+ if( apply_filters( 'cozmoslabs_elementor_excerpt_hide_element', false, $element_data ) ) {
+ $removed = true;
+ continue;
+ }
+
+ if( !empty( $element_data['elements'] ) )
+ $element_data['elements'] = $this->remove_hidden_elements( $element_data['elements'], $removed );
+
+ $kept[] = $element_data;
+ }
+ return $kept;
}
}
--- a/profile-builder/features/content-restriction/content-restriction-filtering.php
+++ b/profile-builder/features/content-restriction/content-restriction-filtering.php
@@ -519,6 +519,19 @@
add_filter( 'wppb_content_restriction_message_logged_in', 'wppb_content_restriction_add_post_preview', 30, 4 );
add_filter( 'wppb_content_restriction_message_logged_out', 'wppb_content_restriction_add_post_preview', 30, 4 );
+/* Drop a restricted post's manual excerpt so wp_trim_excerpt() builds it from the_content, which adds the restriction message and post preview */
+function wppb_content_restriction_filter_excerpt( $excerpt, $post = null ) {
+
+ $post = get_post( $post );
+
+ if( ! empty( $excerpt ) && ! empty( $post ) && wppb_content_restriction_is_post_restricted( $post->ID ) )
+ return '';
+
+ return $excerpt;
+
+}
+add_filter( 'get_the_excerpt', 'wppb_content_restriction_filter_excerpt', 9, 2 );
+
/* if the Static Posts Page has a restriction on it hijack the query */
add_action( 'template_redirect', 'wppb_content_restriction_posts_page_handle_query', 1 );
function wppb_content_restriction_posts_page_handle_query(){
@@ -607,20 +620,36 @@
add_filter( 'wp_list_comments_args', 'wppb_comments_hide_callback_function', 999 );
}
-if( !function_exists( 'pms_exclude_restricted_comments' ) ){
+if( !function_exists( 'pms_exclude_restricted_comments' ) )
add_filter( 'the_comments', 'wppb_exclude_restricted_comments', 10, 2 );
- function wppb_exclude_restricted_comments( $comments, $query ){
- if( !empty( $comments ) && !current_user_can( 'manage_options' ) ){
- $user_id = get_current_user_id();
- foreach ( $comments as $key => $comment ){
- $post = get_post( $comment->comment_post_ID );
- if( ( $post->post_type == 'private-page' && $user_id != (int)$post->post_author ) || ( function_exists( 'wppb_content_restriction_is_post_restricted' ) && wppb_content_restriction_is_post_restricted( $comment->comment_post_ID ) ) || ( function_exists( 'pms_is_post_restricted' ) && pms_is_post_restricted( $comment->comment_post_ID ) ) ){
- unset( $comments[$key] );
- }
+
+function wppb_exclude_restricted_comments( $comments, $query ){
+ if( !empty( $comments ) && !current_user_can( 'manage_options' ) ){
+ $user_id = get_current_user_id();
+ foreach ( $comments as $key => $comment ){
+ $post = get_post( $comment->comment_post_ID );
+ if( empty( $post ) )
+ continue;
+ if( ( $post->post_type == 'private-page' && $user_id != (int)$post->post_author ) || ( function_exists( 'wppb_content_restriction_is_post_restricted' ) && wppb_content_restriction_is_post_restricted( $comment->comment_post_ID ) ) || ( function_exists( 'pms_is_post_restricted' ) && pms_is_post_restricted( $comment->comment_post_ID ) ) ){
+ unset( $comments[$key] );
}
}
- return $comments;
}
+ return $comments;
+}
+
+// comment feeds load their comments with their own query, which skips the_comments
+if( apply_filters( 'wppb_enable_comment_restriction', true ) )
+ add_action( 'wp', 'wppb_exclude_restricted_comments_from_feeds' );
+
+function wppb_exclude_restricted_comments_from_feeds(){
+ global $wp_query;
+
+ if( !is_comment_feed() || empty( $wp_query->comments ) )
+ return;
+
+ $wp_query->comments = array_values( wppb_exclude_restricted_comments( $wp_query->comments, $wp_query ) );
+ $wp_query->comment_count = count( $wp_query->comments );
}
@@ -664,7 +693,7 @@
// check if restricted post preview is set
$settings = get_option( 'wppb_content_restriction_settings' );
- $preview_option = ( !empty( $settings['restricted_post_preview']['option'] ) ? $settings['restricted_post_preview']['option'] : '' );
+ $preview_option = ( !empty( $settings['post_preview'] ) ? $settings['post_preview'] : '' );
if ( !empty($preview_option) && ($preview_option != 'none') ) {
// display product title
@@ -826,7 +855,7 @@
*/
function wppb_woo_hide_restricted_product_price( $price, WC_Product $product ){
// check if current user can view this product, and if not, remove the price
- if ( wppb_content_restriction_is_post_restricted( $product->get_id() ) ) {
+ if ( wppb_woo_is_product_view_restricted( $product ) ) {
$price = '';
}
@@ -837,6 +866,201 @@
/**
+ * Function that checks if the current user can't view a product
+ *
+ * @param WC_Product $product The product
+ * @return bool
+ */
+ function wppb_woo_is_product_view_restricted( $product ){
+ $product_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id();
+
+ return ! empty( $product_id ) && wppb_content_restriction_is_post_restricted( $product_id );
+ }
+
+ /**
+ * Function that returns the name of the WooCommerce Store API route that handles a REST request
+ *
+ * @param array $handler The REST route handler
+ * @return string
+ */
+ function wppb_woo_get_store_api_route_name( $handler ){
+ $namespace = 'Automattic\WooCommerce\StoreApi\Routes\V1\';
+
+ if ( empty( $handler['callback'] ) || ! is_array( $handler['callback'] ) || ! is_object( $handler['callback'][0] ) )
+ return '';
+
+ $route_class = get_class( $handler['callback'][0] );
+
+ return strpos( $route_class, $namespace ) === 0 ? substr( $route_class, strlen( $namespace ) ) : '';
+ }
+
+ /**
+ * Function that hides a view-restricted product's data in a Store API product response item
+ *
+ * @param array $item The Store API product data
+ * @return array
+ */
+ function wppb_woo_hide_restricted_store_api_product( $item ){
+ $product = empty( $item['id'] ) ? false : wc_get_product( $item['id'] );
+
+ if ( ! $product || ! wppb_woo_is_product_view_restricted( $product ) )
+ return $item;
+
+ $item['description'] = '';
+ $item['short_description'] = '';
+ $item['prices'] = (object) array_merge( (array) $item['prices'], array( 'price' => '', 'regular_price' => '', 'sale_price' => '', 'price_range' => null ) );
+
+ return $item;
+ }
+
+ /**
+ * Function that hides view-restricted products' data in WooCommerce Store API product responses and cart cross-sells. It runs for
+ * REST requests and for the Store API data WooCommerce blocks hydrate into pages, which skips the REST server hooks.
+ *
+ * @param WP_REST_Response|WP_Error|mixed $response The route response
+ * @param array $handler The REST route handler
+ * @return WP_REST_Response|WP_Error|mixed
+ */
+ function wppb_woo_hide_restricted_store_api_products( $response, $handler ){
+ if ( ! $response instanceof WP_REST_Response || $response->is_error() || ! is_array( $response->get_data() ) )
+ return $response;
+
+ $data = $response->get_data();
+ $route_name = wppb_woo_get_store_api_route_name( $handler );
+
+ if ( $route_name === 'Products' )
+ $data = array_map( 'wppb_woo_hide_restricted_store_api_product', $data );
+ else if ( in_array( $route_name, array( 'ProductsById', 'ProductsBySlug' ), true ) )
+ $data = wppb_woo_hide_restricted_store_api_product( $data );
+ else if ( $route_name !== '' && ! empty( $data['cross_sells'] ) )
+ $data['cross_sells'] = array_map( 'wppb_woo_hide_restricted_store_api_product', $data['cross_sells'] );
+
+ $response->set_data( $data );
+
+ return $response;
+ }
+ add_filter( 'rest_request_after_callbacks', 'wppb_woo_hide_restricted_store_api_products', 10, 2 );
+ add_filter( 'woocommerce_hydration_request_after_callbacks', 'wppb_woo_hide_restricted_store_api_products', 10, 2 );
+
+ /**
+ * Function that returns the IDs of the published products the current user can't view, together with their variations
+ *
+ * @return array
+ */
+ function wppb_woo_get_view_restricted_product_ids(){
+ $restriction_meta_query = array(
+ 'relation' => 'OR',
+ array( 'key' => 'wppb-content-restrict-user-status', 'compare' => 'EXISTS' ),
+ array( 'key' => 'wppb-content-restrict-user-role', 'compare' => 'EXISTS' ),
+ );
+
+ $restricted_terms_query = array( 'relation' => 'OR' );
+
+ foreach( get_object_taxonomies( 'product' ) as $taxonomy ) {
+ $term_ids = get_terms( array( 'taxonomy' => $taxonomy, 'hide_empty' => false, 'fields' => 'ids', 'meta_query' => $restriction_meta_query ) );
+
+ if ( ! empty( $term_ids ) && ! is_wp_error( $term_ids ) )
+ $restricted_terms_query[] = array( 'taxonomy' => $taxonomy, 'terms' => $term_ids );
+ }
+
+ // Full posts, not IDs, so WP_Query loads the post meta and term meta the restriction check reads in bulk
+ $query_args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1 );
+ $products = get_posts( $query_args + array( 'meta_query' => $restriction_meta_query ) );
+
+ if ( count( $restricted_terms_query ) > 1 )
+ $products = array_merge( $products, get_posts( $query_args + array( 'tax_query' => $restricted_terms_query ) ) );
+
+ $restricted_ids = array_values( array_filter( array_unique( wp_list_pluck( $products, 'ID' ) ), 'wppb_content_restriction_is_post_restricted' ) );
+
+ if ( empty( $restricted_ids ) )
+ return array();
+
+ return array_merge( $restricted_ids, get_posts( array( 'post_type' => 'product_variation', 'post_parent__in' => $restricted_ids, 'fields' => 'ids' ) + $query_args ) );
+ }
+
+ /**
+ * Function that answers a Store API product request that filters, sorts or aggregates by price without the products the current user
+ * can't view, since whether a product matches such a request reveals its hidden price. It runs for REST requests and for hydrated ones.
+ *
+ * @param mixed $result The dispatch result, null unless another filter answered the request
+ * @param WP_REST_Request $request The request
+ * @param string $route The matched route
+ * @param array $handler The REST route handler
+ * @return mixed
+ */
+ function wppb_woo_dispatch_store_api_price_request( $result, $request, $route, $handler ){
+ global $wppb_woo_store_api_price_query_exclusions;
+
+ $route_name = wppb_woo_get_store_api_route_name( $handler );
+
+ if ( $result !== null || ! in_array( $route_name, array( 'Products', 'ProductCollectionData' ), true ) )
+ return $result;
+
+ $matching_reveals_prices = ! empty( $request['min_price'] ) || ! empty( $request['max_price'] ) || ! empty( $request['calculate_price_range'] ) || $request['orderby'] === 'price';
+
+ if ( ! $matching_reveals_prices )
+ return $result;
+
+ $restricted_ids = wppb_woo_get_view_restricted_product_ids();
+
+ if ( empty( $restricted_ids ) )
+ return $result;
+
+ // WooCommerce caches collection data by query vars for all viewers, so the excluded IDs must be part of them
+ if ( $route_name === 'ProductCollectionData' )
+ $request->set_param( 'exclude', array_merge( (array) $request['exclude'], $restricted_ids ) );
+
+ $wppb_woo_store_api_price_query_exclusions[] = $restricted_ids;
+
+ try {
+ return call_user_func( $handler['callback'], $request );
+ } finally {
+ array_pop( $wppb_woo_store_api_price_query_exclusions );
+ }
+ }
+ add_filter( 'rest_dispatch_request', 'wppb_woo_dispatch_store_api_price_request', 10, 4 );
+ add_filter( 'woocommerce_hydration_dispatch_request', 'wppb_woo_dispatch_store_api_price_request', 10, 4 );
+
+ /**
+ * Function that leaves view-restricted products out of the queries run while a Store API price request is being answered.
+ * The route's include and on_sale=true params become post__in, which makes WP_Query ignore post__not_in, so the products are excluded in SQL.
+ *
+ * @param string $where The WHERE clause of the query
+ * @return string
+ */
+ function wppb_woo_exclude_restricted_products_from_store_api_price_queries( $where ){
+ global $wpdb, $wppb_woo_store_api_price_query_exclusions;
+
+ if ( empty( $wppb_woo_store_api_price_query_exclusions ) )
+ return $where;
+
+ $restricted_ids = array_unique( call_user_func_array( 'array_merge', $wppb_woo_store_api_price_query_exclusions ) );
+
+ return $where . " AND {$wpdb->posts}.ID NOT IN (" . implode( ',', array_map( 'absint', $restricted_ids ) ) . ")";
+ }
+ add_filter( 'posts_where', 'wppb_woo_exclude_restricted_products_from_store_api_price_queries' );
+
+ /**
+ * Function that hides a view-restricted product's variation data that WooCommerce sends to the product page
+ *
+ * @param array $variation_data The variation data
+ * @param WC_Product_Variable $product The variable product
+ * @return array
+ */
+ function wppb_woo_hide_restricted_variation_data( $variation_data, $product ){
+ if ( ! wppb_woo_is_product_view_restricted( $product ) )
+ return $variation_data;
+
+ $variation_data['variation_description'] = '';
+ $variation_data['display_price'] = 0;
+ $variation_data['display_regular_price'] = 0;
+
+ return $variation_data;
+ }
+ add_filter( 'woocommerce_available_variation', 'wppb_woo_hide_restricted_variation_data', 10, 2 );
+
+
+ /**
* Function that hides the product image thumbnail for view-restricted products
*
*/
--- a/profile-builder/features/email-customizer/email-customizer.php
+++ b/profile-builder/features/email-customizer/email-customizer.php
@@ -1275,7 +1275,7 @@
'wppb_epaa_admin_email' => 'wppb_admin_emailc_epaa_notification_enabled',
);
- if ( !empty( $actions[$context] ) )
+ if ( is_string( $context ) && !empty( $actions[$context] ) )
$option_name = $actions[$context];
else
return $send_email;
--- a/profile-builder/features/functions.php
+++ b/profile-builder/features/functions.php
@@ -1028,7 +1028,7 @@
if( apply_filters( 'wppb_show_password_visibility_toggle', false ) ){
return '
<button type="button" class="wppb-toggle-pw wppb-show-pw hide-if-no-js" data-toggle="0" aria-label="Show password" tabindex="-1">
- <img src="'.WPPB_PLUGIN_URL.'/assets/images/eye-outline.svg" title="'. esc_html__( 'Show password', 'profile-builder' ) .'" width="20px" height="20px" />
+ <img src="'.WPPB_PLUGIN_URL.'assets/images/eye-outline.svg" title="'. esc_html__( 'Show password', 'profile-builder' ) .'" width="20px" height="20px" />
</button>';
}
return '';
@@ -1081,12 +1081,12 @@
if ( "password" === input.attr( "type" ) ) {
input.attr( "type", "text" );
button.removeClass( "wppb-show-pw" ).addClass( "wppb-hide-pw" );
- icon.attr( "src", "<?php echo esc_attr( WPPB_PLUGIN_URL ); ?>/assets/images/eye-off-outline.svg" );
+ icon.attr( "src", "<?php echo esc_attr( WPPB_PLUGIN_URL ); ?>assets/images/eye-off-outline.svg" );
icon.attr( "title", "<?php esc_html_e( 'Hide password', 'profile-builder' ); ?>" );
} else {
input.attr( "type", "password" );
button.removeClass( "wppb-hide-pw" ).addClass( "wppb-show-pw" );
- icon.attr( "src", "<?php echo esc_attr( WPPB_PLUGIN_URL ); ?>/assets/images/eye-outline.svg" );
+ icon.attr( "src", "<?php echo esc_attr( WPPB_PLUGIN_URL ); ?>assets/images/eye-outline.svg" );
icon.attr( "title", "<?php esc_html_e( 'Show password', 'profile-builder' ); ?>" );
}
}
--- a/profile-builder/form-builder/multiple-forms/edit-profile-forms.php
+++ b/profile-builder/form-builder/multiple-forms/edit-profile-forms.php
@@ -36,6 +36,7 @@
'has_archive' => false,
'hierarchical' => false,
'capability_type' => 'post',
+ 'map_meta_cap' => true,
'supports' => array( 'title' )
);
--- a/profile-builder/form-builder/multiple-forms/register-forms.php
+++ b/profile-builder/form-builder/multiple-forms/register-forms.php
@@ -36,6 +36,7 @@
'has_archive' => false,
'hierarchical' => false,
'capability_type' => 'post',
+ 'map_meta_cap' => true,
'supports' => array( 'title' )
);
--- a/profile-builder/front-end/default-fields/upload/upload_helper_functions.php
+++ b/profile-builder/front-end/default-fields/upload/upload_helper_functions.php
@@ -124,6 +124,38 @@
}
/**
+ * WordPress maps .rar to application/rar, but fileinfo reports real RAR archives as application/x-rar
+ * (or application/vnd.rar), so wp_check_filetype_and_ext() rejects every .rar. Accept those variants
+ * when the extension is allowed by WordPress. Only hooked while a simple upload is validated and saved.
+ *
+ * @param array $data Values for the extension, mime type, and corrected filename.
+ * @param string $file Full path to the file.
+ * @param string $filename The name of the file.
+ * @param array|null $mimes Array of mime types keyed by their file extension regex.
+ * @param string|bool $real_mime The actual mime type or false if the type cannot be determined.
+ *
+ * @return array
+ */
+function wppb_accept_archive_real_mime_types( $data, $file, $filename, $mimes, $real_mime = false ){
+ if ( ! empty( $data['ext'] ) && ! empty( $data['type'] ) )
+ return $data;
+
+ $real_mime_variants = array(
+ 'rar' => array( 'application/x-rar', 'application/vnd.rar', 'application/x-rar-compressed' ),
+ );
+
+ $wp_filetype = wp_check_filetype( $filename, $mimes );
+ $ext = strtolower( (string) $wp_filetype['ext'] );
+
+ if ( isset( $real_mime_variants[ $ext ] ) && in_array( $real_mime, $real_mime_variants[ $ext ], true ) ) {
+ $data['ext'] = $wp_filetype['ext'];
+ $data['type'] = $wp_filetype['type'];
+ }
+
+ return $data;
+}
+
+/**
* Function that performs validation for the simple upload field
*
* @param $field - simple upload field
@@ -164,7 +196,9 @@
return false;
}
+ add_filter( 'wp_check_filetype_and_ext', 'wppb_accept_archive_real_mime_types', 10, 5 );
$checked = wp_check_filetype_and_ext( $upload['tmp_name'], $upload['name'] );
+ remove_filter( 'wp_check_filetype_and_ext', 'wppb_accept_archive_real_mime_types', 10 );
$detected_type = ! empty( $checked['type'] ) ? $checked['type'] : '';
$detected_ext = ! empty( $checked['ext'] ) ? strtolower( $checked['ext'] ) : '';
$allowed_by_wordpress = ( $detected_type !== '' && in_array( $detected_type, $allowed_mime_types, true ) );
@@ -397,8 +431,11 @@
require_once(ABSPATH . 'wp-admin/includes/file.php');
$upload_overrides = array('test_form' => false);
- if( isset( $_FILES[$field_name] ) )
+ if( isset( $_FILES[$field_name] ) ) {
+ add_filter( 'wp_check_filetype_and_ext', 'wppb_accept_archive_real_mime_types', 10, 5 );
$file = wp_handle_upload($_FILES[$field_name], $upload_overrides);
+ remove_filter( 'wp_check_filetype_and_ext', 'wppb_accept_archive_real_mime_types', 10 );
+ }
if (isset($file['error'])) {
return new WP_Error('upload_error', $file['error']);
--- a/profile-builder/index.php
+++ b/profile-builder/index.php
@@ -3,7 +3,7 @@
* Plugin Name: Profile Builder
* Plugin URI: https://www.cozmoslabs.com/wordpress-profile-builder/
* Description: Login, registration and edit profile shortcodes for the front-end. Also you can choose what fields should be displayed or add new (custom) ones both in the front-end and in the dashboard.
- * Version: 4.0.6
+ * Version: 4.0.7
* Author: Cozmoslabs
* Author URI: https://www.cozmoslabs.com/
* Text Domain: profile-builder
@@ -11,8 +11,8 @@
* License: GPL2
* WC requires at least: 3.0.0
* WC tested up to: 11.2
- * Elementor tested up to: 4.3.5
- * Elementor Pro tested up to: 4.3.5
+ * Elementor tested up to: 4.4.0
+ * Elementor Pro tested up to: 4.4.0
*
* == Copyright ==
* Copyright 2014 Cozmoslabs (www.cozmoslabs.com)
@@ -387,7 +387,7 @@
*
*
*/
-define('PROFILE_BUILDER_VERSION', '4.0.6' );
+define('PROFILE_BUILDER_VERSION', '4.0.7' );
define('WPPB_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('WPPB_PLUGIN_URL', plugin_dir_url(__FILE__));
define('WPPB_PLUGIN_BASENAME', plugin_basename(__FILE__));
--- a/profile-builder/translation/profile-builder.catalog.php
+++ b/profile-builder/translation/profile-builder.catalog.php
@@ -2268,6 +2268,7 @@
<?php __("Link with LinkedIn", "profile-builder"); ?>
<?php __("Error Receiving Request Token", "profile-builder"); ?>
<?php __("Connection with twitter Failed", "profile-builder"); ?>
+<?php __("Login Error", "profile-builder"); ?>
<?php __("Sign in with Twitter", "profile-builder"); ?>
<?php __("Link with Twitter", "profile-builder"); ?>
<?php __("Communication Preferences", "profile-builder"); ?>