PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | features/content-restriction/class-elementor-content-restriction.php +38 -10 3.9.6 → 4.0.3 View file →
@@ -45,8 +45,11 @@
45 45 add_action( 'elementor/frontend/container/after_render', array( $this, 'section_custom_messages' ), 10, 2 );
46 46
47 47 // Filter Elementor `the_content` hook
48 48 add_action( 'elementor/frontend/the_content', array( $this, 'filter_elementor_templates' ), 20 );
49 +
50 + // Disable Element Cache when Content Restriction rules are setup for an element
51 + add_filter( 'elementor/element/is_dynamic_content', array( $this, 'are_content_restriction_rules_setup' ), 20, 3 );
49 52 }
50 53
51 54 /**
52 55 *
@@ -223,17 +226,22 @@
223 226 // Verifies if element is hidden
224 227 public function is_hidden( $element ) {
225 228 $settings = $element->get_settings();
226 229
227 - if( is_user_logged_in() && $settings['wppb_restriction_loggedout_users'] === 'yes' ) {
230 + // Our controls are not present on every element that goes through these filters, so don't assume the settings exist
231 + $restrict_loggedin_users = isset( $settings['wppb_restriction_loggedin_users'] ) ? $settings['wppb_restriction_loggedin_users'] : '';
232 + $restrict_loggedout_users = isset( $settings['wppb_restriction_loggedout_users'] ) ? $settings['wppb_restriction_loggedout_users'] : '';
233 + $restrict_user_roles = isset( $settings['wppb_restriction_user_roles'] ) ? array_filter( (array)$settings['wppb_restriction_user_roles'] ) : array();
234 +
235 + if( is_user_logged_in() && $restrict_loggedout_users === 'yes' ) {
228 236 return true;
229 237 }
230 238
231 - if( !empty( $settings['wppb_restriction_user_roles'] ) && is_user_logged_in() ) {
239 + if( !empty( $restrict_user_roles ) && is_user_logged_in() ) {
232 240
233 241 $user_data = get_userdata( get_current_user_id() );
234 242
235 - foreach( $settings['wppb_restriction_user_roles'] as $restriction_role ) {
243 + foreach( $restrict_user_roles as $restriction_role ) {
236 244 foreach( $user_data->roles as $user_role ) {
237 245 if( $user_role == $restriction_role ) {
238 246 return false;
239 247 }
@@ -241,9 +249,9 @@
241 249 }
242 250
243 251 return true;
244 252 } else if ( !is_user_logged_in() && (
245 - ( $settings['wppb_restriction_loggedin_users'] == 'yes' ) || ( !empty( $settings['wppb_restriction_user_roles'] ) )
253 + ( $restrict_loggedin_users == 'yes' ) || ( !empty( $restrict_user_roles ) )
246 254 ) ) {
247 255
248 256 return true;
249 257 }
@@ -254,17 +262,19 @@
254 262 // Retrieves custom element message or the default message from PB settings
255 263 private function get_custom_message( $element ) {
256 264 $settings = $element->get_settings();
257 265
258 - if( $settings['wppb_restriction_default_messages'] != 'yes' )
266 + if( !isset( $settings['wppb_restriction_default_messages'] ) || $settings['wppb_restriction_default_messages'] != 'yes' )
259 267 return false;
260 268
261 - if( $settings['wppb_restriction_custom_messages'] == 'yes' ) {
269 + if( isset( $settings['wppb_restriction_custom_messages'] ) && $settings['wppb_restriction_custom_messages'] == 'yes' ) {
262 270
263 - if( $settings['wppb_restriction_custom_messages_type'] == 'text' )
264 - return $settings['wppb_restriction_fallback_text'];
265 - elseif( $settings['wppb_restriction_custom_messages_type'] == 'template' ) {
266 - return $this->render_template( $settings['wppb_restriction_fallback_template'] );
271 + $custom_message_type = isset( $settings['wppb_restriction_custom_messages_type'] ) ? $settings['wppb_restriction_custom_messages_type'] : '';
272 +
273 + if( $custom_message_type == 'text' )
274 + return isset( $settings['wppb_restriction_fallback_text'] ) ? $settings['wppb_restriction_fallback_text'] : '';
275 + elseif( $custom_message_type == 'template' ) {
276 + return isset( $settings['wppb_restriction_fallback_template'] ) ? $this->render_template( $settings['wppb_restriction_fallback_template'] ) : '';
267 277 }
268 278 } else {
269 279 if( is_user_logged_in() )
270 280 return wppb_content_restriction_process_content_message( 'logged_in', get_current_user_id() );
@@ -338,8 +348,26 @@
338 348 $document = \Elementor\Plugin::$instance->documents->get_current();
339 349
340 350 return wppb_content_restriction_filter_content( $content, $document->get_post() );
341 351 }
352 +
353 + public function are_content_restriction_rules_setup( $is_dynamic_content, $data, $element ){
354 +
355 + if( empty( $data['settings'] ) )
356 + return $is_dynamic_content;
357 +
358 + if( isset( $data['settings']['wppb_restriction_loggedin_users'] ) && $data['settings']['wppb_restriction_loggedin_users'] == 'yes' )
359 + return true;
360 +
361 + if( isset( $data['settings']['wppb_restriction_loggedout_users'] ) && $data['settings']['wppb_restriction_loggedout_users'] == 'yes' )
362 + return true;
363 +
364 + if( isset( $data['settings']['wppb_restriction_user_roles'] ) && !empty( $data['settings']['wppb_restriction_user_roles'] ) )
365 + return true;
366 +
367 + return $is_dynamic_content;
368 +
369 + }
342 370 }
343 371
344 372 // Instantiate Plugin Class
345 373 WPPB_Elementor::instance();