定制 joem/saturn 二次开发

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

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

joem/saturn

Composer 安装命令:

composer require joem/saturn

包简介

Object-based post-type management in WordPress.

README 文档

README

Logo

An object-mapped post type builder & interface for WordPress.

Saturn is a fluent interface used to effortlessly create and manipulate post types and their contents in WordPress.

How Effortlessly? Take a look:

// Provide arguments.
$args = array(
    'slug'      => 'interview',
    'singular'  => 'Interview',
    'plural'    => 'Interviews',
    'namespace' => 'twentytwenty',
);

// Register the post type.
$saturn = new Saturn($args);

// Run a query, returning 10 posts.
$posts = $saturn->query()->limit( 10 )->runQuery();

Saturn is designed to almost act as a model, or resource to represent a post type, this means you can create, delete and change post types through an instance of Saturn, and it's easy peasy.

Not only that, Saturn provides a query engine to interact with post objects (or pages) directly within the instance. The query builder wraps get_posts, which means everything in get_posts is possible from a saturn instance - with a beautifully simple interface.

Create an instance

Creating an instance of Saturn is simple:

// Provide arguments.
$args = array(
    'slug'      => 'interview',
    'singular'  => 'Interview',
    'plural'    => 'Interviews',
    'namespace' => 'twentytwenty',
);

// Register the post type.
$saturn = new Saturn($args);

Saturn requires an array of parameters, which are used to construct the post type and create the instance:

Parameters

  • slug (string) - The slug used to identify the post type.
  • singular (string) - The singular name of the post type - human readable, used in labels.
  • plural (string) - The plural name of the post type - human readable, used in labels.
  • namespace (string) - The text & theme namespace (often referred to as domain) for the text strings.

Instance methods

Methods which are available in an instance of Saturn are detailed below.

instance

Usage

$saturn->instance();

Return

Type: Object WP_Post_Type

An instance of a post type. We do not recommend altering its contents - instead, use Saturn methods. Helpful to quickly access the object.

query

Usage

$saturn->query();

Return

Type: Object Saturn

Used to clear any lingering parameters in the query engine from previous queries. It is important to use this method before setting up queries to prevent any strange or unexpected results.

limit

Parameters

  • quantity (int) - The quantity of objects to return for a specified query.

Usage

$saturn->limit( 15 );

Return

Type: Object Saturn

Sets the number of objects to return from a query. The query engine will return the FIRST n matches if specified.

meta

Parameters

  • metaQuery (array) - An array which can contain a single key-value pair, where the key is the meta slug, and the value is the meta value. You can query multiple meta values by instead passing an array of arrays which contain the key-value pair.

  • queryConfig (array) - A list of key-value config items, which would otherwise be provided inside of meta_query. An example of config item would be relation. Not required.

Usage

Single meta query:

$saturn->query()
    ->meta( ['name' => 'joe'] )
    ->runQuery();

Multiple meta queries:

$saturn->query()
    ->meta([
        ['name' => 'joe'],
        ['age' => 43]])
    ->runQuery();

Multiple meta queries with config:

$saturn->query()
    ->meta([
        ['name' => 'joe'],
        ['age' => 43]],
        ['relation' => 'AND'])
    ->runQuery();

Return

Type: Object Saturn

Sets the meta_query for the query.

tax

Add a tax_query to the query. Parameters

  • taxQuery (array) - An array containing a single taxonomy query, to the spec of WP_Query's tax_query parameter.

Usage

$saturn->query()
    ->tax([
        'taxonomy' => 'people',
        'field'    => 'slug',
        'terms'    => 'bob',
    ])
    ->runQuery();

joem/saturn 适用场景与选型建议

joem/saturn 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 joem/saturn 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 joem/saturn 我们能提供哪些服务?
定制开发 / 二次开发

基于 joem/saturn 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-11-28