/** * Constructor * * @since 0.1.3 * * @param string $search_query * @param GCS_Sermons $sermons * @param GCS_Series $series */ public function __construct($search_query, $atts, GCS_Sermons $sermons, GCS_Series $series) { $this->search_query = $search_query; $this->current_page = absint(gc__get_arg('results-page', 1)); parent::__construct($sermons, $series); $this->create_shortcode_object(shortcode_atts($this->atts_defaults, $atts, $this->shortcode), ''); }
/** * Shortcode Output */ public function shortcode() { $this->search_query = gc__get_arg('sermon-search', ''); $show_results = gc__get_arg('results-for', ''); $series_slug = $this->taxonomies->series->taxonomy(); $cpt_slug = $this->sermons->post_type(); $to_search = $this->att('search'); $search_both = !$to_search; $format = current_theme_supports('html5', 'search-form') ? 'html5' : 'xhtml'; $format = apply_filters('search_form_format', $format); $template = 'searchform' . ('xhtml' === $format ? '-' . $format : ''); $args = array('search_query' => $this->search_query, 'action_url' => add_query_arg('sermon-search', 1), 'sermons_value' => $cpt_slug, 'sermons_label' => $this->sermons->post_type('singular'), 'series_value' => $series_slug, 'series_label' => $this->taxonomies->series->taxonomy('singular'), 'show_filter' => $search_both, 'show_results' => $show_results); $content = GCS_Template_Loader::get_template($template, $args); // If a search was performed, let's get the results. if ($this->search_query) { if (strlen($this->search_query) < 3) { // Uh-oh, we need at least 3 characters. $content .= GCS_Template_Loader::get_template('search-query-error'); } else { $show_sermon_results = !$show_results || $cpt_slug === $show_results; $show_series_results = !$show_results || $series_slug === $show_results; $search_sermons = $search_both || in_array($to_search, array('sermons'), 1); $search_series = $search_both || in_array($to_search, array('series'), 1); if ($search_sermons && $show_sermon_results) { $content .= $this->sermon_search_results(); } if ($search_series && $show_series_results) { $content .= $this->series_search_results(); } } } return $content; }
/** * Gets the previous search results page link when using the search widget. * * @since 0.1.5 * * @return string Next results page link, if there is a previous page. */ function gc_search_get_previous_results_link() { $page = absint(gc__get_arg('results-page', 1)); $link = ''; if ($page-- > 1) { $url = $page > 1 ? add_query_arg('results-page', $page) : remove_query_arg('results-page'); $link = sprintf('<a href="%s" %s>%s</a>', esc_url($url), apply_filters('gc_previous_results_page_link_attributes', ''), __('<span>←</span> Newer', 'gc-sermons')); } return $link; }
/** * Constructor * * @since 0.1.3 * * @param string $search_query * @param GCS_Sermons $sermons * @param GCS_Taxonomies $taxonomies */ public function __construct($search_query, GCS_Sermons $sermons, GCS_Taxonomies $taxonomies) { $this->search_query = $search_query; $this->current_page = absint(gc__get_arg('results-page', 1)); parent::__construct($sermons, $taxonomies); }