Skip to content

Commit

Permalink
Fix spacing field
Browse files Browse the repository at this point in the history
  • Loading branch information
dovy committed Sep 13, 2013
1 parent d39a60c commit 68ca11e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
32 changes: 16 additions & 16 deletions inc/fields/spacing/field_spacing.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function render(){

// No errors please
$defaults = array(
'units' => "px",
'units' => '',
'top' => true,
'bottom'=> true,
'left' => true,
Expand All @@ -51,8 +51,6 @@ function render(){

echo '<div id="'.$this->field['id'].'-container" class="redux-spacing-container" data-id="'.$this->field['id'].'">';



/**
Top
**/
Expand Down Expand Up @@ -87,21 +85,23 @@ function render(){
Units
**/

if ( empty( $this->field['units'] ) ):
echo '<div class="select_wrapper spacing-units" original-title="'.__('Units','redux-framework').'">';
echo '<select data-placeholder="'.__('Units','redux-framework').'" class="redux-spacing redux-spacing-units select'.$this->field['class'].'" original-title="'.__('Units','redux-framework').'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][units]" id="'. $this->field['id'].'_units">';
if (empty($this->value['units'])) {
echo '<option value=""></option>';
}
echo '<option value="px" '.selected($this->value['units'], 'px', false).'>px</option>';
if ( $this->field['units'] !== false ):

echo '<div class="select_wrapper spacing-units" original-title="'.__('Units','redux-framework').'">';
echo '<select data-placeholder="'.__('Units','redux-framework').'" class="redux-spacing redux-spacing-units select'.$this->field['class'].'" original-title="'.__('Units','redux-framework').'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][units]" id="'. $this->field['id'].'_units">';

$testUnits = array('px', 'em', '%');

if ( in_array($this->field['units'], $testUnits) ) {
echo '<option value="'.$this->field['units'].'" selected="selected">'.$this->field['units'].'</option>';
} else {

echo '<option value="px" '.selected($this->value['units'], 'px', false).'>px</option>';
echo '<option value="em"'.selected($this->value['units'], 'em', false).'>em</option>';
echo '<option value="%"'.selected($this->value['units'], '%', false).'>%</option>';
echo '</select></div>';
else :
echo '<div class="select_wrapper spacing-units" original-title="'.__('Units','redux-framework').'">';
echo '<select data-placeholder="'.__('Units','redux-framework').'" class="redux-spacing redux-spacing-units select'.$this->field['class'].'" original-title="'.__('Units','redux-framework').'" name="'.$this->args['opt_name'].'['.$this->field['id'].'][units]" id="'. $this->field['id'].'_units">';
echo '<option value="'.$this->field['units'].'" selected="selected">'.$this->field['units'].'</option>';
echo '</select></div>';
}
echo '</select></div>';

endif;


Expand Down
35 changes: 23 additions & 12 deletions sample/sample-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ function setup_framework_options(){
// Default: null
$args['dev_mode_icon_class'] = 'icon-large';

// Set a custom option name. Don't forget to replace spaces with underscores!
$args['opt_name'] = 'twenty_eleven';

// Setting system info to true allows you to view info useful for debugging.
// Default: true
Expand Down Expand Up @@ -173,15 +175,6 @@ function setup_framework_options(){
// Default: 'standard'
//$args['admin_stylesheet'] = 'standard';

// Add HTML before the form.
$args['intro_text'] = __('<p>This text is displayed above the options panel. It isn\'t required, but more info is always better! The intro_text field accepts all HTML.</p>', 'redux-framework');

// Add content after the form.
$args['footer_text'] = __('<p>This text is displayed below the options panel. It isn\'t required, but more info is always better! The footer_text field accepts all HTML.</p>', 'redux-framework');

// Set footer/credit line.
//$args['footer_credit'] = __('<p>This text is displayed in the options panel footer across from the WordPress version (where it normally says \'Thank you for creating with WordPress\'). This field accepts all HTML.</p>', 'redux-framework');

// Setup custom links in the footer for share icons
$args['share_icons']['twitter'] = array(
'link' => 'http://twitter.com/ghost1227',
Expand Down Expand Up @@ -209,9 +202,6 @@ function setup_framework_options(){
// Default: null
$args['import_icon_class'] = 'icon-large';

// Set a custom option name. Don't forget to replace spaces with underscores!
$args['opt_name'] = 'twenty_eleven';

// Set a custom menu icon.
//$args['menu_icon'] = '';

Expand Down Expand Up @@ -275,6 +265,26 @@ function setup_framework_options(){
// Set the help sidebar for the options page.
$args['help_sidebar'] = __('<p>This is the sidebar content, HTML is allowed.</p>', 'redux-framework');


// Add HTML before the form.
if (!isset($args['global_variable']) || $args['global_variable'] !== false ) {
if (!empty($args['global_variable'])) {
$v = $args['global_variable'];
} else {
$v = str_replace("-", "_", $args['opt_name']);
}
$args['intro_text'] = __('<p>Did you know that Redux sets a global variable for you? To access any of your saved options from within your code you can use your global variable: <strong>$'.$v.'</strong></p>', 'redux-framework');
} else {
$args['intro_text'] = __('<p>This text is displayed above the options panel. It isn\'t required, but more info is always better! The intro_text field accepts all HTML.</p>', 'redux-framework');
}

// Add content after the form.
$args['footer_text'] = __('<p>This text is displayed below the options panel. It isn\'t required, but more info is always better! The footer_text field accepts all HTML.</p>', 'redux-framework');

// Set footer/credit line.
//$args['footer_credit'] = __('<p>This text is displayed in the options panel footer across from the WordPress version (where it normally says \'Thank you for creating with WordPress\'). This field accepts all HTML.</p>', 'redux-framework');


$sections = array();

//Background Patterns Reader
Expand Down Expand Up @@ -554,6 +564,7 @@ function setup_framework_options(){
array(
'id'=>'spacing',
'type' => 'spacing',
//'units' => 'em', // You can specify a unit value. Possible: px, em, %
'title' => __('Padding/Margin Option', 'redux-framework'),
'subtitle' => __('Allow your users to choose the spacing or margin they want.', 'redux-framework'),
'desc' => __('You can enable or diable any piece of this field. Top, Right, Bottom, Left, or Units.', 'redux-framework'),
Expand Down

0 comments on commit 68ca11e

Please sign in to comment.