Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iamntz/carbon-fields-urlpicker
Add an URL Picker field to Carbon
https://github.com/iamntz/carbon-fields-urlpicker
carbon-fields carbon-fields-field wordpress wordpress-plugin
Last synced: 3 months ago
JSON representation
Add an URL Picker field to Carbon
- Host: GitHub
- URL: https://github.com/iamntz/carbon-fields-urlpicker
- Owner: iamntz
- Created: 2017-09-01T15:10:33.000Z (over 7 years ago)
- Default Branch: v3
- Last Pushed: 2023-03-10T07:34:26.000Z (almost 2 years ago)
- Last Synced: 2024-04-16T09:22:08.327Z (10 months ago)
- Topics: carbon-fields, carbon-fields-field, wordpress, wordpress-plugin
- Language: JavaScript
- Size: 691 KB
- Stars: 13
- Watchers: 5
- Forks: 18
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Carbon Field: urlpicker
_(this is an extension of [Carbon Fields](http://carbonfields.net/) plugin)_
You can install it via composer:
```
composer require iamntz/carbon-fields-urlpicker --prefer-dist
```If you install it from the source, you need to make sure that you also run `npm install` and `npm run production` in order to have assets compiled.
## Return values:
The field will return an associative array with the following values:```
url: the actual URL
anchor: the text anchor (might be blank)
blank: wether the link should open in a new window or not
```## 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`.```php
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
Note that the `blank` field will return `0` or `1`, depending on whether the checkbox is ticked next to "Open link in a new tab".
## Found this useful?
You can get [hosting](https://m.do.co/c/c95a44d0e992) (and receive $10 credit!), [donate](https://www.paypal.me/iamntz) or buy me a [gift](http://iamntz.com/wishlist).