本文整理汇总了PHP中wpcf_getarr函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_getarr函数的具体用法?PHP wpcf_getarr怎么用?PHP wpcf_getarr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_getarr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: hack_around_legacy_import_routine
private function hack_around_legacy_import_routine($import_data, $import_args = null)
{
add_filter('wpcf_admin_message_store', '__return_false');
$_POST['overwrite-settings'] = isset($import_args['overwrite-settings']) ? (bool) $import_args['overwrite-settings'] : false;
$_POST['overwrite-groups'] = isset($import_args['overwrite-groups']) && 1 == $import_args['overwrite-groups'] ? 1 : 0;
$_POST['overwrite-fields'] = isset($import_args['overwrite-fields']) && 1 == $import_args['overwrite-fields'] ? 1 : 0;
$_POST['overwrite-types'] = isset($import_args['overwrite-types']) && 1 == $import_args['overwrite-types'] ? 1 : 0;
$_POST['overwrite-tax'] = isset($import_args['overwrite-tax']) && 1 == $import_args['overwrite-tax'] ? 1 : 0;
$_POST['post_relationship'] = isset($import_args['post_relationship']) ? (bool) $import_args['post_relationship'] : false;
$_POST['delete-groups'] = isset($import_args['delete-groups']) ? (bool) $import_args['delete-groups'] : false;
$_POST['delete-fields'] = isset($import_args['delete-fields']) ? (bool) $import_args['delete-fields'] : false;
$_POST['delete-types'] = isset($import_args['delete-types']) ? (bool) $import_args['delete-types'] : false;
$_POST['delete-tax'] = isset($import_args['delete-tax']) ? (bool) $import_args['delete-tax'] : false;
/**
* This can be emtpy string '' or 'wpvdemo', but this second option has a serious bug with xml parsing/looping
*/
$context = isset($import_args['context']) ? $import_args['context'] : '';
// Not sure if this is needed
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/import-export.php';
// Prepare legacy arguments for Types_Data_Installer
$legacy_args = array();
if (isset($import_args['overwrite'])) {
$legacy_args['force_import_post_name'] = wpcf_getarr($import_args, 'overwrite', array());
}
if (isset($import_args['skip'])) {
$legacy_args['force_skip_post_name'] = wpcf_getarr($import_args, 'skip', array());
}
if (isset($import_args['duplicate'])) {
$legacy_args['force_duplicate_post_name'] = wpcf_getarr($import_args, 'duplicate', array());
}
$result = wpcf_admin_import_data($import_data, false, $context, $legacy_args);
return true;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:34,代码来源:import_from_zip_file.php
示例2: render_single
/**
* @param mixed $value Single field value in the intermediate format (see data mappers for details)
*
* @return string Rendered HTML
*/
protected function render_single($value)
{
// Simply get the Skype name.
$skype_name = wpcf_getarr($value, 'skypename');
$skype_name = is_string($skype_name) ? $skype_name : '';
return sanitize_text_field($skype_name);
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:12,代码来源:skype.php
示例3: 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
示例4: get_link_label
/**
* @param string[] $url_components Result of parse_url().
* @return string Label of the resulting link.
* @since 1.9.1
*/
protected function get_link_label($url_components)
{
// Build link label only from host, path and query.
$url_query = wpcf_getarr($url_components, 'query');
$url_query = empty($url_query) ? '' : '?' . $url_query;
$url_path = wpcf_getarr($url_components, 'path');
if (empty($url_query)) {
// Omit last slash when it would be the last label character
$url_path = substr($url_path, 0, strlen($url_path) - 1);
}
$label = sprintf('%s%s%s', wpcf_getarr($url_components, 'host'), $url_path, $url_query);
return $label;
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:18,代码来源:url.php
示例5: __construct
/**
* WPCF_Field_Type_Definition constructor.
*
* @param string $field_type_slug Field type slug.
* @param array $args Additional array of arguments which should contain at least 'display_name' (or 'title')
* and 'description' elements, but omitting them is not critical.
*/
public function __construct($field_type_slug, $args)
{
if (sanitize_title($field_type_slug) != $field_type_slug) {
throw new InvalidArgumentException('Invalid field type slug.');
}
if (!is_array($args)) {
throw new InvalidArgumentException('Wrong arguments provided.');
}
$this->field_type_slug = $field_type_slug;
// Try to fall back to legacy "title", and if even that fails, use id instead.
$this->display_name = sanitize_text_field(wpcf_getarr($args, 'display_name', wpcf_getarr($args, 'title', $field_type_slug)));
$this->description = wpcf_getarr($args, 'description', '');
$this->args = $args;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:21,代码来源:type_definition.php
示例6: get_display_value
/**
* Determine value to be displayed for this option.
*
* @param bool $is_checked For which value should the output be rendered.
* @return string Display value depending on option definition and field display mode
* @since 1.9.1
*/
public function get_display_value($is_checked = true)
{
$field_definition_array = $this->field_definition->get_definition_array();
$display_mode = wpcf_getnest($field_definition_array, array('data', 'display'), 'db');
$display_mode = 'value' == $display_mode ? 'value' : 'db';
if ('db' == $display_mode) {
return $is_checked ? $this->get_value_to_store() : '';
} else {
if ($is_checked) {
return wpcf_getarr($this->config, 'display_value');
} else {
return '';
}
}
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:22,代码来源:option_radio.php
示例7: sanitize_field_definition_array_type_specific
/**
* @inheritdoc
*
* @param array $definition_array
* @return array
* @since 2.1
*/
protected function sanitize_field_definition_array_type_specific($definition_array)
{
$definition_array['type'] = Types_Field_Type_Definition_Factory::SELECT;
$options = wpcf_ensarr(wpcf_getnest($definition_array, array('data', 'options')));
foreach ($options as $key => $option) {
if ('default' == $key) {
continue;
}
$options[$key] = $this->sanitize_single_option($option);
}
$default_option = wpcf_getarr($options, 'default');
if (!is_string($default_option) || !array_key_exists($default_option, $options)) {
$default_option = 'no-default';
}
$options['default'] = $default_option;
$definition_array['data']['options'] = $options;
return $definition_array;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:25,代码来源:select.php
示例8: 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
示例9: load_field_type_definition
/**
* Load a field type definition.
*
* @param string $field_type_slug Slug of the field type. If the function fails to find the field type and the slug
* starts with a "wpcf-" prefix, it attempts to remove it and search again. This way, passing a field type ID,
* which usually has this form, is also supported.
* @return null|WPCF_Field_Type_Definition Field type definition or null if it can't be loaded.
*/
public function load_field_type_definition($field_type_slug)
{
if (!is_string($field_type_slug)) {
return null;
}
// Check if we can use cached version.
if (!in_array($field_type_slug, $this->field_type_definitions)) {
// now it gets hacky
$field_types = $this->get_legacy_field_types();
if (!in_array($field_type_slug, array_keys($field_types))) {
// Field slug not recognized. Maybe we got a field identifier instead. Check if we can remove
// the wpcf- prefix and try again.
$prefix = 'wpcf-';
if (substr($field_type_slug, 0, strlen($prefix)) == $prefix) {
$field_type_slug = substr($field_type_slug, strlen($prefix));
if (!in_array($field_type_slug, $field_types)) {
// Removing prefix didn't help
return null;
}
} else {
// There was no prefix to remove.
return null;
}
}
// Not using getFieldTypeData() directly to avoid unnecessary getFieldsTypes() and filter applying.
$field_type_configuration_path = $field_types[$field_type_slug];
$field_type_configuration = WPCF_Fields::getFieldTypeConfig($field_type_configuration_path);
$field_type_id = wpcf_getarr($field_type_configuration, 'id', null);
if (null == $field_type_id) {
return null;
}
try {
$field_type_definition = new WPCF_Field_Type_Definition($field_type_slug, $field_type_configuration);
} catch (Exception $e) {
return null;
}
// Save new instance to cache.
$this->field_type_definitions[$field_type_slug] = $field_type_definition;
}
// Use cache.
return $this->field_type_definitions[$field_type_slug];
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:50,代码来源:type_definition_factory.php
示例10: process_call
/**
* @param array $arguments Original action/filter arguments.
*
* @return mixed
*/
function process_call($arguments)
{
$query = wpcf_getarr($arguments, 1, array());
$domain = wpcf_getarr($query, 'domain', 'all');
unset($query['domain']);
// Sanitize input
if (!is_string($domain) || !is_array($query)) {
return null;
}
if ('all' == $domain) {
// Separate query for each available domain.
$groups_by_domain = array();
$domains = Types_Field_Utils::get_domains();
foreach ($domains as $field_domain) {
$groups_by_domain[$field_domain] = $this->query_specific_domain($field_domain, $query);
}
return $groups_by_domain;
} else {
return $this->query_specific_domain($domain, $query);
}
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:26,代码来源:query_groups.php
示例11: query_groups
/**
* Get field groups based on query arguments.
*
* @param array $query_args Optional. Arguments for the WP_Query that will be applied on the underlying posts.
* Post type query is added automatically.
* Additional arguments are allowed:
* - 'types_search': String for extended search. See WPCF_Field_Group::is_match() for details.
* - 'is_active' bool: If defined, only active/inactive field groups will be returned.
*
* @return Types_Field_Group[]
* @since 1.9
*/
public function query_groups($query_args = array())
{
// Read specific arguments
$search_string = wpcf_getarr($query_args, 'types_search');
$is_active = wpcf_getarr($query_args, 'is_active', null);
// Query posts
$query_args = array_merge($query_args, array('post_type' => $this->get_post_type(), 'posts_per_page' => -1));
// Group's "activeness" is defined by the post status.
if (null !== $is_active) {
unset($query_args['is_active']);
$query_args['post_status'] = $is_active ? 'publish' : 'draft';
}
$query = new WP_Query($query_args);
$posts = $query->get_posts();
// Transform posts into Types_Field_Group
$all_groups = array();
foreach ($posts as $post) {
$field_group = $this->load_field_group($post);
if (null != $field_group) {
$all_groups[] = $field_group;
}
}
// Filter groups by the search string.
$selected_groups = array();
if (empty($search_string)) {
$selected_groups = $all_groups;
} else {
/** @var Types_Field_Group $group */
foreach ($all_groups as $group) {
if ($group->is_match($search_string)) {
$selected_groups[] = $group;
}
}
}
return $selected_groups;
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:48,代码来源:factory.php
示例12: wpcf_getnest
/**
* Get a value from nested associative array.
*
* This function will try to traverse a nested associative array by the set of keys provided.
*
* E.g. if you have $source = array( 'a' => array( 'b' => array( 'c' => 'my_value' ) ) ) and want to reach 'my_value',
* you need to write: $my_value = wpcf_getnest( $source, array( 'a', 'b', 'c' ) );
*
* @param mixed|array $source The source array.
* @param string[] $keys Keys which will be used to access the final value.
* @param null|mixed $default Default value to return when the keys cannot be followed.
*
* @return mixed|null Value in the nested structure defined by keys or default value.
*/
function wpcf_getnest(&$source, $keys = array(), $default = null)
{
$current_value = $source;
while (!empty($keys)) {
$current_key = array_shift($keys);
$is_last_key = empty($keys);
$current_value = wpcf_getarr($current_value, $current_key, null);
if ($is_last_key) {
return $current_value;
} elseif (!is_array($current_value)) {
return $default;
}
}
return $default;
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:29,代码来源:functions.php
示例13: get_ellipsis
/**
* @return string Ellipsis to be added when some field values are omitted.
* @since 1.9.1
*/
protected function get_ellipsis()
{
return wpcf_getarr($this->args, 'ellipsis', $this->get_value_separator() . '...');
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:8,代码来源:base.php
示例14: 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
示例15: change_field_cardinality
/**
* Change cardinality of given field, if it is permitted by its type.
*
* @param string $field_slug Field definition slug.
* @param string $domain Field domain.
* @param string[] $arguments Needs to contain the 'target_cardinality' key with 'single'|'repetitive' value.
* @return bool|WP_Error|WPCF_Field_Definition The updated definition on succes, error/false otherwise.
* @since 2.0
*/
public static function change_field_cardinality($field_slug, $domain, $arguments)
{
$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)));
} else {
if (!$definition->is_managed_by_types()) {
return new WP_Error(42, sprintf(__('Field "%s" will not be converted because it is not managed by Types.', 'wpcf'), sanitize_text_field($field_slug)));
}
}
$target_cardinality = wpcf_getarr($arguments, 'target_cardinality', null, array('single', 'repetitive'));
if (null == $target_cardinality) {
return false;
}
$set_as_repetitive = 'repetitive' == $target_cardinality;
$result = $definition->set_is_repetitive($set_as_repetitive);
if ($result) {
return $definition;
} else {
return false;
}
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:32,代码来源:utils.php
示例16: get_help_content
/**
* Render help tab content from its configuration.
*
* @param string $page_name Name of current page.
* @return array|null Null when no help tab should be displayed, or an array with keys 'title' and 'content'.
* @since 2.0
*/
private function get_help_content($page_name)
{
$config = $this->get_help_config($page_name);
if (null == $config) {
return null;
}
$twig = $this->get_twig();
return array('title' => wpcf_getarr($config, 'title'), 'content' => $twig->render(wpcf_getarr($config, 'template'), wpcf_getarr($config, 'context')));
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:16,代码来源:help_tab_loader.php
示例17: get_maximum_image_size
protected function get_maximum_image_size()
{
return wpcf_getarr($this->args, 'maximum_image_size', self::DEFAULT_MAX_IMAGE_SIZE);
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:4,代码来源:image.php
示例18: transform_operators_to_text_equivalents
/**
* Uses the Toolset_Tokenizer to break down the expression, replace problematic operators by their text-only
* equivalents and glue the expression back together.
*
* Side-effects: Loses custom whitespace characters. All operators (except parentheses) will be surrounded by spaces
* while everywhere else the whitespace characters will be trimmed.
*
* Note: If an invalid expression is provided, it doesn't do anything with it.
*
* @param string $expression Condition expression.
* @return string Equivalent expression but without <, <=, etc.
* @since 2.0
*/
protected function transform_operators_to_text_equivalents($expression)
{
try {
// The expression may come directly from parse_str() which may add backslashes to quotes. The tokenizer
// wouldn't survive that.
$expression = stripslashes($expression);
$toolset_bootstrap = Toolset_Common_Bootstrap::getInstance();
$toolset_bootstrap->register_parser();
$tokenizer = new Toolset_Tokenizer();
$tokens = $tokenizer->Tokanize($expression);
$token_value_replacements = array('<' => 'lt', '>' => 'gt', '<=' => 'lte', '>=' => 'gte', '<>' => 'ne', '=' => 'eq');
$result = '';
foreach ($tokens as $token) {
if ($token->isCompOp) {
$token->val = wpcf_getarr($token_value_replacements, $token->val, $token->val);
}
if ($token->isCompOp || $token->isArithmeticOp || $token->isLogicOp) {
$result .= ' ' . $token->val . ' ';
} else {
if ($token->isStringLiteral) {
$result .= '\'' . $token->val . '\'';
} else {
$result .= $token->val;
}
}
}
return $result;
} catch (Exception $e) {
// Most probably we were unable to tokenize the expression. We give up.
return $expression;
}
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:45,代码来源:class.types.fields.conditional.php
示例19: get_meta_key
/**
* @return string Meta_key use to store this field's values. Defaults to wpcf-$slug.
*/
public function get_meta_key()
{
if (null == $this->meta_key) {
$this->meta_key = sanitize_title(wpcf_getarr($this->definition_array, 'meta_key', self::FIELD_META_KEY_PREFIX . $this->get_slug()));
}
return $this->meta_key;
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:10,代码来源:definition.php
示例20: query_definitions
/**
* Query field definitions.
*
* @param array $args Following arguments are recognized:
*
* - filter: What field definitions should be retrieved: 'types'|'generic'|'all'
* - orderby: 'name'|'slug'|'is_under_types_control'|'field_type'
* - order: 'asc'|'desc'
* - search: String for fulltext search.
* - field_type: string|array Field type slug(s). Allowed only for Types fields.
* - group_id: int Field group ID where this field belongs to. Allowed only for Types fields.
* - group_slug: string Slug of an existing firld group where this field belongs to. If defined, overrides
* the group_id argument. Allowed only for Types fields.
*
* @return WPCF_Field_Definition_Abstract[] Field definitions that match query arguments.
*
* @since 1.9
*/
public function query_definitions($args)
{
$args = wp_parse_args($args, array('filter' => 'all'));
// Get only certain type of field definitions (generic, Types or both)
$filter = wpcf_getarr($args, 'filter');
if ('types' == $filter) {
$results = $this->load_types_field_definitions();
} else {
if ('generic' == $filter) {
$results = $this->load_generic_field_definitions();
} else {
if ('all' == $filter) {
$results = $this->load_all_definitions();
} else {
$results = array();
}
}
}
// Save us some work if there will be no results at all
if (empty($results)) {
return array();
}
// Perform fulltext search if needed
$search_string = wpcf_getarr($args, 'search', '');
if (!empty($search_string)) {
$matches = array();
foreach ($results as $definition) {
if ($definition->is_match($search_string)) {
$matches[] = $definition;
}
}
$results = $matches;
}
// Select only fields of desired type
$field_type = wpcf_getarr($args, 'field_type', array());
$field_type = empty($field_type) ? array() : $field_type;
$field_type = is_array($field_type) ? $field_type : array($field_type);
if (!empty($field_type)) {
$type_matches = array();
foreach ($results as $definition) {
if ($definition instanceof WPCF_Field_Definition) {
$type = $definition->get_type();
if (in_array($type->get_slug(), $field_type)) {
$type_matches[] = $definition;
}
}
}
$results = $type_matches;
}
// Select fields by field group.
$group_source = wpcf_getarr($args, 'group_slug', (int) wpcf_getarr($args, 'group_id'));
if (!empty($group_source)) {
$group_factory = $this->get_group_factory();
$group = $group_factory->load_field_group($group_source);
$group_matches = array();
if (null != $group) {
foreach ($results as $field_definition) {
if ($field_definition instanceof WPCF_Field_Definition && $field_definition->belongs_to_group($group)) {
$group_matches[] = $field_definition;
}
}
}
$results = $group_matches;
}
// Sort results
$orderby = wpcf_getarr($args, 'orderby', 'name');
$order = wpcf_getarr($args, 'order', 'asc', array('asc', 'desc'));
$results = $this->order_definitions($results, $orderby, $order);
return $results;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:88,代码来源:definition_factory.php
注:本文中的wpcf_getarr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论