public function __construct($args) { global $stt2extat_query, $wp; if (is_admin()) { $wp = $stt2extat_query; } $searchterms = isset($args['searchterms']) ? sanitize_text_field($args['searchterms']) : null; $post_id = isset($args['post_id']) ? absint($args['post_id']) : null; $highlight = isset($args['highlight']) ? $args['highlight'] : '<mark>\\0</mark>'; if (null == $searchterms) { $text = stt2extat_filter_text($wp->query_vars['s']); $this->text = !is_array($text) ? $text : ''; } else { $this->text = $searchterms; } $this->post_id = $post_id; $this->highlight = $highlight; }
/** * proccess terms from referrer * * @since 1.1 * */ public function ref_proccess($referrer) { $this->referrer = !empty($referrer) ? esc_url($referrer) : false; $post_ids = isset($_POST['post_ID']) && is_array($_POST['post_ID']) ? $_POST['post_ID'] : stt2extat_post_ids_query(); $post_ids = array_map('absint', $post_ids); $localhost = $this->allow_localhost(); $this->referrer = $this->get_referer(); if (false != $localhost) { $this->referrer = $localhost; } if (!$this->referrer || !is_array($this->referrer) || !array_filter($this->referrer)) { return false; } if (false != $this->get_delimiter()) { if (3 < mb_strlen($this->get_term()) && 70 >= mb_strlen($this->get_term())) { global $stt2extat_data; $last_id = (int) $stt2extat_data->last_id + (int) 1; $q = stt2extat_filter_text($this->get_term()); if (isset($q['error']) || '' == $q) { return false; } $ignore = apply_filters('stt2extat_ignore_relevant', true); $post_id = stt2extat_get_the_id_relevant_post($post_ids, $q, $ignore); if (null == $post_id) { return false; } do_action('stt2extat_nopriv_update_post_meta', $q, $post_id, null, $last_id, $stt2extat_data->terms, null); } } return false; }
/** * sanitize text for plugin search excerpt * * @since 1.1 * */ public function remove_char($q) { if ('' != $q) { $q = stt2extat_filter_text($q); if (!isset($q['error'])) { return $q; } } return 0; }
/** * filter get_search_link * * @since 1.1 * */ function stt2extat_filter_search_link($link, $search) { $query = stt2extat_filter_text($search); if (empty($query) || isset($query['error'])) { return home_url(); } $slug = stt2extat_create_slug($query); $link = stt2extat_create_link($slug); return $link; }