定制 alleyinteractive/internal-flags 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

alleyinteractive/internal-flags

最新稳定版本:v0.2.0

Composer 安装命令:

composer require alleyinteractive/internal-flags

包简介

Use a hidden taxonomy to improve expensive queries.

README 文档

README

Testing Suite

Creates a hidden taxonomy to improve expensive query performance by not relying on meta queries. Allows for 'flags' to be set/unset on posts easily and entirely hidden from the end-user.

Instructions

By default, the internal taxonomy will be added to all registered post types.

Common Use Cases

  • Hiding from archives/searches
  • Posts by an author (where author is stored as a meta normally)
  • Showing/hiding sponsored posts

Usage

Setting a flag on a post

use Internal_Flags\set_flag;
set_flag( 'hide-from-archives', $post_id );

Removing a flag on a post

use Internal_Flags\remove_flag;
remove_flag( 'hide-from-archives', $post_id );

Checking if a flag is on a post

use Internal_Flags\has_flag;
has_flag( 'hide-from-archives', $post_id ); // bool

Searching for posts with a flag

use Internal_Flags\get_flag_tax_query;
$posts = new \WP_Query(
	[
		// ...
		'tax_query' => [
			get_flag_tax_query( 'show-on-page' )
		],
	],
);

Searching for posts without a flag

Inverse of the above

use Internal_Flags\get_flag_tax_query;
$posts = new \WP_Query(
	[
		// ...
		'tax_query' => [
			get_flag_tax_query( 'hide-from-archives', false )
		],
	],
);

统计信息

  • 总下载量: 209.97k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 30
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2022-07-27