public function __construct($data) { $this->name = isset($data['name']) ? $data['name'] : ''; $this->tag = isset($data['tag']) ? $data['tag'] : ''; $this->tag_type = isset($data['tag_type']) ? $data['tag_type'] : ''; $this->content = isset($data['content']) ? $data['content'] : ''; $this->before = isset($data['before']) ? $data['before'] : ''; $this->after = isset($data['after']) ? $data['after'] : ''; $this->attributes = isset($data['attributes']) ? $data['attributes'] : array(); $this->hide = isset($data['hide']) ? $data['hide'] : false; $this->suppress_filters = isset($data['suppress_filters']) ? $data['suppress_filters'] : true; $this->markup = ''; if (isset($data['post'])) { $this->post_object = $data['post']; } else { $this->post_object = get_post(); } // Ensures that the 'class' attribute is set if it wasn't passed in with attributes. if (!isset($this->attributes['class'])) { $this->attributes['class'] = array(); } // Add the Atom name as a class $this->attributes['class'][] = $this->name; if (!empty($data['class'])) { $classes_arr = Utility::parse_classes_as_array($data['class']); if (!empty($classes_arr)) { $this->attributes['class'] = array_merge($this->attributes['class'], $classes_arr); } } unset($this->class); // Filter the Atom properties. $atom_structure_filter = $this->name . '_properties_filter'; apply_filters($atom_structure_filter, $this, $data); Atom::add_debug_entry('Filter', $atom_structure_filter); }
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 = 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]]]]; } }
public function __construct($data) { parent::__construct($data); if ('' === $this->name) { $this->name = 'list-pages'; } $this->tag = isset($data['tag']) ? $data['tag'] : 'ul'; // Set up default list args. $list_args_defaults_arr = ['post_type' => 'page', 'echo' => 0, 'title_li' => '']; // Parse supplied args from the organism setup. if (isset($data['list_args'])) { $list_args_arr = wp_parse_args($data['list_args'], $list_args_defaults_arr); } else { $list_args_arr = $list_args_defaults_arr; } /** * list_pages_list_args. * * A generic filter for site-wide use. * * @since 0.5.0 * * @param array $list_args_arr An array of list arguments. */ $list_args_arr = apply_filters('list_pages_list_args', $list_args_arr); Atom::add_debug_entry('Filter', 'list_pages_list_args'); /** * $this->name_list_pages_list_args. * * An atom-specific wp_list_categories args filter. * * @since 0.5.0 * * @param array $list_args_arr An array of list arguments. */ $list_args_arr_filter = $this->name . '_list_pages_list_args'; $list_args_arr = apply_filters($list_args_arr_filter, $list_args_arr); Atom::add_debug_entry('Filter', $list_args_arr_filter); // Assign the resolved args to the object. $this->list_args = $list_args_arr; $this->content = wp_list_pages($this->list_args); }
public function __construct($data) { parent::__construct($data); if (!isset($data['name'])) { $this->name = 'eventbadge'; } $this->tag = 'p'; if (isset($data['badge_pieces'])) { $badge_pieces_arr = $data['badge_pieces']; } else { $badge_pieces_arr = ['month' => date('F', $this->event_start_date), 'day' => date('d', $this->event_start_date)]; } $badge_pieces_arr_filter = $this->name . '_badge_pieces_arr'; $badge_pieces_arr = apply_filters($badge_pieces_arr_filter, $badge_pieces_arr); Atom::add_debug_entry('Filter', $badge_pieces_arr_filter); $badge_pieces_markup_arr = array(); foreach ($badge_pieces_arr as $badge_label => $badge_piece) { $format = '<span class="' . $this->name . '__%1$s">%2$s</span>'; $badge_pieces_markup_arr[$badge_label] = sprintf($format, $badge_label, $badge_piece); } $this->badge_pieces = $badge_pieces_markup_arr; $this->content = implode('', $this->badge_pieces); }
private function determine_fallback_subnav_type() { global $post; $behavior = ''; if (is_home()) { $behavior = 'archive-home'; } if (is_post_type_archive()) { $behavior = 'archive-post_type'; } if (is_tax() || is_category()) { $behavior = 'archive-taxonomy'; } if (is_singular()) { if (is_post_type_hierarchical($post->post_type)) { $behavior = 'single-hierarchical'; } else { $behavior = 'single-nonhierarchical'; } } $behavior = apply_filters('subnav_location', $behavior); Atom::add_debug_entry('Filter,', 'subnav_location'); $subnav_location_filter = $this->name . '_subnav_location'; $behavior = apply_filters($subnav_location_filter, $behavior); Atom::add_debug_entry('Filter,', $subnav_location_filter); if ('' === $behavior) { return false; } else { $this->behavior = $behavior; } }
/** * get_post_pieces * * Function for looking * * @param $type * @param string $return_format * @param $current_post_index * @param $total_posts_count * * @return array|string */ protected function get_post_pieces($type, $return_format = 'string', $current_post_index, $total_posts_count) { if ('string' === $return_format) { $return = ''; } if ('array' === $return_format) { $return = array(); } $current_post_index_type_property = 'post_' . $current_post_index . '_' . $type; $post_first_type_property = 'post_first_' . $type; $post_last_type_property = 'post_last_' . $type; $post_even_type_property = 'post_even_' . $type; $post_odd_type_property = 'post_odd_' . $type; // Check for first post. if (isset($this->{$post_first_type_property}) && 0 === $current_post_index) { $return = $this->{$post_first_type_property}; } // Check for last post. if (isset($this->{$post_last_type_property}) && $total_posts_count - 1 === $current_post_index) { $return = $this->{$post_last_type_property}; } // Check for even post. if (isset($this->{$post_even_type_property}) && 0 === $current_post_index % 2) { $return = $this->{$post_even_type_property}; } // Check for odd post. if (isset($this->{$post_odd_type_property}) && 0 !== $current_post_index % 2) { $return = $this->{$post_odd_type_property}; } // Check for specific index. if (isset($this->{$current_post_index_type_property}) && !empty($this->{$current_post_index_type_property})) { $return = $this->{$current_post_index_type_property}; } // This is the one non-agnostic part of this function, so that we're always assured to get the posts structure. if ('structure' === $type && empty($return)) { $return = $this->posts_structure; } // Add a filter for good measure. $organism_name_post_type_filter = $this->name . '_post_' . $type; $return = apply_filters($organism_name_post_type_filter, $return, $current_post_index, $total_posts_count); Atom::add_debug_entry('Filter', $organism_name_post_type_filter); return $return; }
private function setDateFormat() { switch ($this->event_date_type) { case 'now': // Now - 1:45 PM $event_date_formatted = sprintf('Now - %s', date('g:i A', $this->event_end_date)); break; case 'allday-single': // Jan 1, 2016 - All Day $event_date_formatted = date('M j, Y', $this->event_start_date) . ' - All Day'; break; case 'allday-multiple': // Mon, Jan 13 - Fri, Jan 18 $event_date_formatted = sprintf('%s - %s', date('D, M j, Y', $this->event_start_date), date('D, M j, Y', $this->event_end_date)); break; case 'single-day': // 11:05 AM - 1:45 PM $event_date_formatted = sprintf('%s - %s', date('g:i A', $this->event_start_date), date('g:i A', $this->event_end_date)); break; default: // Mon, Jan 13 @ 11:05 AM - Fri, Jan 18 @ 1:45 PM $event_date_formatted = sprintf('%s - %s', date('D, M j, Y @ g:i A', $this->event_start_date), date('D, M j, Y @ g:i A', $this->event_end_date)); break; } /** * event_date_format. * * A site-wide filter for adjusting the event date format. * * @since 0.5.0 * * @param string $var The formatted event date. * @param string $this ->event_date_type Include the event date type so that making an intelligent adjustment is easier. */ $event_date_formatted = apply_filters('event_date_format', $event_date_formatted, $this); Atom::add_debug_entry('Filter', 'event_date_format'); /** * $this->name_event_date_format. * * An atom-specific event date format filter. * * @since 0.5.0 * * @param string $var The formatted event date. * @param string $this ->event_date_type Include the event date type so that making an intelligent adjustment is easier. */ $event_date_format_filter = $this->name . '_event_date_format'; $this->event_date_formatted = apply_filters($event_date_format_filter, $event_date_formatted, $this); Atom::add_debug_entry('Filter', $event_date_format_filter); }