iceagency/lumberjack-posttypes-acf-fields 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

iceagency/lumberjack-posttypes-acf-fields

Composer 安装命令:

composer create-project iceagency/lumberjack-posttypes-acf-fields

包简介

A Service Provider for the Lumberjack framework that allows you to define fields for your custom post types.

README 文档

README

Latest Stable Version Coverage Status Total Downloads License

A Service Provider for the Lumberjack framework that allows you to define fields for your custom post types.

Written & maintained by the team at The ICE Agency

Please note, this repo is not ready for production.

Roadmap

  1. Add support for repeater fields
  2. Add support for all field types that ACF offers
  3. Update documentation

Requirements

Installing

  1. Install Lumberjack, see the guide here.

  2. Install via Composer: composer require iceagency/lumberjack-posttypes-acf-fields

  3. Add the provider within web/app/themes/lumberjack/config/app.php

    'providers' => [
        ...
        IceAgency\Lumberjack\Providers\PostTypeFieldsServiceProvider::class,
        ...
    ]
    

Getting Started

  1. Register your Post Type within web/app/themes/lumberjack/app/config/posttypes.php

    'register' => [
        ...
        App\PostTypes\YourPostType::class,
        ...
    ]
    
  2. Create your Post Type class within web/app/themes/lumberjack/app/PostTypes/YourPostType.php

  3. Add the HasACFFields interface to your Post Type

    use IceAgency\Lumberjack\Interfaces\HasAcfFields;
    
    class YourPostType extends Post implements HasAcfFields
    {
        ...
    }
    
  4. For each field type you need to use, ensure that you include the relevent classes at the top of your Post Type class, for this example:

    use IceAgency\Lumberjack\AcfFields\TextField;
    use IceAgency\Lumberjack\AcfFields\TextAreaField;
    
  5. Add a static method to define your field configuration, as follows:

    public static function getFieldConfig() : array
    {
        return [
            TextField::create('text_field_name')
                ->withLabel('Text Field Label')
                ->isRequired(),
            TextAreaField::create('textarea_field_name')
                ->withLabel('Textarea Field Label')
        ]
    }
    

Field Types

  • Text: IceAgency\Lumberjack\AcfFields\TextField
  • Text Area: IceAgency\Lumberjack\AcfFields\TextField
  • Image: IceAgency\Lumberjack\AcfFields\ImageField
  • True/False: IceAgency\Lumberjack\AcfFields\BoolField
  • Checkbox: IceAgency\Lumberjack\AcfFields\CheckboxField
  • Email: IceAgency\Lumberjack\AcfFields\EmailField
  • File: IceAgency\Lumberjack\AcfFields\FileField
  • Number: IceAgency\Lumberjack\AcfFields\NumberField
  • Page Link: IceAgency\Lumberjack\AcfFields\PageLinkField
  • Password: IceAgency\Lumberjack\AcfFields\PasswordField
  • Post Object: IceAgency\Lumberjack\AcfFields\PostObjectField
  • Radio: IceAgency\Lumberjack\AcfFields\RadioField
  • Select: IceAgency\Lumberjack\AcfFields\SelectField
  • URL: IceAgency\Lumberjack\AcfFields\UrlField
  • User: IceAgency\Lumberjack\AcfFields\UserField
  • WYSIWYG: IceAgency\Lumberjack\AcfFields\WysiwygField

Generic Field Methods

create($name)

Create a field with the name given, this is the name that is used to retrieve the data with ACF's get_field() function

withLabel($label)

Set the label for the field within the WordPress Admin area.

isRequired()

Make the field required.

withInstructions($instructions)

Add instructions for the field.

withDefaultValue($default_value)

Add a default value to the field.

withPlaceholder($placeholder)

Used to set the placeholder for the field within the WordPress Admin area. (Please note, this is only possible on Text, TextArea, Number, Email, URL and Password)

Individual Field Methods

Text

withMaxLength($max_length)

Set maximum length of text (accepts integer).

isReadOnly()

Set field as read-only.

isDisabled()

Set field as disabled.

TextArea

withMaxLength($max_length)

Set maximum length of text (accepts integer).

isReadOnly()

Set field as read-only.

isDisabled()

Set field as disabled.

Image

withMinWidth($min_width)

Set minimum width in pixels (accepts integer)

withMinHeight($min_height)

Set minimum height in pixels (accepts integer)

withMaxWidth($max_width)

Set maximum width in pixels (accepts integer)

withMaxHeight($max_height)

Set maximum height in pixels (accepts integer)

withMinSize($min_size)

Set minimum size in MB (accepts integer)

withMaxSize($max_size)

Set maximum size in MB (accepts integer)

withMimeTypes($mime_types)

Comma-seperated list of mime types (e.g. "image/png,image/jpg,image/gif")

withReturnFormat($return_format)

Set the format that is returned, choose from "array", "url" or "id"

True/False

withMessage($message)

Set the message that appears with the checkbox

Checkbox

withOptions($options)

Set the checkbox items that appear, $options should be an array where the key is the checkbox value and the value represents the label of the checkbox.

File

withMinSize($min_size)

Set minimum size in MB (accepts integer)

withMaxSize($max_size)

Set maximum size in MB (accepts integer)

withMimeTypes($mime_types)

Comma-seperated list of mime types (e.g. "image/png,image/jpg,image/gif")

withReturnFormat($return_format)

Set the format that is returned, choose from "array", "url" or "id"

Number

withMin($min)

Set minimum number (accepts integer).

withMax($max)

Set maximum number (accepts integer).

withStep($step)

Set how many numbers are skipped when arrows are clicked (accepts integer).

Page Link

withPostTypes($post_types)

An array of post types that should be given as options.

withTaxonomy($taxonomy)

An array of taxonomies that contain the options that are given.

allowNull()

Set if the select can be set as null.

isMultiple()

Allow the user to select multiple options.

Post Object

withPostTypes($post_types)

An array of post types that should be given as options.

withTaxonomy($taxonomy)

An array of taxonomies that contain the options that are given.

allowNull()

Set if the select can be set as null.

isMultiple()

Allow the user to select multiple options.

withReturnFormat($return_format)

Choose the format that should be returned, choose between "object" and "id"

Radio

withOptions($options)

Set the checkbox items that appear, $options should be an array where the key is the checkbox value and the value represents the label of the checkbox.

Select

withOptions($options)

Set the checkbox items that appear, $options should be an array where the key is the checkbox value and the value represents the label of the checkbox.

allowNull()

Set if the select can be set as null.

isMultiple()

Allow the user to select multiple options.

User

withRoles($roles)

Set the roles of users that should appear in the select. Needs to be an array of user roles.

allowNull()

Set if the select can be set as null.

isMultiple()

Allow the user to select multiple options.

WYSIWYG

withTabs($tab_perference)

Set which tabs should show on the WYSIWYG, choose between "all", "visual" and "text"

withToolbar($toolbar_perference)

Set which toolbar to show in the WYSIWYG, choose between "full" and "basic"

canUploadMedia()

Set it so that the user can upload media with the WYSIWYG

iceagency/lumberjack-posttypes-acf-fields 适用场景与选型建议

iceagency/lumberjack-posttypes-acf-fields 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 33 次下载、GitHub Stars 达 3, 最近一次更新时间为 2018 年 07 月 10 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 iceagency/lumberjack-posttypes-acf-fields 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-10