Check if there is any post related to a tag.

@param  int    $tagID        ID of tag
@param  string $postTypeSlug Slug of post type
@return boolean Returns true if there is any post
352480
public static function hasPosts($tagID, $postTypeSlug = '')
    {
        $postTypeSlug($postTypeSlug ? $postTypeSlug : PostType::getSlug());
        $queryObject = DB::table(tagsRelationTable($postTypeSlug))->where('tagID', $tagID);

        if($queryObject->count() > 0) {
            return true;
        }

        return false;
    }
356293
public function registered($postType)
    {
        if (isset($this->registeredMappings[$postType])) {
            return $this->registeredMappings[$postType];
        }

        return null;
    }
879846
public function hasTags()
    {
        $tags = "tags";
        $postType = getPostType($this->getTable());
        return ($postType->hasTags && isset($this->$tags) && !$this->$tags->isEmpty());
    }
175817
private function getLastmodifiedByContentLog($contenttypeslug, $contentid)
    {
        // Get the proper ContentType.
        $contenttype = $this->getContentType($contenttypeslug);

        // get the changelog for the requested ContentType.
        $options = ['limit' => 5, 'order' => 'date', 'direction' => 'DESC'];

        if ((int) $contentid == 0) {
            $isFiltered = false;
        } else {
            $isFiltered = true;
            $options['contentid'] = (int) $contentid;
        }

        /** @var Repository\LogChangeRepository $repo */
        $repo = $this->storage()->getRepository(Entity\LogChange::class);
        $changelog = $repo->getChangeLogByContentType($contenttype['slug'], $options);

        $context = [
            'changelog'   => $changelog,
            'contenttype' => $contenttype,
            'contentid'   => $contentid,
            'filtered'    => $isFiltered,
        ];

        return $this->render('@bolt/components/panel-lastmodified.twig', ['context' => $context]);
    }
759744
public function lookForBrokenLinks($postId = null, $url = null)
    {
        \BrokenLinkDetector\App::checkInstall();
        $foundUrls = array();

        if ($url) {
            $url = "REGEXP ('.*(href=\"{$url}\").*')";
        } else {
            $url = "RLIKE ('href=*')";
        }

        global $wpdb;
        $sql = "
            SELECT ID, post_content
            FROM $wpdb->posts
            WHERE
                post_content {$url}
                AND post_type NOT IN ('attachment', 'revision', 'acf', 'acf-field', 'acf-field-group')
                AND post_status IN ('publish', 'private', 'password')
        ";

        if (is_numeric($postId)) {
            $sql .= " AND ID = $postId";
        }

        $posts = $wpdb->get_results($sql);

        if(is_array($posts) && !empty($posts)) {
            foreach ($posts as $post) {
                preg_match_all('/<a[^>]+href=([\'"])(http|https)(.+?)\1[^>]*>/i', $post->post_content, $m);

                if (!isset($m[3]) || count($m[3]) > 0) {
                    foreach ($m[3] as $key => $url) {
                        $url = $m[2][$key] . $url;

                        // Replace whitespaces in url
                        if (preg_match('/\s/', $url)) {
                            $newUrl = preg_replace('/ /', '%20', $url);
                            $wpdb->query(
                                $wpdb->prepare(
                                    "UPDATE $wpdb->posts
                                        SET post_content = REPLACE(post_content, %s, %s)
                                        WHERE post_content LIKE %s
                                        AND ID = %d",
                                    $url,
                                    $newUrl,
                                    '%' . $wpdb->esc_like($url) . '%',
                                    $post->ID
                                )
                            );
                            $url = $newUrl;
                        }

                        if ($postId !== 'internal' && !$this->isBroken($url)) {
                            continue;
                        }

                        $foundUrls[] = array(
                            'post_id' => $post->ID,
                            'url' => $url
                        );
                    }
                }
            }
        }

        $this->saveBrokenLinks($foundUrls, $postId);
    }
1310698
public static Specification<JpaTarget> hasTag(final Long tagId) {

        return (targetRoot, query, cb) -> {
            final SetJoin<JpaTarget, JpaTargetTag> tags = targetRoot.join(JpaTarget_.tags, JoinType.LEFT);
            return cb.equal(tags.get(JpaTargetTag_.id), tagId);
        };
    }
441801
public function getAllByPostType($lang = "", $postTypeID)
    {
        $orderBy = (isset($_GET['order'])) ? $orderBy = $_GET['order'] : 'tagID';
        $orderType = (isset($_GET['type'])) ? $orderType = $_GET['type'] : 'DESC';
        // get data
        return Tag::where('postTypeID', $postTypeID)->orderBy($orderBy, $orderType)->paginate(Tag::$rowsPerPage);
    }
507987
public static function findBySlug($slug, $postTypeSlug = '')
    {
        $postTypeSlug = ($postTypeSlug ? $postTypeSlug : PostType::getSlug());

        $postObj = (new Post())->setTable($postTypeSlug);
        $post = $postObj
            ->where('slug_'.App::getLocale(), $slug)
            ->with($postObj->getDefaultRelations(getPostType($postTypeSlug)))
            ->first();

        return $post;
    }
64232
public static function isChildPost($postOrPostId = null)
    {
        $post = self::getPost($postOrPostId);
        if (empty($post)) {
            return false;
        }

        return $post->post_parent > 0;
    }
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;
    }
92
public static function clearCache($postId, $post)
    {
        if (wp_is_post_revision($postId) || get_post_status($postId) != 'publish') {
            return false;
        }

        wp_cache_delete($postId, self::getKeyGroup());
        wp_cache_delete($post->post_type, self::getKeyGroup());

        // Empty post type for all sites in network (?)
        if (function_exists('is_multisite') && is_multisite() && apply_filters('Municipio\Cache\EmptyForAllBlogs', false, $post)) {
            $blogs = get_sites();

            foreach ($blogs as $blog) {
                wp_cache_delete($post->post_type, self::getKeyGroup($blog->blog_id));
            }
        }

        return true;
    }
709865
public static function isExistBySlugType( $slug, $type, $config = [] ) {

		$model	= static::findBySlugType( $slug, $type, $config );

		return isset( $model );
	}
950940
public function getAllWithoutPaginationByPostType($lang = "", $postType = "")
    {
        return DB::table('tags')->join('post_type', 'post_type.postTypeID', 'tags.postTypeID')->where('post_type.slug', $postType)->orderBy('name', 'postTypeID')->get();
    }
1111603
private static function get_module_id( $id_or_slug, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
            if ( is_numeric( $id_or_slug ) ) {
                return $id_or_slug;
            }

            foreach ( self::$_instances as $instance ) {
                // Also check the module type since there can be a plugin and a theme with the same slug.
                if ( ( $module_type === $instance->get_module_type() ) && ( $id_or_slug === $instance->get_slug() ) ) {
                    return $instance->get_id();
                }
            }

            return false;
        }
938524
public function makeSearch($lang, $postTypeSlug, $term)
    {
        // check if user has permissions to access this link
        if(!User::hasAccess($postTypeSlug, 'read')) {
            return $this->noPermission();
        }


        $orderBy = (isset($_GET['order'])) ? $_GET['order'] : 'postID';
        $orderType  = (isset($_GET['type'])) ? $orderType = $_GET['type'] : 'DESC';

        $excludeColumns = array('remember_token', 'created_at', 'updated_at');

        $searchResults = Search::searchByTerm($postTypeSlug, $term, Post::$rowsPerPage, true, [], $excludeColumns, $orderBy, $orderType);

        $response = $this
            ->appendListColumnsFromEvents($postTypeSlug)
            ->appendListRowsFromEvents($searchResults, $postTypeSlug)
            ->toArray();

        $response['inTableColumns'] = $this->getInTableColumns($postTypeSlug);

        return $response;
    }
243991
def query_by_post(postid):
        '''
        
        '''
        return TabPost2Tag.select().where(
            TabPost2Tag.post_id == postid
        ).order_by(TabPost2Tag.order)
894557
static public function exists( $tagID, $keyword, $parentID )
    {
        $db = eZDB::instance();
        $sql = "SELECT COUNT(*) AS row_count FROM eztags, eztags_keyword
                WHERE eztags.id = eztags_keyword.keyword_id AND
                eztags.parent_id = " . (int) $parentID . " AND
                eztags.id <> " . (int) $tagID . " AND
                eztags_keyword.keyword LIKE '" . $db->escapeString( $keyword ) . "'";

        $result = $db->arrayQuery( $sql );

        if ( is_array( $result ) && !empty( $result ) )
        {
            if ( (int) $result[0]['row_count'] > 0 )
                return true;
        }

        return false;
    }