Download the PHP package gillesgoetsch/acf-smart-button without Composer
On this page you can find all versions of the php package gillesgoetsch/acf-smart-button. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gillesgoetsch/acf-smart-button
More information about gillesgoetsch/acf-smart-button
Files in gillesgoetsch/acf-smart-button
Package acf-smart-button
Short Description A simple, clean and lean ACF Field for internal and external links.
License GPLv2.0+
Informations about the package acf-smart-button
ACF Smart Button
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.
Example (twig style):
Isn't that lean =)?
Example (vanilla PHP):
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 selector7626ad4- 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
- Copy the 'acf-button' folder into your plugins folder
- Activate the plugin via the Plugins admin page
Include within theme
- 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
- Edit your functions.php file and add the code below (Make sure the path is correct to include the acf-button.php file)
Else
Partially inspired by https://github.com/envex/acf-button-field, but is missing acf5 support and didn't meet my requirements fully.