Advertisement
verygoodplugins

Untitled

Oct 13th, 2018
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | None | 0 0
  1.     private function can_access( $element ) {
  2.  
  3.         if( is_admin() ) {
  4.             return true;
  5.         }
  6.  
  7.         $widget_tags = $element->get_settings( 'wpf_tags' );
  8.  
  9.         $widget_tags_not = $element->get_settings( 'wpf_tags_not' );
  10.  
  11.         if( empty( $widget_tags ) && empty( $widget_tags_not ) ) {
  12.             return true;
  13.         }
  14.  
  15.         if ( wp_fusion()->settings->get( 'exclude_admins' ) == true && current_user_can( 'manage_options' ) ) {
  16.             return true;
  17.         }
  18.  
  19.         $can_access = true;
  20.  
  21.         if( is_user_logged_in() ) {
  22.  
  23.             // See if user has required tags
  24.             $user_tags = wp_fusion()->user->get_tags();
  25.  
  26.             if( ! empty( $widget_tags ) ) {
  27.  
  28.                 $result = array_intersect( $widget_tags, $user_tags );
  29.  
  30.                 if( empty( $result ) ) {
  31.                     $can_access = false;
  32.                 }
  33.  
  34.             }
  35.  
  36.             if( $can_access == true && ! empty( $widget_tags_not ) ) {
  37.  
  38.                 $result = array_intersect( $widget_tags_not, $user_tags );
  39.  
  40.                 if( ! empty( $result ) ) {
  41.                     $can_access = false;
  42.                 }
  43.  
  44.             }
  45.  
  46.         } else {
  47.  
  48.             // Not logged in
  49.             $can_access = false;
  50.  
  51.         }
  52.  
  53.         $can_access = apply_filters( 'wpf_elementor_can_access', $can_access, $element, $user_tags );
  54.  
  55.         if( $can_access ) {
  56.             return true;
  57.         } else {
  58.             return false;
  59.         }
  60.  
  61.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement