bump and updated changelog

This commit is contained in:
Mte90 2019-03-27 21:50:14 +01:00
parent f6cbf3b434
commit 716920f25a
3 changed files with 16 additions and 10 deletions

View File

@ -27,7 +27,7 @@ if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) {
/** /**
* Current version number * Current version number
*/ */
const VERSION = '1.0.2'; const VERSION = '1.0.3';
/** /**
* Initialize the plugin by hooking into CMB2 * Initialize the plugin by hooking into CMB2
@ -116,8 +116,8 @@ if( ! class_exists( 'CMB2_Field_Ajax_Search' ) ) {
echo $field_type->input( array( echo $field_type->input( array(
'type' => 'text', 'type' => 'text',
'name' => $field->_name() . '_input', 'name' => '_' . $field->_name(),
'id' => $field_name . '_input', 'id' => $field_name,
'class' => 'cmb-ajax-search cmb-' . $object_to_search . '-ajax-search', 'class' => 'cmb-ajax-search cmb-' . $object_to_search . '-ajax-search',
'value' => $input_value, 'value' => $input_value,
'desc' => false, 'desc' => false,

View File

@ -3,7 +3,7 @@
$('.cmb-ajax-search:not([data-ajax-search="true"])').each(function () { $('.cmb-ajax-search:not([data-ajax-search="true"])').each(function () {
$(this).attr('data-ajax-search', true); $(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 object_type = $(this).attr('data-object-type');
var query_args = $(this).attr('data-query-args'); var query_args = $(this).attr('data-query-args');
@ -50,17 +50,17 @@
onSelect: function ( suggestion ) { onSelect: function ( suggestion ) {
$(this).devbridgeAutocomplete('clearCache'); $(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 multiple = $(this).attr('data-multiple');
var limit = parseInt( $(this).attr('data-limit') ); var limit = parseInt( $(this).attr('data-limit') );
var sortable = $(this).attr('data-sortable'); 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 ) { if( multiple == 1 ) {
// Multiple // Multiple
$('#' + field_name_temp + '_results' ).append( '<li>' + $('#' + field_name_temp + '_results' ).append( '<li>' +
( ( sortable == 1 ) ? '<span class="hndl"></span>' : '' ) + ( ( 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 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>' + '<a class="remover"><span class="dashicons dashicons-no"></span><span class="dashicons dashicons-dismiss"></span></a>' +
'</li>' ); '</li>' );

View File

@ -62,7 +62,7 @@ function cmb2_ajax_search_metabox() {
'desc' => __( 'Field description (optional)', 'cmb2' ), 'desc' => __( 'Field description (optional)', 'cmb2' ),
'id' => $prefix . 'posts', 'id' => $prefix . 'posts',
'type' => 'post_ajax_search', 'type' => 'post_ajax_search',
'multiple' => true, 'multiple-item' => true,
'limit' => 10, 'limit' => 10,
'query_args' => array( 'query_args' => array(
'post_type' => array( 'post', 'page' ), 'post_type' => array( 'post', 'page' ),
@ -88,7 +88,7 @@ function cmb2_ajax_search_metabox() {
'desc' => __( 'Field description (optional)', 'cmb2' ), 'desc' => __( 'Field description (optional)', 'cmb2' ),
'id' => $prefix . 'users', 'id' => $prefix . 'users',
'type' => 'user_ajax_search', 'type' => 'user_ajax_search',
'multiple' => true, 'multiple-item' => true,
'limit' => 5, 'limit' => 5,
'query_args' => array( 'query_args' => array(
'role__not_in' => array( 'Administrator', 'Editor' ), 'role__not_in' => array( 'Administrator', 'Editor' ),
@ -113,7 +113,7 @@ function cmb2_ajax_search_metabox() {
'desc' => __( 'Field description (optional)', 'cmb2' ), 'desc' => __( 'Field description (optional)', 'cmb2' ),
'id' => $prefix . 'terms', 'id' => $prefix . 'terms',
'type' => 'term_ajax_search', 'type' => 'term_ajax_search',
'multiple' => true, 'multiple-item' => true,
'limit' => -1, 'limit' => -1,
'query_args' => array( 'query_args' => array(
'taxonomy' => 'post_tag', 'taxonomy' => 'post_tag',
@ -156,6 +156,12 @@ If multiple == true will return an array of IDs of attached object:
## Changelog ## 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 ### 1.0.2
* Updated devbridgeAutocomplete lib * Updated devbridgeAutocomplete lib