本文整理汇总了PHP中wpcf_frontend_wrap_field函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_frontend_wrap_field函数的具体用法?PHP wpcf_frontend_wrap_field怎么用?PHP wpcf_frontend_wrap_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_frontend_wrap_field函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: wpcf_fields_numeric_view
/**
* View function.
*
* @param type $params
*/
function wpcf_fields_numeric_view($params)
{
$output = '';
if (!empty($params['format'])) {
$patterns = array('/FIELD_NAME/', '/FIELD_VALUE/');
$replacements = array($params['field']['name'], $params['field_value']);
$output = preg_replace($patterns, $replacements, $params['format']);
$output = sprintf($output, $params['field_value']);
}
$output = wpcf_frontend_wrap_field_value($params['field'], $output, $params);
$output = wpcf_frontend_wrap_field($params['field'], $output, $params);
return $output;
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:18,代码来源:numeric.php
示例2: wpcf_fields_email_view
/**
* View function.
*
* @param type $params
*/
function wpcf_fields_email_view($params)
{
if ($params['style'] == 'raw') {
return '';
}
$title = '';
$add = '';
if (!empty($params['title'])) {
$add .= ' title="' . $params['title'] . '"';
$title .= $params['title'];
} else {
$add .= ' title="' . $params['field_value'] . '"';
$title .= $params['field_value'];
}
$output = '<a href="mailto:' . $params['field_value'] . '"' . $add . '>' . $title . '</a>';
$output = wpcf_frontend_wrap_field_value($params['field'], $output, $params);
return wpcf_frontend_wrap_field($params['field'], $output, $params);
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:23,代码来源:email.php
示例3: wpcf_fields_select_view
/**
* View function.
*
* @param type $params
*/
function wpcf_fields_select_view($params)
{
if ($params['style'] == 'raw') {
return '';
}
$field = wpcf_fields_get_field_by_slug($params['field']['slug']);
$output = '';
if (!empty($field['data']['options'])) {
$field_value = $params['field_value'];
foreach ($field['data']['options'] as $option_key => $option) {
if (isset($option['value']) && $option['value'] == $params['field_value']) {
$field_value = wpcf_translate('field ' . $params['field']['id'] . ' option ' . $option_key . ' title', $option['title']);
}
}
$field_value = wpcf_frontend_wrap_field_value($params['field'], $field_value, $params);
$output = wpcf_frontend_wrap_field($params['field'], $field_value, $params);
}
return $output;
}
开发者ID:rdbartlett,项目名称:kellyspencer.co.nz,代码行数:24,代码来源:select.php
示例4: wpcf_frontend_compat_html_output
function wpcf_frontend_compat_html_output($output, $field, $content, $params)
{
// Count fields (if there are duplicates)
static $count = array();
// Count it
if (!isset($count[$field['slug']])) {
$count[$field['slug']] = 1;
} else {
$count[$field['slug']] += 1;
}
// If no output
if (empty($output) && !empty($params['field_value'])) {
$output = wpcf_frontend_wrap_field_value($field, $params['field_value'], $params);
$output = wpcf_frontend_wrap_field($field, $output, $params);
} else {
if ($output != '__wpcf_skip_empty') {
$output = wpcf_frontend_wrap_field_value($field, $output, $params);
$output = wpcf_frontend_wrap_field($field, $output, $params);
} else {
$output = '';
}
}
// Add count
if (isset($count[$field['slug']]) && intval($count[$field['slug']]) > 1) {
$add = '-' . intval($count[$field['slug']]);
$output = str_replace('id="wpcf-field-' . $field['slug'] . '"', 'id="wpcf-field-' . $field['slug'] . $add . '"', $output);
}
return $output;
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:29,代码来源:frontend.php
示例5: wpcf_fields_radio_view
/**
* View function.
*
* @param type $params
*/
function wpcf_fields_radio_view($params)
{
if ($params['style'] == 'raw') {
return '';
}
$field = wpcf_fields_get_field_by_slug($params['field']['slug']);
$output = '';
// See if user specified output for each field
if (isset($params['option'])) {
foreach ($field['data']['options'] as $option_key => $option) {
if (isset($option['value']) && $option['value'] == $params['field_value'] && $option_key == $params['option']) {
return htmlspecialchars_decode($params['#content']);
}
}
return ' ';
}
if (!empty($field['data']['options'])) {
$field_value = $params['field_value'];
foreach ($field['data']['options'] as $option_key => $option) {
if (isset($option['value']) && $option['value'] == $params['field_value']) {
$field_value = wpcf_translate('field ' . $params['field']['id'] . ' option ' . $option_key . ' title', $option['title']);
if (isset($params['field']['data']['display']) && $params['field']['data']['display'] != 'db' && !empty($option['display_value'])) {
$field_value = wpcf_translate('field ' . $params['field']['id'] . ' option ' . $option_key . ' display value', $option['display_value']);
}
}
}
$field_value = wpcf_frontend_wrap_field_value($params['field'], $field_value, $params);
$output = wpcf_frontend_wrap_field($params['field'], $field_value);
}
return $output;
}
开发者ID:rdbartlett,项目名称:kellyspencer.co.nz,代码行数:36,代码来源:radio.php
示例6: wpcf_fields_skype_view
/**
* View function.
*
* @param type $params
*/
function wpcf_fields_skype_view($params)
{
if (!isset($params['field_value']['skypename'])) {
return '--';
}
// Style can be overrided by params (shortcode)
if (!isset($params['field_value']['style'])) {
$params['field_value']['style'] = '';
}
$style = !empty($params['style']) && $params['style'] != 'default' ? $params['style'] : $params['field_value']['style'];
$content = wpcf_fields_skype_get_button($params['field_value']['skypename'], $style);
return wpcf_frontend_wrap_field($params['field'], $content);
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:18,代码来源:skype.php
示例7: wpcf_fields_date_view
/**
* View function.
*
* @param type $params
*/
function wpcf_fields_date_view($params)
{
global $wp_locale;
$defaults = array('format' => get_option('date_format'));
$params = wp_parse_args($params, $defaults);
$output = '';
switch ($params['style']) {
case 'calendar':
$output .= wpcf_fields_date_get_calendar($params, true, false);
break;
default:
$field_name = '';
// Extract the Full month and Short month from the format.
// We'll replace with the translated months if possible.
$format = $params['format'];
$format = str_replace('F', '#111111#', $format);
$format = str_replace('M', '#222222#', $format);
// Same for the Days
$format = str_replace('D', '#333333#', $format);
$format = str_replace('l', '#444444#', $format);
$date_out = date($format, intval($params['field_value']));
$month = date('m', intval($params['field_value']));
$month_full = $wp_locale->get_month($month);
$date_out = str_replace('#111111#', $month_full, $date_out);
$month_short = $wp_locale->get_month_abbrev($month_full);
$date_out = str_replace('#222222#', $month_short, $date_out);
$day = date('w', intval($params['field_value']));
$day_full = $wp_locale->get_weekday($day);
$date_out = str_replace('#333333#', $day_full, $date_out);
$day_short = $wp_locale->get_weekday_abbrev($day_full);
$date_out = str_replace('#444444#', $day_short, $date_out);
$field_value = wpcf_frontend_wrap_field_value($params['field'], $date_out, $params);
$output = wpcf_frontend_wrap_field($params['field'], $field_value, $params);
break;
}
return $output;
}
开发者ID:rdbartlett,项目名称:kellyspencer.co.nz,代码行数:42,代码来源:date.php
示例8: wpcf_fields_file_view
/**
* View function.
*
* @param type $params
*/
function wpcf_fields_file_view($params)
{
$output = '';
if (isset($params['link']) && $params['link'] == 'true') {
$title = '';
$add = '';
if (!empty($params['title'])) {
$add .= ' title="' . $params['title'] . '"';
$title .= $params['title'];
} else {
$add .= ' title="' . $params['field_value'] . '"';
$title .= $params['field_value'];
}
if (!empty($params['class'])) {
$add .= ' class="' . $params['class'] . '"';
}
$output = '<a href="' . $params['field_value'] . '"' . $add . '>' . $title . '</a>';
} else {
$output = $params['field_value'];
}
$output = wpcf_frontend_wrap_field_value($params['field'], $output, $params);
$output = wpcf_frontend_wrap_field($params['field'], $output, $params);
return $output;
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:29,代码来源:file.php
示例9: types_render_field_single
/**
* Calls view function for specific field type by single field.
*
* @param type $field
* @param type $atts
* @return type
*/
function types_render_field_single($field, $params, $content = null, $code = '')
{
global $post;
// Count fields (if there are duplicates)
static $count = array();
// Count it
if (!isset($count[$field['slug']])) {
$count[$field['slug']] = 1;
} else {
$count[$field['slug']] += 1;
}
// Load type
$type = wpcf_fields_type_action($field['type']);
// If 'class' or 'style' parameters are set - force HTML output
if ((!empty($params['class']) || !empty($params['style'])) && $field['type'] != 'date') {
$params['output'] = 'html';
}
// Apply filters to field value
$params['field_value'] = apply_filters('wpcf_fields_value_display', $params['field_value'], $params);
$params['field_value'] = apply_filters('wpcf_fields_slug_' . $field['slug'] . '_value_display', $params['field_value'], $params);
$params['field_value'] = apply_filters('wpcf_fields_type_' . $field['type'] . '_value_display', $params['field_value'], $params);
// To make sure
if (is_string($params['field_value'])) {
$params['field_value'] = addslashes(stripslashes($params['field_value']));
}
// Set values
$field['name'] = wpcf_translate('field ' . $field['id'] . ' name', $field['name']);
$params['field'] = $field;
$params['#content'] = htmlspecialchars($content);
$params['#code'] = $code;
$output = '';
if (isset($params['raw']) && $params['raw'] == 'true') {
// Skype is array
if ($field['type'] == 'skype' && isset($params['field_value']['skypename'])) {
$output = $params['field_value']['skypename'];
} else {
$output = $params['field_value'];
}
} else {
$output = wpcf_fields_type_action($field['type'], 'view', $params);
// Convert to string
if (!empty($output)) {
$output = strval($output);
}
// If no output
if (empty($output) && !empty($params['field_value'])) {
$output = wpcf_frontend_wrap_field_value($field, $params['field_value'], $params);
$output = wpcf_frontend_wrap_field($field, $output, $params);
} else {
if ($output != '__wpcf_skip_empty') {
$output = wpcf_frontend_wrap_field_value($field, $output, $params);
$output = wpcf_frontend_wrap_field($field, $output, $params);
} else {
$output = '';
}
}
// Add count
if (isset($count[$field['slug']]) && intval($count[$field['slug']]) > 1) {
$add = '-' . intval($count[$field['slug']]);
$output = str_replace('id="wpcf-field-' . $field['slug'] . '"', 'id="wpcf-field-' . $field['slug'] . $add . '"', $output);
}
}
// Apply filters
$output = strval(apply_filters('types_view', $output, $params['field_value'], $field['type'], $field['slug'], $field['name'], $params));
return htmlspecialchars_decode(stripslashes($output));
}
开发者ID:sriram911,项目名称:pls,代码行数:73,代码来源:frontend.php
示例10: types_render_field
/**
* Calls view function for specific field type.
*
* @param type $field
* @param type $atts
* @return type
*/
function types_render_field($field, $params, $content = null, $code = '')
{
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
// Count fields (if there are duplicates)
static $count = array();
// Get field
$field = wpcf_fields_get_field_by_slug($field);
if (empty($field)) {
return '';
}
// Count it
if (!isset($count[$field['slug']])) {
$count[$field['slug']] = 1;
} else {
$count[$field['slug']] += 1;
}
// Get post field value
global $post;
$value = get_post_meta($post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
if ($value == '' && $field['type'] != 'checkbox') {
return '';
}
// Load type
$type = wpcf_fields_type_action($field['type']);
// Apply filters to field value
$value = apply_filters('wpcf_fields_value_display', $value);
$value = apply_filters('wpcf_fields_slug_' . $field['slug'] . '_value_display', $value);
$value = apply_filters('wpcf_fields_type_' . $field['type'] . '_value_display', $value);
// To make sure
if (is_string($value)) {
$value = addslashes(stripslashes($value));
}
// Set values
$field['name'] = wpcf_translate('field ' . $field['id'] . ' name', $field['name']);
$params['field'] = $field;
$params['post'] = $post;
$params['field_value'] = $value;
// Get output
$params['#content'] = htmlspecialchars($content);
$params['#code'] = $code;
$output = wpcf_fields_type_action($field['type'], 'view', $params);
// Convert to string
if (!empty($output)) {
$output = strval($output);
}
// @todo Reconsider if ever changing this (works fine now)
// If no output or 'raw' return default
if (($params['raw'] == 'true' || empty($output)) && !empty($value)) {
$field_name = '';
if ($params['show_name'] == 'true') {
$field_name = wpcf_frontend_wrap_field_name($field, $field['name'], $params);
}
$field_value = wpcf_frontend_wrap_field_value($field, $value, $params);
$output = wpcf_frontend_wrap_field($field, $field_name . $field_value);
}
// Apply filters
$output = strval(apply_filters('types_view', $output, $value, $field['type'], $field['slug'], $field['name'], $params));
// Add count
if (isset($count[$field['slug']]) && intval($count[$field['slug']]) > 1) {
$add = '-' . intval($count[$field['slug']]);
$output = str_replace('id="wpcf-field-' . $field['slug'] . '"', 'id="wpcf-field-' . $field['slug'] . $add . '"', $output);
}
return htmlspecialchars_decode(stripslashes($output));
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:71,代码来源:frontend.php
示例11: wpcf_fields_image_view
/**
* View function.
*
* @param type $params
*/
function wpcf_fields_image_view($params)
{
$output = '';
$alt = false;
$title = false;
$class = array();
// Get image data
$image_data = wpcf_fields_image_get_data($params['field_value']);
// Display error to admin only
if (!empty($image_data['error'])) {
if (current_user_can('administrator')) {
return '<div style="padding:10px;background-color:Red;color:#FFFFFF;">' . 'Types: ' . $image_data['error'] . '</div>';
}
return $params['field_value'];
}
if (!$image_data['is_outsider'] && !$image_data['is_dir_writable']) {
if (current_user_can('administrator')) {
return '<div style="padding:10px;background-color:Red;color:#FFFFFF;">' . 'Types: ' . sprintf(__('Directory %s not writable', 'wpcf'), $image_data['abspath']) . '</div>';
}
return $params['field_value'];
}
// Set alt
if (isset($params['alt'])) {
$alt = $params['alt'];
}
// Set title
if (isset($params['title'])) {
$title = $params['title'];
}
// Set attachment class
if (!empty($params['size'])) {
$class[] = 'attachment-' . $params['size'];
}
// Set align class
if (!empty($params['align']) && $params['align'] != 'none') {
$class[] = 'align' . $params['align'];
}
// Pre-configured size (use WP function)
if ($image_data['is_attachment'] && !empty($params['size'])) {
$output = wp_get_attachment_image($image_data['is_attachment'], $params['size'], false, array('class' => implode(' ', $class), 'alt' => $alt, 'title' => $title));
$output = wpcf_frontend_wrap_field_value($params['field'], $output, $params);
$output = wpcf_frontend_wrap_field($params['field'], $output, $params);
} else {
// Custom size
$width = !empty($params['width']) ? intval($params['width']) : null;
$height = !empty($params['height']) ? intval($params['height']) : null;
$crop = !empty($params['proportional']) && $params['proportional'] == 'true' ? false : true;
// Check if image is outsider
if (!$image_data['is_outsider']) {
$resized_image = wpcf_fields_image_resize_image($params['field_value'], $width, $height, 'relpath', false, $crop);
if (!$resized_image) {
$resized_image = $params['field_value'];
}
} else {
$resized_image = $params['field_value'];
}
$output = '<img alt="';
$output .= $alt !== false ? $alt : $resized_image;
$output .= '" title="';
$output .= $title !== false ? $title : $resized_image;
$output .= '"';
$output .= !empty($params['onload']) ? ' onload="' . $params['onload'] . '"' : '';
$output .= !empty($class) ? ' class="' . implode(' ', $class) . '"' : '';
$output .= ' src="' . $resized_image . '" />';
$output = wpcf_frontend_wrap_field_value($params['field'], $output, $params);
$output = wpcf_frontend_wrap_field($params['field'], $output, $params);
}
return $output;
}
开发者ID:rdbartlett,项目名称:kellyspencer.co.nz,代码行数:74,代码来源:image.php
注:本文中的wpcf_frontend_wrap_field函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论