• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP types_render_field_single函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中types_render_field_single函数的典型用法代码示例。如果您正苦于以下问题:PHP types_render_field_single函数的具体用法?PHP types_render_field_single怎么用?PHP types_render_field_single使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了types_render_field_single函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: types_render_usermeta

/**
 * Calls view function for specific usermeta field type.
 *
 * @global object $wpdb
 *
 * @param type $field
 * @param type $atts (additional attributes: user_id, user_name, user_is_author, user_current)
 * @return type
 */
function types_render_usermeta($field_id, $params, $content = null, $code = '')
{
    global $wpcf, $post, $wpdb, $WP_Views;
    // HTML var holds actual output
    $html = '';
    $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;
    }
    //print_r($params);exit;
    //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 '';
    }
    // See if repetitive
    if (wpcf_admin_is_repetitive($field)) {
        $wpcf->usermeta_repeater->set($user_id, $field);
        $_meta = $wpcf->usermeta_repeater->_get_meta();
        $meta = '';
        if (isset($_meta['custom_order'])) {
            $meta = $_meta['custom_order'];
        }
        if (count($meta) == 1) {
            $meta_id = key($meta);
            $_temp = array_shift($meta);
            if (strval($_temp) == '') {
                return '';
            } else {
                $params['field_value'] = $_temp;
                return types_render_field_single($field, $params, $content, $code, $meta_id);
            }
        } else {
            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 === '') {
//.........这里部分代码省略.........
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:frontend.php


示例2: wpcf_admin_post_meta_box_preview

/**
 * Renders meta box content (preview).
 *
 *
 *
 * @param type $post
 * @param type $group
 */
function wpcf_admin_post_meta_box_preview($post, $group, $echo = '')
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    require_once WPCF_EMBEDDED_ABSPATH . '/frontend.php';
    global $wpcf;
    if (isset($group['args'])) {
        $fields = $group['args']['fields'];
    } else {
        $fields = $group['fields'];
    }
    if (isset($group['slug'])) {
        $slug = $group['slug'];
        $name = $group['name'];
    } else {
        $slug = $group['id'];
        $name = $group['title'];
    }
    /**
     * fake post object if need
     */
    $post = wpcf_admin_create_fake_post_if_need($post);
    $group_output = '';
    if (!empty($echo)) {
        $group_output = '<h3>This Preview generated for latest post "' . $post->post_title . '"</h3>';
        $group_output .= '<div id="test-field-group" class="postbox " >
<h3 class=\'hndle\'><span>' . $name . '</span></h3>
<div class="inside">';
    }
    $group_output .= '<table class="form-table fields-preview fields-preview-' . $slug . '">
<tbody>' . "\n\n";
    $content = $code = '';
    foreach ($fields as $field) {
        $html = '';
        $params['separator'] = ', ';
        if (wpcf_admin_is_repetitive($field)) {
            $wpcf->repeater->set($post, $field);
            $_meta = $wpcf->repeater->_get_meta();
            if (isset($_meta['custom_order'])) {
                $meta = $_meta['custom_order'];
            } else {
                $meta = array();
            }
            $content = $code = '';
            // Sometimes if meta is empty - array(0 => '') is returned
            if (count($meta) == 1) {
                $meta_id = key($meta);
                $_temp = array_shift($meta);
                if (!is_array($_temp) && strval($_temp) == '') {
                } else {
                    $params['field_value'] = $_temp;
                    if (!empty($params['field_value'])) {
                        $html = types_render_field_single($field, $params, $content, $code, $meta_id);
                    }
                }
            } else {
                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;
                            if (!empty($params['field_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'])) {
                            $output = implode(html_entity_decode($params['separator']), $output);
                        } else {
                            if (!empty($output)) {
                                $output = implode('', $output);
                            }
                        }
                    } else {
                        // Make sure indexed right
                        $_index = 0;
                        foreach ($meta as $temp_key => $temp_value) {
                            if ($_index == $index) {
                                $params['field_value'] = $temp_value;
                                if (!empty($params['field_value'])) {
                                    $output = types_render_field_single($field, $params, $content, $code, $temp_key);
                                }
                            }
//.........这里部分代码省略.........
开发者ID:SpencerNeitzke,项目名称:types,代码行数:101,代码来源:fields-post.php


示例3: wpcf_usermeta_preview_profile

function wpcf_usermeta_preview_profile($user_id, $group, $echo = '')
{
    if (is_object($user_id)) {
        $user_id = $user_id->ID;
    }
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    require_once WPCF_EMBEDDED_ABSPATH . '/frontend.php';
    global $wpcf;
    //print_r($group);exit;
    $fields = $group['fields'];
    $group_output = '<div class="wpcf-group-area wpcf-group-area-' . $group['slug'] . '">' . "\n\n";
    $group_output .= '<h3 class="wpcf-group-header-' . $group['slug'] . '">' . wpcf_translate('group ' . $group['id'] . ' name', $group['name']) . '</h3>' . "\n\n";
    foreach ($fields as $field) {
        $html = '';
        $params['post_type'] = TYPES_USER_META_FIELD_GROUP_CPT_NAME;
        $params['option_name'] = 'wpcf-usermeta';
        $params['separator'] = ', ';
        if (wpcf_admin_is_repetitive($field)) {
            $wpcf->usermeta_repeater->set($user_id, $field);
            $_meta = $wpcf->usermeta_repeater->_get_meta();
            if (isset($_meta['custom_order'])) {
                $meta = $_meta['custom_order'];
            } else {
                $meta = array();
            }
            $content = $code = '';
            // Sometimes if meta is empty - array(0 => '') is returned
            if (count($meta) == 1) {
                $meta_id = key($meta);
                $_temp = array_shift($meta);
                if (!is_array($_temp) && strval($_temp) == '') {
                } else {
                    $params['field_value'] = $_temp;
                    if (!empty($params['field_value'])) {
                        $html = types_render_field_single($field, $params, $content, $code, $meta_id);
                    }
                }
            } else {
                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;
                            if (!empty($params['field_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'])) {
                            $output = implode(html_entity_decode($params['separator']), $output);
                        } else {
                            if (!empty($output)) {
                                $output = implode(' ', $output);
                            }
                        }
                    } else {
                        // Make sure indexed right
                        $_index = 0;
                        foreach ($meta as $temp_key => $temp_value) {
                            if ($_index == $index) {
                                $params['field_value'] = $temp_value;
                                if (!empty($params['field_value'])) {
                                    $output = types_render_field_single($field, $params, $content, $code, $temp_key);
                                }
                            }
                            $_index++;
                        }
                    }
                    $html = $output;
                }
            }
        } else {
            $params['field_value'] = get_user_meta($user_id, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
            if (!empty($params['field_value']) && $field['type'] != 'date') {
                $html = types_render_field_single($field, $params);
            }
            if ($field['type'] == 'date' && !empty($params['field_value'])) {
                $html = types_render_field_single($field, $params);
                if ($field['data']['date_and_time'] == 'and_time') {
                    $html .= ' ' . date("H", $params['field_value']) . ':' . date("i", $params['field_value']);
                }
            }
        }
        // API filter
        $wpcf->usermeta_field->set($user_id, $field);
        $field_value = $wpcf->usermeta_field->html($html, $params);
        $group_output .= '<div class="wpcf-profile-field-line wpcf-profile-field-line-' . $field['slug'] . '">
		<div class="wpcf-profile-line-left">
		<b>' . $field['name'] . '</b>
		</div>
//.........这里部分代码省略.........
开发者ID:sonvq,项目名称:passioninvestment,代码行数:101,代码来源:usermeta-post.php


示例4: 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_ABSPATH . '/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:chrismathers,项目名称:premierplacement,代码行数:101,代码来源:frontend.php


示例5: types_render_usermeta_field

/**
 * Calls view function for specific field type.
 *
 * @param type $field
 * @param type $atts
 * @return type
 */
function types_render_usermeta_field($field_id, $params, $content = null, $code = '')
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    global $wpcf, $post;
    // HTML var holds actual output
    $html = '';
    // Set post ID
    $post_id = $post->ID;
    if (isset($params['post_id']) && !empty($params['post_id'])) {
        $post_id = $params['post_id'];
    }
    // Get field
    $field = wpcf_fields_get_field_by_slug($field_id, 'wpcf-usermeta');
    // If field not found return empty string
    if (empty($field)) {
        // Log
        if (!function_exists('wplogger')) {
            require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
        }
        global $wplogger;
        $wplogger->log('types_render_usermeta_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
        return '';
    }
    //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("SELECT * FROM " . $wpdb->prefix . "users WHERE user_login = '" . $params['user_name'] . "'", 0, 0);
        } 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 = wpcf_usermeta_get_user();
                } 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;
    }
    // Set field
    $wpcf->usermeta_field->set($user_id, $field);
    // See if repetitive
    if (wpcf_admin_is_repetitive($field)) {
        $wpcf->usermeta_repeater->set($user_id, $field);
        $_meta = $wpcf->usermeta_repeater->_get_meta();
        $meta = $_meta['custom_order'];
        //        $meta = get_post_meta( $post_id,
        //                wpcf_types_get_meta_prefix( $field ) . $field['slug'], false );
        // Sometimes if meta is empty - array(0 => '') is returned
        if (count($meta) == 1) {
            $meta_id = key($meta);
            $_temp = array_shift($meta);
            if (strval($_temp) == '') {
                return '';
            } else {
                $params['field_value'] = $_temp;
                return types_render_field_single($field, $params, $content, $code, $meta_id);
            }
        } else {
            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'])) {
                        $output = implode(html_entity_decode($params['separator']), $output);
                    } else {
//.........这里部分代码省略.........
开发者ID:MiquelAdell,项目名称:miqueladell,代码行数:101,代码来源:usermeta-init.php


示例6: types_render_field

/**
 * Calls view function for specific field type.
 * 
 * @param type $field
 * @param type $atts
 * @return type 
 */
function types_render_field($field_id, $params, $content = null, $code = '')
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    global $post;
    // Get field
    $field = wpcf_fields_get_field_by_slug($field_id);
    if (empty($field)) {
        if (!function_exists('wplogger')) {
            require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
        }
        global $wplogger;
        $wplogger->log('types_render_field call for missing field \'' . $field_id . '\'', WPLOG_DEBUG);
        return '';
    }
    // See if repetitive
    if (wpcf_admin_is_repetitive($field)) {
        $meta = get_post_meta($post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], false);
        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);
                    if (!empty($temp_output)) {
                        $output[] = $temp_output;
                    }
                }
                if (!empty($output) && isset($params['separator'])) {
                    $output = implode($params['separator'], $output);
                } else {
                    if (!empty($output)) {
                        $output = implode('', $output);
                    } else {
                        return '';
                    }
                }
            } else {
                if (isset($meta[$index])) {
                    $params['field_value'] = $meta[$index];
                    return types_render_field_single($field, $params, $content, $code);
                } else {
                    return '';
                }
            }
            return $output;
        } else {
            return '';
        }
    } else {
        $params['field_value'] = get_post_meta($post->ID, wpcf_types_get_meta_prefix($field) . $field['slug'], true);
        if ($params['field_value'] == '' && $field['type'] != 'checkbox') {
            return '';
        }
        return types_render_field_single($field, $params, $content, $code);
    }
}
开发者ID:sriram911,项目名称:pls,代码行数:71,代码来源:frontend.php


示例7: wpcf_fields_get_field_by_slug

    // TODO set the field slug you want to display
    // Parameters that define the field
    $field_definition = wpcf_fields_get_field_by_slug($field_slug);
    if (!empty($field_definition)) {
        // Get the raw field data.
        $images = get_post_meta($post_id, "wpcf-{$field_slug}");
        foreach ($images as $image_index => $image) {
            // Parameters for the Types field rendering mechanism.
            $image_parameters = array('proportional' => 'true', 'url' => 'true', 'field_value' => $image);
            // Get an image of specific (maximum) proportions.
            // NOTE: Update image size to your needs
            $thumbnail_parameters = array_merge($image_parameters, array('width' => '200', 'height' => '200'));
            $thumbnail_url = types_render_field_single($field_definition, $thumbnail_parameters, null, '', $image_index);
            // Get the image in full size.
            $fullsize_parameters = array_merge($image_parameters, array('size' => 'full'));
            $fullsize_url = types_render_field_single($field_definition, $fullsize_parameters, null, '', $image_index);
            // Append the markup (a thumbnail linking to the full image) to existing content.
            // NOTE: Customize the output to your needs
            $output .= sprintf('<div class="img"><a href=" ' . $fullsize_url . ' "><img src=" ' . $thumbnail_url . ' "></a></div>');
        }
    }
    echo $output;
}
?>
				
	</div><!-- .entry-content -->
	
<!-- Continue the standard Twenty Sixteen content footer output -->		
	<footer class="entry-footer">
		<?php 
twentysixteen_entry_meta();
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:31,代码来源:content-house.php



注:本文中的types_render_field_single函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP typo函数代码示例发布时间:2022-05-23
下一篇:
PHP types_render_field函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap