本文整理汇总了PHP中Redux_Helpers::array_in_array方法的典型用法代码示例。如果您正苦于以下问题:PHP Redux_Helpers::array_in_array方法的具体用法?PHP Redux_Helpers::array_in_array怎么用?PHP Redux_Helpers::array_in_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Redux_Helpers
的用法示例。
在下文中一共展示了Redux_Helpers::array_in_array方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Field Render Function.
* Takes the vars and outputs the HTML for the field in the settings
*
* @since ReduxFramework 1.0.0
*/
function render()
{
/*
* So, in_array() wasn't doing it's job for checking a passed array for a proper value.
* It's wonky. It only wants to check the keys against our array of acceptable values, and not the key's
* value. So we'll use this instead. Fortunately, a single no array value can be passed and it won't
* take a dump.
*/
// No errors please
$defaults = array('width' => true, 'height' => true, 'units_extended' => false, 'units' => 'px', 'mode' => array('width' => false, 'height' => false));
$this->field = wp_parse_args($this->field, $defaults);
$defaults = array('width' => '', 'height' => '', 'units' => 'px');
$this->value = wp_parse_args($this->value, $defaults);
if (isset($this->value['unit'])) {
$this->value['units'] = $this->value['unit'];
}
/*
* Acceptable values checks. If the passed variable doesn't pass muster, we unset them
* and reset them with default values to avoid errors.
*/
// If units field has a value but is not an acceptable value, unset the variable
if (isset($this->field['units']) && !Redux_Helpers::array_in_array($this->field['units'], array('', false, '%', 'in', 'cm', 'mm', 'em', 'ex', 'pt', 'pc', 'px', 'rem'))) {
unset($this->field['units']);
}
//if there is a default unit value but is not an accepted value, unset the variable
if (isset($this->value['units']) && !Redux_Helpers::array_in_array($this->value['units'], array('', '%', 'in', 'cm', 'mm', 'em', 'ex', 'pt', 'pc', 'px'))) {
unset($this->value['units']);
}
/*
* Since units field could be an array, string value or bool (to hide the unit field)
* we need to separate our functions to avoid those nasty PHP index notices!
*/
// if field units has a value and IS an array, then evaluate as needed.
if (isset($this->field['units']) && !is_array($this->field['units'])) {
//if units fields has a value but units value does not then make units value the field value
if (isset($this->field['units']) && !isset($this->value['units']) || $this->field['units'] == false) {
$this->value['units'] = $this->field['units'];
// If units field does NOT have a value and units value does NOT have a value, set both to blank (default?)
} else {
if (!isset($this->field['units']) && !isset($this->value['units'])) {
$this->field['units'] = 'px';
$this->value['units'] = 'px';
// If units field has NO value but units value does, then set unit field to value field
} else {
if (!isset($this->field['units']) && isset($this->value['units'])) {
$this->field['units'] = $this->value['units'];
// if unit value is set and unit value doesn't equal unit field (coz who knows why)
// then set unit value to unit field
} elseif (isset($this->value['units']) && $this->value['units'] !== $this->field['units']) {
$this->value['units'] = $this->field['units'];
}
}
}
// do stuff based on unit field NOT set as an array
} elseif (isset($this->field['units']) && is_array($this->field['units'])) {
// nothing to do here, but I'm leaving the construct just in case I have to debug this again.
}
echo '<fieldset id="' . $this->field['id'] . '" class="redux-dimensions-container" data-id="' . $this->field['id'] . '">';
if (isset($this->field['select2'])) {
// if there are any let's pass them to js
$select2_params = json_encode($this->field['select2']);
$select2_params = htmlspecialchars($select2_params, ENT_QUOTES);
echo '<input type="hidden" class="select2_params" value="' . $select2_params . '">';
}
// This used to be unit field, but was giving the PHP index error when it was an array,
// so I changed it.
echo '<input type="hidden" class="field-units" value="' . $this->value['units'] . '">';
/**
* Width
* */
if ($this->field['width'] === true) {
if (!empty($this->value['width']) && strpos($this->value['width'], $this->value['units']) === false) {
$this->value['width'] = filter_var($this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
if ($this->field['units'] !== false) {
$this->value['width'] .= $this->value['units'];
}
}
echo '<div class="field-dimensions-input input-prepend">';
echo '<span class="add-on"><i class="el el-resize-horizontal icon-large"></i></span>';
echo '<input type="text" class="redux-dimensions-input redux-dimensions-width mini' . $this->field['class'] . '" placeholder="' . __('Width', 'redux-framework') . '" rel="' . $this->field['id'] . '-width" value="' . filter_var($this->value['width'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) . '">';
echo '<input data-id="' . $this->field['id'] . '" type="hidden" id="' . $this->field['id'] . '-width" name="' . $this->field['name'] . $this->field['name_suffix'] . '[width]' . '" value="' . $this->value['width'] . '"></div>';
}
/**
* Height
* */
if ($this->field['height'] === true) {
if (!empty($this->value['height']) && strpos($this->value['height'], $this->value['units']) === false) {
$this->value['height'] = filter_var($this->value['height'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
if ($this->field['units'] !== false) {
$this->value['height'] .= $this->value['units'];
}
}
echo '<div class="field-dimensions-input input-prepend">';
echo '<span class="add-on"><i class="el el-resize-vertical icon-large"></i></span>';
//.........这里部分代码省略.........
示例2: render
/**
* Field Render Function.
*
* Takes the vars and outputs the HTML for the field in the settings
*
* @since ReduxFramework 1.0.0
*/
function render()
{
/*
* So, in_array() wasn't doing it's job for checking a passed array for a proper value.
* It's wonky. It only wants to check the keys against our array of acceptable values, and not the key's
* value. So we'll use this instead. Fortunately, a single no array value can be passed and it won't
* take a dump.
*/
// No errors please
// Set field values
$defaults = array('units' => '', 'mode' => 'padding', 'top' => true, 'bottom' => true, 'all' => false, 'left' => true, 'right' => true, 'units_extended' => false, 'display_units' => true);
$this->field = wp_parse_args($this->field, $defaults);
// Set default values
$defaults = array('top' => '', 'right' => '', 'bottom' => '', 'left' => '', 'units' => 'px');
$this->value = wp_parse_args($this->value, $defaults);
/*
* Acceptable values checks. If the passed variable doesn't pass muster, we unset them
* and reset them with default values to avoid errors.
*/
// If units field has a value but is not an acceptable value, unset the variable
if (isset($this->field['units']) && !Redux_Helpers::array_in_array($this->field['units'], array('', false, '%', 'in', 'cm', 'mm', 'em', 'rem', 'ex', 'pt', 'pc', 'px'))) {
unset($this->field['units']);
}
//if there is a default unit value but is not an accepted value, unset the variable
if (isset($this->value['units']) && !Redux_Helpers::array_in_array($this->value['units'], array('', '%', 'in', 'cm', 'mm', 'em', 'rem', 'ex', 'pt', 'pc', 'px'))) {
unset($this->value['units']);
}
if ($this->field['mode'] == "absolute") {
$this->field['units'] = "";
$this->value['units'] = "";
}
if ($this->field['units'] == false) {
$this->value == "";
}
if (isset($this->field['mode']) && !in_array($this->field['mode'], array('margin', 'padding'))) {
if ($this->field['mode'] == "absolute") {
$absolute = true;
}
$this->field['mode'] = "";
}
$value = array('top' => isset($this->value[$this->field['mode'] . '-top']) ? filter_var($this->value[$this->field['mode'] . '-top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : filter_var($this->value['top'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 'right' => isset($this->value[$this->field['mode'] . '-right']) ? filter_var($this->value[$this->field['mode'] . '-right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : filter_var($this->value['right'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 'bottom' => isset($this->value[$this->field['mode'] . '-bottom']) ? filter_var($this->value[$this->field['mode'] . '-bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : filter_var($this->value['bottom'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION), 'left' => isset($this->value[$this->field['mode'] . '-left']) ? filter_var($this->value[$this->field['mode'] . '-left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) : filter_var($this->value['left'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
// if field units has a value and is NOT an array, then evaluate as needed.
if (isset($this->field['units']) && !is_array($this->field['units'])) {
//if units fields has a value and is not empty but units value does not then make units value the field value
if (isset($this->field['units']) && $this->field['units'] != "" && !isset($this->value['units']) || $this->field['units'] == false) {
$this->value['units'] = $this->field['units'];
// If units field does NOT have a value and units value does NOT have a value, set both to blank (default?)
} else {
if (!isset($this->field['units']) && !isset($this->value['units'])) {
$this->field['units'] = 'px';
$this->value['units'] = 'px';
// If units field has NO value but units value does, then set unit field to value field
} else {
if (!isset($this->field['units']) && isset($this->value['units'])) {
// If Value is defined
$this->field['units'] = $this->value['units'];
// if unit value is set and unit value doesn't equal unit field (coz who knows why)
// then set unit value to unit field
} elseif (isset($this->value['units']) && $this->value['units'] !== $this->field['units']) {
$this->value['units'] = $this->field['units'];
}
}
}
// do stuff based on unit field NOT set as an array
} elseif (isset($this->field['units']) && is_array($this->field['units'])) {
// nothing to do here, but I'm leaving the construct just in case I have to debug this again.
}
if (isset($this->field['units'])) {
$value['units'] = $this->value['units'];
}
$this->value = $value;
if (!empty($this->field['mode'])) {
$this->field['mode'] = $this->field['mode'] . "-";
}
$defaults = array('top' => '', 'right' => '', 'bottom' => '', 'left' => '', 'units' => '');
$this->value = wp_parse_args($this->value, $defaults);
echo '<input type="hidden" class="field-units" value="' . $this->value['units'] . '">';
if (isset($this->field['all']) && $this->field['all'] == true) {
echo '<div class="field-spacing-input input-prepend"><span class="add-on"><i class="el-icon-fullscreen icon-large"></i></span><input type="text" class="redux-spacing-all redux-spacing-input mini' . $this->field['class'] . '" placeholder="' . __('All', 'redux-framework') . '" rel="' . $this->field['id'] . '-all" value="' . $this->value['top'] . '"></div>';
}
if ($this->field['top'] === true) {
echo '<input type="hidden" class="redux-spacing-value" id="' . $this->field['id'] . '-top" name="' . $this->field['name'] . '[' . $this->field['mode'] . 'top]' . $this->field['name_suffix'] . '" value="' . $this->value['top'] . (!empty($this->value['top']) ? $this->value['units'] : '') . '">';
}
if ($this->field['right'] === true) {
echo '<input type="hidden" class="redux-spacing-value" id="' . $this->field['id'] . '-right" name="' . $this->field['name'] . '[' . $this->field['mode'] . 'right]' . $this->field['name_suffix'] . '" value="' . $this->value['right'] . (!empty($this->value['right']) ? $this->value['units'] : '') . '">';
}
if ($this->field['bottom'] === true) {
echo '<input type="hidden" class="redux-spacing-value" id="' . $this->field['id'] . '-bottom" name="' . $this->field['name'] . '[' . $this->field['mode'] . 'bottom]' . $this->field['name_suffix'] . '" value="' . $this->value['bottom'] . (!empty($this->value['bottom']) ? $this->value['units'] : '') . '">';
}
if ($this->field['left'] === true) {
echo '<input type="hidden" class="redux-spacing-value" id="' . $this->field['id'] . '-left" name="' . $this->field['name'] . '[' . $this->field['mode'] . 'left]' . $this->field['name_suffix'] . '" value="' . $this->value['left'] . (!empty($this->value['left']) ? $this->value['units'] : '') . '">';
}
if (!isset($this->field['all']) || $this->field['all'] !== true) {
//.........这里部分代码省略.........