2017 © Pedro Peláez
 

project lumberjack-posttypes-acf-fields

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

image

iceagency/lumberjack-posttypes-acf-fields

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

  • Tuesday, July 10, 2018
  • by theiceagency
  • Repository
  • 0 Watchers
  • 0 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Post Type Fields for Lumberjack

Latest Stable Version Coverage Status Total Downloads License, (*1)

A Service Provider for the Lumberjack framework that allows you to define fields for your custom post types., (*2)

Written & maintained by the team at The ICE Agency, (*3)

Please note, this repo is not ready for production., (*4)

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, (*5)

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

Getting Started

  1. Register your Post Type within web/app/themes/lumberjack/app/config/posttypes.php, (*6)

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

  3. Add the HasACFFields interface to your Post Type, (*8)

    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:, (*9)

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

    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), (*11)

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

withLabel($label), (*13)

Set the label for the field within the WordPress Admin area., (*14)

isRequired(), (*15)

Make the field required., (*16)

withInstructions($instructions), (*17)

Add instructions for the field., (*18)

withDefaultValue($default_value), (*19)

Add a default value to the field., (*20)

withPlaceholder($placeholder), (*21)

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), (*22)

Individual Field Methods

Text

withMaxLength($max_length), (*23)

Set maximum length of text (accepts integer)., (*24)

isReadOnly(), (*25)

Set field as read-only., (*26)

isDisabled(), (*27)

Set field as disabled., (*28)

TextArea

withMaxLength($max_length), (*29)

Set maximum length of text (accepts integer)., (*30)

isReadOnly(), (*31)

Set field as read-only., (*32)

isDisabled(), (*33)

Set field as disabled., (*34)

Image

withMinWidth($min_width), (*35)

Set minimum width in pixels (accepts integer), (*36)

withMinHeight($min_height), (*37)

Set minimum height in pixels (accepts integer), (*38)

withMaxWidth($max_width), (*39)

Set maximum width in pixels (accepts integer), (*40)

withMaxHeight($max_height), (*41)

Set maximum height in pixels (accepts integer), (*42)

withMinSize($min_size), (*43)

Set minimum size in MB (accepts integer), (*44)

withMaxSize($max_size), (*45)

Set maximum size in MB (accepts integer), (*46)

withMimeTypes($mime_types), (*47)

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

withReturnFormat($return_format), (*49)

Set the format that is returned, choose from "array", "url" or "id", (*50)

True/False

withMessage($message), (*51)

Set the message that appears with the checkbox, (*52)

Checkbox

withOptions($options), (*53)

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., (*54)

File

withMinSize($min_size), (*55)

Set minimum size in MB (accepts integer), (*56)

withMaxSize($max_size), (*57)

Set maximum size in MB (accepts integer), (*58)

withMimeTypes($mime_types), (*59)

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

withReturnFormat($return_format), (*61)

Set the format that is returned, choose from "array", "url" or "id", (*62)

Number

withMin($min), (*63)

Set minimum number (accepts integer)., (*64)

withMax($max), (*65)

Set maximum number (accepts integer)., (*66)

withStep($step), (*67)

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

withPostTypes($post_types), (*69)

An array of post types that should be given as options., (*70)

withTaxonomy($taxonomy), (*71)

An array of taxonomies that contain the options that are given., (*72)

allowNull(), (*73)

Set if the select can be set as null., (*74)

isMultiple(), (*75)

Allow the user to select multiple options., (*76)

Post Object

withPostTypes($post_types), (*77)

An array of post types that should be given as options., (*78)

withTaxonomy($taxonomy), (*79)

An array of taxonomies that contain the options that are given., (*80)

allowNull(), (*81)

Set if the select can be set as null., (*82)

isMultiple(), (*83)

Allow the user to select multiple options., (*84)

withReturnFormat($return_format), (*85)

Choose the format that should be returned, choose between "object" and "id", (*86)

Radio

withOptions($options), (*87)

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., (*88)

Select

withOptions($options), (*89)

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., (*90)

allowNull(), (*91)

Set if the select can be set as null., (*92)

isMultiple(), (*93)

Allow the user to select multiple options., (*94)

User

withRoles($roles), (*95)

Set the roles of users that should appear in the select. Needs to be an array of user roles., (*96)

allowNull(), (*97)

Set if the select can be set as null., (*98)

isMultiple(), (*99)

Allow the user to select multiple options., (*100)

WYSIWYG

withTabs($tab_perference), (*101)

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

withToolbar($toolbar_perference), (*103)

Set which toolbar to show in the WYSIWYG, choose between "full" and "basic", (*104)

canUploadMedia(), (*105)

Set it so that the user can upload media with the WYSIWYG, (*106)

The Versions

10/07 2018

dev-master

9999999-dev https://github.com/ICEAgency/lumberjack-posttypes-acf-fields

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

  Sources   Download

MIT

The Requires

 

10/07 2018

1.0.2

1.0.2.0 https://github.com/ICEAgency/lumberjack-posttypes-acf-fields

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

  Sources   Download

MIT

The Requires

 

10/07 2018

1.0.1

1.0.1.0 https://github.com/ICEAgency/lumberjack-posttypes-acf-fields

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

  Sources   Download

MIT

The Requires

 

10/07 2018

1.0.0

1.0.0.0 https://github.com/ICEAgency/lumberjack-posttypes-acf-fields

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

  Sources   Download

MIT

The Requires