WP Manifestindependent plugin directory
manifest / content / acf-smart-button

Advanced Custom Fields: Smart Button WP Registry grade A. No security issues foundWP RegistryNo security issues foundOpen the reportA

A simple, clean and lean acf Field for internal and external links.

★ 77stars
26kcomposer installs
1.0.4latest · 6 years ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/gillesgoetsch/acf-smart-button/archive/refs/heads/master.zip

On Packagist as gillesgoetsch/acf-smart-button:

composer require gillesgoetsch/acf-smart-button
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

A simple, clean and lean ACF Field that allows the user to select an internal link as a post_object or an external link as a url field via a smooth toggle.

It always returns the url as the same field, whether it's an internal or external link. With button.target you can additionally add target="_blank" in your template without additional casing.

alt tag

alt tag

Example (twig style):

{% if button %}   
  <a href="{{ button.url }}" {{button.target }}>{{ button.text }}</a>   
{% endif %}

Isn't that lean =)?

Example (vanilla PHP):

if ( get_field( 'acf_button_field' ) ) :
  $button = get_field( 'acf_button_field' );
  $button_label = $button['text'];
  $button_url = $button['url'];
  $button_target = $button['target'];
endif;

Output / Return

When Internal

[text] => I am an internal button
[url] => http://yoursite.dev/selected-page
[target] => ''

When External

[text] => I am an external button
[url] => http://kollektiv.ag
[target] => 'target="blank"'

Note: In both cases the field data will only be returned if the button text is set in combination with a target. If either one is missing, there will be no data returned.

Future Plans

  • option to select allowed post_types for post_object selector 7626ad4
  • language support
  • validate url field
  • cleanups etc.
  • eventually acf4 support (no?)

Compatibility

This add-on works only with version 5 and up.

Installation

This add-on can be treated as both a WP plugin and a theme include.

Install as Plugin

  1. Copy the 'acf-button' folder into your plugins folder
  2. Activate the plugin via the Plugins admin page

Include within theme

  1. Copy the 'acf-smart-button' folder into your theme folder (can use sub folders). You can place the folder anywhere inside the 'wp-content' directory
  2. Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-button.php file)
include_once('acf-smart-button/acf-smart-button.php');

Else

Partially inspired by https://github.com/envex/acf-button-field, but is missing acf5 support and didn't meet my requirements fully.

Releases

4 releases.

Tag
Published
1.0.4 latest
Jul 9, 2020 6 years ago
Oct 25, 2018 7 years ago
Oct 24, 2018 8 years ago
Aug 17, 2017 9 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

A grade

Security

Advanced Custom Fields: Smart Button 1.0.4 · audited by WP Registry

No security issues found.

Audited release
1.0.4
Findings
none
Worst severity
—
Content hash
fdf377ddd4a5dcefb7d0e91b…

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.