Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 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 = get_post_meta( $form_id, 'wpuf_form', true );
- $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 ( $attr['input_type'] == 'hidden' ) {
- continue;
- }
- 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 );
- $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'] );
- $html .= sprintf( '<li><label>%s</label>: %s</li>', $attr['label'], make_clickable( implode( ', ', $value ) ) );
- }
- }
- }
- $html .= '</ul>';
- return $content . $html;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement