function action_Wp($wp)
 {
     if (current_user_can("manage_options")) {
         return;
     }
     $settings = am4Settings::getInstance()->getAll();
     $access = new am4UserAccess();
     $type = $access->isLoggedIn() ? "user" : "guest";
     // handle blog protection;
     if ($settings['protected'] && !defined('AM_VERSION')) {
         if (!$access->isLoggedIn() || $access->isLoggedIn() && !$access->anyTrue(am4AccessRequirement::createRequirements($settings['access']))) {
             // First check if user try to access page that he is redirected to
             if (!($settings[$type . '_action'] == 'page' && is_page() && ($page = get_page($settings[$type . '_action_page'])) && $page->ID == $GLOBALS['wp_query']->post->ID)) {
                 $this->makeRedirect($type, $settings);
             }
         }
     }
     if (is_single() || is_page()) {
         $settings = $this->getPostAccess($GLOBALS['wp_query']->post);
         if ($settings['protected'] && !$access->anyTrue($this->getPostRequirements($GLOBALS['wp_query']->post))) {
             $this->makeRedirect($type, $settings);
         }
     }
     if (is_category()) {
         $cat_settings = get_option(AM4_CAT_OPTION);
         if (is_array($cat_settings) && ($settings = $cat_settings[$GLOBALS['wp_query']->query_vars['cat']]) && $settings['protected']) {
             if (!$access->anyTrue(am4AccessRequirement::createRequirements($settings['access']))) {
                 $this->makeRedirect($type, $settings, true);
             }
         }
     }
 }
Exemple #2
0
 function saveForm($options)
 {
     am4Settings::getInstance()->setAll($options);
 }