本文整理汇总了PHP中wptoolset_form_field函数的典型用法代码示例。如果您正苦于以下问题:PHP wptoolset_form_field函数的具体用法?PHP wptoolset_form_field怎么用?PHP wptoolset_form_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wptoolset_form_field函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: _wptoolset_forms_test_fields
function _wptoolset_forms_test_fields()
{
global $_html_test;
$fields = types_get_fields();
//debug($fields);
foreach ($fields as $field) {
$config = wptoolset_forms_types_filter_field($field, 'testme');
$_html_test .= wptoolset_form_field('post', $config);
}
}
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:10,代码来源:test.php
示例2: field_form
/**
* Returns element form as array.
*
* This is done per field.
*
* @param type $key Field key as stored
* @return array
*/
function field_form()
{
if (defined('WPTOOLSET_FORMS_VERSION')) {
$field = $this->cf->cf;
$meta = get_post_meta($this->child->ID, $field['meta_key']);
$field['suffix'] = "-{$this->child->ID}";
$config = wptoolset_form_filter_types_field($field, $this->child->ID);
// Do not allow repetitive
$config['repetitive'] = false;
$config['name'] = $this->cf->alter_form_name('wpcf_post_relationship[' . $this->parent->ID . ']', $config['name']);
if (!empty($config['options'])) {
foreach ($config['options'] as &$v) {
if (isset($v['name'])) {
$v['name'] = $this->alter_form_name($v['name']);
}
}
}
if ($config['type'] == 'wysiwyg') {
$config['type'] = 'textarea';
}
return wptoolset_form_field('post', $config, $meta);
}
/*
*
* Get meta form for field
*/
$form = $this->cf->_get_meta_form($this->cf->__meta, $this->cf->meta_object->meta_id, false);
/*
*
* Filter form
*/
$_filtered_form = $this->__filter_meta_form($form);
return wpcf_form_simple(apply_filters('wpcf_relationship_child_meta_form', $_filtered_form, $this->cf));
}
开发者ID:phuocdungit,项目名称:fundy,代码行数:42,代码来源:form-child.php
示例3: wpcf_admin_post_meta_box
/**
* Renders meta box content.
*
* Core function. Works and stable.
* If required, add hooks only.
*
* @todo Revise this 1.1.5
*
* @param type $post
* @param type $group
* @param type $echo
* @param type boolean $open_style_editor if true use code for open style editor when edit group
*/
function wpcf_admin_post_meta_box($post, $group, $echo = '', $open_style_editor = false)
{
if (false === $open_style_editor && defined('WPTOOLSET_FORMS_VERSION')) {
if (isset($group['args']['html'])) {
/**
* show group description
*/
if (array_key_exists('description', $group['args']) && !empty($group['args']['description'])) {
echo '<div class="wpcf-meta-box-description">';
echo wpautop(wpcf_translate('group ' . $group['args']['id'] . ' description', $group['args']['description']));
echo '</div>';
}
foreach ($group['args']['html'] as $field) {
echo is_array($field) ? wptoolset_form_field('post', $field['config'], $field['meta']) : $field;
}
}
return;
}
global $wpcf;
/**
* fake post object if need
*/
$post = wpcf_admin_create_fake_post_if_need($post);
static $nonce_added = false;
$group_output = '';
if (!isset($group['title'])) {
$temp = $group;
$group = '';
$group['args'] = $temp;
$group['id'] = $temp['slug'];
$group['title'] = $temp['name'];
$name = $temp['name'];
}
if (!empty($echo)) {
$group_output = '<h3>This Preview generated for latest post "' . $post->post_title . '"</h3>' . "\n" . '<!-- Previous lines visible only in Admin Style Editor.-->' . "\n\n";
$group_output .= '<div id="wpcf-group-' . $group['id'] . '" class="postbox " >
<h3 class=\'hndle\'><span>' . $name . '</span></h3>
<div class="inside">' . "\n";
}
/*
* TODO Document where this is used
*/
if (!$nonce_added && empty($echo)) {
$nonce_action = 'update-' . $post->post_type . '_' . $post->ID;
wp_nonce_field($nonce_action, '_wpcf_post_wpnonce');
$nonce_added = true;
}
$group_output .= "\n\n" . '<div id="wpcf-group-metabox-id-' . $group['args']['slug'] . '">' . "\n";
/*
* TODO Move to Conditional code
*
* This is already checked. Use hook to add wrapper DIVS and apply CSS.
*/
if (!empty($group['args']['_conditional_display'])) {
if ($group['args']['_conditional_display'] == 'failed') {
$group_output .= '<div class="wpcf-cd-group wpcf-cd-group-failed" style="display:none;">';
} else {
$group_output .= '<div class="wpcf-cd-group wpcf-cd-group-passed">';
}
}
/*
* TODO Move this into Field code
* Process fields
*/
if (!empty($group['args']['fields'])) {
// Display description
if (!empty($group['args']['description'])) {
$group_output .= '<div class="wpcf-meta-box-description">' . wpautop(wpcf_translate('group ' . $group['args']['id'] . ' description', $group['args']['description'])) . '</div>';
}
foreach ($group['args']['fields'] as $field_slug => $field) {
if (empty($field) || !is_array($field)) {
continue;
}
$field = $wpcf->field->_parse_cf_form_element($field);
if (isset($field['wpcf-type'])) {
// May be ignored
$field = apply_filters('wpcf_fields_' . $field['wpcf-type'] . '_meta_box_form_value_display', $field);
}
if (!isset($field['#id'])) {
$field['#id'] = wpcf_unique_id(serialize($field));
}
// Render form elements
if (wpcf_compare_wp_version() && array_key_exists('#type', $field) && 'wysiwyg' == $field['#type'] && !isset($field['#attributes']['disabled'])) {
// if ( isset( $field['#attributes']['disabled'] ) ) {
// $field['#editor_settings']['tinymce'] = false;
// $field['#editor_settings']['teeny'] = false;
// $field['#editor_settings']['media_buttons'] = false;
//.........这里部分代码省略.........
开发者ID:SpencerNeitzke,项目名称:types,代码行数:101,代码来源:fields-post.php
示例4: wpcf_admin_userprofile_init
/**
* Init functions for User profile edit pages.
*/
function wpcf_admin_userprofile_init($user_id)
{
global $wpcf;
if (!is_object($user_id)) {
$user_id = new stdClass();
$user_id->ID = 0;
}
$user_role = isset($user_id->roles) ? array_shift($user_id->roles) : 'subscriber';
$groups = wpcf_admin_usermeta_get_groups_fields();
$wpcf_active = false;
$profile_only_preview = '';
foreach ($groups as $group) {
if (!empty($group['fields'])) {
$wpcf_active = true;
$for_users = wpcf_admin_get_groups_showfor_by_group($group['id']);
$profile_only_preview = '';
if (count($for_users) != 0) {
if (!in_array($user_role, $for_users)) {
continue;
} else {
//If Access plugin activated
if (function_exists('wpcf_access_register_caps')) {
//If user can't view own profile fields
if (!current_user_can('view_own_in_profile_' . $group['slug'])) {
continue;
}
//If user can modify current group in own profile
if (!current_user_can('modify_own_' . $group['slug'])) {
$profile_only_preview = 1;
}
}
}
} else {
if (function_exists('wpcf_access_register_caps')) {
if (!current_user_can('view_own_in_profile_' . $group['slug'])) {
continue;
}
if (!current_user_can('modify_own_' . $group['slug'])) {
$profile_only_preview = 1;
}
}
}
// Process fields
if (empty($profile_only_preview)) {
if (defined('WPTOOLSET_FORMS_VERSION')) {
$errors = get_user_meta($user_id->ID, '__wpcf-invalid-fields', true);
// OLD
delete_post_meta($user_id->ID, 'wpcf-invalid-fields');
delete_post_meta($user_id->ID, '__wpcf-invalid-fields');
if (empty($group['fields'])) {
continue;
}
$output = '<div class="wpcf-group-area wpcf-group-area_' . $group['slug'] . '">' . "\n\n" . '<h3>' . wpcf_translate('group ' . $group['id'] . ' name', $group['name']) . '</h3>' . "\n\n";
if (!empty($group['description'])) {
$output .= '<span>' . wpautop(wpcf_translate('group ' . $group['id'] . ' description', $group['description'])) . '</span>' . "\n\n";
}
$output .= '<div class="wpcf-profile-field-line">' . "\n\n";
foreach ($group['fields'] as $field) {
$config = wptoolset_form_filter_types_field($field, $user_id->ID);
$config = array_map('fix_fields_config_output_for_display', $config);
$meta = get_user_meta($user_id->ID, $field['meta_key']);
if ($errors) {
$config['validate'] = true;
}
if (isset($config['validation']['required'])) {
$config['title'] .= '*';
}
$config['_title'] = $config['title'];
$output .= '
<div class="wpcf-profile-field-line">
<div class="wpcf-profile-line-left">
' . $config['title'] . '
</div>
<div class="wpcf-profile-line-right">
';
$description = false;
if (!empty($config['description'])) {
$description = sprintf('<span class="description">%s</span>', $config['description']);
}
$config['title'] = $config['description'] = '';
$form_name = $user_id->ID ? 'your-profile' : 'createuser';
$output .= wptoolset_form_field($form_name, $config, $meta);
if ($description) {
$output .= $description;
}
$output .= '
</div>
</div>';
}
$output .= '</div></div>';
echo $output;
} else {
$group['fields'] = wpcf_admin_usermeta_process_fields($user_id, $group['fields'], true);
wpcf_admin_render_fields($group, $user_id);
}
} else {
// Render profile fields (text only)
//.........这里部分代码省略.........
开发者ID:sonvq,项目名称:passioninvestment,代码行数:101,代码来源:usermeta-post.php
示例5: renderField
/**
* This function render the single field
* @global type $post
* @param type $field
* @param type $add2form_content
* @return type
*/
public function renderField($field, $add2form_content = false)
{
global $post;
//echo "<br>{$field['name']}";
if (defined('WPTOOLSET_FORMS_ABSPATH') && function_exists('wptoolset_form_field')) {
require_once WPTOOLSET_FORMS_ABSPATH . '/api.php';
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.fieldconfig.php';
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.types.php';
require_once WPTOOLSET_FORMS_ABSPATH . '/classes/class.cred.php';
$id = $this->form_id;
$field['id'] = $id;
if ($field['type'] == 'messages') {
$this->isForm = true;
return;
}
if ($this->form_type == 'edit' && $field['name'] == 'user_login') {
$field['attr']['readonly'] = "readonly";
$field['attr']['style'] = "background-color:#ddd;";
$field['attr']['onclick'] = "blur();";
}
if ($field['type'] == 'credfile' || $field['type'] == 'credaudio' || $field['type'] == 'credvideo' || $field['type'] == 'credimage' || $field['type'] == 'file') {
$this->isUploadForm = true;
//$field['type'] = 'credfile';
}
/* $validation = array(
'validation' => array(
'required' => array(
'args' => array($field['value'], true),
'message' => 'Required'),
'maxlength' => array(
'args' => array($field['value'], 12),
'message' => 'maxlength of 12 exceeded'
),
'rangelength' => array(
'args' => array($field['value'], 3, 25),
'message' => 'input range from 3 to 25'
),
)); */
//#############################################################################################################################################################
//Client-side validation is not using the custom messages provided in CRED forms for CRED custom fields
//https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/187800735/comments
$this->fixCredCustomFieldMessages($field);
//#############################################################################################################################################################
$mytype = $this->transType($field['type']);
$fieldConfig = new FieldConfig();
$fieldConfig->setDefaultValue($field['type'], $field);
$fieldConfig->setOptions($field['name'], $field['type'], $field['value'], $field['attr']);
$fieldConfig->setId($this->form_properties['name'] . "_" . $field['name']);
$fieldConfig->setName($field['name']);
$this->cleanAttr($field['attr']);
$fieldConfig->setAttr($field['attr']);
$_curr_value = "";
//#############################################################################################################################################################
//Fix https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/192427784/comments#300129108
//losting filled data if using hook validate system
if (isset($this->controls[$field['name']]) && !empty($this->controls[$field['name']])) {
$_curr_value = $this->controls[$field['name']];
} else {
if (isset($field['value']) && !empty($field['value'])) {
$_curr_value = $field['value'];
}
}
//#############################################################################################################################################################
if (!$this->is_submit_success && ($mytype != 'credfile' && $mytype != 'credaudio' && $mytype != 'credvideo' && $mytype != 'credimage')) {
$_curr_value = isset($this->controls[$field['name']]) ? $this->controls[$field['name']] : $field['value'];
} else {
if (isset($field['attr']['preset_value']) && !empty($field['attr']['preset_value'])) {
$_curr_value = $field['attr']['preset_value'];
}
}
$fieldConfig->setValue($_curr_value);
$fieldConfig->setDescription(!empty($field['description']) ? $field['description'] : "");
$fieldConfig->setTitle($field['title']);
$fieldConfig->setType($mytype);
if (isset($field['data']) && isset($field['data']['repetitive'])) {
$fieldConfig->setRepetitive((bool) $field['data']['repetitive']);
}
if (isset($field['attr']) && isset($field['attr']['type'])) {
$fieldConfig->setDisplay($field['attr']['type']);
}
$config = $fieldConfig->createConfig();
// Modified by Srdjan
// Validation and conditional filtering
if (isset($field['plugin_type']) && $field['plugin_type'] == 'types') {
// This is not set in DB
$field['meta_key'] = WPToolset_Types::getMetakey($field);
$config['validation'] = WPToolset_Types::filterValidation($field);
if ($post) {
$config['conditional'] = WPToolset_Types::filterConditional($field, $post->ID);
}
} else {
$config['validation'] = WPToolset_Cred::filterValidation($field);
}
//.........这里部分代码省略.........
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:101,代码来源:CredForm.php
注:本文中的wptoolset_form_field函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论