当前位置: 首页>>代码示例>>PHP>>正文


PHP RW_Meta_Box类代码示例

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


在下文中一共展示了RW_Meta_Box类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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