All Projects → nickforddev → acf-swatch

nickforddev / acf-swatch

Licence: other
ACF Color Swatch Field

Programming Languages

PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to acf-swatch

acf-field-boilerplate
Modernized PSR-2 boilerplate for creating custom fields for ACF5.
Stars: ✭ 54 (-19.4%)
Mutual labels:  wordpress-plugin, acf, advanced-custom-fields
acf-typography
A Typography Add-on for the Advanced Custom Fields Plugin
Stars: ✭ 14 (-79.1%)
Mutual labels:  wordpress-plugin, acf, advanced-custom-fields
acf-country
ACF Country field - Display a select field of all countries, in any language.
Stars: ✭ 103 (+53.73%)
Mutual labels:  wordpress-plugin, acf, advanced-custom-fields
Acf Quickedit Fields
WordPress Plugin implementing Column Displaying, QuickEdit and BulkEdit for Advanced Custom Fields (ACF)
Stars: ✭ 328 (+389.55%)
Mutual labels:  wordpress-plugin, acf
acf-flexible-content-preview
Transforms ACF's flexible content field's layout list into a modal with image previews.
Stars: ✭ 21 (-68.66%)
Mutual labels:  wordpress-plugin, acf
bea-beautiful-flexible
Transform ACF's flexible layouts list into a nice and UX popup.
Stars: ✭ 19 (-71.64%)
Mutual labels:  wordpress-plugin, acf
Acf Star Rating Field
A simple star rating field for ACF.
Stars: ✭ 94 (+40.3%)
Mutual labels:  wordpress-plugin, acf
Fewbricks
Write code to create ACF field groups, fields and re-usable modules.
Stars: ✭ 100 (+49.25%)
Mutual labels:  wordpress-plugin, acf
Acf To Rest Api
Exposes Advanced Custom Fields Endpoints in the WordPress REST API
Stars: ✭ 1,152 (+1619.4%)
Mutual labels:  wordpress-plugin, acf
Acf Codifier
A wrapper class to help write more readable ACF field declarations.
Stars: ✭ 114 (+70.15%)
Mutual labels:  wordpress-plugin, acf
acf-image-aspect-ratio-crop
Image Aspect Ratio Crop field for Advanced Custom Fields
Stars: ✭ 100 (+49.25%)
Mutual labels:  acf, advanced-custom-fields
acf-conditional-logic-advanced
Advanced Custom Fields - Conditional Logic Advanced
Stars: ✭ 31 (-53.73%)
Mutual labels:  acf, advanced-custom-fields
acf-recaptcha
Google reCAPTCHA plugin for Advanced Custom Fields on WordPress
Stars: ✭ 29 (-56.72%)
Mutual labels:  wordpress-plugin, advanced-custom-fields
acf-phone-number
A real ACF phone number field powered by libphonenumber and intl-tel-input
Stars: ✭ 68 (+1.49%)
Mutual labels:  wordpress-plugin, acf
Acf Options For Polylang
A WordPress plugin for adding ACF options page support for Polylang.
Stars: ✭ 131 (+95.52%)
Mutual labels:  wordpress-plugin, acf
acf-field-group-composer
Configuration builder for advanced custom fields field groups
Stars: ✭ 37 (-44.78%)
Mutual labels:  acf, advanced-custom-fields
flexible-templates
Allows saving templates of the "Flexible Content" field, for easy and fast use of them on other pages.
Stars: ✭ 36 (-46.27%)
Mutual labels:  wordpress-plugin, acf
color-palette-generator
This WordPress plugin allows you to generate & show color palettes for all your images in your Media Library.
Stars: ✭ 19 (-71.64%)
Mutual labels:  wordpress-plugin
index-autoload
Adds an index to the autoload in wp_options table and verifies it exists on a daily basis (using WP Cron), resulting in a more efficient database.
Stars: ✭ 18 (-73.13%)
Mutual labels:  wordpress-plugin
DigiPass
DigiPass (Paywall) WordPress plugin
Stars: ✭ 11 (-83.58%)
Mutual labels:  wordpress-plugin

ACF - Color Swatch field add-on

  • Author: Nick Ford
  • Tags: acf, acf add-on, color, color swatch, color swatches
  • Requires at least: 4.0
  • Tested up to: 5

License: GPLv2 or later

Description

This is a simple ACF Add-on field allowing the creation of color swatches that behave as radio buttons. This is particularly useful if you want to limit the color options available to the end users, instead of using a color picker field.

This is an add-on for the Advanced Custom Fields WordPress plugin and will not provide any functionality to WordPress unless Advanced Custom Fields is installed and activated.

The color swatch field is a radio button field, with a few modifications. The syntax for building the choices is the same as a radio button field, in that you may include a key : value pair, or just a single value, each option separated by a line break.

The field expects each line to be a color string, and can interpret all of the possible color formats.

For example, all of the following will produce a bright red swatch:

  • red
  • #ff0000
  • rgb(255,0,0)
  • rgba(255,0,0, 1)
  • hsl(0,100%,50%)
  • hsla(0,100%,50%, 1)

Additionally, if you are using rgb/rgba or hsl/hsla, you may use only the values, if desired. For instance:

  • 255,0,0, 1 // will be recognized as rgba
  • 0,100%,50% // will be recognized as hsl

This may be useful for defining CSS linear-gradients, or other situations where you may want to alter some of the values in the view.

Note that while the field can recognize these shortened syntaxes to display the color swatch in the Wordpress back end, it will still output only what you entered when using the_field() or get_field().

Screenshots

Choices Field

Color Swatches

Installation

Wordpress Plugin Store


https://wordpress.org/plugins/acf-color-swatches

Composer


If using Composer (e.g. with Bedrock)

  • Add repo to composer.json:
"repositories": [
  {
    "type": "git",
    "url": "https://github.com/nickforddesign/acf-swatch"
  }
]
  • Install using composer composer require nickford/acf-swatch

Manual


  • Clone the repository to /wp-content/plugins/ in your Wordpress installation
  • Activate in the Plugins manager.

Suggested Usage

Assuming you select a swatch with value "rgba(255,0,0, 1)":

As inline CSS:

<section style="background-color: <?php the_field('swatches')?>">

Inside a <style> tag:

<style>
section {
  background-color: <?php the_field('swatches')?>;
}
</style>

One situation where you might want to take advantage of the shorthand syntax would be to control a CSS linear-gradient that fades a color from 100% opacity to 0%.

Assuming you select a swatch with value "255,0,0":

<style>
section {
  background: linear-gradient(
                to bottom,
                rgba(<?php the_field('swatches')?>, 1) 0%,
                rgba(<?php the_field('swatches')?>, 0) 100%
              );
}
</style>

Including Within Theme

Take advantage of the acf/swatch_settings/path and acf/swatch_settings/url filters to modify where acf-swatch is located so that js and css are found correctly in the backend.

/**
 * Include ACF Color Swatch Field
 */

add_filter('acf/swatch_settings/path', 'my_swatch_path', 10, 1);

function my_swatch_path( $path ) {
  
  $path = get_template_directory() . '/path/to/acf-swatch';
  
  return $path;
  
}

add_filter('acf/swatch_settings/url', 'my_swatch_url', 10, 1);

function my_swatch_url( $url ) {
  
  $url = get_template_directory_uri() . '/path/to/acf-swatch';
  
  return $url;
  
}

include( 'path/to/acf-swatch.php' );

Changelog

4/25/18 - v1.0.7

  • issue - Fixed bug with returning value instead of array

10/23/17 - v1.0.6

  • d57ec40 - Match background-color syntax
  • 4892d0e - Allow transparent values to be selected

10/23/17 - v1.0.5

  • fa93a8b - Add return value option

2/13/17 - v1.0.4

  • 44912a6 - Allow inclusion within theme

10/21/16 - v1.0.3-rc.1

  • 7bdc1d2 - Improved composer instructions

10/7/16 - v1.0.3

  • 9d733d9 - Add composer.json
  • Added readme.txt for Wordpress plugin database

5/19/16 - v1.0.3-alpha

11/9/15 - v1.0.2

  • Added checkerboard pattern to indicate transparency
  • Added subtle border to show swatches that match the background color

10/14/15 - v1.0.1

  • Improved browser / OS support by replacing input elements with block elements

9/20/15 - v1.0.0

  • Initial Release
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].