Skip to content

Commit

Permalink
bump and updated changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Mte90 committed Mar 27, 2019
1 parent f6cbf3b commit 716920f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmb2-field-ajax-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CMB2_Field_Ajax_Search {
/**
* Current version number
*/
const VERSION = '1.0.2';
const VERSION = '1.0.3';

/**
* Initialize the plugin by hooking into CMB2
Expand Down Expand Up @@ -116,8 +116,8 @@ public function render( $field, $value, $object_id, $object_type, $field_type )

echo $field_type->input( array(
'type' => 'text',
'name' => $field->_name() . '_input',
'id' => $field_name . '_input',
'name' => '_' . $field->_name(),
'id' => $field_name,
'class' => 'cmb-ajax-search cmb-' . $object_to_search . '-ajax-search',
'value' => $input_value,
'desc' => false,
Expand Down
8 changes: 4 additions & 4 deletions js/ajax-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$('.cmb-ajax-search:not([data-ajax-search="true"])').each(function () {
$(this).attr('data-ajax-search', true);

var field_id = $(this).attr('id').replace( new RegExp('_input$'), '' ).replace(/[\[\]']+/g, '_'); // Field id, the true one field
var field_id = $(this).attr('id').replace(/[\[\]']+/g, '_'); // Field id, the true one field
var object_type = $(this).attr('data-object-type');
var query_args = $(this).attr('data-query-args');

Expand Down Expand Up @@ -50,17 +50,17 @@
onSelect: function ( suggestion ) {
$(this).devbridgeAutocomplete('clearCache');

var field_name = $(this).attr('name').replace( new RegExp('_input$'), '' );
var field_name = $(this).attr('name');
var multiple = $(this).attr('data-multiple');
var limit = parseInt( $(this).attr('data-limit') );
var sortable = $(this).attr('data-sortable');
var field_name_temp = field_name.replace( /[\[\]']+/g, '_' );
var field_name_temp = field_name.substring(1).replace( /[\[\]']+/g, '_' );

if( multiple == 1 ) {
// Multiple
$('#' + field_name_temp + '_results' ).append( '<li>' +
( ( sortable == 1 ) ? '<span class="hndl"></span>' : '' ) +
'<input type="hidden" name="' + field_name + '[]" value="' + suggestion.id + '">' +
'<input type="hidden" name="' + field_name.substring(1) + '[]" value="' + suggestion.id + '">' +
'<a href="' + suggestion.link + '" target="_blank" class="edit-link">' + suggestion.value + '</a>' +
'<a class="remover"><span class="dashicons dashicons-no"></span><span class="dashicons dashicons-dismiss"></span></a>' +
'</li>' );
Expand Down
12 changes: 9 additions & 3 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function cmb2_ajax_search_metabox() {
'desc' => __( 'Field description (optional)', 'cmb2' ),
'id' => $prefix . 'posts',
'type' => 'post_ajax_search',
'multiple' => true,
'multiple-item' => true,
'limit' => 10,
'query_args' => array(
'post_type' => array( 'post', 'page' ),
Expand All @@ -88,7 +88,7 @@ function cmb2_ajax_search_metabox() {
'desc' => __( 'Field description (optional)', 'cmb2' ),
'id' => $prefix . 'users',
'type' => 'user_ajax_search',
'multiple' => true,
'multiple-item' => true,
'limit' => 5,
'query_args' => array(
'role__not_in' => array( 'Administrator', 'Editor' ),
Expand All @@ -113,7 +113,7 @@ function cmb2_ajax_search_metabox() {
'desc' => __( 'Field description (optional)', 'cmb2' ),
'id' => $prefix . 'terms',
'type' => 'term_ajax_search',
'multiple' => true,
'multiple-item' => true,
'limit' => -1,
'query_args' => array(
'taxonomy' => 'post_tag',
Expand Down Expand Up @@ -156,6 +156,12 @@ If multiple == true will return an array of IDs of attached object:

## Changelog

### 1.0.3

* Fixed issues with repeatable fields
* Removed unused code
* Moved to new paramenter `multiple-item` to avoid conflicts with CMB2

### 1.0.2
* Updated devbridgeAutocomplete lib

Expand Down

0 comments on commit 716920f

Please sign in to comment.