Last active
December 14, 2019 16:19
-
-
Save jrstaatsiii/0bf57311cd83f4bbb34887621fdd9733 to your computer and use it in GitHub Desktop.
Default Fields for SSM Projects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use StoutLogic\AcfBuilder\FieldsBuilder; | |
/** | |
* 01. Options | |
* a. Admin Options | |
* b. Background Options | |
* c. Column Alignment Options | |
* d. Block Grid Columns Per Row Options | |
* e. Column Layout Options | |
* f. Default Button Options | |
* j. HTML Attributes | |
* h. Image Link | |
* i. Mobile Sort Order | |
* j. Template Header | |
* k. Text Alignment | |
* 02. Components | |
* a. Button | |
* b. Conditional Button | |
* b. Form | |
* c. Header | |
* d. Image | |
* e. Text Editor | |
* f. Simple Text Editor | |
* g. Video | |
* h. Accordion | |
* i. Gallery | |
* 03. Modules | |
* a. Button | |
* b. Form | |
* c. Header | |
* d. Image | |
* e. Text Editor | |
* f. Video | |
* g. Accordion | |
* h. Gallery | |
* 04. Lists | |
* a. Buttons | |
* b. Modules | |
* 05. Templates | |
* a. Call to Action | |
* b. Column(s) | |
* c. Related Content | |
* d. Block Grid | |
* e. Split Content | |
* f. Gallery | |
* 06. Brand Settings Page | |
* a. Logo Assets | |
* b. Business Information | |
* c. Social Networks | |
* d. Global Footer | |
* e. Analytics | |
* f. Global Inline Styles | |
* 07. {% CPT %} Page | |
* a. Hero Unit | |
* b. Layout Builder | |
* b. Inline Styles | |
* c. Inline Scripts | |
* d. Facebook Conversion Pixel | |
* 08. {% CPT %} Settings Page | |
* ... | |
* 09. Features | |
* ... | |
*/ | |
// 01. Options | |
/** | |
* [Option] - Admin Options | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Code Snippet | |
*/ | |
$adminOptions = new FieldsBuilder('admin_options'); | |
$adminOptions | |
->addText('option_section_label', [ | |
'label' => 'Admin Label', | |
'instructions' => 'Use this text field to override the template name that is shown on this metabox', | |
]) | |
->addTrueFalse('option_status', [ | |
'label' => 'Status', | |
'instructions' => 'Set to inactive to remove from the frontend without deleting from the Database', | |
'ui' => 1, | |
'default_value' => 1, | |
'ui_on_text' => 'Active', | |
'ui_off_text' => 'Inactive', | |
]); | |
/** | |
* [Option] - Background Options | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Extract each background option into their own reusable block | |
* @todo Link to Team Snippet Code | |
*/ | |
$backgroundOptions = new FieldsBuilder('background_options'); | |
$backgroundOptions | |
->addRadio('option_background', [ | |
'label' => 'Background Options', | |
'layout' => 'horizontal' | |
]) | |
->addChoice('none', 'None') | |
->addChoice('color', 'Color') | |
->addChoice('image', 'Image') | |
->addChoice('video', 'Video') | |
->addRadio('option_background_color', [ | |
'layout' => 'horizontal', | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->addChoice('bg-grey-light', 'Light Grey') | |
->addChoice('bg-grey-dark', 'Dark Grey') | |
->conditional('option_background', '==', 'color') | |
->addImage('option_background_image', [ | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->conditional('option_background', '==', 'image') | |
->addFile('option_background_video', [ | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->conditional('option_background', '==', 'video'); | |
/** | |
* [Option] - Column Alignment Options | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$columnAlignmentOptions = new FieldsBuilder('column_alignment_options'); | |
$columnAlignmentOptions | |
->addRadio('option_y_alignment', [ | |
'label' => 'Y Alignment', | |
'layout' => 'horizontal', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->addChoice('top', 'Top') | |
->addChoice('middle', 'Middle') | |
->addChoice('bottom', 'Bottom') | |
->addRadio('option_x_alignment', [ | |
'label' => 'X Alignment', | |
'layout' => 'horizontal', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->addChoice('left', 'Left') | |
->addChoice('center', 'Center') | |
->addChoice('Right', 'Right'); | |
/** | |
* [Option] - Column Layout Options | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$columnLayoutOptions = new FieldsBuilder('column_layout_options'); | |
$columnLayoutOptions | |
->addRadio('option_column_layout', [ | |
'label' => 'Column Layout', | |
'layout' => 'horizontal', | |
'wrapper' => [ | |
'class' => 'column-layout' | |
] | |
]) | |
->addChoice(8, '8') | |
->addChoice(10, '10'); | |
/** | |
* [Option] - Block Grid Columns Per Row | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$blockGridColumnsPerRowOptions = new FieldsBuilder('block_grid_columns_per_row_options'); | |
$blockGridColumnsPerRowOptions | |
->addRadio('columns_per_row', [ | |
'label' => 'Columns Per Row', | |
'layout' => 'horizontal' | |
]) | |
->addChoice('2') | |
->addChoice('3') | |
->addChoice('4'); | |
/** | |
* [Option] - Default Button Options | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$defaultButtonOptions = new FieldsBuilder('default_button_options'); | |
$defaultButtonOptions | |
->addRadio('option_button_alignment', [ | |
'label' => 'Alignment', | |
'layout' => 'horizontal', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->addChoice('align-left', 'Left') | |
->addChoice('align-center', 'Center') | |
->addChoice('align-right', 'Right') | |
->addRadio('option_button_target', [ | |
'label' => 'Target', | |
'layout' => 'horizontal', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->addChoice('_self', 'Default') | |
->addChoice('_blank', 'New Tab'); | |
/** | |
* [Option] - HTML Attributes | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$htmlAttributesOptions = new FieldsBuilder('html_attributes_options'); | |
$htmlAttributesOptions | |
->addText('option_html_id', [ | |
'label' => 'HTML ID' | |
]) | |
->addText('option_html_classes', [ | |
'label' => 'HTML Classes' | |
]); | |
/** | |
* [Option] - Image Link | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Extract Link Source into it's own snippet | |
* @todo Link to Team Snippet Code | |
*/ | |
$imageLinkOptions = new FieldsBuilder('image_link_options'); | |
$imageLinkOptions | |
->addTrueFalse('option_add_image_link', [ | |
'label' => 'Add Image Link', | |
'message' => 'Add Image Link', | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->addRadio('link_source', [ | |
'label' => 'Source', | |
'layout' => 'horizontal', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->addChoice('internal', 'Internal Page') | |
->addChoice('external', 'External URL') | |
->conditional('option_add_image_link', '==', 1) | |
->addPostObject('option_image_link_page_id', [ | |
'label' => 'Select Page', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->conditional('link_source', '==', 'internal') | |
->addText('option_image_link_url', [ | |
'label' => 'URL', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->conditional('link_source', '==', 'external'); | |
/** | |
* [Option] - Mobile Sort Order | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$mobileSortOrderOptions = new FieldsBuilder('mobile_sort_order_options'); | |
$mobileSortOrderOptions | |
->addRadio('option_mobile_sort_order', [ | |
'label' => 'Mobile Sort Order', | |
'layout' => 'horizontal' | |
]) | |
->addChoice('medium-order-1', 'First') | |
->addChoice('medium-order-2', 'Last'); | |
/** | |
* [Option] - Template Header | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Extract Headline / Subheadline into a Header Snippet | |
* @todo Link to Team Snippet Code | |
*/ | |
$templateHeaderOptions = new FieldsBuilder('template_header_options'); | |
$templateHeaderOptions | |
->addTrueFalse('option_include_template_header', [ | |
'message' => 'Include Template Header', | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->addText('option_template_headline', [ | |
'label' => 'Headline' | |
]) | |
->conditional('option_include_template_header', '==', 1) | |
->addText('option_template_subheadline', [ | |
'label' => 'Subheadline' | |
]) | |
->conditional('option_include_template_header', '==', 1); | |
/** | |
* [Option] - Text Alignment | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$textAlignmentOptions = new FieldsBuilder('text_alignment_options'); | |
$textAlignmentOptions | |
->addRadio('option_text_alignment', [ | |
'label' => 'Text Alignment', | |
'layout' => 'horizontal' | |
]) | |
->addChoice('align-left', 'Left') | |
->addChoice('align-center', 'Center') | |
->addChoice('align-right', 'Right'); | |
// 02. Components | |
/** | |
* [Component] - Button | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$buttonComponent = new FieldsBuilder('button_component'); | |
$buttonComponent | |
->addRadio('button_source',[ | |
'label' => 'Source', | |
'layout' => 'horizontal' | |
]) | |
->addChoice('Internal Page') | |
->addChoice('External URL') | |
->setDefaultValue('Internal Page') | |
->addText('button_label', [ | |
'label' => 'Label', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->addPostObject('button_page_id', [ | |
'label' => 'Select a Page', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->conditional('button_source', '==', 'Internal Page') | |
->addText('button_url', [ | |
'label' => 'URL', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->conditional('button_source', '==', 'External URL'); | |
/** | |
* [Component] - Conditional Button | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$ConditionalButtonComponent = new FieldsBuilder('conditional_button_component'); | |
$ConditionalButtonComponent | |
->addTrueFalse('include_button', [ | |
'label' => 'Include Button', | |
'message' => 'Include Button', | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->addRadio('conditional_button_source',[ | |
'label' => 'Source', | |
'layout' => 'horizontal' | |
]) | |
->addChoice('Internal Page') | |
->addChoice('External URL') | |
->setDefaultValue('Internal Page') | |
->conditional('include_button', '==', 1) | |
->addText('conditional_button_label', [ | |
'label' => 'Label', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->conditional('include_button', '==', 1) | |
->addPostObject('conditional_button_page_id', [ | |
'label' => 'Select a Page', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->conditional('conditional_button_source', '==', 'Internal Page') | |
->and('include_button', '==', 1) | |
->addText('conditional_button_url', [ | |
'label' => 'URL', | |
'wrapper' => [ | |
'width' => '50' | |
] | |
]) | |
->conditional('conditional_button_source', '==', 'External URL') | |
->and('include_button', '==', 1); | |
/** | |
* [Component] - Form | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$formComponent = new FieldsBuilder('form_component'); | |
$formComponent | |
->addField('form', 'forms', [ | |
'wrapper' => [ | |
'classes' => 'hide-label' | |
] | |
]); | |
/** | |
* [Component] - Header | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$headerComponent = new FieldsBuilder('header_component'); | |
$headerComponent | |
->addText('headline') | |
->addText('subheadline'); | |
/** | |
* [Component] - Image | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$imageComponent = new FieldsBuilder('image_component'); | |
$imageComponent | |
->addImage('image', [ | |
'label' => 'Upload Image', | |
'preview_size' => 'large', | |
]); | |
/** | |
* [Component] - Text Editor | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$textEditorComponent = new FieldsBuilder('text_editor_component'); | |
$textEditorComponent | |
->addWysiwyg('text_editor', [ | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]); | |
/** | |
* [Component] - Simple Text Editor | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$simpleTextEditorComponent = new FieldsBuilder('simple_text_editor_component'); | |
$simpleTextEditorComponent | |
->addWysiwyg('simple_text_editor', [ | |
'wrapper' => [ | |
'class' => 'hide-label' | |
], | |
'toolbar' => 'basic', | |
'media_upload' => 0, | |
]); | |
/** | |
* [Component] - Video | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$videoComponent = new FieldsBuilder('video_component'); | |
$videoComponent | |
->addOembed('video', [ | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]); | |
/** | |
* [Component] - Accordion | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$accordionComponent = new FieldsBuilder('accordion_component'); | |
$accordionComponent | |
->addRepeater('accordion', [ | |
'layout' => 'block', | |
'min' => 1, | |
'collapsed' => 'title', | |
'button_label' => 'Add Item', | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->addText('title') | |
->addWysiwyg('explanation') | |
->endRepeater(); | |
/** | |
* [Component] - Gallery | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$galleryComponent = new FieldsBuilder('gallery_component'); | |
$galleryComponent | |
->addGallery('gallery', [ | |
'label' => 'Image Gallery' | |
]); | |
// 03. Modules | |
/** | |
* [Module] - Button | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$buttonModule = new FieldsBuilder('button_module', [ | |
'title' => 'Button' | |
]); | |
$buttonModule | |
->addTab('Content') | |
->addFields($buttonComponent) | |
->addTab('Options') | |
->addFields($defaultButtonOptions) | |
->addFields($htmlAttributesOptions); | |
/** | |
* [Module] - Form | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$formModule = new FieldsBuilder('form_module', [ | |
'title' => 'Form' | |
]); | |
$formModule | |
->addTab('Content') | |
->addFields($formComponent) | |
->addTab('Options') | |
->addFields($htmlAttributesOptions); | |
/** | |
* [Module] - Header | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$headerModule = new FieldsBuilder('header_module', [ | |
'title' => 'Header' | |
]); | |
$headerModule | |
->addTab('Content') | |
->addFields($headerComponent) | |
->addTab('Options') | |
->addFields($textAlignmentOptions) | |
->addFields($htmlAttributesOptions); | |
/** | |
* [Module] - Image | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$imageModule = new FieldsBuilder('image_module', [ | |
'title' => 'Image' | |
]); | |
$imageModule | |
->addTab('Content') | |
->addFields($imageComponent) | |
->addTab('Options') | |
->addFields($imageLinkOptions) | |
->addFields($htmlAttributesOptions); | |
/** | |
* [Module] - Text Edtior | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$textEditorModule = new FieldsBuilder('text_editor_module', [ | |
'title' => 'Text Editor' | |
]); | |
$textEditorModule | |
->addTab('Content') | |
->addFields($textEditorComponent) | |
->addTab('Options') | |
->addFields($htmlAttributesOptions); | |
/** | |
* [Module] - Video | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$videoModule = new FieldsBuilder('video_module', [ | |
'title' => 'Video' | |
]); | |
$videoModule | |
->addTab('Content') | |
->addFields($videoComponent) | |
->addTab('Options') | |
->addFields($htmlAttributesOptions); | |
/** | |
* [Module] - Accordion | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$accordionModule = new FieldsBuilder('accordion_module', [ | |
'title' => 'Accordion' | |
]); | |
$accordionModule | |
->addTab('Content') | |
->addFields($accordionComponent) | |
->addTab('Options') | |
->addFields($htmlAttributesOptions); | |
/** | |
* [Module] - Gallery | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$galleryModule = new FieldsBuilder('gallery_module'); | |
$galleryModule | |
->addTab('Content') | |
->addFields($galleryComponent) | |
->addTab('Options') | |
->addFields($htmlAttributesOptions); | |
// 04. Lists | |
/** | |
* [List] - Buttons | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$buttonsList = new FieldsBuilder('buttons_list', [ | |
'title' => 'Button(s)' | |
]); | |
$buttonsList | |
->addRepeater('buttons', [ | |
'layout' => 'block', | |
'min' => 1, | |
'max' => 2, | |
'button_label' => 'Add Button' | |
]) | |
->addFields($buttonModule); | |
/** | |
* [List] - Modules | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$modulesList = new FieldsBuilder('modules_list'); | |
$modulesList | |
->addFlexibleContent('modules') | |
->addLayout($headerModule) | |
->addLayout($textEditorModule) | |
->addLayout($imageModule) | |
->addLayout($videoModule) | |
->addLayout($buttonsList) | |
->addLayout($formModule) | |
->addLayout($accordionModule) | |
->endFlexibleContent(); | |
// 05. Templates | |
/** | |
* [Template] - Call to Action | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$callToActionTemplate = new FieldsBuilder('call_to_action_template', [ | |
'title' => 'Call To Action' | |
]); | |
$callToActionTemplate | |
->addTab('Content') | |
->addFields($headerComponent) | |
->addFields($buttonsList) | |
->addTab('Options') | |
->addFields($backgroundOptions) | |
->addFields($htmlAttributesOptions) | |
->addTab('Admin') | |
->addFields($adminOptions); | |
/** | |
* [Template] - Columns | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$columnsTemplate = new FieldsBuilder('columns_template', [ | |
'title' => 'Column(s)' | |
]); | |
$columnsTemplate | |
->addTab('Content') | |
->addFields($templateHeaderOptions) | |
->addRepeater('columns', [ | |
'layout' => 'block', | |
'min' => 1, | |
'max' => 2, | |
'button_label' => 'Add Column', | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->addTab('Content', [ | |
'placement' => 'left' | |
]) | |
->addFields($modulesList) | |
->addTab('Options') | |
->addFields($mobileSortOrderOptions) | |
->addFields($htmlAttributesOptions) | |
->endRepeater() | |
->addTab('Options') | |
->addFields($backgroundOptions) | |
->addFields($columnLayoutOptions) | |
->addFields($columnAlignmentOptions) | |
->addFields($htmlAttributesOptions) | |
->addTab('Admin') | |
->addFields($adminOptions); | |
/** | |
* [Template] - Related Content | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$relatedContentTemplate = new FieldsBuilder('related_content_template', [ | |
'title' => 'Related Content' | |
]); | |
$relatedContentTemplate | |
->addTab('Content') | |
->addFields($templateHeaderOptions) | |
->addRadio('post_query', [ | |
'layout' => 'horizontal', | |
'default_value' => 'most_recent' | |
]) | |
->addChoice('most_recent', 'Most Recent') | |
->addChoice('curated', 'Curated') | |
->addNumber('number_of_posts_to_show') | |
->conditional('post_query', '==', 'most_recent') | |
->addRelationship('posts_to_show', [ | |
'filters' => '', | |
'post_type' => array( | |
0 => 'post', | |
) | |
]) | |
->conditional('post_query', '==', 'curated') | |
->addTab('Options') | |
->addFields($backgroundOptions) | |
->addFields($htmlAttributesOptions) | |
->addTab('Admin') | |
->addFields($adminOptions); | |
/** | |
* [Template] - Block Grid | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$blockGridTemplate = new FieldsBuilder('block_grid_template', [ | |
'label' => 'Block Grid' | |
]); | |
$blockGridTemplate | |
->addTab('Content') | |
->addFields($templateHeaderOptions) | |
->addRepeater('block_grid_items', [ | |
'layout' => 'block', | |
'button_label' => 'Add Item', | |
'min' => 1, | |
'collapsed' => 'block_grid_title', | |
'wrapper' => [ | |
'class' => 'hide-label' | |
] | |
]) | |
->addImage('block_grid_icon', [ | |
'label' => 'Icon' | |
]) | |
->addText('block_grid_title', [ | |
'label' => 'Title' | |
]) | |
->addMessage('Short Description', 'Short Description', [ | |
'wrapper' => [ | |
'class' => 'hide-label faux-label' | |
] | |
]) | |
->addFields($simpleTextEditorComponent) | |
->addFields($ConditionalButtonComponent) | |
->endRepeater() | |
->addTab('Options') | |
->addFields($backgroundOptions) | |
->addFields($blockGridColumnsPerRowOptions) | |
->addFields($htmlAttributesOptions) | |
->addTab('Admin') | |
->addFields($adminOptions); | |
/** | |
* [Template] - Split Content | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$splitContentTemplate = new FieldsBuilder('split_content_template', [ | |
'label' => 'Split Content' | |
]); | |
$splitContentTemplate | |
->addTab('Content') | |
->addFields($modulesList) | |
->addRadio('media_position', [ | |
'layout' => 'horizontal' | |
]) | |
->addChoice('media-left', 'Left') | |
->addChoice('media-Right', 'Right') | |
->addFields($imageComponent) | |
->addTab('Options') | |
->addFields($backgroundOptions) | |
->addFields($htmlAttributesOptions) | |
->addTab('Admin') | |
->addFields($adminOptions); | |
/** | |
* [Template] - Gallery | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$galleryTemplate = new FieldsBuilder('gallery_template', [ | |
'label' => 'Image Gallery' | |
]); | |
$galleryTemplate | |
->addTab('Content') | |
->addFields($templateHeaderOptions) | |
->addFields($galleryComponent) | |
->addTab('Options') | |
->addFields($backgroundOptions) | |
->addFields($htmlAttributesOptions) | |
->addTab('Admin') | |
->addFields($adminOptions); | |
// 06. Brand Settings Page | |
/** | |
* Logo Assets | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$logoAssets = new FieldsBuilder('logo_assets', [ | |
'menu_order' => 1 | |
]); | |
$logoAssets | |
->addImage('brand_icon', [ | |
'Label' => 'Icon', | |
'preview_size' => 'medium' | |
]) | |
->addImage('brand_logo', [ | |
'Label' => 'Full Logo', | |
'preview_size' => 'large' | |
]) | |
->addImage('favicon', [ | |
'Label' => 'Icon', | |
'preview_size' => 'medium', | |
'mime_types' => 'png, svg, ico' | |
]) | |
->setLocation('options_page', '==', 'acf-options-brand-settings'); | |
// Register Logo Assets | |
add_action('acf/init', function() use ($logoAssets) { | |
acf_add_local_field_group($logoAssets->build()); | |
}); | |
/** | |
* Business Information | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$businessInformation = new FieldsBuilder('business_information', [ | |
'menu_order' => 2 | |
]); | |
$businessInformation | |
->addField('primary_phone_number', 'phone', [ | |
'initial_country' => 'US', | |
'wrapper' => [ | |
'width' => '33' | |
] | |
]) | |
->addField('primary_fax_number', 'phone', [ | |
'initial_country' => 'US', | |
'wrapper' => [ | |
'width' => '34' | |
] | |
]) | |
->addEmail('primary_email_address', [ | |
'wrapper' => [ | |
'width' => '33' | |
] | |
]) | |
->addField('physical_address', 'address', [ | |
'output_type' => 'object', | |
'address_layout' => '[[{"id":"street1","label":"Street 1"}],[{"id":"street2","label":"Street 2"}],[],[{"id":"city","label":"City"},{"id":"state","label":"State"},{"id":"zip","label":"Postal Code"},{"id":"country","label":"Country"}],[]]', | |
'address_options' => '{"street1":{"id":"street1","label":"Street 1","defaultValue":"","enabled":true,"cssClass":"street1","separator":""},"street2":{"id":"street2","label":"Street 2","defaultValue":"","enabled":true,"cssClass":"street2","separator":""},"street3":{"id":"street3","label":"Street 3","defaultValue":"","enabled":false,"cssClass":"street3","separator":""},"city":{"id":"city","label":"City","defaultValue":"","enabled":true,"cssClass":"city","separator":","},"state":{"id":"state","label":"State","defaultValue":"","enabled":true,"cssClass":"state","separator":""},"zip":{"id":"zip","label":"Postal Code","defaultValue":"","enabled":true,"cssClass":"zip","separator":""},"country":{"id":"country","label":"Country","defaultValue":"","enabled":true,"cssClass":"country","separator":""}}', | |
]) | |
->setLocation('options_page', '==', 'acf-options-brand-settings'); | |
// Register Business Information | |
add_action('acf/init', function() use ($businessInformation) { | |
acf_add_local_field_group($businessInformation->build()); | |
}); | |
/** | |
* Social Networks | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$socialNetworks = new FieldsBuilder('social_networks', [ | |
'menu_order' => 3 | |
]); | |
$socialNetworks | |
->addText('facebook', [ | |
'prepend' => 'URL', | |
]) | |
->addText('twitter', [ | |
'prepend' => 'URL', | |
]) | |
->addText('linkedin', [ | |
'prepend' => 'URL', | |
]) | |
->addText('instagram', [ | |
'prepend' => 'URL', | |
]) | |
->setLocation('options_page', '==', 'acf-options-brand-settings'); | |
// Register Social Networks | |
add_action('acf/init', function() use ($socialNetworks) { | |
acf_add_local_field_group($socialNetworks->build()); | |
}); | |
/** | |
* Global Footer | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$globalFooter = new FieldsBuilder('global_footer', [ | |
'menu_order' => 4 | |
]); | |
$globalFooter | |
->addWysiwyg('footer_copyright', [ | |
'label' => 'Copyright' | |
]) | |
->setLocation('options_page', '==', 'acf-options-brand-settings'); | |
// Register Global Footer | |
add_action('acf/init', function() use ($globalFooter) { | |
acf_add_local_field_group($globalFooter->build()); | |
}); | |
/** | |
* Analytics | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$analytics = new FieldsBuilder('analytics', [ | |
'menu_order' => 5 | |
]); | |
$analytics | |
->addText('google_tag_manager_id') | |
->addText('google_site_verification_id') | |
->addText('facebook_account_id') | |
->addRepeater('custom_tracking_scripts', [ | |
'layout' => 'block', | |
'button_label' => 'Add Tracking Script' | |
]) | |
->addText('title') | |
->addField('script', 'acf_code_field', [ | |
'mode' => 'htmlmixed', | |
'theme' => 'monokai', | |
]) | |
->endRepeater() | |
->setLocation('options_page', '==', 'acf-options-brand-settings'); | |
// Register Analytics | |
add_action('acf/init', function() use ($analytics) { | |
acf_add_local_field_group($analytics->build()); | |
}); | |
/** | |
* Global Inline Styles | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$globalInlineStyles = new FieldsBuilder('global_inline_styles', [ | |
'menu_order' => 6 | |
]); | |
$globalInlineStyles | |
->addField('global_inline_styles', 'acf_code_field', [ | |
'label' => 'CSS Editor', | |
'mode' => 'css', | |
'theme' => 'monokai' | |
]) | |
->setLocation('options_page', '==', 'acf-options-brand-settings'); | |
// Register Analytics | |
add_action('acf/init', function() use ($globalInlineStyles) { | |
acf_add_local_field_group($globalInlineStyles->build()); | |
}); | |
// 07. {% CPT %} Page | |
/** | |
* Hero Unit | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$heroUnit = new FieldsBuilder('hero_unit', [ | |
'position' => 'acf_after_title' | |
]); | |
$heroUnit | |
->addTab('Content') | |
->addFields($headerComponent) | |
->addFields($buttonsList) | |
->addTab('Options') | |
->addFields($backgroundOptions) | |
->addFields($htmlAttributesOptions) | |
->setLocation('post_type', '==', 'page'); | |
// Register Hero Unit | |
add_action('acf/init', function() use ($heroUnit) { | |
acf_add_local_field_group($heroUnit->build()); | |
}); | |
/** | |
* Layout Builder | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$layoutBuilder = new FieldsBuilder('layout_builder', [ | |
'style' => 'seamless' | |
]); | |
$layoutBuilder | |
->addFlexibleContent('templates', [ | |
'label' => 'Layout Builder', | |
'button_label' => 'Add Template' | |
]) | |
->addLayout($columnsTemplate) | |
->addLayout($callToActionTemplate) | |
->addLayout($relatedContentTemplate) | |
->addLayout($blockGridTemplate) | |
->addLayout($splitContentTemplate) | |
->addLayout($galleryTemplate) | |
->setLocation('post_type', '==', 'page'); | |
// Register Layout Builder | |
add_action('acf/init', function() use ($layoutBuilder) { | |
acf_add_local_field_group($layoutBuilder->build()); | |
}); | |
/** | |
* Inline Styles | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$inlineStyles = new FieldsBuilder('inline_styles', [ | |
'menu_order' => 5 | |
]); | |
$inlineStyles | |
->addField('inline_styles', 'acf_code_field', [ | |
'label' => 'CSS Editor', | |
'mode' => 'css', | |
'theme' => 'monokai' | |
]) | |
->setLocation('post_type', '==', 'page'); | |
// Register Inline Styles | |
add_action('acf/init', function() use ($inlineStyles) { | |
acf_add_local_field_group($inlineStyles->build()); | |
}); | |
/** | |
* Inline Scripts | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$inlineScripts = new FieldsBuilder('inline_scripts', [ | |
'menu_order' => 6 | |
]); | |
$inlineScripts | |
->addField('inline_scripts', 'acf_code_field', [ | |
'label' => 'JS Editor', | |
'mode' => 'js', | |
'theme' => 'monokai', | |
]) | |
->setLocation('post_type', '==', 'page'); | |
// Register Inline Scripts | |
add_action('acf/init', function() use ($inlineScripts) { | |
acf_add_local_field_group($inlineScripts->build()); | |
}); | |
/** | |
* Facebook Conversion Pixel | |
* @author Rich Staats <[email protected]> | |
* @since 3.0.0 | |
* @todo Link to Team Snippet Code | |
*/ | |
$facebookConversionPixel = new FieldsBuilder('facebook_conversion_pixel', [ | |
'menu_order' => 99, | |
'position' => 'side' | |
]); | |
$facebookConversionPixel | |
->addSelect('facebook_standard_event', [ | |
'label' => 'Standard Event', | |
'default_value' => array(), | |
'allow_null' => 1 | |
]) | |
->addChoice('fbq("track", "ViewContent");', 'Key Page View') | |
->addChoice('fbq("track", "Lead");', 'Lead') | |
->addChoice('fbq("track", "CompleteRegistration");', 'Completed Registration') | |
->addChoice('fbq("track", "InitiateCheckout");', 'Initiated Checkout') | |
->addChoice('fbq("track", "AddPaymentInfo");', 'Added Payment Info') | |
->addChoice('fbq("track", "Purchase");', 'Made a Purchase') | |
->setLocation('post_type', '==', 'page'); | |
// Register Inline Scripts | |
add_action('acf/init', function() use ($facebookConversionPixel) { | |
acf_add_local_field_group($facebookConversionPixel->build()); | |
}); | |
// 9. {% CPT %} Settings Page | |
// 10. Features |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment