has_premium_meta() public méthode

public has_premium_meta ( $the_post )
 function mp_content_placement_exemptions($content, $CheckEditPermission = true)
 {
     global $post;
     $excluded_posts = get_option(MediaPass_Plugin::OPT_EXCLUDED_POSTS);
     $included_posts = get_option(MediaPass_Plugin::OPT_INCLUDED_POSTS);
     $enable = false;
     if (current_user_can('edit_posts') && !CheckEditPermission) {
         // when the user is editing the content, we want to show the short codes
         $enable = false;
         // has premium meta
     } else {
         if (MediaPass_Plugin::has_premium_meta($post) && (count($excluded_posts) == 0 || !isset($excluded_posts[$post->ID]))) {
             $enable = true;
         } else {
             if (MediaPass_Plugin::has_premium_meta($post) && isset($excluded_posts[$post->ID])) {
                 $enable = false;
                 // following doesn't have premium meta
             } else {
                 if (isset($included_posts[$post->ID])) {
                     $enable = $included_posts[$post->ID];
                     // will take the form of true or false
                 } else {
                     if (MediaPass_ContentHelper::has_existing_protection($content)) {
                         $enable = true;
                     }
                 }
             }
         }
     }
     // either enable or disable the short codes / overlay
     if ($enable) {
         $content = MediaPass_ContentHelper::enable_overlay($content, "", !$CheckEditPermission);
     } else {
         $content = MediaPass_ContentHelper::strip_all_shortcodes($content);
     }
     /*
     if (current_user_can('edit_posts') || (!MediaPass_Plugin::has_premium_meta($post) && (isset($excluded_posts[$post->ID]) || !$included_posts[$post->ID]))){
     	$content = MediaPass_ContentHelper::strip_all_shortcodes($content);
     } else if (MediaPass_ContentHelper::has_existing_protection($content)){
     	$content = MediaPass_ContentHelper::enable_overlay($content);
     } else {
     	$content = MediaPass_ContentHelper::enable_overlay($content);
     }
     */
     return $content;
 }
 public function add_save_shortcodes($content)
 {
     global $post;
     $excluded_posts = get_option(MediaPass_Plugin::OPT_EXCLUDED_POSTS);
     $included_posts = get_option(MediaPass_Plugin::OPT_INCLUDED_POSTS);
     $PremiumMeta = MediaPass_Plugin::has_premium_meta($post);
     $Protection = MediaPass_ContentHelper::has_existing_protection($content);
     if ($PremiumMeta && $Protection) {
         if (isset($included_posts[$post->ID])) {
             unset($included_posts[$post->ID]);
         }
         // Remove any exclusions
         if (isset($excluded_posts[$post->ID])) {
             unset($excluded_posts[$post->ID]);
         }
     } else {
         if (!$PremiumMeta && $Protection) {
             $included_posts[$post->ID] = true;
             // Remove any exclusions
             if (isset($excluded_posts[$post->ID])) {
                 unset($excluded_posts[$post->ID]);
             }
         } else {
             if ($PremiumMeta && !$Protection) {
                 if (isset($included_posts[$post->ID])) {
                     unset($included_posts[$post->ID]);
                 }
                 $excluded_posts[$post->ID] = true;
             } else {
                 if (!$PremiumMeta && !$Protection) {
                     if (isset($included_posts[$post->ID])) {
                         unset($included_posts[$post->ID]);
                     }
                     // Remove any exclusions
                     if (isset($excluded_posts[$post->ID])) {
                         unset($excluded_posts[$post->ID]);
                     }
                 }
             }
         }
     }
     update_option(MediaPass_Plugin::OPT_EXCLUDED_POSTS, $excluded_posts);
     update_option(MediaPass_Plugin::OPT_INCLUDED_POSTS, $included_posts);
     return $content;
 }
 public function action_update_post_protection()
 {
     check_ajax_referer(self::TARGET_POST, 'nonce');
     if (!$this->can_protect_posts()) {
         die;
     }
     $data = json_decode(stripslashes($_POST['data']), true);
     $posts = $data['selectedPosts'];
     $action = $data['actionRequested'];
     $processed = array();
     foreach ($posts as $p) {
         $the_post = get_post($p);
         //if( $action == 'remove' && MediaPass_ContentHelper::has_existing_protection($the_post->post_content) ) {
         //	$the_post->post_content = MediaPass_ContentHelper::strip_all_shortcodes($the_post->post_content);
         //}
         wp_update_post($the_post);
         // If the post belongs to a Premium Category, Tag, or Author but the user marks it as Free then we should exclude it
         // If the post has been previously excluded and the user wants to add it back to be Premium then remove the post from the Exclusion
         // Alter the exclusion options
         $excluded_posts = get_option(MediaPass_Plugin::OPT_EXCLUDED_POSTS);
         $included_posts = get_option(MediaPass_Plugin::OPT_INCLUDED_POSTS);
         if (MediaPass_Plugin::has_premium_meta($the_post)) {
             if ($action == 'remove') {
                 // Remove inclusion, this post is now free
                 $included_posts[$the_post->ID] = false;
                 unset($included_posts[$the_post->ID]);
                 // Add an exclusion, so the post is free even if it has premium meta data
                 $excluded_posts[$the_post->ID] = true;
             } else {
                 // Add this inclusion, this post is now premium
                 $included_posts[$the_post->ID] = true;
                 // Remove any exclusions
                 if (isset($excluded_posts[$the_post->ID])) {
                     unset($excluded_posts[$the_post->ID]);
                 }
             }
         } else {
             // This will include or not include posts without premium meta data
             if ($action == 'remove') {
                 $included_posts[$the_post->ID] = false;
                 unset($included_posts[$the_post->ID]);
             } else {
                 $included_posts[$the_post->ID] = true;
                 // Remove any exclusions
                 if (isset($excluded_posts[$the_post->ID])) {
                     unset($excluded_posts[$the_post->ID]);
                 }
             }
         }
         update_option(MediaPass_Plugin::OPT_EXCLUDED_POSTS, $excluded_posts);
         update_option(MediaPass_Plugin::OPT_INCLUDED_POSTS, $included_posts);
         array_push($processed, $p);
     }
     $resp = array();
     $resp['result'] = "success";
     $resp['updatedStatus'] = $action == 'remove' ? 'unprotected' : 'protected';
     $resp['updatedPosts'] = $processed;
     echo json_encode($resp);
     die;
 }