Beispiel #1
0
 public function children($post_type = 'any', $childPostClass = false)
 {
     $children = $this->post->children($post_type, $childPostClass);
     $return = array();
     foreach ($children as $child) {
         $return[] = new TimberProxy($child);
     }
     return $return;
 }
 function testPostChildren()
 {
     $parent_id = $this->factory->post->create();
     $children = $this->factory->post->create_many(8, array('post_parent' => $parent_id));
     $parent = new TimberPost($parent_id);
     $this->assertEquals(8, count($parent->children()));
 }
Beispiel #3
0
 function testPostChildrenWithArray()
 {
     $parent_id = $this->factory->post->create(array('post_type' => 'foo'));
     $children = $this->factory->post->create_many(8, array('post_parent' => $parent_id, 'post_type' => 'bar'));
     $children = $this->factory->post->create_many(4, array('post_parent' => $parent_id, 'post_type' => 'foo'));
     $parent = new TimberPost($parent_id);
     $this->assertEquals(12, count($parent->children(array('foo', 'bar'))));
 }
Beispiel #4
0
 function add_to_context($context)
 {
     // SITE INFO
     $context['site'] = $this;
     // PRIMARY MENU
     $context['primary_menu'] = array();
     // Loop through each primary menu item
     foreach (get_fields('option')['primary_menu'] as $key => $item) {
         $context['primary_menu'][$key] = $item;
         // Getting parent's info
         $context['primary_menu'][$key]['pm_children'] = array();
         $itemPost = new TimberPost($item['pm_parent']);
         $context['primary_menu'][$key]['pm_label'] = $itemPost->name();
         $context['primary_menu'][$key]['pm_link'] = $itemPost->link();
         // Loop through each primary menu item's children
         foreach ($itemPost->children('page') as $subitem) {
             $context['primary_menu'][$key]['pm_children'][$subitem->name()] = $subitem->link();
         }
     }
     // SECONDARY MENU
     $context['secondary_menu'] = get_fields('option')['secondary_menu'];
     // LANGUAGES
     $context['languages']['english'] = get_fields('option')['english'];
     $context['languages']['indonesian'] = get_fields('option')['indonesian'];
     // MISC MOBILE MENU
     $context['misc_menu'] = get_fields('option')['quicklinks'];
     // FOOTER
     $context['footer']['bg'] = get_fields('option')['footer_bg'];
     $context['footer']['slogan'] = get_fields('option')['footer_slogan'];
     $context['footer']['social'] = get_fields('option')['footer_social'];
     // GLOBAL SETTINGS
     $context['global']['name'] = get_fields('option')['global_name'];
     $context['global']['address'] = get_fields('option')['global_address'];
     $context['global']['contacts'] = get_fields('option')['global_contacts'];
     return $context;
 }