Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save stalukder03/c821eeebab1cd9fb6b811d307fc89a77 to your computer and use it in GitHub Desktop.
Save stalukder03/c821eeebab1cd9fb6b811d307fc89a77 to your computer and use it in GitHub Desktop.
Example of the required attribute for the Redux Framework.
<?php
$options = array(
'required' => array('id','equals',array( 1,3 ) ) // Multiple values
);
$options = array(
'required' => array('id','equals', array( 1 ) ) // Single value
);
$options = array(
'required' => array('id','equals', 1 ) // Also a single value
);
$options = array(
'required' => array('id','equals', false ) // Means id = 0 or false or in the case of a switch, off
);
<?php
$options[] =
array(
'id'=>'switch-custom',
'type' => 'switch',
'title' => __('Switch - Custom Titles', 'redux-framework'),
'subtitle'=> __('Look, it\'s on! Also hidden child elements!', 'redux-framework'),
"default" => 0,
'on' => 'Enabled',
'off' => 'Disabled',
),
array(
'id'=>'switch-required',
'type' => 'switch',
'required' => array('switch-custom', '=' , '1')
'title' => __('Switch - With Hidden Items (NESTED!)', 'redux-framework'),
'subtitle'=> __('Also called a "required" parent.', 'redux-framework'),
'desc' => __('Items set with a required to this ID will hide unless this is set to the appropriate value.', 'redux-framework'),
'default' => 0,
),
array(
'id'=>'patterns',
'type' => 'image_select',
'tiles' => true,
'required' => array('switch-custom', '=' , '0')
'title' => __('Images Option (with pattern=>true)', 'redux-framework'),
'subtitle'=> __('Select a background pattern.', 'redux-framework'),
'default' => 0,
'options' => array(
'1' => array('alt' => '1 Column', 'img' => REDUX_URL.'assets/img/1col.png'),
'2' => array('alt' => '2 Column Left', 'img' => REDUX_URL.'assets/img/2cl.png'),
'3' => array('alt' => '2 Column Right', 'img' => REDUX_URL.'assets/img/2cr.png'),
'4' => array('alt' => '3 Column Middle', 'img' => REDUX_URL.'assets/img/3cm.png'),
'5' => array('alt' => '3 Column Left', 'img' => REDUX_URL.'assets/img/3cl.png'),
'6' => array('alt' => '3 Column Right', 'img' => REDUX_URL.'assets/img/3cr.png')
),
)
);
  • = / equals

    • Exact value of parent.
  • != / not

    • Value of parent is not equal to this.
  • > / greater / is_larger

    • Value is larger than the value of the parent. Must be an int/float value. No string comparisons will function.
  • < / less / is_smaller

    • Value is less than the value of the parent. Must be an int/float value. No string comparisons will function.
  • contains

    • String comparison. Checks to see if value is within the parent's value.
  • doesnt_contains

    • String comparison. Checks to see if value is not within the parent's value.
  • is_empty_or

    • Checks to see if the value of the parent is empty or equal to the current value. Same as equals, but also allows visibility if parent value is not set.
  • not_empty_and

    • Checks to see if the value of the parent is not empty and equal to the current value. Same as not, but also hides visibility if parent value is not set.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment