' . $msg . '
', 'redux-framework-demo') ); $screen->add_help_tab( $tab ); } // Sidebar text if( $this->args['help_sidebar'] != '' ) { // Specify users text from arguments $screen->set_help_sidebar( $this->args['help_sidebar'] ); } else { // If sidebar text is empty and hints are active, display text // about hints. if (true == $this->show_hints) { $screen->set_help_sidebar( 'Redux Framework
Hint Tooltip Preferences
';
print_r($field);
echo "";
print_r($wpdb->queries);
echo "";
}
echo '";
print_r($value);
echo "";
*/
/**
* filter 'redux-field-{opt_name}'
* @deprecated
* @param string rendered field markup
* @param array $field field data
*/
$_render = apply_filters( "redux-field-{$this->args['opt_name']}", ob_get_contents(), $field ); // REMOVE
/**
* filter 'redux/field/{opt_name}/{field.type}/render/after'
* @param string rendered field markup
* @param array $field field data
*/
$_render = apply_filters( "redux/field/{$this->args['opt_name']}/{$field['type']}/render/after", $_render, $field );
/**
* filter 'redux/field/{opt_name}/render/after'
* @param string rendered field markup
* @param array $field field data
*/
$_render = apply_filters( "redux/field/{$this->args['opt_name']}/render/after", $_render, $field );
ob_end_clean();
//save the values into a unique array in case we need it for dependencies
$this->fieldsValues[$field['id']] = (isset($value['url']) && is_array($value) )?$value['url']:$value;
//create default data und class string and checks the dependencies of an object
$class_string = '';
$data_string = '';
$this->check_dependencies($field);
/**
* action 'redux/field/{opt_name}/{field.type}/fieldset/before/{opt_name}'
* @param array $field field data
* @param string $value field id
*/
do_action( "redux/field/{$this->args['opt_name']}/{$field['type']}/fieldset/before/{$this->args['opt_name']}", $field, $value );
/**
* action 'redux/field/{opt_name}/fieldset/before/{opt_name}'
* @param array $field field data
* @param string $value field id
*/
do_action( "redux/field/{$this->args['opt_name']}/fieldset/before/{$this->args['opt_name']}", $field, $value );
if (!isset($field['fields']) || empty($field['fields'])) {
echo '';
}
/**
* action 'redux-after-field-{opt_name}'
* @deprecated
* @param array $field field data
* @param string $value field id
*/
do_action( "redux-after-field-{$this->args['opt_name']}", $field, $value ); // REMOVE
/**
* action 'redux/field/{opt_name}/{field.type}/fieldset/after/{opt_name}'
* @param array $field field data
* @param string $value field id
*/
do_action( "redux/field/{$this->args['opt_name']}/{$field['type']}/fieldset/after/{$this->args['opt_name']}", $field, $value );
/**
* action 'redux/field/{opt_name}/fieldset/after/{opt_name}'
* @param array $field field data
* @param string $value field id
*/
do_action( "redux/field/{$this->args['opt_name']}/fieldset/after/{$this->args['opt_name']}", $field, $value );
}
}
} // _field_input()
/**
* Can Output CSS
* Check if a field meets its requirements before outputting to CSS
* @param $field
* @return bool
*/
public function _can_output_css($field) {
$return = true;
$field = apply_filters( "redux/field/{$this->args['opt_name']}/_can_output_css", $field );
if( isset( $field['force_output'] ) && $field['force_output'] == true ){
return $return;
}
if (!empty($field['required'])) {
if (isset($field['required'][0])) {
if (!is_array($field['required'][0]) && count($field['required']) == 3) {
$parentValue = $GLOBALS[$this->args['global_variable']][$field['required'][0]];
$checkValue = $field['required'][2];
$operation = $field['required'][1];
$return = $this->compareValueDependencies($parentValue, $checkValue, $operation);
} else if ( is_array($field['required'][0] ) ) {
foreach ($field['required'] as $required) {
if (!is_array($required[0]) && count($required) == 3) {
$parentValue = $GLOBALS[$this->args['global_variable']][$required[0]];
$checkValue = $required[2];
$operation = $required[1];
$return = $this->compareValueDependencies($parentValue, $checkValue, $operation);
}
if (!$return) {
return $return;
}
}
}
}
}
return $return;
} // _can_output_css
/**
* Checks dependencies between objects based on the $field['required'] array
*
* If the array is set it needs to have exactly 3 entries.
* The first entry describes which field should be monitored by the current field. eg: "content"
* The second entry describes the comparison parameter. eg: "equals, not, is_larger, is_smaller ,contains"
* The third entry describes the value that we are comparing against.
*
* Example: if the required array is set to array('content','equals','Hello World'); then the current
* field will only be displayed if the field with id "content" has exactly the value "Hello World"
*
* @param array $field
* @return array $params
*/
public function check_dependencies($field) {
//$params = array('data_string' => "", 'class_string' => "");
if (!empty($field['required'])) {
//$this->folds[$field['id']] = $this->folds[$field['id']] ? $this->folds[$field['id']] : array();
if (!isset($this->required_child[$field['id']])) {
$this->required_child[$field['id']] = array();
}
if (!isset($this->required[$field['id']])) {
$this->required[$field['id']] = array();
}
if ( is_array( $field['required'][0] ) ) {
foreach ( $field['required'] as $value ) {
if (is_array($value) && count($value) == 3) {
$data = array();
$data['parent'] = $value[0];
$data['operation'] = $value[1];
$data['checkValue'] = $value[2];
$this->required[$data['parent']][$field['id']][] = $data;
if (!in_array($data['parent'], $this->required_child[$field['id']])) {
$this->required_child[$field['id']][] = $data;
}
$this->checkRequiredDependencies($field, $data);
}
}
} else {
$data = array();
$data['parent'] = $field['required'][0];
$data['operation'] = $field['required'][1];
$data['checkValue'] = $field['required'][2];
$this->required[$data['parent']][$field['id']][] = $data;
if (!in_array($data['parent'], $this->required_child[$field['id']])) {
$this->required_child[$field['id']][] = $data;
}
$this->checkRequiredDependencies($field, $data);
}
}
//return $params;
}
// Compare data for required field
function compareValueDependencies($parentValue, $checkValue, $operation) {
$return = false;
switch ($operation) {
case '=':
case 'equals':
$data['operation'] = "=";
if(is_array($checkValue)){
if(in_array($parentValue, $checkValue)) {
$return = true;
}
} else {
if ($parentValue == $checkValue) {
$return = true;
} else if (is_array($parentValue)) {
if (in_array($checkValue, $parentValue)) {
$return = true;
}
}
}
break;
case '!=':
case 'not':
$data['operation'] = "!==";
if(is_array($checkValue)){
if(!in_array($parentValue, $checkValue))
$return = true;
} else {
if ($parentValue != $checkValue) {
$return = true;
} else if (is_array($parentValue)) {
if (!in_array($checkValue, $parentValue)) {
$return = true;
}
}
}
break;
case '>':
case 'greater':
case 'is_larger':
$data['operation'] = ">";
if ($parentValue > $checkValue)
$return = true;
break;
case '>=':
case 'greater_equal':
case 'is_larger_equal':
$data['operation'] = ">=";
if ($parentValue >= $checkValue)
$return = true;
break;
case '<':
case 'less':
case 'is_smaller':
$data['operation'] = "<";
if ($parentValue < $checkValue)
$return = true;
break;
case '<=':
case 'less_equal':
case 'is_smaller_equal':
$data['operation'] = "<=";
if ($parentValue <= $checkValue)
$return = true;
break;
case 'contains':
if (strpos($parentValue, $checkValue) !== false)
$return = true;
break;
case 'doesnt_contain':
case 'not_contain':
if (strpos($parentValue, $checkValue) === false)
$return = true;
break;
case 'is_empty_or':
if (empty($parentValue) || $parentValue == $checkValue)
$return = true;
break;
case 'not_empty_and':
if (!empty($parentValue) && $parentValue != $checkValue)
$return = true;
break;
case 'is_empty':
case 'empty':
case '!isset':
if (empty($parentValue) || $parentValue == "" || $parentValue == null)
$return = true;
break;
case 'not_empty':
case '!empty':
case 'isset':
if (!empty($parentValue) && $parentValue != "" && $parentValue != null)
$return = true;
break;
}
return $return;
}
function checkRequiredDependencies($field, $data) {
//required field must not be hidden. otherwise hide this one by default
if ( !in_array( $data['parent'], $this->fieldsHidden ) && ( !isset($this->folds[$field['id']]) || $this->folds[$field['id']] != "hide") ) {
if (isset($this->options[$data['parent']])) {
$return = $this->compareValueDependencies($this->options[$data['parent']], $data['checkValue'], $data['operation']);
}
}
if ( (isset($return) && $return) && ( !isset($this->folds[$field['id']]) || $this->folds[$field['id']] != "hide") ) {
$this->folds[$field['id']] = "show";
} else {
$this->folds[$field['id']] = "hide";
if (!in_array($field['id'], $this->fieldsHidden)) {
$this->fieldsHidden[] = $field['id'];
}
}
}
/**
* converts an array into a html data string
*
* @param array $data example input: array('id'=>'true')
* @return string $data_string example output: data-id='true'
*/
public function create_data_string($data = array()){
$data_string = "";
foreach($data as $key=>$value){
if(is_array($value)) $value = implode("|",$value);
$data_string .= " data-$key='$value' ";
}
return $data_string;
}
} // ReduxFramework
/**
* action 'redux/init'
* @param null
*/
do_action( 'redux/init', ReduxFramework::init() );
} // class_exists('ReduxFramework')