Giter Site home page Giter Site logo

log1x / modern-acf-options Goto Github PK

View Code? Open in Web Editor NEW
32.0 6.0 2.0 130 KB

A modern approach to ACF Theme Options

Home Page: https://github.com/Log1x/modern-acf-options

License: MIT License

CSS 43.39% PHP 32.51% JavaScript 24.10%
wordpress acf acf-addon mu-plugin wp-plugin

modern-acf-options's Introduction

Modern ACF Options

Latest Stable Version Total Downloads

Here lives a simple mu-plugin to modernize and brand theme options created with ACF. No admin panels, no bloat โ€“ just a simple filter to optionally customize the CSS properties with your color palette.

Screenshot

Requirements

Installation

Bedrock

Install via Composer:

$ composer require log1x/modern-acf-options

Manual

Download the release .zip and install into wp-content/plugins.

Usage

The styling for Modern ACF Options requires the usage of seamless mode and tabs with their placement set to left.

Example using ACF Builder

use StoutLogic\AcfBuilder\FieldsBuilder;

acf_add_options_page([
    'page_title' => get_bloginfo('name'),
    'menu_title' => 'Theme Options',
    'menu_slug' => 'theme-options',
    'update_button' => 'Update Options',
    'capability' => 'edit_theme_options',
    'position' => '999',
    'autoload' => true,
]);

$options = new FieldsBuilder('theme_options', [
    'style' => 'seamless',
]);

$options
    ->setLocation('options_page', '==', 'theme-options');

$options
    ->addTab('general')
        ->setConfig('placement', 'left')

        ->addAccordion('customization')
          ->addImage('logo')

        ->addAccordion('tracking')
            ->addText('gtm')
                ->setConfig('label', 'Google Tag Manager')
        ->addAccordion('tracking_end')->endpoint()

    ->addTab('advanced')
        ->setConfig('placement', 'left')

        ->addTrueFalse('debug')
          ->setConfig('ui', '1');

acf_add_local_field_group($options->build());

Customization

To customize the color palette, simply pass an array containing one or more of the colors you would like to change to the acf_color_palette filter:

add_filter('acf_color_palette', function () {
    return [
        'brand' => '#0073aa',
        'trim' => '#181818',
    ];
});

Disabling Screen Options Tab

use Illuminate\Support\Str;

/**
 * Disable Screen Options on the theme options page.
 *
 * @param  bool       $show
 * @param  \WP_Screen $screen
 * @return bool
 */
add_filter('screen_options_show_screen', function ($show, $screen) {
    if (is_a($screen, 'WP_Screen') && Str::contains($screen->base, 'theme-options')) {
        return false;
    }
}, 1, 2);

Remove Admin Footer Text

/**
 * Remove admin footer text.
 *
 * @return bool
 */
add_filter('admin_footer_text', '__return_false', 100);

Development

Modern ACF Options is built using TailwindCSS and compiled with Laravel Mix.

$ yarn install
$ yarn run start

Todo

  • Continue optimizing/cleaning up existing styles.
  • Add styles for ACF switches, input fields (focus, hover), buttons, etc.

Bug Reports

If you discover a bug in Modern ACF Options, please open an issue.

Contributing

Contributing whether it be through PRs, reporting an issue, or suggesting an idea is encouraged and appreciated.

License

Modern ACF Options is provided under the MIT License.

modern-acf-options's People

Contributors

log1x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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