本文整理汇总了PHP中FW_Option_Type类的典型用法代码示例。如果您正苦于以下问题:PHP FW_Option_Type类的具体用法?PHP FW_Option_Type怎么用?PHP FW_Option_Type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FW_Option_Type类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _form_render
/**
* @internal
*/
public function _form_render($data)
{
$this->add_admin_static();
$options = array(array('custom_css' => array('title' => false, 'type' => 'box', 'options' => self::$user_options)));
$values = FW_Request::POST(FW_Option_Type::get_default_name_prefix(), fw_get_db_extension_data($this->get_name(), 'options'));
echo fw()->backend->render_options($options, $values);
$data['submit']['html'] = '<button class="button-primary button-large">' . __('Save', 'fw') . '</button>';
unset($options);
return $data;
}
开发者ID:puriwp,项目名称:Framework-Styling,代码行数:13,代码来源:class-fw-extension-styling.php
示例2: setting_sanitize_callback
public function setting_sanitize_callback($input)
{
$input = json_decode($input, true);
if (is_null($input)) {
return null;
}
$POST = array();
foreach ($input as $var) {
fw_aks(fw_html_attr_name_to_array_multi_key($var['name']), $var['value'], $POST);
}
$value = fw_get_options_values_from_input(array($this->id => $this->fw_option), fw_akg(FW_Option_Type::get_default_name_prefix(), $POST));
$value = array_pop($value);
return $value;
}
开发者ID:alireza--noori,项目名称:initial-portfolio-website-test-,代码行数:14,代码来源:class--fw-customizer-control-option-wrapper.php
示例3: _render
* @internal
*/
protected function _render($id, $option, $data)
{
$css_uri = fw()->extensions->get('seo')->get_declared_URI('/includes/option-types/' . $this->get_type() . '/static/css/style.css');
$js_uri = fw()->extensions->get('seo')->get_declared_URI('/includes/option-types/' . $this->get_type() . '/static/js/scripts.js');
$seo_tags = fw()->extensions->get('seo')->get_seo_tags();
$tags_names = array();
foreach ($seo_tags as $tag_id => $tag) {
array_push($tags_names, '%%' . $tag_id . '%%');
}
$version = fw()->extensions->get('seo')->manifest->get_version();
wp_enqueue_style('fw-option-' . $this->get_type(), $css_uri, array(), $version);
wp_enqueue_script('fw-option-' . $this->get_type(), $js_uri, array('jquery', 'jquery-ui', 'jquery-ui-autocomplete'), $version, true);
wp_localize_script('fw-option-' . $this->get_type(), 'fw_ext_seo_tags', $tags_names);
return fw()->backend->option_type('text')->render($id, $option, $data);
}
public function get_type()
{
return 'seo-tags';
}
/**
* @internal
*/
protected function _get_value_from_input($option, $input_value)
{
return fw()->backend->option_type('text')->get_value_from_input($this->internal_options, $input_value);
}
}
FW_Option_Type::register('FW_Option_Type_SEO_Tags');
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:30,代码来源:class-fw-option-type-seo-tags.php
示例4: _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;
}
/**
* @internal
*/
public function _get_backend_width_type()
{
return 'full';
}
/**
* @internal
*/
protected function _get_defaults()
{
return array('inner-options' => array(), 'value' => array());
}
}
FW_Option_Type::register('FW_Option_Type_Multi');
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:30,代码来源:class-fw-option-type-multi.php
示例5: customizer_register_options
/**
* @param WP_Customize_Manager $wp_customize
* @param array $options
* @param array $parent_data {'type':'...','id':'...'}
*/
private function customizer_register_options($wp_customize, $options, $parent_data = array())
{
$collected = array();
fw_collect_options($collected, $options, array('limit_option_types' => false, 'limit_container_types' => false, 'limit_level' => 1, 'info_wrapper' => true));
if (empty($collected)) {
return;
}
foreach ($collected as &$opt) {
switch ($opt['group']) {
case 'container':
$_collected = array();
fw_collect_options($_collected, $opt['option']['options'], array('limit_option_types' => array(), 'limit_container_types' => false, 'limit_level' => 1, 'limit' => 1, 'info_wrapper' => false));
$has_containers = !empty($_collected);
unset($_collected);
$children_data = array('group' => 'container', 'id' => $opt['id']);
$args = array('title' => empty($opt['option']['title']) ? fw_id_to_title($opt['id']) : $opt['option']['title'], 'description' => empty($opt['option']['desc']) ? '' : $opt['option']['desc']);
if (isset($opt['option']['wp-customizer-args']) && is_array($opt['option']['wp-customizer-args'])) {
$args = array_merge($opt['option']['wp-customizer-args'], $args);
}
if ($has_containers) {
if ($parent_data) {
trigger_error($opt['id'] . ' panel can\'t have a parent (' . $parent_data['id'] . ')', E_USER_WARNING);
break;
}
$wp_customize->add_panel($opt['id'], $args);
$children_data['customizer_type'] = 'panel';
} else {
if ($parent_data) {
if ($parent_data['customizer_type'] === 'panel') {
$args['panel'] = $parent_data['id'];
} else {
trigger_error($opt['id'] . ' section can have only panel parent (' . $parent_data['id'] . ')', E_USER_WARNING);
break;
}
}
$wp_customize->add_section($opt['id'], $args);
$children_data['customizer_type'] = 'section';
}
$this->customizer_register_options($wp_customize, $opt['option']['options'], $children_data);
unset($children_data);
break;
case 'option':
$setting_id = FW_Option_Type::get_default_name_prefix() . '[' . $opt['id'] . ']';
$args = array('label' => empty($opt['option']['label']) ? fw_id_to_title($opt['id']) : $opt['option']['label'], 'description' => empty($opt['option']['desc']) ? '' : $opt['option']['desc'], 'settings' => $setting_id);
if (isset($opt['option']['wp-customizer-args']) && is_array($opt['option']['wp-customizer-args'])) {
$args = array_merge($opt['option']['wp-customizer-args'], $args);
}
if ($parent_data) {
if ($parent_data['customizer_type'] === 'section') {
$args['section'] = $parent_data['id'];
} else {
trigger_error('Invalid control parent: ' . $parent_data['customizer_type'], E_USER_WARNING);
break;
}
} else {
// the option is not placed in a section, create a section automatically
$args['section'] = 'fw_option_auto_section_' . $opt['id'];
$wp_customize->add_section($args['section'], array('title' => empty($opt['option']['label']) ? fw_id_to_title($opt['id']) : $opt['option']['label']));
}
if (!class_exists('_FW_Customizer_Setting_Option')) {
require_once fw_get_framework_directory('/includes/customizer/class--fw-customizer-setting-option.php');
}
if (!class_exists('_FW_Customizer_Control_Option_Wrapper')) {
require_once fw_get_framework_directory('/includes/customizer/class--fw-customizer-control-option-wrapper.php');
}
$wp_customize->add_setting(new _FW_Customizer_Setting_Option($wp_customize, $setting_id, array('default' => fw()->backend->option_type($opt['option']['type'])->get_value_from_input($opt['option'], null), 'fw_option' => $opt['option'])));
$wp_customize->add_control(new _FW_Customizer_Control_Option_Wrapper($wp_customize, $opt['id'], $args));
break;
default:
trigger_error('Unknown group: ' . $opt['group'], E_USER_WARNING);
}
}
}
开发者ID:isatrio,项目名称:Unyson,代码行数:78,代码来源:backend.php
示例6: fw_render_view
self::$googleFontsPrinted = true;
}
return fw_render_view(fw_get_framework_directory('/includes/option-types/' . $this->get_type() . '/view.php'), array('id' => $id, 'option' => $option, 'data' => $data, 'fonts' => self::$fonts));
}
public function get_type()
{
return 'typography';
}
/**
* @internal
*/
protected function _get_value_from_input($option, $input_value)
{
if (!is_array($input_value)) {
return $option['value'];
}
$components = isset($option['components']) && is_array($option['components']) ? $option['components'] : array();
$components = array_merge(array('size' => true, 'family' => true, 'color' => true), $components);
$values = array('size' => $components['size'] ? isset($input_value['size']) ? intval($input_value['size']) : intval($option['value']['size']) : false, 'family' => $components['family'] ? isset($input_value['family']) ? $input_value['family'] : $option['value']['family'] : false, 'style' => $components['family'] ? isset($input_value['style']) ? $input_value['style'] : $option['value']['style'] : false, 'color' => $components['color'] ? isset($input_value['color']) && preg_match('/^#[a-f0-9]{6}$/i', $input_value['color']) ? $input_value['color'] : $option['value']['color'] : false);
return $values;
}
/**
* @internal
*/
protected function _get_defaults()
{
return array('value' => array('size' => 12, 'family' => 'Arial', 'style' => '400', 'color' => '#000000'));
}
}
FW_Option_Type::register('FW_Option_Type_Typography');
开发者ID:outlinez,项目名称:Unyson,代码行数:30,代码来源:class-fw-option-type-typography.php
示例7: fw_get_options_values_from_input
/**
* Get correct values from input (POST) for given options
* This values can be saved in db then replaced with $option['value'] for each option
* @param array $options
* @param array $input_array
* @return array Values
*/
function fw_get_options_values_from_input(array $options, $input_array = null)
{
if (!is_array($input_array)) {
$input_array = FW_Request::POST(FW_Option_Type::get_default_name_prefix());
}
$values = array();
foreach (fw_extract_only_options($options) as $id => $option) {
$values[$id] = fw()->backend->option_type($option['type'])->get_value_from_input($option, isset($input_array[$id]) ? $input_array[$id] : null);
if (is_null($values[$id])) {
// do not save null values
unset($values[$id]);
}
}
return $values;
}
开发者ID:joelgarciajr84,项目名称:Unyson,代码行数:22,代码来源:general.php
示例8: _get_value_from_input
protected function _get_value_from_input($option, $input_value)
{
if (is_null($input_value)) {
return $option['value'];
} else {
$input_values = isset($option['properties']['values']) && is_array($option['properties']['values']) ? explode(';', $input_value) : array_map('intval', explode(';', $input_value));
return array('from' => $input_values[0], 'to' => $input_values[1]);
}
}
/**
* Used to update option from and to value to be equal to max and min in case they are not defined
*
* @param array $option
*
* @return array
*/
private function update_option($option)
{
if ($option['value']['from'] < $option['properties']['min'] || $option['value']['from'] > $option['properties']['max']) {
$option['value']['from'] = $option['properties']['min'];
$option['properties']['from'] = $option['properties']['min'];
}
if ($option['value']['to'] > $option['properties']['max'] || $option['value']['to'] < $option['properties']['min']) {
$option['value']['to'] = $option['properties']['max'];
$option['properties']['to'] = $option['properties']['max'];
}
return $option;
}
}
FW_Option_Type::register('FW_Option_Type_Range_Slider');
开发者ID:ExtPoint,项目名称:Unyson,代码行数:30,代码来源:class-fw-option-type-range-slider.php
示例9: foreach
$option = $this->prepare_options($option);
foreach ($input_value as $block_id => $block_settings) {
if (!is_array($block_settings)) {
unset($input_value[$block_id]);
continue;
}
foreach ($block_settings as $tag => $tag_settings) {
if (in_array($tag, array_keys(self::$settings['typography_tags']))) {
//Typography
$tag_settings = fw()->backend->option_type('typography')->get_value_from_input(array('value' => $option['value'][$block_id][$tag]), $tag_settings);
} elseif (in_array($tag, array_keys(self::$settings['links']))) {
//Links
$tag_settings = fw()->backend->option_type('color-picker')->get_value_from_input(array('value' => $option['value'][$block_id][$tag]), $tag_settings);
} elseif ($tag === 'background' && !empty($tag_settings)) {
//Background
$tag_settings['background-color']['primary'] = fw()->backend->option_type('color-picker')->get_value_from_input(array('value' => $option['value'][$block_id]['background']['background-color']['primary']), $tag_settings['background-color']['primary']);
$tag_settings['background-image'] = fw()->backend->option_type('background-image')->get_value_from_input(json_decode($tag_settings['background-image']['data'], true), $tag_settings['background-image']);
$block_settings[$tag] = $tag_settings;
} elseif (($tag === 'before' || $tag === 'after') && !empty($option['blocks'][$block_id][$tag])) {
$tag_settings = fw_get_options_values_from_input($option['blocks'][$block_id][$tag], $input_value[$block_id][$tag]);
}
$block_settings[$tag] = $tag_settings;
}
$input_value[$block_id] = $block_settings;
}
$saved['blocks'] = $input_value;
return $saved;
}
}
FW_Option_Type::register('FW_Option_Type_Style');
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:30,代码来源:class-fw-option-type-style.php
示例10: wp_enqueue_style
wp_enqueue_style($this->get_type() . '-scripts', fw_ext('mailer')->get_uri() . '/includes/option-type-mailer/static/css/style.css');
wp_enqueue_script($this->get_type() . '-scripts', fw_ext('mailer')->get_uri() . '/includes/option-type-mailer/static/js/scripts.js', array('fw-events'), fw()->manifest->get_version(), true);
}
/**
* @internal
*/
protected function _render($id, $option, $data)
{
$data['value'] = fw_ext('mailer')->get_db_settings_option();
$wrapper_attr = $option['attr'];
unset($wrapper_attr['name'], $wrapper_attr['value']);
return '<div ' . fw_attr_to_html($wrapper_attr) . '>' . fw()->backend->option_type('multi')->render($id, array('inner-options' => $this->get_inner_options()), $data) . '</div>';
}
/**
* @internal
*
* @param array $option
* @param array|null|string $input_value
*
* @return array|bool|int|string
*/
protected function _get_value_from_input($option, $input_value)
{
if (is_array($input_value) && !empty($input_value)) {
fw_ext('mailer')->set_db_settings_option(null, fw_get_options_values_from_input($this->get_inner_options(), $input_value));
}
return fw_ext('mailer')->get_db_settings_option();
}
}
FW_Option_Type::register('FW_Option_Type_Mailer');
开发者ID:chrisuehlein,项目名称:couponsite,代码行数:30,代码来源:class-fw-option-type-mailer.php
示例11: _get_json_value_to_insert_in_html
}
if ($input['type'] === 'custom-upload') {
$result['attachment-id'] = $input['attachment-id'];
$result['url'] = $input['url'];
}
return $result;
}
protected function _get_json_value_to_insert_in_html($data)
{
$result = array();
$result['type'] = $data['value']['type'];
if ($data['value']['type'] === 'icon-font') {
$result['icon-class'] = $data['value']['icon-class'];
}
if ($data['value']['type'] === 'custom-upload') {
$result['attachment-id'] = $data['value']['attachment-id'];
$result['url'] = $data['value']['url'];
}
return json_encode($result);
}
protected function _get_defaults()
{
return array('value' => array('type' => 'icon-font', 'icon-class' => '', 'icon-class-without-root' => false, 'pack-name' => false, 'pack-css-uri' => false), 'preview-size' => 'medium');
}
public function _get_backend_width_type()
{
return 'full';
}
}
FW_Option_Type::register('FW_Option_Type_Icon_v2');
开发者ID:cristeamdev,项目名称:Unyson,代码行数:30,代码来源:class-fw-option-type-icon-v2.php
示例12: _init
public function _init()
{
if (is_null(self::$original_value)) {
self::$original_value = self::get_key();
}
}
public function get_type()
{
return 'gmap-key';
}
/**
* @internal
*/
protected function _get_defaults()
{
return array('value' => self::get_key(), 'fw-storage' => array('type' => 'wp-option', 'wp-option' => self::get_key_option_id()));
}
/**
* Restrict option save if the option value is same as the one in the database
* @inheritdoc
*/
protected function _storage_save($id, array $option, $value, array $params)
{
if ($value == self::$original_value) {
return $value;
}
return parent::_storage_save($id, $option, $value, $params);
}
}
FW_Option_Type::register('FW_Option_Type_GMap_Key');
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:30,代码来源:simple.php
示例13: switch
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 => $options) {
foreach ($options as $option_id => $option) {
$value[$choice_id][$option_id] = fw()->backend->option_type($option['type'])->get_value_from_input($option, isset($input_value[$choice_id][$option_id]) ? $input_value[$choice_id][$option_id] : null);
}
}
return $value;
}
}
FW_Option_Type::register('FW_Option_Type_Multi_Picker');
开发者ID:floq-design,项目名称:Unyson,代码行数:30,代码来源:class-fw-option-type-multi-picker.php
示例14: customizer_register_options
/**
* @param WP_Customize_Manager $wp_customize
* @param array $options
* @param array $parent_data {'type':'...','id':'...'}
*/
private function customizer_register_options($wp_customize, $options, $parent_data = array())
{
$collected = array();
fw_collect_first_level_options($collected, $options);
if (empty($collected['all'])) {
return;
}
foreach ($collected['all'] as &$opt) {
switch ($opt['type']) {
case 'tab':
$args = array('title' => $opt['option']['title'], 'description' => empty($opt['option']['desc']) ? '' : $opt['option']['desc']);
if ($parent_data) {
trigger_error('Not supported panel parent, type: ' . $parent_data['type'], E_USER_WARNING);
break;
}
$wp_customize->add_panel($opt['id'], $args);
$this->customizer_register_options($wp_customize, $opt['option']['options'], array('type' => 'panel', 'id' => $opt['id']));
break;
case 'box':
$args = array('title' => $opt['option']['title']);
if ($parent_data) {
if ($parent_data['type'] === 'panel') {
$args['panel'] = $parent_data['id'];
} else {
trigger_error('Not supported section parent, type: ' . $parent_data['type'], E_USER_WARNING);
break;
}
}
$wp_customize->add_section($opt['id'], $args);
$this->customizer_register_options($wp_customize, $opt['option']['options'], array('type' => 'section', 'id' => $opt['id']));
break;
case 'option':
$setting_id = FW_Option_Type::get_default_name_prefix() . '[' . $opt['id'] . ']';
$args = array('label' => empty($opt['option']['label']) ? '' : $opt['option']['label'], 'description' => empty($opt['option']['desc']) ? '' : $opt['option']['desc'], 'settings' => $setting_id, 'type' => 'radio', 'choices' => array('a' => 'Demo A', 'b' => 'Demo B'));
if ($parent_data) {
if ($parent_data['type'] === 'section') {
$args['section'] = $parent_data['id'];
} else {
trigger_error('Not supported control parent, type: ' . $parent_data['type'], E_USER_WARNING);
break;
}
} else {
// the option is not placed in a section, create a section automatically
$args['section'] = 'fw_option_auto_section_' . $opt['id'];
$wp_customize->add_section($args['section'], array('title' => empty($opt['option']['label']) ? fw_id_to_title($opt['id']) : $opt['option']['label']));
}
if (!class_exists('_FW_Customizer_Control_Option_Wrapper')) {
require_once fw_get_framework_directory('/includes/customizer/class--fw-customizer-control-option-wrapper.php');
}
$wp_customize->add_setting($setting_id, array('default' => fw()->backend->option_type($opt['option']['type'])->get_value_from_input($opt['option'], null)));
$control = new _FW_Customizer_Control_Option_Wrapper($wp_customize, $opt['id'], $args, array('fw_option' => $opt['option']));
add_filter("customize_sanitize_{$setting_id}", array($control, 'setting_sanitize_callback'), 10, 2);
$wp_customize->add_control($control);
break;
default:
trigger_error('Not supported option in customizer, type: ' . $opt['type'], E_USER_WARNING);
// todo: uncomment
}
}
}
开发者ID:alireza--noori,项目名称:initial-portfolio-website-test-,代码行数:65,代码来源:backend.php
示例15: set_default_values
return $input_value;
}
private function set_default_values(&$input_value, &$option)
{
if (!isset($input_value['textarea']) || empty($input_value['textarea'])) {
$input_value['textarea'] = $option['value']['textarea'];
}
if (!isset($input_value['rows']) || empty($input_value['rows'])) {
$input_value['rows'] = $option['value']['rows'];
}
if (!isset($input_value['cols']) || empty($input_value['cols'])) {
$input_value['cols'] = $option['value']['cols'];
}
}
/**
* @internal
*/
protected function _get_defaults()
{
return array('row_options' => array('choices' => array('' => __('Default row', 'fw'), 'heading-row' => __('Heading row', 'fw'), 'pricing-row' => __('Pricing row', 'fw'))), 'columns_options' => array('choices' => array('' => __('Default column', 'fw'), 'highlight-col' => __('Highlight column', 'fw'), 'desc-col' => __('Description column', 'fw'), 'center-col' => __('Center text column', 'fw'))), 'value' => array('cols' => array('', '', ''), 'rows' => array('', '', ''), 'textarea' => array(array('', '', ''), array('', '', ''), array('', '', ''))));
}
/**
* @internal
*/
public function _get_backend_width_type()
{
return 'full';
}
}
FW_Option_Type::register('FW_Option_Type_Table_Builder');
开发者ID:AdsonCicilioti,项目名称:Unyson,代码行数:30,代码来源:class-fw-option-type-table-builder.php
示例16: esc_attr
} else {
// simple choice
$html .= '<option value="' . esc_attr($c_value) . '" ' . (in_array($c_value, $value) ? 'selected="selected" ' : '') . '>' . htmlspecialchars($choice, ENT_COMPAT, 'UTF-8') . '</option>';
}
}
return $html;
}
/**
* @internal
*/
protected function _get_defaults()
{
return array('value' => array(), 'choices' => array());
}
}
FW_Option_Type::register('FW_Option_Type_Select_Multiple');
$dir = dirname(__FILE__);
require $dir . '/option-types/icon/class-fw-option-type-icon.php';
require $dir . '/option-types/image-picker/class-fw-option-type-image-picker.php';
require $dir . '/option-types/upload/class-fw-option-type-upload.php';
require $dir . '/option-types/color-picker/class-fw-option-type-color-picker.php';
require $dir . '/option-types/gradient/class-fw-option-type-gradient.php';
require $dir . '/option-types/background-image/class-fw-option-type-background-image.php';
require $dir . '/option-types/multi/class-fw-option-type-multi.php';
require $dir . '/option-types/switch/class-fw-option-type-switch.php';
require $dir . '/option-types/typography/class-fw-option-type-typography.php';
require $dir . '/option-types/multi-upload/class-fw-option-type-multi-upload.php';
require $dir . '/option-types/multi-picker/class-fw-option-type-multi-picker.php';
require $dir . '/option-types/wp-editor/class-fw-option-type-wp-editor.php';
require $dir . '/option-types/date-picker/class-fw-option-type-wp-date-picker.php';
require $dir . '/option-types/addable-option/class-fw-option-type-addable-option.php';
开发者ID:floq-design,项目名称:Unyson,代码行数:31,代码来源:option-types.php
示例17: _get_value_from_input
protected function _get_value_from_input($option, $input_value)
{
if (is_null($input_value)) {
return $option['value'];
} else {
if ($input_value) {
// checked
return $option['right-choice']['value'];
} else {
// unchecked
return $option['left-choice']['value'];
}
}
}
/**
* @internal
*/
public function _get_backend_width_type()
{
return 'auto';
}
/**
* @internal
*/
protected function _get_defaults()
{
return array('value' => false, 'left-choice' => array('value' => false, 'label' => __('No', 'fw')), 'right-choice' => array('value' => true, 'label' => __('Yes', 'fw')));
}
}
FW_Option_Type::register('FW_Option_Type_Switch');
开发者ID:HilderH,项目名称:emprendamos,代码行数:30,代码来源:class-fw-option-type-switch.php
示例18: _get_defaults
*
* array(
* 'value' => '',
* ...
* )
* @internal
*/
protected function _get_defaults()
{
return array('value' => '', 'attr' => array('placeholder' => 'https://www.youtube.com'), 'preview' => array('width' => 428, 'height' => 320, 'keep_ratio' => true));
}
protected function _enqueue_static($id, $option, $data)
{
wp_enqueue_style('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/css/styles.css'), array('fw'));
wp_enqueue_script('fw-option-' . $this->get_type(), fw_get_framework_directory_uri('/includes/option-types/' . $this->get_type() . '/static/js/' . $this->get_type() . '.js'), array('underscore', 'fw-events', 'fw', 'wp-util'), false, true);
}
public static function _action_get_oembed_response()
{
if (wp_verify_nonce(FW_Request::POST('_nonce'), '_action_get_oembed_response')) {
$url = FW_Request::POST('url');
$width = FW_Request::POST('preview/width');
$height = FW_Request::POST('preview/height');
$keep_ratio = FW_Request::POST('preview/keep_ratio') === 'true';
$iframe = empty($keep_ratio) ? fw_oembed_get($url, compact('width', 'height')) : wp_oembed_get($url, compact('width', 'height'));
wp_send_json_success(array('response' => $iframe));
}
wp_send_json_error(array('message' => 'Invalid nonce'));
}
}
FW_Option_Type::register('FW_Option_Type_Oembed');
add_action('wp_ajax_get_oembed_response', array("FW_Option_Type_Oembed", '_action_get_oembed_response'));
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:31,代码来源:class-fw-option-type-oembed.php
示例19: strtotime
if (isset($option['datetime-picker']['minDate']) and !empty($option['datetime-picker']['minDate'])) {
$min_timestamp_value = strtotime($option['datetime-picker']['minDate']);
if ($min_timestamp_value > $input_timestamp_value) {
return $option['value'];
}
}
if (isset($option['datetime-picker']['maxDate']) and !empty($option['datetime-picker']['maxDate'])) {
$max_timestamp_value = strtotime($option['datetime-picker']['maxDate']);
if ($max_timestamp_value < $input_timestamp_value) {
return $option['value'];
}
}
} catch (Exception $e) {
return $option['value'];
}
return (string) $input_value;
}
private function _fw_validate_date_format($date, $format = 'Y/m/d H:i', $extra_formats = array())
{
$extra_formats = array_merge($extra_formats, array($format));
foreach ($extra_formats as $format) {
$d = DateTime::createFromFormat($format, $date);
if ($d && $d->format($format) == $date) {
return true;
}
}
return false;
}
}
FW_Option_Type::register('FW_Option_Type_Datetime_Picker');
开发者ID:kvsemenoff,项目名称:proetis,代码行数:30,代码来源:class-fw-option-type-datetime-picker.php
示例20: _get_value_from_input
}
/**
* @internal
*/
protected function _get_value_from_input($option, $input_value)
{
if (empty($input_value)) {
return $option['value'];
} else {
return $this->get_attachments_info($input_value);
}
}
private function get_attachments_info($attachment_ids)
{
$decoded_ids = json_decode($attachment_ids, true);
if (!is_array($decoded_ids) || empty($decoded_ids)) {
$defaults = $this->get_defaults();
return $defaults['value'];
}
$return_arr = array();
foreach ($decoded_ids as $id) {
$url = wp_get_attachment_url($id);
if ($url) {
$return_arr[] = array('attachment_id' => $id, 'url' => preg_replace('/^https?:\\/\\//', '//', $url));
}
}
return $return_arr;
}
}
FW_Option_Type::register('FW_Option_Type_Multi_Upload');
开发者ID:puriwp,项目名称:Theme-Framework,代码行数:30,代码来源:class-fw-option-type-multi-upload.php
注:本文中的FW_Option_Type类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论