Skip to content

Commit

Permalink
Merge pull request #13 from AyeCode/master
Browse files Browse the repository at this point in the history
* Select2 not being added if other JS options selected - FIXED
  • Loading branch information
kprajapatii authored Oct 13, 2020
2 parents 3df4bd5 + 9afd2ac commit 56b02fe
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ayecode-ui-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
add_action('after_setup_theme', function () {
global $ayecode_ui_version,$ayecode_ui_file_key;
$this_version = "0.1.32";
$this_version = "0.1.33";
if(version_compare($this_version , $ayecode_ui_version, '>')){
$ayecode_ui_version = $this_version ;
$ayecode_ui_file_key = wp_hash( __FILE__ );
Expand Down
4 changes: 4 additions & 0 deletions change-log.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
= 0.1.33 =
* Select2 not being added if other JS options selected - FIXED
* Inputs now have wrap_class argument to add classes to the wrapper - ADDED

= 0.1.32 =
* Multi-select not always adding [] to name attribute - FIXED
* Multi-select not checking if values is_array - FIXED
Expand Down
4 changes: 2 additions & 2 deletions includes/ayecode-ui-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ public function enqueue_scripts() {
wp_add_inline_script( 'bootstrap-js-bundle', $script );
}elseif($this->settings[$js_setting]=='popper'){
$url = $this->url.'assets/js/popper.min.js';
wp_register_script( 'bootstrap-js-popper', $url, array('jquery'), $this->latest );
wp_register_script( 'bootstrap-js-popper', $url, array('select2','jquery'), $this->latest );
wp_enqueue_script( 'bootstrap-js-popper' );
$load_inline = true;
}else{
Expand All @@ -833,7 +833,7 @@ public function enqueue_scripts() {

// Load needed inline scripts by faking the loading of a script if the main script is not being loaded
if($load_inline){
wp_register_script( 'bootstrap-dummy', '',array('jquery') );
wp_register_script( 'bootstrap-dummy', '',array('select2','jquery') );
wp_enqueue_script( 'bootstrap-dummy' );
$script = $this->inline_script();
wp_add_inline_script( 'bootstrap-dummy', $script );
Expand Down
20 changes: 18 additions & 2 deletions includes/components/class-aui-component-input.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static function input($args = array()){
'type' => 'text',
'name' => '',
'class' => '',
'wrap_class' => '',
'id' => '',
'placeholder'=> '',
'title' => '',
Expand Down Expand Up @@ -149,7 +150,7 @@ public static function input($args = array()){
}

// class
$class = !empty($args['class']) ? $args['class'] : '';
$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
$output .= ' class="form-control '.$class.'" ';

// data-attributes
Expand Down Expand Up @@ -254,6 +255,7 @@ public static function input($args = array()){

$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
$output = self::wrap(array(
'content' => $output,
'class' => $wrap_class,
Expand All @@ -280,6 +282,7 @@ public static function textarea($args = array()){
$defaults = array(
'name' => '',
'class' => '',
'wrap_class' => '',
'id' => '',
'placeholder'=> '',
'title' => '',
Expand Down Expand Up @@ -447,6 +450,7 @@ public static function textarea($args = array()){
if(!$args['no_wrap']){
$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
$output = self::wrap(array(
'content' => $output,
'class' => $wrap_class,
Expand Down Expand Up @@ -497,6 +501,7 @@ public static function label($args = array(), $type = ''){
}

// class
$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
$output .= ' class="'.$class.'" ';

// close
Expand All @@ -518,6 +523,13 @@ public static function label($args = array(), $type = ''){
return $output;
}

/**
* Wrap some content in a HTML wrapper.
*
* @param array $args
*
* @return string
*/
public static function wrap($args = array()){
$defaults = array(
'type' => 'div',
Expand Down Expand Up @@ -553,7 +565,7 @@ public static function wrap($args = array()){
}

// class
$class = !empty($args['class']) ? $args['class'] : '';
$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
$output .= ' class="'.$class.'" ';

// close wrap
Expand Down Expand Up @@ -599,6 +611,7 @@ public static function wrap($args = array()){
public static function select($args = array()){
$defaults = array(
'class' => '',
'wrap_class' => '',
'id' => '',
'title' => '',
'value' => '', // can be an array or a string
Expand Down Expand Up @@ -808,6 +821,7 @@ public static function select($args = array()){
// wrap
if(!$args['no_wrap']){
$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
$output = self::wrap(array(
'content' => $output,
'class' => $wrap_class,
Expand All @@ -830,6 +844,7 @@ public static function select($args = array()){
public static function radio($args = array()){
$defaults = array(
'class' => '',
'wrap_class' => '',
'id' => '',
'title' => '',
'horizontal' => false, // sets the lable horizontal
Expand Down Expand Up @@ -894,6 +909,7 @@ public static function radio($args = array()){

// wrap
$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
$output = self::wrap(array(
'content' => $output,
'class' => $wrap_class,
Expand Down

0 comments on commit 56b02fe

Please sign in to comment.