redux-framework icon indicating copy to clipboard operation
redux-framework copied to clipboard

Spacing field outputting zeros when nothing entered

Open Webcreations907 opened this issue 12 years ago • 1 comments

Hey there,

When using a spacing field, if you don't enter any values it still prints out zeros.

array(
    'id'             => 'opts-spacing',
    'type'           => 'spacing',
    'output'         => array('.my-padding-test'),
    'units'          => 'px',
    'left'           => false,
    'right'          => false,
    'units_extended' => false,
    'title'          => __('Title Area', 'framework'),
    'subtitle'       => __('Sub Title', 'framework'),
    'desc'           => __('Description', 'framework'),
    'default'        => array(
        'padding-top'     => '',
        'padding-bottom'  => '',
    )
)

If you leave the the fields empty in theme options, then it would output the below.

.my-padding-test{
padding-top:0;
padding-bottom:0;
}

WP 3.8 and 4.0 ReduxFramework 3.3.6.9 was on previous version as well, just forgot till updated to latest

Made a change to keep it from doing that, maybe if considered a issue could be looked into. https://gist.github.com/Webcreations907/789ac1da06448b90d398#file-field_spacing-php-L321-L324

Thanks :)

EDITED: Just updated that gist, smaller change to check if it's value is empty

Webcreations907 avatar Sep 04 '14 21:09 Webcreations907

The only problem is this will not allow 0 to output it it's there. This is a better solution and I just pushed it:

// Output if it's a numeric entry
if ( isset( $value ) && is_numeric( $value ) ) {
  $style .= $key . ':' . $value . ';';
}

dovy avatar Sep 05 '14 19:09 dovy