本文整理汇总了PHP中wpuf_get_form_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP wpuf_get_form_fields函数的具体用法?PHP wpuf_get_form_fields怎么用?PHP wpuf_get_form_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpuf_get_form_fields函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: shortcode_handler
/**
* Add post shortcode handler
*
* @param array $atts
* @return string
*/
function shortcode_handler($atts)
{
extract(shortcode_atts(array('id' => 0, 'type' => 'registration'), $atts));
//registration time redirect to subscription
if ($type == 'registration') {
$is_fource_pack = wpuf_get_option('register_subscription', 'wpuf_payment');
if ($is_fource_pack == 'on' && !isset($_GET['type']) || $is_fource_pack == 'on' && $_GET['type'] != 'wpuf_sub') {
$subscription_page_id = wpuf_get_option('subscription_page', 'wpuf_payment');
if (empty($subscription_page_id)) {
_e('Please select subscription page', 'wpuf');
return;
} else {
wp_redirect(get_permalink($subscription_page_id));
exit;
}
}
}
ob_start();
$form_vars = wpuf_get_form_fields($id);
//get_post_meta( $id, self::$meta_key, true );
$form_settings = wpuf_get_form_settings($id);
if (!$form_vars) {
return;
}
if ($type == 'profile') {
if (is_user_logged_in()) {
if (isset($_GET['msg']) && $_GET['msg'] == 'profile_update') {
echo '<div class="wpuf-success">';
echo $form_settings['update_message'];
echo '</div>';
}
$this->profile_edit($id, $form_vars, $form_settings);
} else {
echo '<div class="wpuf-info">' . __('Please login to update your profile!', 'wpuf') . '</div>';
}
} elseif ($type == 'registration') {
if (is_user_logged_in()) {
echo '<div class="wpuf-info">' . __('You are already logged in!', 'wpuf') . '</div>';
} else {
if (get_option('users_can_register') != '1') {
echo '<div class="wpuf-info">';
_e('User registration is currently not allowed.');
echo '</div>';
return;
}
$this->profile_edit($id, $form_vars, $form_settings);
}
}
// var_dump( $id, $type, $form_vars, $form_settings );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
示例2: wpuf_show_custom_fields
/**
* Show custom fields in post content area
*
* @global object $post
* @param string $content
* @return string
*/
function wpuf_show_custom_fields($content)
{
global $post;
$show_custom = wpuf_get_option('cf_show_front', 'wpuf_general');
$show_caption = wpuf_get_option('image_caption', 'wpuf_general');
if ($show_custom != 'on') {
return $content;
}
$form_id = get_post_meta($post->ID, '_wpuf_form_id', true);
if (!$form_id) {
return $content;
}
$html = '<ul class="wpuf_customs">';
$form_vars = wpuf_get_form_fields($form_id);
$meta = array();
if ($form_vars) {
foreach ($form_vars as $attr) {
if (isset($attr['is_meta']) && $attr['is_meta'] == 'yes') {
$meta[] = $attr;
}
}
if (!$meta) {
return $content;
}
foreach ($meta as $attr) {
$field_value = get_post_meta($post->ID, $attr['name']);
$return_for_no_cond = 0;
if (isset($attr['wpuf_cond']['condition_status']) && $attr['wpuf_cond']['condition_status'] == 'yes') {
foreach ($attr['wpuf_cond']['cond_field'] as $field_key => $cond_field_name) {
$cond_field_value = get_post_meta($post->ID, $cond_field_name, 'true');
if (isset($attr['wpuf_cond']['cond_option'][$field_key]) && $attr['wpuf_cond']['cond_option'][$field_key] != $cond_field_value) {
$return_for_no_cond = 1;
}
}
}
if ($return_for_no_cond == 1) {
continue;
}
if (!count($field_value)) {
continue;
}
if ($attr['input_type'] == 'hidden') {
continue;
}
//var_dump( $attr );
if ($attr['input_type'] == 'image_upload' || $attr['input_type'] == 'file_upload') {
$image_html = '<li><label>' . $attr['label'] . ':</label> ';
if ($field_value) {
foreach ($field_value as $attachment_id) {
if ($attr['input_type'] == 'image_upload') {
$thumb = wp_get_attachment_image($attachment_id, 'thumbnail');
} else {
$thumb = get_post_field('post_title', $attachment_id);
}
$full_size = wp_get_attachment_url($attachment_id);
if ($thumb) {
$image_html .= sprintf('<a href="%s">%s</a> ', $full_size, $thumb);
if ($show_caption == 'on') {
$post_detail = get_post($attachment_id);
if (!empty($post_detail->post_title)) {
$image_html .= '<br /><label>' . __('Title', 'wpuf') . ':</label> <span class="image_title">' . esc_html($post_detail->post_title) . '</span>';
}
if (!empty($post_detail->post_excerpt)) {
$image_html .= '<br /><label>' . __('Caption', 'wpuf') . ':</label> <span class="image_caption">' . esc_html($post_detail->post_excerpt) . '</span>';
}
if (!empty($post_detail->post_content)) {
$image_html .= '<br /><label>' . __('Description', 'wpuf') . ':</label> <span class="image_description">' . esc_html($post_detail->post_content) . '</span>';
}
}
}
}
}
$html .= $image_html . '</li>';
} elseif ($attr['input_type'] == 'map') {
ob_start();
wpuf_shortcode_map_post($attr['name'], $post->ID);
$html .= ob_get_clean();
} elseif ($attr['input_type'] == 'address') {
include_once 'countries.php';
$address_html = '';
if (isset($field_value[0])) {
foreach ($field_value[0] as $field_key => $value) {
if ($field_key == 'country_select') {
if (isset($countries[$value])) {
$value = $countries[$value];
}
}
$address_html .= '<li><label>' . $attr['address'][$field_key]['label'] . ': </label> ';
$address_html .= ' ' . $value . '</li>';
}
}
$html = $address_html;
} else {
//.........这里部分代码省略.........
示例3: edit_form_area_profile
/**
* Edit form elements area for profile
*
* @global object $post
* @global string $pagenow
*/
function edit_form_area_profile()
{
global $post, $pagenow, $form_inputs;
$form_inputs = wpuf_get_form_fields($post->ID);
?>
<input type="hidden" name="wpuf_form_editor" id="wpuf_form_editor" value="<?php
echo wp_create_nonce(plugin_basename(__FILE__));
?>
" />
<div style="margin-bottom: 10px">
<button class="button wpuf-collapse"><?php
_e('Toggle All', 'wpuf');
?>
</button>
</div>
<div class="wpuf-updated">
<p><?php
_e('Click on a form element to add to the editor', 'wpuf');
?>
</p>
</div>
<ul id="wpuf-form-editor" class="wpuf-form-editor unstyled">
<?php
if ($form_inputs) {
$count = 0;
foreach ($form_inputs as $order => $input_field) {
$name = ucwords(str_replace('_', ' ', $input_field['template']));
WPUF_Admin_Template_Profile::$input_field['template']($count, $name, $input_field);
$count++;
}
}
?>
</ul>
<?php
}
示例4: wpuf_show_custom_fields
/**
* Show custom fields in post content area
*
* @global object $post
* @param string $content
* @return string
*/
function wpuf_show_custom_fields($content)
{
global $post;
$show_custom = wpuf_get_option('cf_show_front', 'wpuf_general');
if ($show_custom != 'on') {
return $content;
}
$form_id = get_post_meta($post->ID, '_wpuf_form_id', true);
if (!$form_id) {
return $content;
}
$html = '<ul class="wpuf_customs">';
$form_vars = wpuf_get_form_fields($form_id);
$meta = array();
if ($form_vars) {
foreach ($form_vars as $attr) {
if (isset($attr['is_meta']) && $attr['is_meta'] == 'yes') {
$meta[] = $attr;
}
}
if (!$meta) {
return $content;
}
foreach ($meta as $attr) {
$field_value = get_post_meta($post->ID, $attr['name']);
if (!count($field_value)) {
continue;
}
if ($attr['input_type'] == 'hidden') {
continue;
}
//var_dump( $attr );
if ($attr['input_type'] == 'image_upload' || $attr['input_type'] == 'file_upload') {
$image_html = '<li><label>' . $attr['label'] . ':</label> ';
if ($field_value) {
foreach ($field_value as $attachment_id) {
if ($attr['input_type'] == 'image_upload') {
$thumb = wp_get_attachment_image($attachment_id, 'thumbnail');
} else {
$thumb = get_post_field('post_title', $attachment_id);
}
$full_size = wp_get_attachment_url($attachment_id);
if ($thumb) {
$image_html .= sprintf('<a href="%s">%s</a> ', $full_size, $thumb);
}
}
}
$html .= $image_html . '</li>';
} elseif ($attr['input_type'] == 'map') {
ob_start();
wpuf_shortcode_map_post($attr['name'], $post->ID);
$html .= ob_get_clean();
} else {
$value = get_post_meta($post->ID, $attr['name']);
$new = implode(', ', $value);
if ($new) {
$html .= sprintf('<li><label>%s</label>: %s</li>', $attr['label'], make_clickable($new));
}
}
}
}
// var_dump( $attr );
$html .= '</ul>';
return $content . $html;
}
示例5: render_registration_form
/**
* Render registration form
*/
public static function render_registration_form()
{
global $post, $pagenow, $form_inputs;
$form_inputs = wpuf_get_form_fields($post->ID);
?>
<div style="margin-bottom: 10px">
<button class="button wpuf-collapse"><?php
_e('Toggle All', 'wpuf');
?>
</button>
</div>
<div class="wpuf-updated">
<p><?php
_e('Click on a form element to add to the editor', 'wpuf');
?>
</p>
</div>
<ul id="wpuf-form-editor" class="wpuf-form-editor unstyled">
<?php
if ($form_inputs) {
$count = 0;
foreach ($form_inputs as $order => $input_field) {
$name = ucwords(str_replace('_', ' ', $input_field['template']));
if (method_exists('WPUF_Admin_Template_Profile', $input_field['template'])) {
WPUF_Admin_Template_Profile::$input_field['template']($count, $name, $input_field);
} else {
do_action('wpuf_admin_template_post_' . $input_field['template'], $name, $count, $input_field, 'WPUF_Admin_Template_Post', '');
}
$count++;
}
}
?>
</ul>
<?php
}
示例6: render_form
/**
* Handles the add post shortcode
*
* @param $atts
*/
function render_form($form_id, $post_id = NULL, $preview = false)
{
$form_vars = wpuf_get_form_fields($form_id);
$form_settings = wpuf_get_form_settings($form_id);
if (!is_user_logged_in() && $form_settings['guest_post'] != 'true') {
echo '<div class="wpuf-message">' . $form_settings['message_restrict'] . '</div>';
wp_login_form();
return;
}
if ($form_vars) {
?>
<?php
if (!$preview) {
?>
<form class="wpuf-form-add" action="" method="post">
<?php
}
?>
<ul class="wpuf-form">
<?php
if (!$post_id) {
do_action('wpuf_add_post_form_top', $form_id, $form_settings);
} else {
do_action('wpuf_edit_post_form_top', $form_id, $post_id, $form_settings);
}
if (!is_user_logged_in() && $form_settings['guest_post'] == 'true' && $form_settings['guest_details'] == 'true') {
$this->guest_fields($form_settings);
}
$this->render_items($form_vars, $post_id, 'post', $form_id, $form_settings);
$this->submit_button($form_id, $form_settings, $post_id);
if (!$post_id) {
do_action('wpuf_add_post_form_bottom', $form_id, $form_settings);
} else {
do_action('wpuf_edit_post_form_bottom', $form_id, $post_id, $form_settings);
}
?>
</ul>
<?php
if (!$preview) {
?>
</form>
<?php
}
?>
<?php
}
//endif
}
示例7: edit_form_area
/**
* Edit form elements area for post
*
* @global object $post
* @global string $pagenow
*/
function edit_form_area()
{
global $post, $pagenow, $form_inputs;
$form_inputs = wpuf_get_form_fields($post->ID);
?>
<input type="hidden" name="wpuf_form_editor" id="wpuf_form_editor" value="<?php
echo wp_create_nonce(plugin_basename(__FILE__));
?>
" />
<div style="margin-bottom: 10px">
<button class="button wpuf-collapse"><?php
_e('Toggle All', 'wpuf');
?>
</button>
</div>
<div class="wpuf-updated">
<p><?php
_e('Click on a form element to add to the editor', 'wpuf');
?>
</p>
</div>
<ul id="wpuf-form-editor" class="wpuf-form-editor unstyled">
<?php
if ($form_inputs) {
$count = 0;
$con_fields = $this->get_conditional_fields($form_inputs);
foreach ($form_inputs as $order => $input_field) {
$input_field['template'] = isset($input_field['template']) ? $input_field['template'] : '';
$name = ucwords(str_replace('_', ' ', $input_field['template']));
if (isset($cond_inputs[$order])) {
$input_field = array_merge($input_field, $cond_inputs[$order]);
}
if ($input_field['template'] == 'taxonomy') {
WPUF_Admin_Template_Post::$input_field['template']($count, $name, $input_field['name'], $input_field);
} else {
if (method_exists('WPUF_Admin_Template_Post', $input_field['template'])) {
WPUF_Admin_Template_Post::$input_field['template']($count, $name, $input_field);
} else {
do_action('wpuf_admin_template_post_' . $input_field['template'], $name, $count, $input_field, 'WPUF_Admin_Template_Post', $this);
}
}
$count++;
}
}
?>
</ul>
<?php
}
示例8: export_to_json
/**
* Export into json file
*
* @param string $post_type
* @param array $post_ids
*/
function export_to_json($post_type, $post_ids = array())
{
$formatted_data = array();
$ids = array();
$blogname = str_replace(" ", "", get_option('blogname'));
$date = date("Y-m-d");
$json_name = $blogname . "-wpuf-" . $date;
// Namming the filename will be generated.
if (!empty($post_ids)) {
foreach ($post_ids as $key => $value) {
array_push($ids, $value);
}
}
$args = array('post_status' => 'publish', 'post_type' => $post_type, 'post__in' => !empty($ids) ? $ids : '');
$query = new WP_Query($args);
foreach ($query->posts as $post) {
$postdata = get_object_vars($post);
unset($postdata['ID']);
$data = array('post_data' => $postdata, 'meta_data' => array('fields' => wpuf_get_form_fields($post->ID), 'settings' => get_post_meta($post->ID, 'wpuf_form_settings', true)));
array_push($formatted_data, $data);
}
$json_file = json_encode($formatted_data);
// Encode data into json data
ob_clean();
echo $json_file;
header("Content-Type: text/json; charset=" . get_option('blog_charset'));
header("Content-Disposition: attachment; filename={$json_name}.json");
exit;
}