Plugin Directory

Changeset 1448137


Ignore:
Timestamp:
07/03/2016 05:21:41 PM (10 years ago)
Author:
iambriansreed
Message:
  • Removed old tag-it library and replaced with Select2 library. Fixed font_size issue: @JoelStransky
Location:
advanced-custom-fields-tag-it/trunk
Files:
3 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • advanced-custom-fields-tag-it/trunk/acf-tag-it.php

    r1232241 r1448137  
    44Plugin Name: Advanced Custom Fields: Tag It
    55Plugin URI: https://wordpress.org/plugins/advanced-custom-fields-tag-it/
    6 Description: The jQuery UI Tag It field for ACF
    7 Version: 1.0.0
     6Description: A tag-it field for ACF
     7Version: 2.0.0
    88Author: Brian Reed
    99Author URI: iambrian.com
  • advanced-custom-fields-tag-it/trunk/field.php

    r1232241 r1448137  
    11<?php
    2 class acf_field_tag_it extends acf_field
    3 {
    4     function __construct()
    5     {
     2
     3class acf_field_tag_it extends acf_field {
     4
     5    function __construct() {
     6
    67        $this->name     = 'tag-it';
    7         $this->label    = __('Tag It', 'acf-tag-it');
     8        $this->label    = __( 'Tag It', 'acf-tag-it' );
    89        $this->category = 'basic';
    910        $this->defaults = array();
    1011        $this->l10n     = array(
    11             'error' => __('Error! Please enter a higher value', 'acf-tag-it')
     12            'error' => __( 'Error! Please enter a higher value', 'acf-tag-it' )
    1213        );
     14
    1315        parent::__construct();
    1416    }
    15     function render_field_settings($field)
    16     {
    17         acf_render_field_setting($field, array(
    18             'label' => __('Available Tags', 'acf-tag-it'),
    19             'instructions' => __("Used as source for autocompletion, unless source is overridden.<br><br>Enter each choice on a new line.", 'acf-tag-it'),
    20             'type' => 'textarea',
    21             'name' => 'available_tags'
    22         ));
     17
     18    function render_field_settings( $field ) {
     19
     20        acf_render_field_setting( $field, array(
     21            'label'        => __( 'Available Tags', 'acf-tag-it' ),
     22            'instructions' => __( "Used as source for autocompletion, unless source is overridden.<br><br>Enter each choice on a new line.", 'acf-tag-it' ),
     23            'type'         => 'textarea',
     24            'name'         => 'available_tags'
     25        ) );
    2326    }
    24     function render_field($field)
    25     {
    26 ?>
    27         <input id="<?php
    28         echo esc_attr($field['id']);
    29 ?>" type="text" name="<?php
    30         echo esc_attr($field['name']);
    31 ?>" value="<?php
    32         echo esc_attr($field['value']);
    33 ?>" style="font-size:<?php
    34         echo $field['font_size'];
    35 ?>px;" class="acf-tag-it" />
    36         <script>window[<?php
    37         echo "'$field[id]_tagit_settings'";
    38 ?>] = {
    39             'availableTags' : <?php
    40         echo json_encode(explode("\n", $field['available_tags']));
    41 ?>
    42         };
     27
     28    function try_json_decode( $string ) {
     29
     30        $value = json_decode( $string );
     31
     32        return (object) array(
     33            'value'   => $value,
     34            'success' => ( json_last_error() == JSON_ERROR_NONE )
     35        );
     36    }
     37
     38    function render_field( $field ) {
     39        $options = json_encode( array_map( 'trim', explode( "\n", $field['available_tags'] ) ) );
     40
     41        ?>
     42        <input id="<?php echo esc_attr( $field['id'] ); ?>"
     43               type="text"
     44               class="acf-tag-it"
     45               name="<?php echo esc_attr( $field['name'] ); ?>"
     46               value="<?php echo esc_attr( $field['value'] ); ?>"
     47               style="width: 100%"
     48        />
     49        <script>
     50            jQuery('#<?php echo $field['id']; ?>').select2({tags: <?php echo $options; ?>});
    4351        </script>
    4452        <?php
    4553    }
    46     function input_admin_enqueue_scripts()
    47     {
    48         $dir = plugin_dir_url(__FILE__);
    49         wp_enqueue_script('acf-input-tag-it', "{$dir}js/input.js", array(
    50             'jquery-ui-autocomplete'
    51         ));
    52         wp_enqueue_style('acf-input-tag-it', "{$dir}css/input.css");
    53     }
    5454}
     55
    5556new acf_field_tag_it();
  • advanced-custom-fields-tag-it/trunk/readme.txt

    r1232241 r1448137  
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
    99
    10 The jQuery UI Tag It field for ACF
     10The Tag It field for ACF using ACF 5's built-in Select2 library.
    1111
    1212== Description ==
    1313
    14 Do you need to be able to select multiple bits of text but a repeater field is overkill? Use the Tag It field. This plugin brings Alex Ehlke's Tag It Field to ACF.
     14Do you need to be able to select multiple bits of text but a repeater field is overkill? Use the tag-it field. This plugin brings uses ACF 5's built-in Select2 library.
    1515
    1616This field currently includes the following options:
     
    1818* available tags : Used as source for the autocompletion.
    1919
    20 The original jQuery UI plugin can be found here: https://github.com/aehlke/tag-it
     20The jQuery UI plugin used in the first version of this plugin can be found here: https://github.com/aehlke/tag-it
     21The Select2 library used in ACF 5 can be found here: http://select2.github.io/select2/
    2122
    2223= Compatibility =
     
    3637= 1.0.0 =
    3738* Initial Release.
     39
     40= 2.0.0 =
     41* Removed old tag-it library and replaced with Select2 library. Fixed font_size issue: @JoelStransky
Note: See TracChangeset for help on using the changeset viewer.