本文整理汇总了PHP中wpcf_ensarr函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_ensarr函数的具体用法?PHP wpcf_ensarr怎么用?PHP wpcf_ensarr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_ensarr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: sanitize_single_option
/**
* Sanitize single checkboxes option definition.
*
* @param array $option
* @return array Sanitized option.
* @since 2.1
*/
private function sanitize_single_option($option)
{
$option = $this->sanitize_element_isset(wpcf_ensarr($option), 'value');
$option = $this->sanitize_element_isset($option, 'title', $option['value']);
$option = $this->sanitize_element_isset($option, 'display_value', $option['value']);
return $option;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:14,代码来源:radio.php
示例2: sanitize_single_option
/**
* Sanitize single checkboxes option definition.
*
* @param array $option
* @return array Sanitized option.
* @since 2.1
*/
private function sanitize_single_option($option)
{
$option = $this->sanitize_element_isset(wpcf_ensarr($option), 'set_value');
$option = $this->sanitize_element_isset($option, 'title', $option['set_value']);
$option = $this->sanitize_element_isset($option, 'display', 'db', array('db', 'value'));
$option = $this->sanitize_element_isset($option, 'display_value_selected');
$option = $this->sanitize_element_isset($option, 'display_value_not_selected');
return $option;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:16,代码来源:checkboxes.php
示例3: get_associated_taxonomies
/**
* Get taxonomies that are associated with this field group.
*
* @return string[] Taxonomy slugs. Empty array means that this group should be displayed with all taxonomies.
*/
public function get_associated_taxonomies()
{
$postmeta = get_post_meta($this->get_id(), self::POSTMETA_ASSOCIATED_TAXONOMY, false);
$postmeta = array_filter($postmeta, function ($value) {
$value = trim($value);
return !empty($value);
});
return wpcf_ensarr($postmeta);
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:14,代码来源:term.php
示例4: sanitize_numeric_validation
/**
* Add the 'number' validation if it was not already there, and activate it.
*
* @param array $definition_array
* @return array
* @since 2.0
*/
protected function sanitize_numeric_validation($definition_array)
{
// Get the original setting or a default one.
$validation_setting = wpcf_ensarr(wpcf_getnest($definition_array, array('data', 'validate', 'number')), array('active' => true, 'message' => __('Please enter numeric data', 'wpcf')));
// Force the activation of this validation.
$validation_setting['active'] = true;
// Store the setting.
$definition_array['data']['validate']['number'] = $validation_setting;
return $definition_array;
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:17,代码来源:numeric.php
示例5: get_possible_conversions
/**
* @param Types_Field_Type_Definition $type
* @return Types_Field_Type_Definition[]
*/
public function get_possible_conversions($type)
{
if (!$type instanceof Types_Field_Type_Definition) {
throw new InvalidArgumentException('Not a field type definition');
}
$matrix = $this->get_conversion_matrix();
$allowed_slugs = wpcf_ensarr(wpcf_getarr($matrix, $type->get_slug()));
$allowed_types = Types_Field_Type_Definition_Factory::get_instance()->load_multiple_definitions($allowed_slugs);
return $allowed_types;
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:14,代码来源:type_converter.php
示例6: get_associated_taxonomies
/**
* Get taxonomies that are associated with this field group.
*
* @return string[] Taxonomy slugs. Empty array means that this group should be displayed with all taxonomies.
*/
public function get_associated_taxonomies()
{
$postmeta = get_post_meta($this->get_id(), self::POSTMETA_ASSOCIATED_TAXONOMY, false);
// Survive empty or whitespace taxonomy slugs (skip them). They are invalid values but
// if we have only them, we need to return an empty array to keep the group displayed everywhere.
foreach ($postmeta as $index => $taxonomy_slug) {
$taxonomy_slug = trim($taxonomy_slug);
if (empty($taxonomy_slug)) {
unset($postmeta[$index]);
}
}
return wpcf_ensarr($postmeta);
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:18,代码来源:term.php
示例7: read_field_values
/**
* Read the field values from $_POST.
*
* @return array Values in the "intermediate" format (see WPCF_Field_DataMapper_Abstract). For non-repetitive values,
* it will be an array with a single item.
*/
private function read_field_values()
{
if (null == $this->field_values) {
$definition = $this->field->get_definition();
$form_data = wpcf_ensarr(wpcf_getpost('wpcf'));
$values = wpcf_getarr($form_data, $definition->get_slug());
// Handle single fields.
if (!$definition->get_is_repetitive()) {
$values = array($values);
}
// Map POST values to intermediate format.
$this->field_values = array();
$data_mapper = $definition->get_data_mapper();
foreach ($values as $value) {
$this->field_values[] = $data_mapper->post_to_intermediate($value, $form_data);
}
}
return wpcf_ensarr($this->field_values);
}
开发者ID:phuocdungit,项目名称:fundy,代码行数:25,代码来源:data_saver.php
示例8: get_field_options
/**
* Retrieve an array of option definitions.
*
* Allowed only for the checkboxes, radio and select field types.
*
* @throws RuntimeException when the field type is invalid
* @throws InvalidArgumentException when option definitions are corrupted
* @return WPCF_Field_Option_Checkboxes[] An option_id => option_data array.
* @since 1.9
*/
public function get_field_options()
{
$this->check_allowed_types(array(Types_Field_Type_Definition_Factory::CHECKBOXES, Types_Field_Type_Definition_Factory::RADIO, Types_Field_Type_Definition_Factory::SELECT));
$options_definition = wpcf_ensarr(wpcf_getnest($this->definition_array, array('data', 'options')));
$results = array();
// The 'default' key can be present, we have to remove it so it's not handled as another option.
$has_default = array_key_exists('default', $options_definition);
$default = wpcf_getarr($options_definition, 'default', 'no-default');
if ($has_default) {
unset($options_definition['default']);
}
foreach ($options_definition as $option_id => $option_config) {
try {
switch ($this->get_type()->get_slug()) {
case Types_Field_Type_Definition_Factory::RADIO:
$option = new WPCF_Field_Option_Radio($option_id, $option_config, $default, $this);
break;
case Types_Field_Type_Definition_Factory::SELECT:
$option = new WPCF_Field_Option_Select($option_id, $option_config, $default, $this);
break;
case Types_Field_Type_Definition_Factory::CHECKBOXES:
$option = new WPCF_Field_Option_Checkboxes($option_id, $option_config, $default);
break;
default:
throw new InvalidArgumentException('Invalid field type');
}
$results[$option_id] = $option;
} catch (Exception $e) {
// Corrupted data, can't do anything but skip the option.
}
}
return $results;
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:43,代码来源:definition.php
示例9: wpcf_fix_exported_taxonomy_assignment_to_cpt
/**
* Filter the data to be exported for custom taxonomies.
*
* Ensure the settings of post types associated with the taxonomy is exported correctly, even with support of legacy
* settings.
*
* @param array $taxonomy_data
* @return array Modified taxonomy data.
* @since unknown
*/
function wpcf_fix_exported_taxonomy_assignment_to_cpt($taxonomy_data = array())
{
$setting_name_prefix = '__types_cpt_supports_';
$post_type_support_settings = array();
// Associated CPTs slugs are stored as XML keys, so they can not start with a number.
// We force a prefix on all of them on export, and restore them on import.
$supported_post_types = wpcf_ensarr(wpcf_getarr($taxonomy_data, 'supports'));
foreach ($supported_post_types as $post_type_slug => $is_supported) {
$setting_name = $setting_name_prefix . $post_type_slug;
$post_type_support_settings[$setting_name] = $is_supported ? 1 : 0;
}
// Here, we will also process the legacy "object_type" setting, containing supported post type slugs as array items,
// in the samve way.
$legacy_supported_post_type_array = wpcf_ensarr(wpcf_getarr($taxonomy_data, 'object_type'));
foreach ($legacy_supported_post_type_array as $post_type_slug) {
$setting_name = $setting_name_prefix . $post_type_slug;
$post_type_support_settings[$setting_name] = 1;
}
// Now we need to remove this legacy setting to prevent producing invalid XML.
unset($taxonomy_data['object_type']);
$taxonomy_data['supports'] = $post_type_support_settings;
return $taxonomy_data;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:33,代码来源:module-manager.php
示例10: change_assignment_to_groups
/**
* Change which groups is a field definition associated with.
*
* AJAX callback helper only, do not use elsewhere.
*
* @param string $field_slug Field definition slug.
* @param string $domain Field domain
* @param string[][] $groups Action-specific data passed through AJAX. Array containing a single key 'group_slugs',
* containing an array of field group slugs.
*
* @return WP_Error|WPCF_Field_Definition The updated field definition on success or an error object.
* @since 2.0
*/
public static function change_assignment_to_groups($field_slug, $domain, $groups)
{
$factory = Types_Field_Utils::get_definition_factory_by_domain($domain);
$definition = $factory->load_field_definition($field_slug);
if (null == $definition) {
return new WP_Error(42, sprintf(__('Field definition for field "%s" not found in options.', 'wpcf'), sanitize_text_field($field_slug)));
}
$new_groups = wpcf_ensarr(wpcf_getarr($groups, 'group_slugs'));
$associated_groups = $definition->get_associated_groups();
$is_success = true;
foreach ($associated_groups as $group) {
if (!in_array($group->get_slug(), $new_groups)) {
$is_success = $is_success && $group->remove_field_definition($definition);
}
}
$group_factory = $factory->get_group_factory();
foreach ($new_groups as $new_group_slug) {
$new_group = $group_factory->load_field_group($new_group_slug);
if (null != $new_group) {
$is_success = $is_success && $new_group->add_field_definition($definition);
} else {
$is_success = false;
}
}
if ($is_success) {
return $definition;
} else {
return new WP_Error();
}
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:43,代码来源:utils.php
示例11: load_multiple_definitions
/**
* Get field type definitions from an array of slugs.
*
* If a definition cannot be loaded for a given slug, the slug is skipped without reporting an error in any other way.
*
* @param string[] $field_type_slugs
* @return Types_Field_Type_Definition[]
* @since 2.0
*/
public function load_multiple_definitions($field_type_slugs)
{
$results = array();
$field_type_slugs = wpcf_ensarr($field_type_slugs);
foreach ($field_type_slugs as $field_type_slug) {
$type_definition = $this->load_field_type_definition($field_type_slug);
if (null != $type_definition) {
$results[$field_type_slug] = $type_definition;
}
}
return $results;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:21,代码来源:definition_factory.php
示例12: get_associated_taxonomies
/**
* Get taxonomies that are associated with this field group.
*
* @return string[] Taxonomy slugs. Empty array means that this group should be displayed with all taxonomies.
*/
public function get_associated_taxonomies()
{
$postmeta = get_post_meta($this->get_id(), self::POSTMETA_ASSOCIATED_TAXONOMY, false);
return wpcf_ensarr($postmeta);
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:10,代码来源:group_term.php
示例13: sanitize_field_definition_array
/**
* Make sure that the field definition array contains all necessary information.
*
* Note: This is a WIP, currently it sanitizes only very specific cases. It should be extended in the future.
*
* @link https://git.onthegosystems.com/toolset/types/wikis/database-layer/field-definition-arrays
* @param array $definition_array Field definition array
* @return array Field definition array that is safe to be used even with legacy code.
* @since 2.0
*/
public final function sanitize_field_definition_array($definition_array)
{
/**
* types_pre_sanitize_field_definition_array
*
* Allow for additional field definition array sanitization before the standard one runs.
*
* @param mixed $definition_array
* @return array
* @since 2.1
*/
$definition_array = wpcf_ensarr(apply_filters('types_pre_sanitize_field_definition_array', $definition_array));
$definition_array = $this->sanitize_field_definition_array_generic($definition_array);
$definition_array = $this->sanitize_numeric_validation($definition_array);
$definition_array = $this->sanitize_field_definition_array_type_specific($definition_array);
/**
* types_post_sanitize_field_definition_array
*
* Allow for additional field definition array sanitization after the standard one runs.
*
* @param array $definition_array
* @return array
* @since 2.1
*/
$definition_array = wpcf_ensarr(apply_filters('types_post_sanitize_field_definition_array', $definition_array));
return $definition_array;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:37,代码来源:definition.php
示例14: sanitize_field_definition_array
/**
* Make sure that the field definition array contains all necessary information.
*
* Note: This is a WIP, currently it sanitizes only very specific cases. It should be extended in the future.
*
* Expected definition array structure common to all fields:
*
* - slug: string
* - data: array
* - validate: array
*
* @param array $definition_array Field definition array
* @return array Field definition array that is safe to be used even with legacy code.
* @since 2.0
*/
public function sanitize_field_definition_array($definition_array)
{
$definition_array['data'] = wpcf_ensarr(wpcf_getarr($definition_array, 'data'));
$definition_array['data']['validate'] = wpcf_ensarr(wpcf_getarr($definition_array['data'], 'validate'));
$definition_array = $this->sanitize_numeric_validation($definition_array);
return $definition_array;
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:22,代码来源:definition.php
示例15: get_field_options
/**
* @return array An option_id => option_data array.
*/
public function get_field_options()
{
return wpcf_ensarr(wpcf_getnest($this->definition_array, array('data', 'options')));
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:7,代码来源:definition.php
示例16: ajax_filter_default_value
private function ajax_filter_default_value($value, $currently_supported = array(), $type = false)
{
if ($type && isset($_REQUEST['all_fields']) && is_array($_REQUEST['all_fields'])) {
switch ($type) {
case 'taxonomies-for-termmeta':
$selected_taxonomies = wpcf_ensarr(wpcf_getnest($_REQUEST, array('all_fields', 'wpcf', 'group', 'taxonomies')));
if (in_array($value, array_keys($selected_taxonomies)) && true == $selected_taxonomies[$value]) {
return true;
}
break;
}
// not selected
return false;
}
if (isset($_REQUEST['current'])) {
if (is_array($_REQUEST['current']) && in_array($value, $_REQUEST['current'])) {
return true;
}
} else {
if ($currently_supported && !empty($currently_supported) && in_array($value, $currently_supported)) {
return true;
}
}
return false;
}
开发者ID:phuocdungit,项目名称:fundy,代码行数:25,代码来源:termmeta_form.php
示例17: wpcf_admin_import_data
//.........这里部分代码省略.........
$fields_existing[$field_id] = $field_data;
$fields_check[] = $field_id;
// WPML
global $iclTranslationManagement;
if (!empty($iclTranslationManagement) && isset($field['wpml_action'])) {
$iclTranslationManagement->settings['custom_fields_translation'][wpcf_types_get_meta_prefix($field) . $field_id] = $field['wpml_action'];
$iclTranslationManagement->save_settings();
}
$return[] = array('type' => 'success', 'content' => sprintf(__('User field "%s" added/updated', 'wpcf'), $field['name']));
}
}
// Delete fields
if ($delete_fields) {
foreach ($fields_existing as $k => $v) {
if (!empty($v['data']['controlled'])) {
continue;
}
if (!in_array($k, $fields_check)) {
$return[] = array('type' => 'success', 'content' => sprintf(__('User field "%s" deleted', 'wpcf'), $fields_existing[$k]['name']));
unset($fields_existing[$k]);
}
}
} else {
if (!empty($_POST['user-fields-to-be-deleted'])) {
foreach ($_POST['user-fields-to-be-deleted'] as $field_to_delete) {
$return[] = array('type' => 'success', 'content' => sprintf(__('User field "%s" deleted', 'wpcf'), $fields_existing[$field_to_delete]['name']));
unset($fields_existing[$field_to_delete]);
}
}
}
update_option('wpcf-usermeta', $fields_existing);
// Handle term field groups and field definitions outside of this mess.
$ie_controller = Types_Import_Export::get_instance();
$term_group_results = $ie_controller->process_field_group_import_per_domain(Types_Field_Utils::DOMAIN_TERMS, $data, 'term_groups', $overwrite_groups, $delete_groups, wpcf_ensarr(wpcf_getpost('term_groups')));
$term_field_results = $ie_controller->process_field_definition_import_per_domain(Types_Field_Utils::DOMAIN_TERMS, $data, 'term_fields', $delete_fields, wpcf_ensarr(wpcf_getpost('term_fields')));
$return = array_merge($return, $term_group_results, $term_field_results);
// Process types
$types_existing = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
$types_check = array();
if (!empty($data->types) && isset($data->types->type)) {
$types = array();
// Set insert data from XML
foreach ($data->types->type as $type) {
$type = wpcf_admin_import_export_simplexml2array($type);
// Set if submitted in 'types' context
if ($context == 'types') {
if (isset($_POST['types'][$type['id']])) {
$types[$type['id']] = $type;
}
} else {
$types[$type['id']] = $type;
}
}
// Set insert data from POST
if (!empty($_POST['types'])) {
foreach ($_POST['types'] as $type_id => $type) {
if (empty($types[$type_id])) {
continue;
}
$types[$type_id]['add'] = !empty($type['add']);
$types[$type_id]['update'] = isset($type['update']) && $type['update'] == 'update' ? true : false;
}
}
// Insert types
foreach ($types as $type_id => $type) {
if (isset($type['add']) && !$type['add'] && !$overwrite_types) {
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:67,代码来源:import-export.php
示例18: get_groups_by_taxonomy
/**
* Get array of groups that are associated with given taxonomy.
*
* @param string $taxonomy_slug Slug of the taxonomy
* @return WPCF_Field_Group_Term[] Associated term field groups.
*/
public function get_groups_by_taxonomy($taxonomy_slug)
{
$groups_by_taxonomies = $this->get_groups_by_taxonomies();
return wpcf_ensarr(wpcf_getarr($groups_by_taxonomies, $taxonomy_slug));
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:11,代码来源:group_term_factory.php
示例19: get_sort_order
/**
* For repetitive field, get the order of individual values.
*
* @return array Meta IDs in the order defining the field value order.
*/
protected function get_sort_order()
{
$accessor = $this->get_order_accessor();
return wpcf_ensarr($accessor->get_raw_value());
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:10,代码来源:instance.php
示例20: __construct
/**
* WPCF_Field_Renderer_Preview_Base constructor.
*
* @param WPCF_Field_Instance_Abstract $field
* @param array $args Preview renderer settings:
* - maximum_item_count => Maximum count of field values that should be displayed.
* - maximum_item_length => Maximum length of single item.
* - maximum_total_length => Maximum length of output.
* - value_separator => Separator to be used between multiple field values.
* - ellipsis => Ellipsis to be added when some field values are omitted.
*
* Specialized renderers may interpret the settings in a different way or add their own.
*
* @since 1.9.1
*/
public function __construct($field, $args = array())
{
parent::__construct($field);
$this->args = wpcf_ensarr($args);
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:20,代码来源:base.php
注:本文中的wpcf_ensarr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论