public function add_post_custom_column($column) { global $post; if ($column !== 'mediapass') { return; } $result = MediaPass_ContentHelper::has_existing_protection($post->post_content); $included_posts = get_option(MediaPass_Plugin::OPT_INCLUDED_POSTS); if (isset($included_posts[$post->ID])) { $result = $included_posts[$post->ID]; } if (MediaPass_Plugin::has_premium_meta($post)) { $result = true; } $excluded_posts = get_option(MediaPass_Plugin::OPT_EXCLUDED_POSTS); if (isset($excluded_posts[$post->ID])) { $result = false; } echo $this->dump_protection_markup($result, $post->ID); }
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; }
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; }