Giter VIP home page Giter VIP logo

acf-fluent's Introduction

Build Status Code Quality Packagist Version MIT License

What is ACF Fluent?

ACF Fluent is a fluent interface for the Advanced Custom Fields WordPress plugin. It enables theme developers to create custom field "queries" using an expressive, fluent interface that makes templating with ACF a breeze.

Why?

If you make heavy use of Advanced Custom Fields in your WordPress templates (you should), then you probably find yourself writing a lot of repetitive code just to print out your fields. For example, you might have a heading field for your page's hero section:

<?php

$heading = get_field('heading');

if (is_null('heading')) {
    $heading = get_the_title();
} else {
    $heading = esc_html($heading);
}

?>

<h1><?= $heading ?></h1>

As you know, this type of template coding will clutter up your template files quickly, turning your well-structured HTML into a mess of PHP tags and blocks. The worst part is, you'll find yourself not only in a clutter of PHP logic, but repeating the same logic over and over!

ACF Fluent aims to minimize the mess with a fluent builder that lets you easily get and update fields and sub fields and add constraints along the way. Let's take a look at the same functionality above, using ACF Fluent:

<?php

use Samrap\Acf\Acf;

$heading = Acf::field('heading')
                ->default(get_the_title())
                ->escape()
                ->get();

?>

<h1><?= $heading ?></h1>

Interested? ACF Fluent packs a lot more features and has no dependencies. Check out the docs see all of the awesome features.

Documentation

Contributing

ACF Fluent is still in its early stages. Issues, PRs, and enhancement ideas are encouraged and appreciated.


Tweeter Built by @thesamrapaport

The ACF logo is owned by Elliot Condon and the Advanced Custom Fields Plugin

acf-fluent's People

Watchers

 avatar  avatar  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.