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


PHP is_protected_meta函数代码示例

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


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

示例1: kapost_is_protected_meta

function kapost_is_protected_meta($protected_fields, $field)
{
    if (!in_array($field, $protected_fields)) {
        return false;
    }
    if (function_exists('is_protected_meta')) {
        return is_protected_meta($field, 'post');
    }
    return $field[0] == '_';
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:10,代码来源:kapost-byline.php

示例2: form


//.........这里部分代码省略.........
						</div>
					</div>

				</div>

				<div class="pis-section pis-2col">

					<h4 class="pis-widget-title"><?php 
        _e('The custom field', 'posts-in-sidebar');
        ?>
</h4>

					<div class="pis-container">

						<div class="pis-column-container">

							<div class="pis-column">

								<?php 
        // ================= Display custom field
        pis_form_checkbox(__('Display the custom field of the post', 'posts-in-sidebar'), $this->get_field_id('custom_field'), $this->get_field_name('custom_field'), checked($custom_field, true, false));
        ?>

								<?php 
        // ================= Custom fields text
        pis_form_input_text(__('Use this text before the custom field', 'posts-in-sidebar'), $this->get_field_id('custom_field_txt'), $this->get_field_name('custom_field_txt'), esc_attr($instance['custom_field_txt']), __('Custom field:', 'posts-in-sidebar'));
        ?>

								<?php 
        // ================= Which custom field
        $options = array();
        $metas = (array) pis_meta();
        foreach ($metas as $meta) {
            if (!is_protected_meta($meta, 'post')) {
                $options[] = array('value' => $meta, 'desc' => $meta);
            }
        }
        pis_form_select(__('Display this custom field', 'posts-in-sidebar'), $this->get_field_id('meta'), $this->get_field_name('meta'), $options, $instance['meta']);
        ?>

							</div>

							<div class="pis-column">

								<?php 
        // ================= Custom field key
        pis_form_checkbox(__('Also display the key of the custom field', 'posts-in-sidebar'), $this->get_field_id('custom_field_key'), $this->get_field_name('custom_field_key'), checked($custom_field_key, true, false));
        ?>

								<?php 
        // ================= Custom field separator
        pis_form_input_text(__('Use this separator between meta key and value', 'posts-in-sidebar'), $this->get_field_id('custom_field_sep'), $this->get_field_name('custom_field_sep'), esc_attr($instance['custom_field_sep']), ':');
        ?>

							</div>

						</div>

					</div>

				</div>

				<div class="pis-section pis-2col">

					<h4 class="pis-widget-title"><?php 
        _e('The link to the archive', 'posts-in-sidebar');
开发者ID:quinntron,项目名称:greendot,代码行数:67,代码来源:pis-widget.php

示例3: wp_ajax_add_meta

/**
 * Ajax handler for adding meta.
 *
 * @since 3.1.0
 */
function wp_ajax_add_meta()
{
    check_ajax_referer('add-meta', '_ajax_nonce-add-meta');
    $c = 0;
    $pid = (int) $_POST['post_id'];
    $post = get_post($pid);
    if (isset($_POST['metakeyselect']) || isset($_POST['metakeyinput'])) {
        if (!current_user_can('edit_post', $pid)) {
            wp_die(-1);
        }
        if (isset($_POST['metakeyselect']) && '#NONE#' == $_POST['metakeyselect'] && empty($_POST['metakeyinput'])) {
            wp_die(1);
        }
        // If the post is an autodraft, save the post as a draft and then attempt to save the meta.
        if ($post->post_status == 'auto-draft') {
            $post_data = array();
            $post_data['action'] = 'draft';
            // Warning fix
            $post_data['post_ID'] = $pid;
            $post_data['post_type'] = $post->post_type;
            $post_data['post_status'] = 'draft';
            $now = current_time('timestamp', 1);
            $post_data['post_title'] = sprintf(__('Draft created on %1$s at %2$s'), date(get_option('date_format'), $now), date(get_option('time_format'), $now));
            $pid = edit_post($post_data);
            if ($pid) {
                if (is_wp_error($pid)) {
                    $x = new WP_Ajax_Response(array('what' => 'meta', 'data' => $pid));
                    $x->send();
                }
                if (!($mid = add_meta($pid))) {
                    wp_die(__('Please provide a custom field value.'));
                }
            } else {
                wp_die(0);
            }
        } elseif (!($mid = add_meta($pid))) {
            wp_die(__('Please provide a custom field value.'));
        }
        $meta = get_metadata_by_mid('post', $mid);
        $pid = (int) $meta->post_id;
        $meta = get_object_vars($meta);
        $x = new WP_Ajax_Response(array('what' => 'meta', 'id' => $mid, 'data' => _list_meta_row($meta, $c), 'position' => 1, 'supplemental' => array('postid' => $pid)));
    } else {
        // Update?
        $mid = (int) key($_POST['meta']);
        $key = wp_unslash($_POST['meta'][$mid]['key']);
        $value = wp_unslash($_POST['meta'][$mid]['value']);
        if ('' == trim($key)) {
            wp_die(__('Please provide a custom field name.'));
        }
        if ('' == trim($value)) {
            wp_die(__('Please provide a custom field value.'));
        }
        if (!($meta = get_metadata_by_mid('post', $mid))) {
            wp_die(0);
        }
        // if meta doesn't exist
        if (is_protected_meta($meta->meta_key, 'post') || is_protected_meta($key, 'post') || !current_user_can('edit_post_meta', $meta->post_id, $meta->meta_key) || !current_user_can('edit_post_meta', $meta->post_id, $key)) {
            wp_die(-1);
        }
        if ($meta->meta_value != $value || $meta->meta_key != $key) {
            if (!($u = update_metadata_by_mid('post', $mid, $value, $key))) {
                wp_die(0);
            }
            // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
        }
        $x = new WP_Ajax_Response(array('what' => 'meta', 'id' => $mid, 'old_id' => $mid, 'data' => _list_meta_row(array('meta_key' => $key, 'meta_value' => $value, 'meta_id' => $mid), $c), 'position' => 0, 'supplemental' => array('postid' => $meta->post_id)));
    }
    $x->send();
}
开发者ID:hughnet,项目名称:WordPress,代码行数:75,代码来源:ajax-actions.php

示例4: the_meta

/**
 * Display list of post custom fields.
 *
 * @since 1.2.0
 *
 * @internal This will probably change at some point...
 *
 */
function the_meta()
{
    if ($keys = get_post_custom_keys()) {
        echo "<ul class='post-meta'>\n";
        foreach ((array) $keys as $key) {
            $keyt = trim($key);
            if (is_protected_meta($keyt, 'post')) {
                continue;
            }
            $values = array_map('trim', get_post_custom_values($key));
            $value = implode($values, ', ');
            /**
             * Filters the HTML output of the li element in the post custom fields list.
             *
             * @since 2.2.0
             *
             * @param string $html  The HTML output for the li element.
             * @param string $key   Meta key.
             * @param string $value Meta value.
             */
            echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>{$key}:</span> {$value}</li>\n", $key, $value);
        }
        echo "</ul>\n";
    }
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:33,代码来源:post-template.php

示例5: insertPages_handleShortcode_insert


//.........这里部分代码省略.........
                        echo get_the_title($inserted_page->ID);
                        ?>
</a></h1><?php 
                        echo $this->insertPages_trim_excerpt(get_post_field('post_excerpt', $inserted_page->ID), $inserted_page->ID, $attributes['should_apply_the_content_filter']);
                        break;
                    case "excerpt-only":
                        echo $this->insertPages_trim_excerpt(get_post_field('post_excerpt', $inserted_page->ID), $inserted_page->ID, $attributes['should_apply_the_content_filter']);
                        break;
                    case "content":
                        $content = get_post_field('post_content', $inserted_page->ID);
                        if ($attributes['should_apply_the_content_filter']) {
                            $content = apply_filters('the_content', $content);
                        }
                        echo $content;
                        break;
                    case "all":
                        // Title.
                        $title_tag = $attributes['inline'] ? 'span' : 'h1';
                        echo "<{$title_tag} class='insert-page-title'>";
                        echo get_the_title($inserted_page->ID);
                        echo "</{$title_tag}>";
                        // Content.
                        $content = get_post_field('post_content', $inserted_page->ID);
                        if ($attributes['should_apply_the_content_filter']) {
                            $content = apply_filters('the_content', $content);
                        }
                        echo $content;
                        // Meta.
                        // @ref https://core.trac.wordpress.org/browser/tags/4.4/src/wp-includes/post-template.php#L968
                        if ($keys = get_post_custom_keys($inserted_page->ID)) {
                            echo "<ul class='post-meta'>\n";
                            foreach ((array) $keys as $key) {
                                $keyt = trim($key);
                                if (is_protected_meta($keyt, 'post')) {
                                    continue;
                                }
                                $values = array_map('trim', get_post_custom_values($key));
                                $value = implode($values, ', ');
                                /**
                                 * Filter the HTML output of the li element in the post custom fields list.
                                 *
                                 * @since 2.2.0
                                 *
                                 * @param string $html  The HTML output for the li element.
                                 * @param string $key   Meta key.
                                 * @param string $value Meta value.
                                 */
                                echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>{$key}:</span> {$value}</li>\n", $key, $value);
                            }
                            echo "</ul>\n";
                        }
                        break;
                    default:
                        // display is either invalid, or contains a template file to use
                        // Legacy/compatibility code: In order to use custom templates,
                        // we use query_posts() to provide the template with the global
                        // state it requires for the inserted page (in other words, all
                        // template tags will work with respect to the inserted page
                        // instead of the parent page / main loop). Note that this may
                        // cause some compatibility issues with other plugins.
                        // @ref https://codex.wordpress.org/Function_Reference/query_posts
                        if (is_numeric($attributes['page'])) {
                            $args = array('p' => intval($attributes['page']), 'post_type' => get_post_types());
                        } else {
                            $args = array('name' => esc_attr($attributes['page']), 'post_type' => get_post_types());
                        }
开发者ID:StudentLifeMarketingAndDesign,项目名称:krui-wp,代码行数:67,代码来源:insert-pages.php

示例6: add_meta

/**
 * Add post meta data defined in $_POST superglobal for post with given ID.
 *
 * @since 1.2.0
 *
 * @param int $post_ID
 * @return int|bool
 */
function add_meta($post_ID)
{
    $post_ID = (int) $post_ID;
    $metakeyselect = isset($_POST['metakeyselect']) ? wp_unslash(trim($_POST['metakeyselect'])) : '';
    $metakeyinput = isset($_POST['metakeyinput']) ? wp_unslash(trim($_POST['metakeyinput'])) : '';
    $metavalue = isset($_POST['metavalue']) ? $_POST['metavalue'] : '';
    if (is_string($metavalue)) {
        $metavalue = trim($metavalue);
    }
    if (('0' === $metavalue || !empty($metavalue)) && ('#NONE#' != $metakeyselect && !empty($metakeyselect) || !empty($metakeyinput))) {
        /*
         * We have a key/value pair. If both the select and the input
         * for the key have data, the input takes precedence.
         */
        if ('#NONE#' != $metakeyselect) {
            $metakey = $metakeyselect;
        }
        if ($metakeyinput) {
            $metakey = $metakeyinput;
        }
        // default
        if (is_protected_meta($metakey, 'post') || !current_user_can('add_post_meta', $post_ID, $metakey)) {
            return false;
        }
        $metakey = wp_slash($metakey);
        return add_post_meta($post_ID, $metakey, $metavalue);
    }
    return false;
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:37,代码来源:post.php

示例7: map_meta_cap


//.........这里部分代码省略.........
                /* translators: 1: post type, 2: capability name */
                _doing_it_wrong(__FUNCTION__, sprintf(__('The post type %1$s is not registered, so it may not be reliable to check the capability "%2$s" against a post of that type.'), $post->post_type, $cap), '4.4.0');
                $caps[] = 'edit_others_posts';
                break;
            }
            $caps[] = $post_type->cap->publish_posts;
            break;
        case 'edit_post_meta':
        case 'delete_post_meta':
        case 'add_post_meta':
            $post = get_post($args[0]);
            $caps = map_meta_cap('edit_post', $user_id, $post->ID);
            $meta_key = isset($args[1]) ? $args[1] : false;
            if ($meta_key && has_filter("auth_post_meta_{$meta_key}")) {
                /**
                 * Filter whether the user is allowed to add post meta to a post.
                 *
                 * The dynamic portion of the hook name, `$meta_key`, refers to the
                 * meta key passed to {@see map_meta_cap()}.
                 *
                 * @since 3.3.0
                 *
                 * @param bool   $allowed  Whether the user can add the post meta. Default false.
                 * @param string $meta_key The meta key.
                 * @param int    $post_id  Post ID.
                 * @param int    $user_id  User ID.
                 * @param string $cap      Capability name.
                 * @param array  $caps     User capabilities.
                 */
                $allowed = apply_filters("auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps);
                if (!$allowed) {
                    $caps[] = $cap;
                }
            } elseif ($meta_key && is_protected_meta($meta_key, 'post')) {
                $caps[] = $cap;
            }
            break;
        case 'edit_comment':
            $comment = get_comment($args[0]);
            if (empty($comment)) {
                break;
            }
            $post = get_post($comment->comment_post_ID);
            /*
             * If the post doesn't exist, we have an orphaned comment.
             * Fall back to the edit_posts capability, instead.
             */
            if ($post) {
                $caps = map_meta_cap('edit_post', $user_id, $post->ID);
            } else {
                $caps = map_meta_cap('edit_posts', $user_id);
            }
            break;
        case 'unfiltered_upload':
            if (defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && (!is_multisite() || is_super_admin($user_id))) {
                $caps[] = $cap;
            } else {
                $caps[] = 'do_not_allow';
            }
            break;
        case 'unfiltered_html':
            // Disallow unfiltered_html for all users, even admins and super admins.
            if (defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML) {
                $caps[] = 'do_not_allow';
            } elseif (is_multisite() && !is_super_admin($user_id)) {
                $caps[] = 'do_not_allow';
开发者ID:NeftaliYagua,项目名称:WordPress,代码行数:67,代码来源:capabilities-functions.php

示例8: _list_meta_row

/**
 * {@internal Missing Short Description}}
 *
 * @since 2.5.0
 *
 * @param unknown_type $entry
 * @param unknown_type $count
 * @return unknown
 */
function _list_meta_row($entry, &$count)
{
    static $update_nonce = false;
    if (is_protected_meta($entry['meta_key'], 'post')) {
        return;
    }
    if (!$update_nonce) {
        $update_nonce = wp_create_nonce('add-meta');
    }
    $r = '';
    ++$count;
    if ($count % 2) {
        $style = 'alternate';
    } else {
        $style = '';
    }
    if (is_serialized($entry['meta_value'])) {
        if (is_serialized_string($entry['meta_value'])) {
            // this is a serialized string, so we should display it
            $entry['meta_value'] = maybe_unserialize($entry['meta_value']);
        } else {
            // this is a serialized array/object so we should NOT display it
            --$count;
            return;
        }
    }
    $entry['meta_key'] = esc_attr($entry['meta_key']);
    $entry['meta_value'] = esc_textarea($entry['meta_value']);
    // using a <textarea />
    $entry['meta_id'] = (int) $entry['meta_id'];
    $delete_nonce = wp_create_nonce('delete-meta_' . $entry['meta_id']);
    $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='{$style}'>";
    $r .= "\n\t\t<td class='left'><label class='screen-reader-text' for='meta[{$entry['meta_id']}][key]'>" . __('Key') . "</label><input name='meta[{$entry['meta_id']}][key]' id='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' />";
    $r .= "\n\t\t<div class='submit'>";
    $r .= get_submit_button(__('Delete'), "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce={$delete_nonce} deletemeta", "deletemeta[{$entry['meta_id']}]", false, array('tabindex' => '6'));
    $r .= "\n\t\t";
    $r .= get_submit_button(__('Update'), "add:the-list:meta-{$entry['meta_id']}::_ajax_nonce-add-meta={$update_nonce} updatemeta", 'updatemeta', false, array('tabindex' => '6'));
    $r .= "</div>";
    $r .= wp_nonce_field('change-meta', '_ajax_nonce', false, false);
    $r .= "</td>";
    $r .= "\n\t\t<td><label class='screen-reader-text' for='meta[{$entry['meta_id']}][value]'>" . __('Value') . "</label><textarea name='meta[{$entry['meta_id']}][value]' id='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>\n\t</tr>";
    return $r;
}
开发者ID:cptpike,项目名称:linuxhardwareguide,代码行数:52,代码来源:template.php

示例9: paypal_ipn_for_wordpress_display_ipn_custome_fields

 /**
  * paypal_ipn_for_wordpress_display_ipn_custome_fields helper function used for display raw dump in html format
  * @since    1.0.0
  * @access   public
  */
 public static function paypal_ipn_for_wordpress_display_ipn_custome_fields()
 {
     if ($keys = get_post_custom_keys()) {
         echo "<div class='wrap'>";
         echo "<table class='widefat'><thead>\n                        <tr>\n                            <th>" . __('IPN Field Name', 'paypal-ipn') . "</th>\n                            <th>" . __('IPN Field Value', 'paypal-ipn') . "</th>\n                        </tr>\n                    </thead>\n                    <tfoot>\n                        <tr>\n                            <th>" . __('IPN Field Name', 'paypal-ipn') . "</th>\n                            <th>" . __('IPN Field Value', 'paypal-ipn') . "</th>\n\n                        </tr>\n                    </tfoot>";
         foreach ((array) $keys as $key) {
             $keyt = trim($key);
             if (is_protected_meta($keyt, 'post')) {
                 continue;
             }
             $values = array_map('trim', get_post_custom_values($key));
             $value = implode($values, ', ');
             /**
              * Filter the HTML output of the li element in the post custom fields list.
              *
              * @since 1.0.0
              *
              * @param string $html  The HTML output for the li element.
              * @param string $key   Meta key.
              * @param string $value Meta value.
              */
             echo apply_filters('paypal_ipn_for_wordpress_the_meta_key', "<tr><th class='post-meta-key'>{$key}:</th> <td>{$value}</td></tr>", $key, $value);
         }
         echo "</table>";
         echo "</div>";
     }
 }
开发者ID:tuvell,项目名称:wordpress-woocommerce-paypal-starter-kit,代码行数:32,代码来源:class-paypal-ipn-for-wordpress-post-types.php

示例10: key

     } else {
         // Update?
         $mid = (int) key($_POST['meta']);
         $key = stripslashes($_POST['meta'][$mid]['key']);
         $value = stripslashes($_POST['meta'][$mid]['value']);
         if ('' == trim($key)) {
             die(__('Please provide a custom field name.'));
         }
         if ('' == trim($value)) {
             die(__('Please provide a custom field value.'));
         }
         if (!($meta = get_metadata_by_mid('post', $mid))) {
             die('0');
         }
         // if meta doesn't exist
         if (is_protected_meta($meta->meta_key, 'post') || is_protected_meta($key, 'post') || !current_user_can('edit_post_meta', $meta->post_id, $meta->meta_key) || !current_user_can('edit_post_meta', $meta->post_id, $key)) {
             die('-1');
         }
         if ($meta->meta_value != $value || $meta->meta_key != $key) {
             if (!($u = update_metadata_by_mid('post', $mid, $value, $key))) {
                 die('0');
             }
             // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems).
         }
         $x = new WP_Ajax_Response(array('what' => 'meta', 'id' => $mid, 'old_id' => $mid, 'data' => _list_meta_row(array('meta_key' => $key, 'meta_value' => $value, 'meta_id' => $mid), $c), 'position' => 0, 'supplemental' => array('postid' => $meta->post_id)));
     }
     $x->send();
     break;
 case 'add-user':
     check_ajax_referer($action);
     if (!current_user_can('create_users')) {
开发者ID:vivekkodira1,项目名称:wordpress,代码行数:31,代码来源:admin-ajax.php

示例11: __construct

 function __construct($post_id)
 {
     $cleaned_metas = array();
     if (!empty($post_id)) {
         $meta_values = get_post_meta($post_id);
         foreach ($meta_values as $key => $values) {
             if (!is_protected_meta($key, 'wpsc-product')) {
                 if (is_array($values)) {
                     foreach ($values as $value) {
                         $cleaned_metas[] = array('meta_key' => $key, 'meta_value' => $value);
                     }
                 }
             }
         }
     }
     $this->custom_meta = $cleaned_metas;
     $this->custom_meta_count = count($this->custom_meta);
 }
开发者ID:VanessaGarcia-Freelance,项目名称:ButtonHut,代码行数:18,代码来源:meta.functions.php

示例12: delete_meta

 /**
  * Delete meta from a post
  *
  * @param int $id Post ID
  * @param int $mid Metadata ID
  * @return array|WP_Error Message on success, WP_Error otherwise
  */
 public function delete_meta($id, $mid)
 {
     $id = (int) $id;
     if (empty($id)) {
         return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
     }
     $post = get_post($id, ARRAY_A);
     if (empty($post['ID'])) {
         return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
     }
     if (!$this->check_edit_permission($post)) {
         return new WP_Error('json_cannot_edit', __('Sorry, you cannot edit this post'), array('status' => 403));
     }
     $current = get_metadata_by_mid('post', $mid);
     if (empty($current)) {
         return new WP_Error('json_meta_invalid_id', __('Invalid meta ID.'), array('status' => 404));
     }
     if (absint($current->post_id) !== $id) {
         return new WP_Error('json_meta_post_mismatch', __('Meta does not belong to this post'), array('status' => 400));
     }
     // for now let's not allow updating of arrays, objects or serialized values.
     if (!$this->is_valid_meta_data($current->meta_value)) {
         return new WP_Error('json_post_invalid_action', __('Invalid existing meta data for action.'), array('status' => 400));
     }
     if (is_protected_meta($current->meta_key)) {
         return new WP_Error('json_meta_protected', sprintf(__('%s is marked as a protected field.'), $current->meta_key), array('status' => 403));
     }
     if (!delete_metadata_by_mid('post', $mid)) {
         return new WP_Error('json_meta_could_not_add', __('Could not delete post meta.'), array('status' => 500));
     }
     return array('message' => __('Deleted meta'));
 }
开发者ID:elangovanaspire,项目名称:bimini,代码行数:39,代码来源:class-wp-json-posts.php

示例13: copy_post_metas

 public function copy_post_metas($from, $to, $lang, $sync = false)
 {
     // copy or synchronize terms
     // FIXME quite a lot of query in foreach
     foreach ($this->get_taxonomies_to_copy($sync) as $tax) {
         $terms = get_the_terms($from, $tax);
         // translated taxonomy
         if ($this->model->is_translated_taxonomy($tax)) {
             $newterms = array();
             if (is_array($terms)) {
                 foreach ($terms as $term) {
                     if ($term_id = $this->model->get_translation('term', $term->term_id, $lang)) {
                         $newterms[] = (int) $term_id;
                     }
                     // cast is important otherwise we get 'numeric' tags
                 }
             }
             // for some reasons, the user may have untranslated terms in the translation. don't forget them.
             if ($sync) {
                 $tr_terms = get_the_terms($to, $tax);
                 if (is_array($tr_terms)) {
                     foreach ($tr_terms as $term) {
                         if (!$this->model->get_translation('term', $term->term_id, $this->model->get_post_language($from))) {
                             $newterms[] = (int) $term->term_id;
                         }
                     }
                 }
             }
             if (!empty($newterms) || $sync) {
                 wp_set_object_terms($to, $newterms, $tax);
             }
             // replace terms in translation
         } else {
             wp_set_object_terms($to, is_array($terms) ? array_map('intval', wp_list_pluck($terms, 'term_id')) : null, $tax);
         }
     }
     // copy or synchronize post metas and allow plugins to do the same
     $metas = get_post_custom($from);
     // get public meta keys (including from translated post in case we just deleted a custom field)
     if (!$sync || in_array('post_meta', $this->options['sync'])) {
         foreach ($keys = array_unique(array_merge(array_keys($metas), array_keys(get_post_custom($to)))) as $k => $meta_key) {
             if (is_protected_meta($meta_key)) {
                 unset($keys[$k]);
             }
         }
     }
     // add page template and featured image
     foreach (array('_wp_page_template', '_thumbnail_id') as $meta) {
         if (!$sync || in_array($meta, $this->options['sync'])) {
             $keys[] = $meta;
         }
     }
     $keys = array_unique(apply_filters('pll_copy_post_metas', empty($keys) ? array() : $keys, $sync));
     // and now copy / synchronize
     foreach ($keys as $key) {
         delete_post_meta($to, $key);
         // the synchronization process of multiple values custom fields is easier if we delete all metas first
         if (isset($metas[$key])) {
             foreach ($metas[$key] as $value) {
                 // important: always maybe_unserialize value coming from get_post_custom. See codex.
                 // thanks to goncalveshugo http://wordpress.org/support/topic/plugin-polylang-pll_copy_post_meta
                 $value = maybe_unserialize($value);
                 // special case for featured images which can be translated
                 add_post_meta($to, $key, $key == '_thumbnail_id' && ($tr_value = $this->model->get_translation('post', $value, $lang)) ? $tr_value : $value);
             }
         }
     }
 }
开发者ID:santikrass,项目名称:apache,代码行数:68,代码来源:admin-sync.php

示例14: prepare_meta

 /**
  * Prepare post meta to send to ES
  *
  * @param object $post
  *
  * @since 0.1.0
  * @return array
  */
 public function prepare_meta($post)
 {
     $meta = (array) get_post_meta($post->ID);
     if (empty($meta)) {
         return array();
     }
     $prepared_meta = array();
     foreach ($meta as $key => $value) {
         if (!is_protected_meta($key)) {
             $prepared_meta[$key] = maybe_unserialize($value);
         }
     }
     return $prepared_meta;
 }
开发者ID:nguyentamvinhlong,项目名称:ElasticPress,代码行数:22,代码来源:class-ep-api.php

示例15: map_meta_cap


//.........这里部分代码省略.........
                break;
            }
            $status_obj = get_post_status_object($post->post_status);
            if ($status_obj->public) {
                $caps[] = $post_type->cap->read;
                break;
            }
            if ('' != $post->post_author) {
                $post_author_data = get_userdata($post->post_author);
            } else {
                // No author set yet, so default to current user for cap checks.
                $post_author_data = $author_data;
            }
            if (is_object($post_author_data) && $user_id == $post_author_data->ID) {
                $caps[] = $post_type->cap->read;
            } elseif ($status_obj->private) {
                $caps[] = $post_type->cap->read_private_posts;
            } else {
                $caps = map_meta_cap('edit_post', $user_id, $post->ID);
            }
            break;
        case 'edit_post_meta':
        case 'delete_post_meta':
        case 'add_post_meta':
            $post = get_post($args[0]);
            $post_type_object = get_post_type_object($post->post_type);
            $caps = map_meta_cap($post_type_object->cap->edit_post, $user_id, $post->ID);
            $meta_key = isset($args[1]) ? $args[1] : false;
            if ($meta_key && has_filter("auth_post_meta_{$meta_key}")) {
                $allowed = apply_filters("auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps);
                if (!$allowed) {
                    $caps[] = $cap;
                }
            } elseif ($meta_key && is_protected_meta($meta_key, 'post')) {
                $caps[] = $cap;
            }
            break;
        case 'edit_comment':
            $comment = get_comment($args[0]);
            $post = get_post($comment->comment_post_ID);
            $post_type_object = get_post_type_object($post->post_type);
            $caps = map_meta_cap($post_type_object->cap->edit_post, $user_id, $post->ID);
            break;
        case 'unfiltered_upload':
            if (defined('ALLOW_UNFILTERED_UPLOADS') && ALLOW_UNFILTERED_UPLOADS && (!is_multisite() || is_super_admin($user_id))) {
                $caps[] = $cap;
            } else {
                $caps[] = 'do_not_allow';
            }
            break;
        case 'edit_files':
        case 'edit_plugins':
        case 'edit_themes':
            if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT) {
                $caps[] = 'do_not_allow';
                break;
            }
            // Fall through if not DISALLOW_FILE_EDIT.
        // Fall through if not DISALLOW_FILE_EDIT.
        case 'update_plugins':
        case 'delete_plugins':
        case 'install_plugins':
        case 'update_themes':
        case 'delete_themes':
        case 'install_themes':
        case 'update_core':
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:67,代码来源:capabilities.php


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