当前位置: 首页>>代码示例>>PHP>>正文


PHP fw_extract_only_options函数代码示例

本文整理汇总了PHP中fw_extract_only_options函数的典型用法代码示例。如果您正苦于以下问题:PHP fw_extract_only_options函数的具体用法?PHP fw_extract_only_options怎么用?PHP fw_extract_only_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了fw_extract_only_options函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_value_from_attributes

 public function get_value_from_attributes($attributes)
 {
     $attributes['type'] = $this->get_type();
     $options = $this->get_shortcode_options();
     if (!empty($options)) {
         if (empty($attributes['atts'])) {
             /**
              * The options popup was never opened and there are no attributes.
              * Extract options default values.
              */
             $attributes['atts'] = fw_get_options_values_from_input($options, array());
         } else {
             /**
              * There are saved attributes.
              * But we need to execute the _get_value_from_input() method for all options,
              * because some of them may be (need to be) changed (auto-generated) https://github.com/ThemeFuse/Unyson/issues/275
              * Add the values to $option['value']
              */
             $options = fw_extract_only_options($options);
             foreach ($attributes['atts'] as $option_id => $option_value) {
                 if (isset($options[$option_id])) {
                     $options[$option_id]['value'] = $option_value;
                 }
             }
             $attributes['atts'] = fw_get_options_values_from_input($options, array());
         }
     }
     return $attributes;
 }
开发者ID:alireza--noori,项目名称:initial-portfolio-website-test-,代码行数:29,代码来源:class-page-builder-contact-form-item.php

示例2: _get_value_from_input

 /**
  * @internal
  */
 protected function _get_value_from_input($option, $input_value)
 {
     if (is_array($input_value) || empty($option['value'])) {
         $value = array();
     } else {
         $value = $option['value'];
     }
     foreach (fw_extract_only_options($option['inner-options']) as $inner_id => $inner_option) {
         $value[$inner_id] = fw()->backend->option_type($inner_option['type'])->get_value_from_input(isset($value[$inner_id]) ? array_merge($inner_option, array('value' => $value[$inner_id])) : $inner_option, isset($input_value[$inner_id]) ? $input_value[$inner_id] : null);
     }
     return $value;
 }
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:15,代码来源:class-fw-option-type-multi.php

示例3: _get_value_from_input

 /**
  * @internal
  */
 protected function _get_value_from_input($option, $input_value)
 {
     if (!is_array($input_value)) {
         return $option['value'];
     }
     $value = array();
     $box_options = fw_extract_only_options($option['box-options']);
     foreach ($input_value as &$list_item_value) {
         $current_value = array();
         foreach ($box_options as $id => $input_option) {
             $current_value[$id] = fw()->backend->option_type($input_option['type'])->get_value_from_input($input_option, isset($list_item_value[$id]) ? $list_item_value[$id] : null);
         }
         $value[] = $current_value;
     }
     return $value;
 }
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:19,代码来源:class-fw-option-type-addable-box.php

示例4: get_fixed_attributes

 protected function get_fixed_attributes($attributes)
 {
     // do not allow sub items
     unset($attributes['_items']);
     $default_attributes = array('type' => $this->get_type(), 'shortcode' => false, 'width' => '', 'options' => array());
     // remove unknown attributes
     $attributes = array_intersect_key($attributes, $default_attributes);
     $attributes = array_merge($default_attributes, $attributes);
     $only_options = array();
     foreach (fw_extract_only_options($this->get_options()) as $option_id => $option) {
         if (array_key_exists($option_id, $attributes['options'])) {
             $option['value'] = $attributes['options'][$option_id];
         }
         $only_options[$option_id] = $option;
     }
     $attributes['options'] = fw_get_options_values_from_input($only_options, array());
     unset($only_options, $option_id, $option);
     $constraints = $attributes['options']['constraints'];
     if (!empty($constraints['constraint'])) {
         $constraint = $constraints['constraint'];
         $constraint_data = $constraints[$constraint];
         switch ($constraint) {
             case 'characters':
             case 'words':
                 if (!empty($constraint_data['min'])) {
                     $constraint_data['min'] = intval($constraint_data['min']);
                     if ($constraint_data['min'] < 0) {
                         $constraint_data['min'] = 0;
                     }
                 }
                 if (!empty($constraint_data['max'])) {
                     $constraint_data['max'] = intval($constraint_data['max']);
                     if ($constraint_data['max'] < 0 || $constraint_data['max'] < $constraint_data['min']) {
                         $constraint_data['max'] = null;
                     }
                 }
                 break;
             default:
                 trigger_error('Invalid constraint: ' . $constraint, E_USER_WARNING);
                 $attributes['options']['constraints']['constraint'] = '';
         }
         $attributes['options']['constraints'][$constraint] = $constraint_data;
     }
     return $attributes;
 }
开发者ID:HilderH,项目名称:emprendamos,代码行数:45,代码来源:class-fw-option-type-form-builder-item-textarea.php

示例5: get_fixed_attributes

 protected function get_fixed_attributes($attributes)
 {
     // do not allow sub items
     unset($attributes['_items']);
     $default_attributes = array('type' => $this->get_type(), 'shortcode' => 'form-header-title', 'width' => '', 'options' => array());
     // remove unknown attributes
     $attributes = array_intersect_key($attributes, $default_attributes);
     $attributes = array_merge($default_attributes, $attributes);
     $only_options = array();
     foreach (fw_extract_only_options($this->get_options()) as $option_id => $option) {
         if (array_key_exists($option_id, $attributes['options'])) {
             $option['value'] = $attributes['options'][$option_id];
         }
         $only_options[$option_id] = $option;
     }
     $attributes['options'] = fw_get_options_values_from_input($only_options, array());
     unset($only_options, $option_id, $option);
     return $attributes;
 }
开发者ID:northpen,项目名称:northpen,代码行数:19,代码来源:class-fw-option-type-form-builder-item-form-header-title.php

示例6: check_settings

 protected function check_settings()
 {
     if (!$this->get_config('display')) {
         return;
     }
     $theme_options = fw_extract_only_options($this->get_parent()->get_settings_options());
     $options = false;
     foreach ($theme_options as $option_name => $option_settings) {
         if ($option_settings['type'] !== 'style') {
             unset($theme_options[$option_name]);
             continue;
         }
         $options = $option_settings;
         break;
     }
     if (!empty($options['predefined'])) {
         $this->options = $options;
         $this->add_theme_actions();
     }
 }
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:20,代码来源:class-fw-extension-switch-style-panel.php

示例7: check_settings

 protected function check_settings()
 {
     if (!fw_get_db_ext_settings_option($this->get_parent()->get_name(), 'switch_style_panel_display')) {
         return;
     }
     $theme_options = fw_extract_only_options($this->get_parent()->get_options('appearance-settings'));
     $options = false;
     foreach ($theme_options as $option_name => $option_settings) {
         if ($option_settings['type'] !== 'style') {
             unset($theme_options[$option_name]);
             continue;
         }
         $options = $option_settings;
         break;
     }
     if (!empty($options['predefined'])) {
         $this->options = $options;
         $this->add_theme_actions();
     }
 }
开发者ID:puriwp,项目名称:Framework-Styling,代码行数:20,代码来源:class-fw-extension-switch-style-panel.php

示例8: _get_value_from_input

 /**
  * @internal
  * {@inheritdoc}
  */
 protected function _get_value_from_input($option, $input_value)
 {
     if (is_null($input_value)) {
         $value = $option['value'];
     } elseif (is_array($input_value)) {
         $option['limit'] = intval($option['limit']);
         $value = array();
         $box_options = fw_extract_only_options($option['box-options']);
         foreach ($input_value as &$list_item_value) {
             $current_value = array();
             foreach ($box_options as $id => $input_option) {
                 $current_value[$id] = fw()->backend->option_type($input_option['type'])->get_value_from_input($input_option, isset($list_item_value[$id]) ? $list_item_value[$id] : null);
             }
             $value[] = $current_value;
             if ($option['limit'] && count($value) === $option['limit']) {
                 break;
             }
         }
     } else {
         $value = array();
     }
     return $value;
 }
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:27,代码来源:class-fw-option-type-addable-box.php

示例9: _get_value_from_input

 /**
  * @internal
  */
 protected function _get_value_from_input($option, $input_value)
 {
     reset($option['picker']);
     $picker_key = key($option['picker']);
     $picker_type = $option['picker'][$picker_key]['type'];
     $picker = $option['picker'][$picker_key];
     $value = array();
     if (is_null($input_value) && isset($option['value'][$picker_key])) {
         $value[$picker_key] = $option['value'][$picker_key];
     } else {
         $value[$picker_key] = fw()->backend->option_type($picker_type)->get_value_from_input($picker, isset($input_value[$picker_key]) ? $input_value[$picker_key] : null);
     }
     // choices
     switch ($picker_type) {
         case 'switch':
             $choices = array_intersect_key($option['choices'], array($picker['left-choice']['value'] => array(), $picker['right-choice']['value'] => array()));
             break;
         case 'select':
         case 'short-select':
             // we need to treat the case with optgroups
             $collected_choices = array();
             foreach ($picker['choices'] as $key => $choice_value) {
                 if (is_array($choice_value) && isset($choice_value['choices'])) {
                     // we have an optgroup
                     $collected_choices = array_merge($collected_choices, $choice_value['choices']);
                 } else {
                     $collected_choices[$key] = $choice_value;
                 }
             }
             $choices = array_intersect_key($option['choices'], $collected_choices);
             break;
         default:
             $choices = array_intersect_key($option['choices'], $picker['choices']);
     }
     foreach ($choices as $choice_id => $choice_options) {
         if (is_null($input_value) && isset($option['value'][$choice_id])) {
             $value[$choice_id] = $option['value'][$choice_id];
         } else {
             foreach (fw_extract_only_options($choice_options) as $choice_option_id => $choice_option) {
                 $value[$choice_id][$choice_option_id] = fw()->backend->option_type($choice_option['type'])->get_value_from_input($choice_option, isset($input_value[$choice_id][$choice_option_id]) ? $input_value[$choice_id][$choice_option_id] : null);
             }
         }
     }
     return $value;
 }
开发者ID:bbwebservices,项目名称:avarel,代码行数:48,代码来源:class-fw-option-type-multi-picker.php

示例10: fw_set_db_post_option

/**
 * Set post option value in database
 *
 * @param null|int $post_id
 * @param string|null $option_id Specific option id (accepts multikey). null - all options
 * @param $value
 */
function fw_set_db_post_option($post_id = null, $option_id = null, $value)
{
    $post_id = intval($post_id);
    if (!$post_id) {
        /** @var WP_Post $post */
        global $post;
        if (!$post) {
            return;
        } else {
            $post_id = $post->ID;
        }
    }
    $options = fw_extract_only_options(fw()->theme->get_post_options(get_post_type(($post_revision_id = wp_is_post_revision($post_id)) ? $post_revision_id : $post_id)));
    $sub_keys = null;
    if ($option_id) {
        $option_id = explode('/', $option_id);
        // 'option_id/sub/keys'
        $_option_id = array_shift($option_id);
        // 'option_id'
        $sub_keys = implode('/', $option_id);
        // 'sub/keys'
        $option_id = $_option_id;
        unset($_option_id);
        $old_value = fw_get_db_post_option($post_id, $option_id);
        if ($sub_keys) {
            // update sub_key in old_value and use the entire value
            $new_value = $old_value;
            fw_aks($sub_keys, $value, $new_value);
            $value = $new_value;
            unset($new_value);
            $old_value = fw_akg($sub_keys, $old_value);
        }
        if (isset($options[$option_id])) {
            $value = fw()->backend->option_type($options[$option_id]['type'])->storage_save($option_id, $options[$option_id], $value, array('post-id' => $post_id));
        }
        FW_WP_Meta::set('post', $post_id, 'fw_options/' . $option_id, $value);
    } else {
        $old_value = fw_get_db_post_option($post_id);
        if (!is_array($value)) {
            $value = array();
        }
        foreach ($value as $_option_id => $_option_value) {
            if (isset($options[$_option_id])) {
                $value[$_option_id] = fw()->backend->option_type($options[$_option_id]['type'])->storage_save($_option_id, $options[$_option_id], $_option_value, array('post-id' => $post_id));
            }
        }
        FW_WP_Meta::set('post', $post_id, 'fw_options', $value);
    }
    /**
     * @deprecated
     */
    fw()->backend->_sync_post_separate_meta($post_id);
    /**
     * @since 2.2.8
     */
    do_action('fw_post_options_update', $post_id, $option_id, explode('/', $sub_keys), $old_value);
}
开发者ID:isatrio,项目名称:Unyson,代码行数:64,代码来源:database.php

示例11: _action_ajax_options_render

 /**
  * Render options html from input json
  *
  * POST vars:
  * - options: '[{option_id: {...}}, {option_id: {...}}, ...]'                  // Required // String JSON
  * - values:  {option_id: value, option_id: {...}, ...}                        // Optional // Object
  * - data:    {id_prefix: 'fw_options-a-b-', name_prefix: 'fw_options[a][b]'}  // Optional // Object
  */
 public function _action_ajax_options_render()
 {
     if (!isset($_POST['options'])) {
         wp_send_json_error(array('message' => 'No options'));
     }
     $options = json_decode(FW_Request::POST('options'), true);
     if (!$options) {
         wp_send_json_error(array('message' => 'Wrong options'));
     }
     if (isset($_POST['values'])) {
         $values = FW_Request::POST('values');
     } else {
         $values = array();
     }
     if (isset($_POST['data'])) {
         $data = FW_Request::POST('data');
     } else {
         $data = array();
     }
     foreach (fw_extract_only_options($options) as $option_id => $option) {
         if (!isset($values[$option_id])) {
             continue;
         }
         /**
          * We detect if option is using booleans by sending it a boolean input value
          * If it returns a boolean, then it works with booleans
          */
         if (!is_bool(fw()->backend->option_type($option['type'])->get_value_from_input($option, true))) {
             continue;
         }
         if (is_bool($values[$option_id])) {
             // value is already boolean, does not need to fix
             continue;
         }
         $values[$option_id] = $values[$option_id] === 'true';
     }
     wp_send_json_success(array('html' => fw()->backend->render_options($options, $values, $data)));
 }
开发者ID:halkibsi,项目名称:Unyson,代码行数:46,代码来源:backend.php

示例12: _get_value_from_input

 /**
  * Extract correct value for $option['value'] from input array
  * If input value is empty, will be returned $option['value']
  *
  * @param array $option
  * @param array|string|null $input_value
  *
  * @return string|array|int|bool Correct value
  * @internal
  */
 protected function _get_value_from_input($option, $input_value)
 {
     if (empty($input_value)) {
         if (empty($option['popup-options'])) {
             return array();
         }
         $popup_options = array();
         foreach (fw_extract_only_options($option['popup-options']) as $popup_option_id => $popup_option) {
             if (isset($option['value'][$popup_option_id])) {
                 $popup_option['value'] = $option['value'][$popup_option_id];
             }
             $popup_options[$popup_option_id] = $popup_option;
         }
         $values = fw_get_options_values_from_input($popup_options, array());
     } else {
         if (is_array($input_value)) {
             /**
              * Don't decode if we have already an array
              */
             $values = $input_value;
         } else {
             $values = json_decode($input_value, true);
         }
     }
     return $values;
 }
开发者ID:cristeamdev,项目名称:Unyson,代码行数:36,代码来源:class-fw-option-type-popup.php

示例13: _storage_save

 /**
  * {@inheritdoc}
  * fixes https://github.com/ThemeFuse/Unyson/issues/1440
  */
 protected function _storage_save($id, array $option, $value, array $params)
 {
     if (apply_filters('fw:option-type:multi-picker:fw-storage:process-inner-options', false)) {
         foreach ($option['choices'] as $choice_id => $choice) {
             foreach (fw_extract_only_options($choice) as $opt_id => $opt) {
                 $value[$choice_id][$opt_id] = fw()->backend->option_type($opt['type'])->storage_save($opt_id, $opt, $value[$choice_id][$opt_id], $params);
             }
         }
     }
     return fw_db_option_storage_save($id, $option, $value, $params);
 }
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:15,代码来源:class-fw-option-type-multi-picker.php

示例14: _admin_action_generate_css

 /**
  * Triggers when the extension settings are saved,
  * it generates css from the styling settings and stores it
  * @internal
  */
 public function _admin_action_generate_css()
 {
     $theme_options = fw_extract_only_options($this->get_options('appearance-settings'));
     $saved_data = fw_get_db_extension_data($this->get_name(), 'options');
     $css_for_style_options = FW_Styling_Css_Generator::get_css($theme_options, $saved_data);
     fw_set_db_extension_data($this->get_name(), 'css', $css_for_style_options);
 }
开发者ID:puriwp,项目名称:Framework-Styling,代码行数:12,代码来源:class-fw-extension-styling.php

示例15: _get_value_from_input

 /**
  * Extract correct value for $option['value'] from input array
  * If input value is empty, will be returned $option['value']
  * @param array $option
  * @param array|string|null $input_value
  * @return string|array|int|bool Correct value
  * @internal
  */
 protected function _get_value_from_input($option, $input_value)
 {
     if (!is_array($input_value)) {
         return $option['value'];
     }
     // unset the last slide that is default for add
     array_pop($input_value);
     $value = array();
     $slides_options = fw_extract_only_options($option['slides_options']);
     foreach ($input_value as &$list_item_value) {
         $current_value = array();
         foreach ($slides_options as $id => $input_option) {
             $current_value[$id] = fw()->backend->option_type($input_option['type'])->get_value_from_input($input_option, isset($list_item_value[$id]) ? $list_item_value[$id] : null);
             $current_value['thumb'] = isset($list_item_value['thumb']) ? $list_item_value['thumb'] : null;
         }
         $value[] = $current_value;
     }
     return $value;
 }
开发者ID:Archrom,项目名称:wordpress_remaf,代码行数:27,代码来源:class-fw-option-type-slides.php


注:本文中的fw_extract_only_options函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。