Exemple #1
0
 /**
  * Get default Term Access
  * 
  * @param array                   $access
  * @param aam_Control_Object_Term $object
  * 
  * @return array
  * 
  * @access public
  */
 public function termAccessOption($access, $object)
 {
     global $wp_post_types;
     $this->setSubject($object->getSubject());
     //find the object type
     $post_type = null;
     foreach ($wp_post_types as $type => $dump) {
         if (is_object_in_taxonomy($type, $object->getTerm()->taxonomy)) {
             $post_type = $type;
             break;
         }
     }
     if (empty($access)) {
         $access = aam_Core_API::getBlogOption($this->getOptionName($post_type), array());
     }
     return $access;
 }
Exemple #2
0
 /**
  * Inherit access from parent term
  * 
  * Go throught the hierarchical branch of terms and retrieve access from the 
  * first parent term that has access defined.
  * 
  * @param int $term_id
  * 
  * @return array
  * 
  * @access private
  */
 private function inheritAccess($term_id)
 {
     $term = new aam_Control_Object_Term($this->getSubject(), $term_id);
     $access = $term->getOption();
     if (isset($access['post']) && $access['post']) {
         $result = array('post' => $access['post']);
         $this->setInherited(true);
     } elseif (is_object($term->getTerm()) && $term->getTerm()->parent) {
         $result = $this->inheritAccess($term->getTerm()->parent);
     } else {
         $result = array();
     }
     return $result;
 }
Exemple #3
0
 /**
  *
  * @param type $term_id
  * @return array
  */
 private function inheritAccess($term_id)
 {
     $term = new aam_Control_Object_Term($this->getSubject(), $term_id);
     if ($term->getTerm()) {
         $access = $term->getOption();
         if (empty($access) && $term->getTerm()->parent) {
             $this->inheritAccess($term->getTerm()->parent);
         } elseif (!empty($access)) {
             $access['inherited'] = true;
         }
     } else {
         $access = array();
     }
     return $access;
 }