Coder Social home page Coder Social logo

acf-meta-builder-helper's Introduction

@geoffdusome/acf-meta-builder-helper

GitHub stars GitHub issues GitHub license

A helper WordPress plugin for the ACF Meta Builder gulp task.

Installation

Clone or download the plugin and upload entire folder to your WordPress installation (usually located under ./wp-content/plugins/).

Usage

The helper plugin uses a get_post_meta($post->ID) call to pull all of the meta for the page. It will then use that meta array to pull from. This allows us to have all of our meta for the page with one call to the DB, instead of one for every meta call. Please note that for repeater, group and flexible content field types, you will need to use base ACF functions to get this data ($repeater_data = get_field('repeater_name'); should do all you need).

acfmb($type, $name, $group, $options)

This function is the heart of the helper plugin, as well as the heart of the gulp task! This function not only creates the meta, but also pulls the meta value from the meta call above.

$type - string
[required]
The type of field you want to use (view field types here).

$name - string
[required]
The name of the field.

$group - string
[required]
The name of the group the field belongs to.

$options - string (JSON encoded string)
Unused in the helper plugin but optional for the gulp task.

acfmb_image_url($value, $size)

Get image URL from an attachment ID

$value - string
[required]
The ID of the image

$size - string
The defined image size of the image you want to display.

acfmb_link_markup($value, $classes, $wrapper)

Get the link object and provide markup for the button

$value - string
[required]
JSON encoded array from DB.

$classes - string
Classes for the button in string format.

$wrapper - bool
Whether or not to show the wrapper for the button.

$unserialize - bool
Whether or not to unserialize the data given to the function.

Example

If you have both the ACF Meta Builder gulp task as well as the ACF Meta Builder WordPress plugin below is an example of the typical workflow of building meta.

// Create a tab
$hero_tab = acfmb('tab', 'Hero', 'Page Meta');

// Create an image
$hero_background_id = acfmb('image', 'Hero Background', 'Page Meta');
$hero_background = acfmb_image_url($hero_background_id, 'large');

// Create a text field
$hero_headline = acfmb('text', 'Hero Headline', 'Page Meta');

acf-meta-builder-helper's People

Contributors

geoffdusome avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.