public static function meta_field_mapping($mapping) { $mapping['non_editable'] = array('class' => 'Voce_Meta_Field', 'args' => array('display_callbacks' => array(function ($field, $value, $post_id) { echo '<p>'; voce_field_label_display($field); printf('<span id="%s">%s</span>', esc_attr($field->get_input_id()), $value); echo '</p>'; }), 'sanitize_callbacks' => array(function ($field, $old_value, $new_value, $post_id) { return $old_value; }))); return $mapping; }
static function display_callback($field, $value, $post_id) { $args = array_merge(array('id' => $field->get_input_id(), 'selected' => is_array($value) ? $value : explode(',', $value)), (array) $field->args); ?> <div class="voce-post-meta-psu-container"> <div class="label"> <?php voce_field_label_display($field); ?> </div> <div class="form-input"> <div class="widget"> <div class="widget-inside" style="display:block; border:0;"> <?php echo post_selection_ui($field->get_name(), $args); echo !empty($args['description']) ? '<br><span class="description">' . $args['description'] . '</span>' : ''; ?> </div> </div> </div> </div> <?php }
/** * Public function for the HTML field callback * @param object $field * @param string $value * @param int $post_id */ function voce_color_field_display($field, $value, $post_id) { $palettes = isset($field->args['palettes']) ? $field->args['palettes'] : true; ?> <p> <?php voce_field_label_display($field); ?> <input data-palettes="<?php echo esc_attr(json_encode($palettes)); ?> " type="text" class="voce-color-picker" id="<?php echo esc_attr($field->get_input_id()); ?> " name="<?php echo esc_attr($field->get_name()); ?> " value="<?php echo esc_attr($value); ?> " /> </p> <?php }
/** * * @global type $content_width * @global type $_wp_additional_image_sizes * @global type $wp_version * @param type $field * @param type $value * @param type $post_id * @return type */ public static function display_media_field($field, $value, $post_id) { if (!class_exists('Voce_Meta_API')) { return; } extract(wp_parse_args($field->args, array('mime_types' => array('image'), 'multiple_select' => false, 'thumb_size' => 'medium'))); // Html content vars $label_add = 'Set ' . $field->label; $label_remove = 'Remove ' . $field->label; $link_content = ''; $value_string = ''; $hide_remove = true; // If value is set get thumbnails to display and show remove button if ($value) { if (!is_array($value)) { $value = array($value); } $value_string = implode(',', $value); foreach ($value as $attachment) { $value_post = get_post($attachment); if ($value_post) { $mime_type = $value_post->post_mime_type; $icon = strpos($mime_type, 'image') ? false : true; $thumbnail_html = wp_get_attachment_image($attachment, $thumb_size, $icon); if (!empty($thumbnail_html)) { $link_content .= $thumbnail_html; $hide_remove = false; } $link_content .= '<br>' . get_the_title($value_post->ID); } } } // If no thumbnails then use link text and hide remove if (empty($link_content)) { $link_content = esc_html($label_add); $hide_remove = true; } // Settings for the the js object $field_settings = array('thumbSize' => $thumb_size, 'modalOptions' => array('multiple' => $multiple_select, 'title' => $label_add, 'button' => array('text' => $label_add), 'library' => array('type' => $mime_types))); ?> <div class="vpm-media-field hide-if-no-js" data-field-settings="<?php echo esc_attr(json_encode($field_settings)); ?> " > <p><?php voce_field_label_display($field); ?> </p> <p> <input class="hidden vpm-id" type="hidden" id="<?php echo esc_attr($field->get_input_id()); ?> " name="<?php echo esc_attr($field->get_name()); ?> " value="<?php echo esc_attr($value_string); ?> " /> <a title="<?php echo esc_attr($label_add); ?> " href="#" class="vpm-add <?php echo $hide_remove ? 'button' : ''; ?> "> <?php echo $link_content; ?> </a> </p> <p> <a href="#" class="vpm-remove button" <?php echo $hide_remove ? 'style="display:none;"' : ''; ?> > <?php echo esc_html($label_remove); ?> </a> </p> </div> <?php }
/** * Public callback function to display HTML meta form field * @param object $field * @param string $value * @param int $post_id */ function voce_date_field_display($field, $value, $post_id) { $defaults = array('max_date' => '', 'min_date' => '', 'max_date_field' => '', 'min_date_field' => '', 'default_text' => 'Select Date', 'default_date' => '', 'year_range' => ''); $args = wp_parse_args($field->args, $defaults); $input_pattern = '<input type="text" class="datepicker" id="%s-formatted" data-default_text="%s" data-default_date="%s" data-max_date="%s" data-min_date="%s" data-max_date_field="%s" data-min_date_field="%s" data-year_range="%s" readonly />'; ?> <p> <?php voce_field_label_display($field); ?> <?php printf($input_pattern, $field->get_input_id(), esc_attr($args['default_text']), esc_attr($args['default_date']), esc_attr($args['max_date']), esc_attr($args['min_date']), esc_attr($args['max_date_field']), esc_attr($args['min_date_field']), esc_attr($args['year_range'])); ?> <input class="hidden" type="hidden" id="<?php echo $field->get_input_id(); ?> " name="<?php echo $field->get_name(); ?> " value="<?php echo esc_attr($value); ?> " /> <a href="#" class="submitdelete deletion voce-date-clear">Clear</a> <?php echo !empty($field->description) ? '<br><span class="description">' . wp_kses($field->description, Voce_Meta_API::GetInstance()->description_allowed_html) . '</span>' : ''; ?> </p> <?php }
function voce_widgets_field_display($field, $value, $post_id) { $value_post = get_post($value); $sidebar_id = Voce_Post_Meta_Widgets::WIDGET_ID_PREFIX . $field->get_input_id() . '_post_id_' . $post_id; ?> <input type="hidden" id="voce-post-widgets-exist" value="true"/> <div class="column-2 voce-post-meta-widget-drop"> <?php voce_field_label_display($field); ?> <div class="sidebar voce-post-meta-widget-wrap"> <div class="column-2-widgets"> <div class="sidebar widget-droppable widget-list" id="<?php echo $value_post->post_name; ?> _0"> <?php Voce_Post_Meta_Widgets::get_active_widgets($sidebar_id); ?> </div> </div> </div> <?php echo !empty($field->description) ? '<span class="description">' . wp_kses($field->description, Voce_Meta_API::GetInstance()->description_allowed_html) . '</span>' : ''; ?> </div> <?php }
function voce_wp_editor_field_display($field, $current_value, $post_id) { ?> <div id="<?php echo esc_attr('vpm_field-' . $field->get_input_id()); ?> " class="voce-post-meta-wp-editor"> <?php voce_field_label_display($field); echo '<div class="wp-editor-wrapper">'; // use the get_input_id method as the $editor_id (second argument in wp_editor()) because WP3.9 deprecated the usage of brackets in the name value for the wp_editor wp_editor($current_value, $field->get_input_id(), $field->args['wp_editor_args']); echo '</div>'; echo !empty($field->description) ? '<br><span class="description">' . wp_kses($field->description, Voce_Meta_API::GetInstance()->description_allowed_html) . '</span>' : ''; ?> </div> <?php }