本文整理汇总了PHP中types_is_repetitive函数的典型用法代码示例。如果您正苦于以下问题:PHP types_is_repetitive函数的具体用法?PHP types_is_repetitive怎么用?PHP types_is_repetitive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了types_is_repetitive函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpcf_admin_post_process_field
//.........这里部分代码省略.........
}
if (!empty($field['disable'])) {
$element['#attributes']['disabled'] = 'disabled';
}
if (!empty($field['readonly'])) {
$element['#attributes']['readonly'] = 'readonly';
if (!empty($element['#options'])) {
foreach ($element['#options'] as $key => $option) {
if (!is_array($option)) {
$element['#options'][$key] = array('#title' => $key, '#value' => $option);
}
$element['#options'][$key]['#attributes']['readonly'] = 'readonly';
if ($element['#type'] == 'select') {
$element['#options'][$key]['#attributes']['disabled'] = 'disabled';
}
}
}
if ($element['#type'] == 'select') {
$element['#attributes']['disabled'] = 'disabled';
}
}
// Check if it was invalid on submit and add error message
if ($post && !empty($invalid_fields)) {
if (isset($invalid_fields[$element['#id']]['#error'])) {
$element['#error'] = $invalid_fields[$element['#id']]['#error'];
}
}
// TODO WPML move Set WPML locked icon
if (wpcf_wpml_field_is_copied($field)) {
$element['#title'] .= '<img src="' . WPCF_EMBEDDED_RES_RELPATH . '/images/locked.png" alt="' . __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf') . '" title="' . __('This field is locked for editing because WPML will copy its value from the original language.', 'wpcf') . '" style="position:relative;left:2px;top:2px;" />';
}
// Add repetitive class
// TODO WPML move
if (types_is_repetitive($field) && $context != 'post_relationship' && wpcf_wpml_field_is_copied($field)) {
if (!empty($element['#options']) && $element['#type'] != 'select') {
foreach ($element['#options'] as $temp_key => $temp_value) {
$element['#options'][$temp_key]['#attributes']['class'] = isset($element['#attributes']['class']) ? $element['#attributes']['class'] . ' wpcf-repetitive' : 'wpcf-repetitive';
}
} else {
$element['#attributes']['class'] = isset($element['#attributes']['class']) ? $element['#attributes']['class'] . ' wpcf-repetitive' : 'wpcf-repetitive';
}
/*
*
*
* Since Types 1.2 we allow same field values
*
* TODO Remove
*
* wpcf_admin_add_js_settings('wpcfFormRepetitiveUniqueValuesCheckText',
'\'' . __('Warning: same values set', 'wpcf') . '\'');
*/
}
// Set read-only if copied by WPML
// TODO WPML Move this to separate WPML code and use only hooks 1.1.5
if (wpcf_wpml_field_is_copied($field)) {
if (isset($element['#options'])) {
foreach ($element['#options'] as $temp_key => $temp_value) {
if (isset($temp_value['#attributes'])) {
$element['#options'][$temp_key]['#attributes']['readonly'] = 'readonly';
} else {
$element['#options'][$temp_key]['#attributes'] = array('readonly' => 'readonly');
}
}
}
if ($field['type'] == 'select') {
if (isset($element['#attributes'])) {
开发者ID:SpencerNeitzke,项目名称:types,代码行数:67,代码来源:fields-post.php
示例2: wpcf_fields_image_editor_callback
/**
* Editor callback form.
*
* @global object $wpdb
*
*/
function wpcf_fields_image_editor_callback($field, $data, $context, $post)
{
// Get post_ID
$post_ID = !empty($post->ID) ? $post->ID : false;
// Get attachment
$image = false;
$attachment_id = false;
if ($post_ID) {
$image = get_post_meta($post_ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
if (empty($image)) {
$user_id = wpcf_usermeta_get_user();
$image = get_user_meta($user_id, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
}
if (!empty($image)) {
// Get attachment by guid
global $wpdb;
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s", $image));
}
}
$data['image'] = $image;
$data['attachment_id'] = $attachment_id;
// Set post type
$post_type = !empty($post->post_type) ? $post->post_type : '';
// Set image_data
$image_data = wpcf_fields_image_get_data($image);
if (!in_array($post_type, array('view', 'view-template'))) {
// We must ignore errors here and treat image as outsider
if (!empty($image_data['error'])) {
$image_data['is_outsider'] = 1;
$image_data['is_attachment'] = 0;
}
} else {
if (!empty($image_data['error'])) {
$image_data['is_outsider'] = 0;
$image_data['is_attachment'] = 0;
}
}
$data['preview'] = $attachment_id ? wp_get_attachment_image($attachment_id, 'thumbnail') : '';
// Title and Alt
if ($attachment_id) {
$alt = trim(strip_tags(get_post_meta($attachment_id, '_wp_attachment_image_alt', true)));
$attachment_post = get_post($attachment_id);
if (!empty($attachment_post)) {
$title = trim(strip_tags($attachment_post->post_title));
} else {
if (!empty($alt)) {
$title = $alt;
}
}
if (empty($alt)) {
$alt = $title;
}
if (!isset($data['title'])) {
$data['title'] = $title;
}
if (!isset($data['alt'])) {
$data['alt'] = $alt;
}
}
// Align options
$data['alignment_options'] = array('none' => __('None', 'wpcf'), 'left' => __('Left', 'wpcf'), 'center' => __('Center', 'wpcf'), 'right' => __('Right', 'wpcf'));
// Remote images settings
$fetch_remote = (bool) wpcf_get_settings('images_remote');
$data['warning_remote'] = false;
if (!types_is_repetitive($field) && $image_data['is_outsider'] && !$fetch_remote && !empty($data['image'])) {
$data['warning_remote'] = true;
}
// Size settings
$data['size_options'] = array('thumbnail' => sprintf(__('Thumbnail - %s', 'wpcf'), get_option('thumbnail_size_w') . 'x' . get_option('thumbnail_size_h')), 'medium' => sprintf(__('Medium - %s', 'wpcf'), get_option('medium_size_w') . 'x' . get_option('medium_size_h')), 'large' => sprintf(__('Large - %s', 'wpcf'), get_option('large_size_w') . 'x' . get_option('large_size_h')), 'full' => __('Original image', 'wpcf'));
$wp_image_sizes = (array) get_intermediate_image_sizes();
foreach ($wp_image_sizes as $wp_size) {
if ($wp_size != 'post-thumbnail' && !array_key_exists($wp_size, $data['size_options'])) {
$data['size_options'][$wp_size] = $wp_size;
}
}
$data['size_options']['wpcf-custom'] = __('Custom size...', 'wpcf');
// Get saved settings
$data = array_merge(wpcf_admin_fields_get_field_last_settings($field['id']), $data);
return array('supports' => array('styling', 'style'), 'tabs' => array('display' => array('menu_title' => __('Display options', 'wpcf'), 'title' => __('Display options for this field:', 'wpcf'), 'content' => WPCF_Loader::template('editor-modal-image', $data))), 'settings' => $data);
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:86,代码来源:image.php
示例3: types_render_field
/**
* Calls view function for specific field type.
*
* @param type $field
* @param type $atts
* @return type
*/
function types_render_field($field_id = null, $params = array(), $content = null, $code = '')
{
if (empty($field_id)) {
return '';
}
global $wpcf;
// HTML var holds actual output
$html = '';
// Set post ID to global
$post_id = get_the_ID();
// Check if other post required
if (isset($params['post_id'])) {
// If numeric value
if (is_numeric($params['post_id'])) {
$post_id = intval($params['post_id']);
// WP parent
} else {
if ($params['post_id'] == '$parent') {
$current_post = get_post($post_id);
if (empty($current_post->post_parent)) {
return '';
}
$post_id = $current_post->post_parent;
// Types parent
} else {
if (strpos($params['post_id'], '$') === 0) {
$post_id = intval(WPCF_Relationship::get_parent($post_id, trim($params['post_id'], '$')));
}
}
}
}
if (empty($post_id)) {
return '';
}
// Set post
$post = get_post($post_id);
if (empty($post)) {
return '';
}
// Get field
$field = types_get_field($field_id);
// If field not found return empty string
if (empty($field)) {
// Log
if (!function_exists('wplogger')) {
require_once WPCF_EMBEDDED_TOOLSET_ABSPATH . '/toolset-common/wplogger.php';
}
global $wplogger;
$wplogger->log('types_render_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
return '';
}
// Set field
$wpcf->field->set($post, $field);
// See if repetitive
if (types_is_repetitive($field)) {
$wpcf->repeater->set($post_id, $field);
$_meta = $wpcf->repeater->_get_meta();
$meta = $_meta['custom_order'];
// Sometimes if meta is empty - array(0 => '') is returned
if (count($meta) == 1 && reset($meta) == '') {
return '';
}
if (!empty($meta)) {
$output = '';
if (isset($params['index'])) {
$index = $params['index'];
} else {
$index = '';
}
// Allow wpv-for-each shortcode to set the index
$index = apply_filters('wpv-for-each-index', $index);
if ($index === '') {
$output = array();
foreach ($meta as $temp_key => $temp_value) {
$params['field_value'] = $temp_value;
$temp_output = types_render_field_single($field, $params, $content, $code, $temp_key);
if (!empty($temp_output)) {
$output[] = $temp_output;
}
}
if (!empty($output) && isset($params['separator']) && $params['separator'] !== '') {
$output = implode(html_entity_decode($params['separator']), $output);
} else {
if (!empty($output)) {
$output = implode(' ', $output);
} else {
return '';
}
}
} else {
// Make sure indexed right
$_index = 0;
foreach ($meta as $temp_key => $temp_value) {
//.........这里部分代码省略.........
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:frontend.php
示例4: wpcf_admin_userprofilesave_init
function wpcf_admin_userprofilesave_init($user_id)
{
if (defined('WPTOOLSET_FORMS_VERSION')) {
global $wpcf;
$errors = false;
/**
* check checkbox type fields to delete or save empty if needed
*/
$groups = wpcf_admin_usermeta_get_groups_fields();
foreach ($groups as $group) {
if (!array_key_exists('fields', $group) || empty($group['fields'])) {
continue;
}
foreach ($group['fields'] as $field) {
switch ($field['type']) {
case 'checkboxes':
if (!array_key_exists('wpcf', $_POST) || !array_key_exists($field['slug'], $_POST['wpcf'])) {
delete_user_meta($user_id, $field['meta_key']);
}
break;
case 'checkbox':
if (!array_key_exists('wpcf', $_POST) || !array_key_exists($field['slug'], $_POST['wpcf'])) {
if ('yes' == $field['data']['save_empty']) {
$_POST['wpcf'][$field['slug']] = 0;
} else {
delete_user_meta($user_id, $field['meta_key']);
}
}
break;
}
}
}
// Save meta fields
if (!empty($_POST['wpcf'])) {
foreach ($_POST['wpcf'] as $field_slug => $field_value) {
// Get field by slug
$field = wpcf_fields_get_field_by_slug($field_slug, 'wpcf-usermeta');
if (empty($field)) {
continue;
}
// Skip copied fields
if (isset($_POST['wpcf_repetitive_copy'][$field['slug']])) {
continue;
}
$_field_value = !types_is_repetitive($field) ? array($field_value) : $field_value;
// Set config
$config = wptoolset_form_filter_types_field($field, $user_id);
foreach ($_field_value as $_k => $_val) {
// Check if valid
$valid = wptoolset_form_validate_field('your-profile', $config, $_val);
if (is_wp_error($valid)) {
$errors = true;
$_errors = $valid->get_error_data();
$_msg = sprintf(__('Field "%s" not updated:', 'wpcf'), $field['name']);
wpcf_admin_message_store($_msg . ' ' . implode(', ', $_errors), 'error');
if (types_is_repetitive($field)) {
unset($field_value[$_k]);
} else {
break;
}
}
}
// Save field
if (types_is_repetitive($field)) {
$wpcf->usermeta_repeater->set($user_id, $field);
$wpcf->usermeta_repeater->save($field_value);
} else {
$wpcf->usermeta_field->set($user_id, $field);
$wpcf->usermeta_field->usermeta_save($field_value);
}
do_action('wpcf_user_field_saved', $user_id, $field);
// TODO Move to checkboxes
if ($field['type'] == 'checkboxes') {
$field_data = wpcf_admin_fields_get_field($field['id'], false, false, false, 'wpcf-usermeta');
if (!empty($field_data['data']['options'])) {
$update_data = array();
foreach ($field_data['data']['options'] as $option_id => $option_data) {
if (!isset($_POST['wpcf'][$field['id']][$option_id])) {
if (isset($field_data['data']['save_empty']) && $field_data['data']['save_empty'] == 'yes') {
$update_data[$option_id] = 0;
}
} else {
$update_data[$option_id] = $_POST['wpcf'][$field['id']][$option_id];
}
}
update_user_meta($user_id, $field['meta_key'], $update_data);
}
}
}
}
if ($errors) {
update_post_meta($user_id, '__wpcf-invalid-fields', true);
}
do_action('wpcf_user_saved', $user_id);
return;
}
global $wpcf;
$all_fields = array();
$_not_valid = array();
$_error = false;
//.........这里部分代码省略.........
开发者ID:sonvq,项目名称:passioninvestment,代码行数:101,代码来源:usermeta-post.php
示例5: types_child_posts
/**
* Gets posts that belongs to current post.
*
* @global type $post
* @param type $post_type
* @param type $args
* @return type
*/
function types_child_posts($post_type, $args = array())
{
static $cache = array();
if (isset($args['post_id'])) {
$post = $args['post_id'] != '0' ? get_post($args['post_id']) : null;
} else {
global $post;
}
if (empty($post->ID)) {
return array();
}
$cache_key = md5($post->ID . serialize(func_get_args()));
if (isset($cache[$cache_key])) {
return $cache[$cache_key];
}
global $wp_post_types;
// WP allows querying inactive post types
if (!isset($wp_post_types[$post_type]) || !$wp_post_types[$post_type]->publicly_queryable) {
return array();
}
$defaults = array('post_status' => array('publish'));
$args = wp_parse_args($args, $defaults);
WPCF_Loader::loadModel('relationship');
WPCF_Loader::loadInclude('fields-post');
$child_posts = WPCF_Relationship_Model::getChildrenByPostType($post, $post_type, array(), array(), $args);
foreach ($child_posts as $child_post_key => $child_post) {
$child_posts[$child_post_key]->fields = array();
$groups = wpcf_admin_post_get_post_groups_fields($child_post);
foreach ($groups as $group) {
if (!empty($group['fields'])) {
// Process fields
foreach ($group['fields'] as $k => $field) {
$data = null;
if (types_is_repetitive($field)) {
$data = wpcf_get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], false);
// get all field instances
} else {
$data = wpcf_get_post_meta($child_post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
// get single field instance
// handle checkboxes which are one value serialized
if ($field['type'] == 'checkboxes' && !empty($data)) {
$data = maybe_unserialize($data);
}
}
if (!is_null($data)) {
$child_posts[$child_post_key]->fields[$k] = $data;
}
}
}
}
}
$cache[$cache_key] = $child_posts;
return $child_posts;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:62,代码来源:api.php
示例6: types_render_usermeta
/**
* Calls view function for specific usermeta field type.
*
* @param $field_id
* @param array $params (additional attributes: user_id, user_name, user_is_author, user_current)
* @param null $content
* @param string $code
*
* @return string|void
* @since unknown
*/
function types_render_usermeta($field_id, $params, $content = null, $code = '')
{
global $wpcf, $post, $wpdb, $WP_Views;
$current_user = wp_get_current_user();
$current_user_id = $current_user->ID;
// Set post ID
// user_id, user_name, user_is_author, user_current
if (is_object($post)) {
$post_id = $post->ID;
} else {
$post_id = 0;
}
if (isset($params['post_id']) && !empty($params['post_id'])) {
$post_id = $params['post_id'];
}
// Get User id from views loop
if (isset($WP_Views->users_data['term']->ID) && !empty($WP_Views->users_data['term']->ID)) {
$params['user_id'] = $WP_Views->users_data['term']->ID;
}
//Get user By ID
if (isset($params['user_id'])) {
$user_id = $params['user_id'];
} else {
if (isset($params['user_name'])) {
//Get user by login
$user_id = $wpdb->get_var($wpdb->prepare("SELECT * FROM " . $wpdb->users . " WHERE user_login = %s", $params['user_name']));
} else {
if (isset($params['user_is_author'])) {
//Get Post author
$user_id = $post->post_author;
} else {
if (isset($params['user_current'])) {
//Get current logged user
$user_id = $current_user_id;
} else {
//If empty get post author, if no post, return empty
if (!empty($post_id)) {
$user_id = $post->post_author;
} else {
return '';
}
}
}
}
}
if (empty($user_id)) {
return '';
}
// Get field
$field = types_get_field($field_id, 'usermeta');
// If field not found return empty string
if (empty($field)) {
// Log
if (!function_exists('wplogger')) {
require_once WPCF_EMBEDDED_TOOLSET_ABSPATH . '/toolset-common/wplogger.php';
}
global $wplogger;
$wplogger->log('types_render_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
return '';
}
if (types_is_repetitive($field)) {
$wpcf->usermeta_repeater->set($user_id, $field);
$_meta = $wpcf->usermeta_repeater->_get_meta();
$meta = toolset_getarr($_meta, 'custom_order', '');
// Sometimes if meta is empty - array(0 => '') is returned
if (count($meta) == 1 && reset($meta) == '') {
return '';
}
if (!empty($meta)) {
$output = '';
if (isset($params['index'])) {
$index = $params['index'];
} else {
$index = '';
}
// Allow wpv-for-each shortcode to set the index
$index = apply_filters('wpv-for-each-index', $index);
if ($index === '') {
$output = array();
foreach ($meta as $temp_key => $temp_value) {
$params['field_value'] = $temp_value;
$temp_output = types_render_field_single($field, $params, $content, $code, $temp_key);
if (!Toolset_Utils::is_field_value_truly_empty($temp_output)) {
$output[] = $temp_output;
}
}
if (!empty($output) && isset($params['separator'])) {
$output = implode(html_entity_decode($params['separator']), $output);
} else {
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:frontend.php
示例7: frame
/**
* Renders Thickbox content.
*
* Field should provide callback function
* that will be called automatically.
*
* Function should be named like:
* 'wpcf_fields_' . $field_type . '_editor_callback'
* e.g. 'wpcf_fields_checkbox__editor_callback'
*
* Function should return array with elements:
* 'supports' - parameters or other feature supported, e.g. 'styling' will
* enable 'Styling' options
*
* Tabs is array with elements:
* 'menu_title' - used for menu title
* 'title' - used for main title
* 'content' - HTML content of tab
*
* @param type $field
* @param type $meta_type
* @param type $post_id
* @param string $shortcode
*/
function frame($field, $meta_type = 'postmeta', $post_id = -1, $shortcode = null, $callback = false, $views_usermeta = false)
{
global $wp_version, $wpcf;
// Queue rendering JS settings
add_action('admin_print_footer_scripts', array($this, 'renderTedSettings'), 1);
wp_enqueue_script('types');
wp_enqueue_script('types-knockout');
wp_enqueue_script('types-editor');
wp_enqueue_script('wp-pointer');
wp_enqueue_style('types-editor');
wp_enqueue_style('wp-pointer');
wp_enqueue_style('toolset-font-awesome');
// Load cloned WP Media Modal CSS
if (version_compare($wp_version, '3.5', '<')) {
wp_enqueue_style('types-editor-cloned');
}
$this->field = $field;
$this->_meta_type = $meta_type;
$this->_post = get_post($post_id);
$this->_settings = is_null($shortcode) ? array() : $this->shortcodeToParameters($shortcode);
$this->callback = $callback;
$this->_data = array('meta_type' => $meta_type, 'field' => $field, 'field_type_data' => WPCF_Fields::getFieldTypeData($field['type']), 'settings' => array(), 'tabs' => array(), 'supports' => array(), 'post' => $this->_post, 'post_types' => get_post_types(array('show_ui' => true)), 'style' => isset($this->_settings['style']) ? $this->_settings['style'] : '', 'class' => isset($this->_settings['class']) ? $this->_settings['class'] : '', 'output' => 'html', 'user_form' => '');
// Set title if updated
if (!is_null($shortcode)) {
$this->_data['title'] = sprintf(__('Update %s', 'wpcf'), $this->_data['field_type_data']['title']);
$this->_data['submit_button_title'] = __('Update shortcode', 'wpcf');
}
// Exclude post types
foreach ($wpcf->excluded_post_types as $_post_type) {
unset($this->_data['post_types'][$_post_type]);
}
/*
* Callback
*/
$function = 'wpcf_fields_' . $field['type'] . '_editor_callback';
if (function_exists($function)) {
// Main callback
$callback = call_user_func($function, $field, $this->_settings, $this->_meta_type, $this->_post);
// Add supports
if (!empty($callback['supports']) && is_array($callback['supports'])) {
$this->_data['supports'] = $callback['supports'];
}
// Add tabs
if (!empty($callback['tabs']) && is_array($callback['tabs'])) {
$this->_data['tabs'] = $callback['tabs'];
}
// Unify settings
if (!empty($callback['settings']) && is_array($callback['settings'])) {
$this->_settings = array_merge($this->_settings, self::sanitizeParams($callback['settings'], 'array'));
}
}
// If no tabs
if (empty($this->_data['tabs'])) {
$this->_data['tabs']['display'] = array('menu_title' => __('Display', 'wpcf'), 'title' => __('Display', 'wpcf'), 'content' => sprintf(__('There are no additional display options for the %s field.', 'wpcf'), $this->_data['field_type_data']['title']));
}
// Add User ID form
if ($this->_meta_type == 'usermeta') {
if (!$views_usermeta) {
$this->_data['user_form'] = wpcf_form_simple(wpcf_get_usermeta_form_addon($this->_settings));
$this->_data['supports'][] = 'user_id';
}
} else {
// Add Post ID form
$this->_data['supports'][] = 'post_id';
}
// Get parents
if (!empty($this->_post->ID)) {
$this->_data['parents'] = WPCF_Relationship::get_parents($this->_post);
}
// Set icons
$icons = array('audio' => 'icon-music', 'checkbox' => 'icon-check', 'checkboxes' => 'icon-checkboxes', 'colorpicker' => 'icon-tint', 'date' => 'icon-calendar', 'email' => 'icon-envelope-alt', 'embed' => 'icon-youtube-play', 'file' => 'icon-file-alt', 'image' => 'icon-picture', 'map' => 'icon-map-marker', 'numeric' => 'icon-numeric', 'phone' => 'icon-phone', 'radio' => 'icon-radio-button', 'select' => 'icon-select-box', 'skype' => 'icon-skype', 'textarea' => 'icon-text-area', 'textfield' => 'icon-text-field', 'url' => 'icon-link', 'video' => 'icon-film', 'wysiwyg' => 'icon-wysiwyg');
$this->_data['icon_class'] = isset($icons[$field['type']]) ? $icons[$field['type']] : 'icon-text-field';
// Is repetitive
$this->_data['is_repetitive'] = (bool) types_is_repetitive($field);
if ($this->_data['is_repetitive']) {
$this->_data['supports'][] = 'separator';
//.........这里部分代码省略.........
开发者ID:santikrass,项目名称:apache,代码行数:101,代码来源:editor.php
注:本文中的types_is_repetitive函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论