class.swpm-protection.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. include_once('class.swpm-protection-base.php');
  3. class SwpmProtection extends SwpmProtectionBase {
  4. private static $_this;
  5. private function __construct() {
  6. $this->msg = "";
  7. $this->init(1);
  8. }
  9. public static function get_instance() {
  10. self::$_this = empty(self::$_this) ? (new SwpmProtection()) : self::$_this;
  11. return self::$_this;
  12. }
  13. public function is_protected($id) {
  14. if ($this->post_in_parent_categories($id) || $this->post_in_categories($id)) {
  15. $this->msg = '<p style="background: #FFF6D5; border: 1px solid #D1B655; color: #3F2502; margin: 10px 0px 10px 0px; padding: 5px 5px 5px 10px;">
  16. ' . SwpmUtils::_('The category or parent category of this post is protected. You can change the category protection settings from the ') .
  17. '<a href="admin.php?page=simple_wp_membership_levels&level_action=category_list" target="_blank">' . SwpmUtils::_('category protection menu') . '</a>.
  18. </p>';
  19. return true;
  20. }
  21. return $this->in_posts($id) || $this->in_pages($id) || $this->in_attachments($id) || $this->in_custom_posts($id);
  22. }
  23. public function get_last_message() {
  24. return $this->msg;
  25. }
  26. public function is_protected_post($id) {
  27. return /* (($this->bitmap&4) != 4) && */ $this->in_posts($id);
  28. }
  29. public function is_protected_page($id) {
  30. return /* (($this->bitmap&4) != 4) && */ $this->in_pages($id);
  31. }
  32. public function is_protected_attachment($id) {
  33. return /* (($this->bitmap&16)!=16) && */ $this->in_attachments($id);
  34. }
  35. public function is_protected_custom_post($id) {
  36. return /* (($this->bitmap&32)!=32) && */ $this->in_custom_posts($id);
  37. }
  38. public function is_protected_comment($id) {
  39. return /* (($this->bitmap&2)!=2) && */ $this->in_comments($id);
  40. }
  41. public function is_post_in_protected_category($post_id) {
  42. return /* (($this->bitmap&1)!=1) && */ $this->post_in_categories($post_id);
  43. }
  44. public function is_post_in_protected_parent_category($post_id) {
  45. return /* (($this->bitmap&1)!=1) && */ $this->post_in_parent_categories($post_id);
  46. }
  47. public function is_protected_category($id) {
  48. return /* (($this->bitmap&1)!=1) && */ $this->in_categories($id);
  49. }
  50. public function is_protected_parent_category($id) {
  51. return /* (($this->bitmap&1)!=1) && */ $this->in_parent_categories($id);
  52. }
  53. }