Skip to content

Commit

Permalink
Merge pull request #223 from codersaiful/3.2.0.2
Browse files Browse the repository at this point in the history
3.2.0.2
  • Loading branch information
codersaiful authored Jul 25, 2022
2 parents d547192 + 5a9d43d commit 5be0441
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 5 deletions.
51 changes: 51 additions & 0 deletions admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,57 @@ function wpt_default_option( $page ){
}
}

/**
* Remove empty Array value from an Multi-dimensional Array
* I have taken help from a stackoverflow tips.
*
* @param Array $array Obviously should be an Array
* @return Array
*
* @link https://stackoverflow.com/questions/9895130/recursively-remove-empty-elements-and-subarrays-from-a-multi-dimensional-array
*
*/
function wpt_remove_empty_value_from_array( $array ){


if( ! is_array( $array ) ) return $array;
// foreach($array as $key=>&$arr){
// if( empty( $arr ) ){
// unset( $array[$key] );
// }
// if( is_array($arr) ){
// wpt_remove_empty_value_from_array( $arr );
// }
// }
// return $array;

// $array = array_filter($array,function($val){
// if( is_array( $val ) ){
// return wpt_remove_empty_value_from_array( $val );
// }
// return ! empty($val);
// });

// $array = array_filter(array_map('array_filter', $array));
// return $array;

foreach ($array as $key => &$value) {
if ( ! is_bool( $value ) && empty($value)) {
unset($array[$key]);
}
else {
if (is_array($value)) {
$value = wpt_remove_empty_value_from_array($value);
if (! is_bool( $value ) && empty($value)) {
unset($array[$key]);
}
}
}
}

return $array;
}



/**
Expand Down
5 changes: 3 additions & 2 deletions admin/post_metabox.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ function wpt_shortcode_configuration_metabox_save_meta( $post_id, $post ) { // s
);

$submitte_data = filter_input_array( INPUT_POST, $filtar_args );
$submitte_data = array_filter( $submitte_data );

$submitte_data = wpt_remove_empty_value_from_array($submitte_data);
/********* Column Setting Optimizing Start here ***********/

//Fixing for tablet setting
Expand Down Expand Up @@ -461,9 +461,10 @@ function wpt_shortcode_configuration_metabox_save_meta( $post_id, $post ) { // s
* Only for customer use at this moment.
*/
$tab_data = apply_filters( 'wpto_tab_data_on_save_' . $tab, $tab_data, $post_id, $save_tab_array );
$tab_data = wpt_remove_empty_value_from_array( $tab_data );
update_post_meta( $post_id, $tab, $tab_data );
}

/**
* @Hook Action: wpto_on_save_post
* To change data when Form will save.
Expand Down
4 changes: 4 additions & 0 deletions assets/css/templates/beautiful_blacky.css
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,8 @@ body.wpt_table_body .beautiful_blacky_wrapper .wpt_search_box .search_box_wrappe
.woocommerce-noreviews,
p.no-comments {
background-color: #37aee9 !important;
}

div.wpt-footer-cart-wrapper>a:after, div.wpt-footer-cart-wrapper>a {
background-color: #37aee9 !important;
}
2 changes: 1 addition & 1 deletion assets/css/templates/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -694,4 +694,4 @@ body.wpt_table_body .default_wrapper button:focus {
background-color: transparent;
border: 1px solid var(--wpt-default-primary);
color: var(--wpt-default-primary);
}
}
5 changes: 3 additions & 2 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,9 @@ function wpt_get_value_with_woocommerce_unit( $target_unit, $value ){
function wpt_adding_body_class( $class ) {

global $post,$shortCodeText;

if( isset($post->post_content) && has_shortcode( $post->post_content, $shortCodeText ) ) {

if( ( isset($post->post_content) && has_shortcode( $post->post_content, $shortCodeText ) )
|| $post->post_type == 'wpt_product_table' ) {
$class[] = 'wpt_table_body';
$class[] = 'woocommerce';
}
Expand Down

0 comments on commit 5be0441

Please sign in to comment.