2017 © Pedro Peláez
 

library carbon-fields-urlpicker

Carbon Fields extension, that adds a URL picker field type.

image

iamntz/carbon-fields-urlpicker

Carbon Fields extension, that adds a URL picker field type.

  • Monday, June 11, 2018
  • by iamntz
  • Repository
  • 1 Watchers
  • 0 Stars
  • 277 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 26 % Grown

The README.md

Carbon Field: urlpicker

(this is an extension of Carbon Fields plugin), (*1)

Adds a urlpicker field type to Carbon Fields. Install using composer:, (*2)

composer require iamntz/carbon-fields-urlpicker

You're using Carbon Fields v3? Then install it from the v3 branch!, (*3)

composer require iamntz/carbon-fields-urlpicker:v3.x-dev

(first, make sure you have "minimum-stability": "dev" set in composer.json), (*4)

Or by installing as a WP plugin (composer is recommended though; installing as a plugin may throw an error)., (*5)

Return values:

The field will return an associative array with the following values:, (*6)

url: the actual URL
anchor: the text anchor (might be blank)
blank: wether the link should open in a new window or not

Demo

https://img.iamntz.com/jing/video_2017-09-01__12_22.mp4, (*7)

Example

Registering A Field

This goes in your functions.php as with other Carbon Fields fields. The only difference is that the type is urlpicker., (*8)

use Carbon_Fields\Container;
use Carbon_Fields\Field;

add_action( 'carbon_fields_register_fields', 'crb_url_picker_test' );

function crb_url_picker_test() {
  Container::make( 'post_meta', 'URL Picker Test' )
    ->add_fields( array(
      Field::make( 'urlpicker', 'crb_my_link', 'URL Picker Test' )
      ->set_help_text( "This is a test of the URL picker." )
    ));
}

Using Field Values

<?php $my_link = carbon_get_the_post_meta( 'crb_my_link' ); ?>
<a href="<?= $my_link[url] ?>"<?= ( $my_link[blank] ? ' target="_blank"' : '') ?>><?= $my_link[anchor] ?></a>

Note that the anchor field will return 0 or 1, depending on whether the checkbox is ticked next to "Open link in a new tab"., (*9)

Found this useful?

You can get hosting (and receive $10 credit!), donate or buy me a gift., (*10)

The Versions

11/06 2018

dev-master

9999999-dev https://github.com/iamntz/carbon-fields-urlpicker

Carbon Fields extension, that adds a URL picker field type.

  Sources   Download

GPL-2.0+

The Requires

 

by Ionut Staicu

wordpress carbon-field carbon-fields-urlpicker