public function __construct($data = array())
 {
     parent::__construct($data);
     if (!isset($data['name'])) {
         $this->name = 'eventlist';
     }
     if (!isset($data['posts'])) {
         $event_args = array();
         // Get the active plugins.
         $active_plugins = get_option('active_plugins');
         // We do some guessing here for Tzolkin
         if (in_array('tzolkin/tzolkin.php', $active_plugins)) {
             $event_args = ['post_type' => 'tz_events'];
         }
         // Some more guessing for The Events Calendar
         if (in_array('the-events-calendar/the-events-calendar.php', $active_plugins)) {
             $event_args = ['post_type' => \Tribe__Events__Main::POSTTYPE, 'orderby' => 'event_date', 'order' => 'ASC', 'posts_per_page' => tribe_get_option('postsPerPage', 10), 'tribe_render_context' => 'default'];
         }
         $eventlist_event_args_filter = $this->name . '_event_args';
         $event_args = apply_filters($eventlist_event_args_filter, $event_args);
         Atom::add_debug_entry('Filter', $eventlist_event_args_filter);
         $this->posts = new \WP_Query($event_args);
     }
     if (!isset($data['posts-structure'])) {
         $posts_structure = ['PostClass' => ['children' => ['image', 'text']], 'image' => ['parts' => ['PostThumbnail']], 'text' => ['parts' => ['EventBadge', 'PostTitleLink', 'EventDate', 'ForceExcerpt', 'PostLink' => 'Read More']]];
         $postlist_posts_structure_filter = $this->name . '_posts_structure';
         $this->posts_structure = apply_filters($postlist_posts_structure_filter, $posts_structure);
         Atom::add_debug_entry('Filter', $postlist_posts_structure_filter);
     }
 }
 public function __construct($data)
 {
     if (!isset($data['name']) && '' === $this->name) {
         $this->name = 'postlist';
     }
     if (!isset($data['posts-structure']) || empty($data['posts-structure'])) {
         $data['posts-structure'] = ['PostClass' => ['children' => ['image', 'text']], 'image' => ['parts' => ['PostThumbnail']], 'text' => ['parts' => ['PostTitleLink', 'PostDate' => 'm/d/Y', 'CategoryList', 'ExcerptForce', 'PostLink' => 'Read More']]];
     }
     parent::__construct($data);
 }
 public function __construct($data = array())
 {
     parent::__construct($data);
     if (!isset($data['name'])) {
         $this->name = 'postheader';
     }
     if (!isset($data['structure'])) {
         $structure = ['title' => ['atom' => 'PostTitleLink', 'sibling' => 'date'], 'date' => ['atom' => 'PostDate', 'sibling' => 'author'], 'author' => ['atom' => 'PostAuthor', 'sibling' => 'categories'], 'categories' => ['atom' => 'CategoryList', 'sibling' => 'excerpt'], 'excerpt' => ['atom' => 'ExcerptForce']];
         if (is_search()) {
             $structure['excerpt']['atom'] = 'ExcerptSearch';
         }
         $postheader_structure_filter = $this->name . '_archive_structure';
         $this->structure = apply_filters($postheader_structure_filter, $structure);
         Atom::add_debug_entry('Filter', $postheader_structure_filter);
     }
 }
 public function __construct($data = array())
 {
     parent::__construct($data);
     if (!isset($data['name'])) {
         $this->name = 'section';
     }
     if (!isset($data['tag'])) {
         $this->name = 'header';
     }
     if (!isset($data['structure'])) {
         $ancestor = get_highest_ancestor();
         $section_title_filter = $this->name . '_title';
         $title = apply_filters($section_title_filter, $ancestor['title']);
         Atom::add_debug_entry('Filter,', $section_title_filter);
         $this->structure = ['row' => ['children' => ['column']], 'column' => ['parts' => ['title' => ['tag' => 'h2', 'content' => $title]]]];
     }
 }
Ejemplo n.º 5
0
 public function __construct($data = array())
 {
     parent::__construct($data);
     if (!isset($data['name'])) {
         $this->name = 'subnav';
     }
     // Add the Organism name as a class
     $this->attributes['class'][] = $this->name;
     // May need to refactor the way the SubnavType is determined in order for settings like this to function properly
     $default_behaviors = ['front-page' => ['behavior' => 'none'], 'home' => ['behavior' => 'archive-post_type', 'taxonomy' => 'category', 'title' => 'All Post Categories'], '404' => ['behavior' => 'none'], 'search' => ['behavior' => 'none'], 'post' => ['single' => ['behavior' => 'single-nonhierarchical', 'taxonomy' => 'category', 'title' => 'Post Categories']], 'category' => ['behavior' => 'none'], 'tag' => ['behavior' => 'none'], 'page' => ['single' => ['title' => 'Pages in this Section']], 'tribe_events' => ['single' => ['behavior' => 'archive-post_type', 'taxonomy' => 'tribe_events_cat', 'title' => 'Event Categories'], 'archive' => ['taxonomy' => 'tribe_events_cat', 'title' => 'Event Categories']], 'tribe_events_cat' => ['behavior' => 'none']];
     // Parse custom content settings.
     if (isset($data['settings_by_content_type'])) {
         $this->settings_by_content_type = array_replace_recursive($default_behaviors, $data['settings_by_content_type']);
     } else {
         $this->settings_by_content_type = $default_behaviors;
     }
     // Figure out which page we're dealing with here.
     self::determine_subnav_settings();
     // Parse global list args
     if (isset($data['list_args'])) {
         $this->list_args = $data['list_args'];
     }
     // Merge any post-type view-specific list args into the defaults.
     if (isset($this->settings['list_args'])) {
         $this->list_args = array_merge($this->list_args, $this->settings['list_args']);
     }
     $this->list_args['subnav'] = true;
     if (isset($this->settings['behavior'])) {
         $this->behavior = $this->settings['behavior'];
     } else {
         self::determine_fallback_subnav_type();
     }
     /* @EXIT: "none" tells us that there isn't supposed to be a subnanv here. */
     if ('none' === $this->behavior) {
         return false;
     }
     if (isset($this->settings['title'])) {
         $this->title = $this->settings['title'];
     }
     $this->manual_additions = array();
     if (isset($data['manual_additions'])) {
         $this->manual_additions = $data['manual_additions'];
     }
     // Get the subnav items, based on the type of subnav
     self::get_subnav_items();
     // Return false if there is no list AND no manual additions.
     if ('' === $this->list && empty($this->manual_additions)) {
         return false;
     }
     // Structure setup is left till here so that we don't return an empty list by accident.
     if (!isset($data['structure'])) {
         // 'List' is initialized here so that manual items can be added after it.
         $this->structure = ['title' => ['tag' => 'h4', 'content' => $this->title, 'sibling' => 'items'], 'items' => ['parts' => ['list']]];
         // Add a separator and the manual items after the main list.
         if (!empty($this->manual_additions)) {
             $this->structure['items']['parts']['separator'] = '';
             $this->structure['items']['parts']['manual'] = $this->manual_additions;
         }
     } else {
         $this->structure = $data['structure'];
     }
     // Add the list in separately, so that different structure can be passed in independent from the list.
     // It is up to the dev to take care that "items" is listed as a child or sibling.
     $this->structure['items']['parts']['list'] = $this->list;
     return true;
 }