本文整理汇总了PHP中RW_Meta_Box类的典型用法代码示例。如果您正苦于以下问题:PHP RW_Meta_Box类的具体用法?PHP RW_Meta_Box怎么用?PHP RW_Meta_Box使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RW_Meta_Box类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: end_html
/**
* Show end HTML markup for fields
* Do not show field description. Field description is shown before list of fields
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function end_html($meta, $field)
{
$button = $field['clone'] ? call_user_func(array(RW_Meta_Box::get_class_name($field), 'add_clone_button'), $field) : '';
// Closes the container
$html = "{$button}</div>";
return $html;
}
开发者ID:sydneycbd,项目名称:meta-box,代码行数:16,代码来源:key-value.php
示例2: field_meta
/**
* Get field meta value
*
* @param mixed $meta Meta value
* @param array $field Field parameters
*
* @return mixed
*/
public function field_meta($meta, $field)
{
if (!$this->is_edit_screen()) {
return $meta;
}
$option_name = sanitize_text_field($this->page_args['option_name']);
$data = get_option($option_name);
if (empty($data)) {
$data = array();
}
if (!is_array($data)) {
$data = (array) $data;
}
$meta = isset($data[$field['id']]) ? $data[$field['id']] : $field['std'];
// Escape attributes
$meta = call_user_func(array(RW_Meta_Box::get_class_name($field), 'esc_meta'), $meta);
// Make sure meta value is an array for clonable and multiple fields
if ($field['clone'] || $field['multiple']) {
if (empty($meta) || !is_array($meta)) {
/**
* Note: if field is clonable, $meta must be an array with values
* so that the foreach loop in self::show() runs properly
* @see self::show()
*/
$meta = $field['clone'] ? array('') : array();
}
}
return $meta;
}
开发者ID:djgoulart,项目名称:intra-callcenter,代码行数:37,代码来源:settings-page-meta-box.php
示例3: field_meta
/**
* Get field meta value
* @param mixed $meta Meta value
* @param array $field Field parameters
* @return mixed
*/
public function field_meta($meta, $field)
{
if (empty($_GET['tag_ID'])) {
return $meta;
}
$term_id = intval($_GET['tag_ID']);
$single = $field['clone'] || !$field['multiple'];
$meta = get_term_meta($term_id, $field['id'], $single);
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
$meta = !$this->is_saved() && '' === $meta || array() === $meta ? $field['std'] : $meta;
// Escape attributes
$meta = call_user_func(array(RW_Meta_Box::get_class_name($field), 'esc_meta'), $meta);
// Make sure meta value is an array for clonable and multiple fields
if ($field['clone'] || $field['multiple']) {
if (empty($meta) || !is_array($meta)) {
/**
* Note: if field is clonable, $meta must be an array with values
* so that the foreach loop in self::show() runs properly
* @see self::show()
*/
$meta = $field['clone'] ? array('') : array();
}
}
return $meta;
}
开发者ID:djgoulart,项目名称:intra-callcenter,代码行数:31,代码来源:term-meta-box.php
示例4: handle_upload
/**
* Upload
* Ajax callback function
*
* @return string Error or (XML-)response
*/
static function handle_upload()
{
global $wpdb;
$post_id = is_numeric($_REQUEST['post_id']) ? $_REQUEST['post_id'] : 0;
$field_id = isset($_REQUEST['field_id']) ? $_REQUEST['field_id'] : '';
check_ajax_referer("rwmb-upload-images_{$field_id}");
// You can use WP's wp_handle_upload() function:
$file = $_FILES['async-upload'];
$file_attr = wp_handle_upload($file, array('test_form' => false));
//Get next menu_order
$meta = get_post_meta($post_id, $field_id, false);
if (empty($meta)) {
$next = 0;
} else {
$meta = implode(',', (array) $meta);
$max = $wpdb->get_var("\n\t\t\t\t\tSELECT MAX(menu_order) FROM {$wpdb->posts}\n\t\t\t\t\tWHERE post_type = 'attachment'\n\t\t\t\t\tAND ID in ({$meta})\n\t\t\t\t");
$next = is_numeric($max) ? (int) $max + 1 : 0;
}
$attachment = array('guid' => $file_attr['url'], 'post_mime_type' => $file_attr['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename($file['name'])), 'post_content' => '', 'post_status' => 'inherit', 'menu_order' => $next);
// Adds file as attachment to WordPress
$id = wp_insert_attachment($attachment, $file_attr['file'], $post_id);
if (!is_wp_error($id)) {
wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file_attr['file']));
// Save file ID in meta field
add_post_meta($post_id, $field_id, $id, false);
RW_Meta_Box::ajax_response(self::img_html($id), 'success');
}
exit;
}
开发者ID:Kafia,项目名称:Mark-WordPress-Theme-,代码行数:35,代码来源:plupload-image.php
示例5: meta
/**
* Get meta value
*
* @param int $post_id
* @param bool $saved
* @param array $field
*
* @return mixed
*/
static function meta($post_id, $saved, $field)
{
/**
* For special fields like 'divider', 'heading' which don't have ID, just return empty string
* to prevent notice error when displayin fields
*/
if (empty($field['id'])) {
return '';
}
/**
* Maybe set value from parent
*/
$post = get_post($post_id);
if ($post && $post->post_parent > 0) {
$property_inheritance = ud_get_wp_property('property_inheritance', array());
$type = get_post_meta($post_id, 'property_type', true);
if (isset($property_inheritance[$type]) && in_array($field['id'], $property_inheritance[$type])) {
$meta = get_post_meta($post->post_parent, $field['id'], !$field['multiple']);
}
}
if (!$meta) {
$meta = get_post_meta($post_id, $field['id'], !$field['multiple']);
}
// Use $field['std'] only when the meta box hasn't been saved (i.e. the first time we run)
$meta = !$saved && '' === $meta || array() === $meta ? $field['std'] : $meta;
// Escape attributes
$meta = call_user_func(array(RW_Meta_Box::get_class_name($field), 'esc_meta'), $meta);
return $meta;
}
开发者ID:Juni4567,项目名称:mycashflow,代码行数:38,代码来源:class-wpp-inherited.php
示例6: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$attributes = call_user_func(array(RW_Meta_Box::get_class_name($field), 'get_attributes'), $field, $meta);
return sprintf('<input %s>
<a href="#" class="show-embed button">%s</a>
<span class="spinner"></span>
<div class="embed-code">%s</div>', self::render_attributes($attributes), $field['size'], __('Preview', 'meta-box'), $meta ? self::get_embed($meta) : '');
}
开发者ID:dsasko,项目名称:meta-box,代码行数:16,代码来源:oembed.php
示例7: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$meta = (array) $meta;
$meta = implode(',', $meta);
$attributes = call_user_func(array(RW_Meta_Box::get_class_name($field), 'get_attributes'), $field, $meta);
$html = sprintf('<input %s>
<div class="rwmb-media-view" data-mime-type="%s" data-max-files="%s" data-force-delete="%s"></div>', self::render_attributes($attributes), $field['mime_type'], $field['max_file_uploads'], $field['force_delete'] ? 'true' : 'false');
return $html;
}
开发者ID:sydneycbd,项目名称:meta-box,代码行数:17,代码来源:media.php
示例8: wp_ajax_attach_media
/**
* Ajax callback for attaching media to field
*
* @return void
*/
static function wp_ajax_attach_media()
{
$post_id = is_numeric($_REQUEST['post_id']) ? $_REQUEST['post_id'] : 0;
$field_id = isset($_POST['field_id']) ? $_POST['field_id'] : 0;
$attachment_id = isset($_POST['attachment_id']) ? $_POST['attachment_id'] : 0;
check_ajax_referer("rwmb-attach-media_{$field_id}");
add_post_meta($post_id, $field_id, $attachment_id, false);
RW_Meta_Box::ajax_response(self::img_html($attachment_id), 'success');
}
开发者ID:abdulhadikaryana,项目名称:kebudayaan,代码行数:14,代码来源:image-advanced.php
示例9: walk
/**
* Walk options
*
* @param mixed $meta
* @param array $field
* @param mixed $options
* @param mixed $db_fields
*
* @return string
*/
public static function walk($options, $db_fields, $meta, $field)
{
$attributes = call_user_func(array(RW_Meta_Box::get_class_name($field), 'get_attributes'), $field, $meta);
$walker = new RWMB_Select_Walker($db_fields, $field, $meta);
$output = sprintf('<select %s>', self::render_attributes($attributes));
$output .= $walker->walk($options, $field['flatten'] ? -1 : 0);
$output .= '</select>';
$output .= self::get_select_all_html($field);
return $output;
}
开发者ID:alons182,项目名称:municipalliberia,代码行数:20,代码来源:select-advanced.php
示例10: start_el
/**
* @see Walker::start_el()
*
* @param string $output Passed by reference. Used to append additional content.
* @param object $object Item data object.
* @param int $depth Depth of item.
* @param int $current_object_id Item ID.
* @param array $args
*/
public function start_el(&$output, $object, $depth = 0, $args = array(), $current_object_id = 0)
{
$label = $this->db_fields['label'];
$id = $this->db_fields['id'];
$meta = $this->meta;
$field = $this->field;
$field_class = RW_Meta_Box::get_class_name($field);
$attributes = call_user_func(array($field_class, 'get_attributes'), $field, $object->{$id});
$output .= sprintf('<li><label><input %s %s>%s</label>', RWMB_Field::render_attributes($attributes), checked(in_array($object->{$id}, $meta), 1, false), $object->{$label});
}
开发者ID:warfare-plugins,项目名称:social-warfare,代码行数:19,代码来源:input-list-walker.php
示例11: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$field_class = RW_Meta_Box::get_class_name($field);
$attributes = call_user_func(array($field_class, 'get_attributes'), $field, $meta);
$html = sprintf('<select %s>', self::render_attributes($attributes));
$html .= self::options_html($field, $meta);
$html .= '</select>';
$html .= self::get_select_all_html($field['multiple']);
return $html;
}
开发者ID:fkallevik,项目名称:meta-box,代码行数:18,代码来源:select-advanced.php
示例12: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
$html = array();
$tpl = '<label><input %s %s> %s</label>';
$field_class = RW_Meta_Box::get_class_name($field);
foreach ($field['options'] as $value => $label) {
$attributes = call_user_func(array($field_class, 'get_attributes'), $field, $value);
$html[] = sprintf($tpl, self::render_attributes($attributes), checked($value, $meta, false), $label);
}
return implode(' ', $html);
}
开发者ID:fkallevik,项目名称:meta-box,代码行数:19,代码来源:radio.php
示例13: wp_ajax_get_embed
/**
* Ajax callback for returning oEmbed HTML
*
* @return void
*/
static function wp_ajax_get_embed()
{
global $post;
$url = isset($_POST['oembed_url']) ? $_POST['oembed_url'] : 0;
$post_id = is_numeric($_REQUEST['post_id']) ? (int) $_REQUEST['post_id'] : 0;
if (isset($_REQUEST['post_id'])) {
$post = get_post($_REQUEST['post_id']);
}
$embed = self::get_embed($url);
RW_Meta_Box::ajax_response($embed, 'success');
exit;
}
开发者ID:luskyj89,项目名称:mt-wordpress,代码行数:17,代码来源:oembed.php
示例14: save
/**
* Save meta value
* If field is cloneable, value is saved as a single entry in DB
* Otherwise value is saved as multiple entries (for backward compatibility)
*
* TODO: A good way to ALWAYS save values in single entry in DB, while maintaining backward compatibility
*
* @param $new
* @param $old
* @param $post_id
* @param $field
*/
static function save($new, $old, $post_id, $field)
{
if (!$field['clone']) {
RW_Meta_Box::save($new, $old, $post_id, $field);
return;
}
if (empty($new)) {
delete_post_meta($post_id, $field['id']);
} else {
update_post_meta($post_id, $field['id'], $new);
}
}
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:24,代码来源:select.php
示例15: find_field
/**
* Find field by field ID.
* This function finds field in meta boxes registered by 'rwmb_meta_boxes' filter.
*
* @param string $field_id Field ID
* @return array|false Field params (array) if success. False otherwise.
*/
static function find_field($field_id)
{
$meta_boxes = RWMB_Core::get_meta_boxes();
foreach ($meta_boxes as $meta_box) {
$meta_box = RW_Meta_Box::normalize($meta_box);
foreach ($meta_box['fields'] as $field) {
if ($field_id == $field['id']) {
return $field;
}
}
}
return false;
}
开发者ID:acconway,项目名称:meta-box,代码行数:20,代码来源:helper.php
示例16: walk
/**
* Walk options
*
* @param mixed $meta
* @param array $field
* @param mixed $options
* @param mixed $db_fields
*
* @return string
*/
public static function walk($options, $db_fields, $meta, $field)
{
$attributes = call_user_func(array(RW_Meta_Box::get_class_name($field), 'get_attributes'), $field, $meta);
$walker = new RWMB_Select_Walker($db_fields, $field, $meta);
$output = sprintf('<select %s>', self::render_attributes($attributes));
if (false === $field['multiple']) {
$output .= isset($field['placeholder']) ? "<option value=''>{$field['placeholder']}</option>" : '<option></option>';
}
$output .= $walker->walk($options, $field['flatten'] ? -1 : 0);
$output .= '</select>';
$output .= self::get_select_all_html($field);
return $output;
}
开发者ID:part-up,项目名称:blog,代码行数:23,代码来源:select.php
示例17: wp_ajax_delete_file
/**
* Ajax callback for deleting files.
* Modified from a function used by "Verve Meta Boxes" plugin
*
* @link http://goo.gl/LzYSq
* @return void
*/
static function wp_ajax_delete_file()
{
$post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
$field_id = isset($_POST['field_id']) ? $_POST['field_id'] : 0;
$attachment_id = isset($_POST['attachment_id']) ? intval($_POST['attachment_id']) : 0;
check_admin_referer("rwmb-delete-file_{$field_id}");
$ok = delete_post_meta($post_id, $field_id, $attachment_id);
$ok = $ok && wp_delete_attachment($attachment_id);
if ($ok) {
RW_Meta_Box::ajax_response('', 'success');
} else {
RW_Meta_Box::ajax_response(__('Error: Cannot delete file', 'bootstrap'), 'error');
}
}
开发者ID:scotlanddig,项目名称:bootstrap_basic,代码行数:21,代码来源:file.php
示例18: html
/**
* Get field HTML
*
* @param mixed $meta
* @param array $field
*
* @return string
*/
static function html($meta, $field)
{
// Get parent field and filter to child field meta value
self::$meta = $meta;
add_filter('rwmb_field_meta', array(__CLASS__, 'child_field_meta'), 10, 3);
ob_start();
foreach ($field['fields'] as $child_field) {
$child_field['field_name'] = self::child_field_name($field['field_name'], $child_field['field_name']);
call_user_func(array(RW_Meta_Box::get_class_name($child_field), 'show'), $child_field, RWMB_Group::$saved);
}
// Remove filter to child field meta value and reset class's parent field's meta
remove_filter('rwmb_field_meta', array(__CLASS__, 'child_field_meta'));
self::$meta = null;
return ob_get_clean();
}
开发者ID:ksan5835,项目名称:rankproperties,代码行数:23,代码来源:group.php
示例19: find_field
/**
* Find field by field ID
* This function finds field in meta boxes registered by 'wcqd_metabox_meta_boxes' filter
* Note: if users use old code to add meta boxes, this function might not work properly
*
* @param string $field_id Field ID
*
* @return array|false Field params (array) if success. False otherwise.
*/
static function find_field($field_id)
{
// Get all meta boxes registered with 'wcqd_metabox_meta_boxes' hook
$meta_boxes = apply_filters('wcqd_metabox_meta_boxes', array());
// Find field
foreach ($meta_boxes as $meta_box) {
$meta_box = RW_Meta_Box::normalize($meta_box);
foreach ($meta_box['fields'] as $field) {
if ($field_id == $field['id']) {
return $field;
}
}
}
return false;
}
开发者ID:bestmazzo,项目名称:woocomerce-quick-donation,代码行数:24,代码来源:helpers.php
示例20: hash_fields
/**
* Hash all fields into an indexed array for search
*
* @param string $post_type Post type
*/
public static function hash_fields($post_type)
{
self::$fields[$post_type] = array();
$meta_boxes = RWMB_Core::get_meta_boxes();
foreach ($meta_boxes as $meta_box) {
$meta_box = RW_Meta_Box::normalize($meta_box);
if (!in_array($post_type, $meta_box['post_types'])) {
continue;
}
foreach ($meta_box['fields'] as $field) {
if (!empty($field['id'])) {
self::$fields[$post_type][$field['id']] = $field;
}
}
}
}
开发者ID:rilwis,项目名称:meta-box,代码行数:21,代码来源:helper.php
注:本文中的RW_Meta_Box类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论