filter the posts using a tag if supplied
434984
function filterTag(posts) {
      var reTag = new RegExp(tag);
      return posts.filter(function filterPosts(post) {
        return post.tags.data.some(function checkRe(postTag) {
          return reTag.test(postTag.name);
        });
      });
    }
1173055
function filterScriptTag(html, config) {
    var result;

    if (config.removeMatchedTag) {
        result = html.replace(REGEXP_TAG_SCRIPT, '');
    } else {
        result = html.replace(REGEXP_TAG_SCRIPT, function(body) {
            return escapeTags(body);
        });
    }

    return result;
}
1138687
def apply_post_filters(instance, html):
    
    for post_func in appsettings.POST_FILTER_FUNCTIONS:
        html = post_func(instance, html)

    return html
400230
public function FilterDescription()
    {
        $params = $this->parseParams();

        $filters = array();
        if ($params['tag']) {
            $term = TaxonomyTerm::get_by_id(TaxonomyTerm::class, $params['tag']);
            if ($term) {
                $filters[] = _t(
                    'CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_WITHIN',
                    'within'
                ) . ' "' . $term->Name . '"';
            }
        }

        if ($params['from'] || $params['to']) {
            if ($params['from']) {
                $from = strtotime($params['from']);
                if ($params['to']) {
                    $to = strtotime($params['to']);
                    $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_BETWEEN', 'between') . ' '
                        . date('j/m/Y', $from) . ' and ' . date('j/m/Y', $to);
                } else {
                    $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_ON', 'on')
                        . ' ' . date('j/m/Y', $from);
                }
            } else {
                $to = strtotime($params['to']);
                $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_ON', 'on')
                    . ' ' . date('j/m/Y', $to);
            }
        }

        if ($params['year'] && $params['month']) {
            $timestamp = mktime(1, 1, 1, $params['month'], 1, $params['year']);
            $filters[] = _t('CWP\\CWP\\PageTypes\\DatedUpdateHolder.FILTER_IN', 'in')
                . ' ' . date('F', $timestamp) . ' ' . $params['year'];
        }

        if ($filters) {
            return $this->getUpdateName() . ' ' . implode(' ', $filters);
        }
    }
986871
public function findEnabledAllPostsThatHaveTagId($tagId)
    {
        // Well, it's late, and the exact eloquent relational query that works for categories
        // is not working for tags. All seems well, it really should be working.
        // So, let's just use DB to get the job done.
        //$collection = $this->model->find($tagId)->post->sortByDesc('updated_at');

        $raw = DB::raw('SELECT * FROM posts JOIN post_tag on posts.id = post_tag.post_id WHERE post_tag.tag_id = '.$tagId.' AND  posts.enabled = 1 AND posts.publish_on < CURDATE() ORDER BY updated_at DESC');

        $results = DB::select($raw);

        if ( count($results) == 0 ) {
            return 0;
        }

        return $results;
    }
65513
public function tag()
    {
        if (!appSetting('tags_enabled', 'blog-' . $this->oBlog->id) || !$this->uri->rsegment(4)) {

            show404();
        }

        // --------------------------------------------------------------------------

        //  Get tag
        $this->data['tag'] = $this->blog_tag_model->getBySlug($this->uri->rsegment(4));

        if (!$this->data['tag']) {

            show404();
        }

        // --------------------------------------------------------------------------

        //  Widgets
        $this->fetchSidebarWidgets();

        // --------------------------------------------------------------------------

        //  Meta
        $this->data['page']->title = $this->oBlog->label . ': ' . ucfirst($this->data['postNamePlural']) . ' tagged with "' . $this->data['tag']->label . '"';
        $this->data['page']->seo->description = 'All ' . $this->data['postNamePlural'] . ' tagged with  ' . $this->data['tag']->label . ' ';
        $this->data['page']->seo->keywords    = '';

        // --------------------------------------------------------------------------

        //  Handle pagination
        $page     = $this->uri->rsegment(5);
        $perPage = appSetting('home_per_page', 'blog-' . $this->oBlog->id);
        $perPage = $perPage ? $perPage : 10;

        $this->data['pagination']           = new stdClass();
        $this->data['pagination']->page     = $page;
        $this->data['pagination']->per_page = $perPage;

        // --------------------------------------------------------------------------

        //  Send any additional data
        $data                    = array();
        $data['include_body']    = !appSetting('use_excerpts', 'blog-' . $this->oBlog->id);
        $data['include_gallery'] = appSetting('home_show_gallery', 'blog-' . $this->oBlog->id);
        $data['sort']            = array('bp.published', 'desc');

        //  Only published items which are not schduled for the future
        $data['where']   = array();
        $data['where'][] = array('column' => 'bp.blog_id',   'value' => $this->oBlog->id);
        $data['where'][] = array('column' => 'is_published', 'value' => true);
        $data['where'][] = array('column' => 'published <=', 'value' => 'NOW()', 'escape' => false);

        // --------------------------------------------------------------------------

        //  Load posts and count
        $this->data['posts'] = $this->blog_post_model->getWithTag($this->data['tag']->id, $page, $perPage, $data);
        $this->data['pagination']->total = $this->blog_post_model->countAll($data);

        // --------------------------------------------------------------------------

        //  Any SEO data?
        if (!empty($this->data['tag']->seo_title)) {

            $this->data['page']->title = $this->data['tag']->seo_title;
        }

        if (!empty($this->data['tag']->seo_description)) {

            $this->data['page']->seo->description = $this->data['tag']->seo_description;
        }

        if (!empty($this->data['tag']->seo_keywords)) {

            $this->data['page']->seo->keywords = $this->data['tag']->seo_keywords;
        }

        // --------------------------------------------------------------------------

        //  Finally, let the views know this is an 'archive' type page
        $this->data['archive_title']       = ucfirst($this->data['postNamePlural']) . ' in tag "' . $this->data['tag']->label . '"';
        $this->data['archive_description'] = $this->data['tag']->description;
        $this->data['isTag']               = true;

        // --------------------------------------------------------------------------

        $oView = Factory::service('View');
        $oView->load('structure/header', $this->data);
        $this->loadView('browse', $this->data);
        $oView->load('structure/footer', $this->data);
    }
1132735
def filter(self, table, users, filter_string):
        """"""
        q = filter_string.lower()
        return [user for user in users
                if (q in user.name.lower() or
                    q in (getattr(user, 'email', None) or '').lower())]
1332304
function getPosts(filter, callback) {
      this.debug('getPosts', filter);
      this.__client.getPosts(filter || { type: 'post' }, callback.bind(this));
      return this;
    }
739480
def _validate_all_tags_are_used(metadata):
    """"""
    tag_names = set([tag_name for tag_name, _ in metadata.tags])
    filter_arg_names = set()
    for location, _ in metadata.registered_locations:
        for filter_info in metadata.get_filter_infos(location):
            for filter_arg in filter_info.args:
                if is_tag_argument(filter_arg):
                    filter_arg_names.add(get_directive_argument_name(filter_arg))

    unused_tags = tag_names - filter_arg_names
    if unused_tags:
        raise GraphQLCompilationError(u'This GraphQL query contains @tag directives whose values '
                                      u'are not used: {}. This is not allowed. Please either use '
                                      u'them in a filter or remove them entirely.'
                                      .format(unused_tags))
997583
def filter(self, record):
        """"""
        if g and hasattr(g, 'request_id'):
            record.request_id = g.request_id
        return True
429020
def filter_event(tag, data, defaults):
    '''
    
    '''
    ret = {}
    keys = []
    use_defaults = True

    for ktag in __opts__.get('filter_events', {}):
        if tag != ktag:
            continue
        keys = __opts__['filter_events'][ktag]['keys']
        use_defaults = __opts__['filter_events'][ktag].get('use_defaults', True)

    if use_defaults is False:
        defaults = []

    # For PY3, if something like ".keys()" or ".values()" is used on a dictionary,
    # it returns a dict_view and not a list like in PY2. "defaults" should be passed
    # in with the correct data type, but don't stack-trace in case it wasn't.
    if not isinstance(defaults, list):
        defaults = list(defaults)

    defaults = list(set(defaults + keys))

    for key in defaults:
        if key in data:
            ret[key] = data[key]

    return ret
1084379
def _filter(self, text, context, encoding):
        """"""

        content = []
        self.current_encoding = encoding
        self.line_num = 1
        self.prev_line = -1
        self.leading = ''
        self.block_comments = []
        self.line_comments = []

        self.find_content(text)
        self.extend_src(content, context)

        return content
890976
def select_one(self, tag):
        """"""

        tags = self.select(tag, limit=1)
        return tags[0] if tags else None
610877
def tagged(self, tag):
        """"""
        return PostCollection([p for p in self if unicode(tag) in p.tags])
1134253
def _tag_matches(tags, filter):
        """"""
        for tag_name, tag_value in filter.items():
            # using _sentinel as I'm not sure that "None"
            # could be used, because it could be a valid
            # series_tags value : when a series has no such tag
            # then I think it's set to /null/None/.. TBC..
            series_tag_value = tags.get(tag_name, _sentinel)
            if series_tag_value != tag_value:
                return False

        return True
234101
public function maybe_filter( WP_Query $wp_query ) {

		if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->post_type, (array) $wp_query->query['post_type'], true ) ) {
			return;
		}

		$vars = self::get_filter_vars( $wp_query->query, $this->args['site_filters'] );

		if ( empty( $vars ) ) {
			return;
		}

		foreach ( $vars as $key => $value ) {
			if ( is_array( $value ) ) {
				$query = $wp_query->get( $key );
				if ( empty( $query ) ) {
					$query = [];
				}
				$value = array_merge( $query, $value );
			}
			$wp_query->set( $key, $value );
		}

	}
974362
def _check_filter_specific_tag(self, specific_tag: list):
        
        if isinstance(specific_tag, list):
            if len(specific_tag) > 0:
                specific_tag = ",".join(specific_tag)
            else:
                specific_tag = ""
        else:
            raise TypeError("'specific_tag' expects a list")
        return specific_tag