• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_protected_meta函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: delete_item

 /**
  * Delete meta from an object.
  *
  * @param WP_REST_Request $request
  * @return WP_REST_Response|WP_Error Message on success, WP_Error otherwise
  */
 public function delete_item($request)
 {
     $parent_id = (int) $request['parent_id'];
     $mid = (int) $request['id'];
     $force = isset($request['force']) ? (bool) $request['force'] : false;
     // We don't support trashing for this type, error out
     if (!$force) {
         return new WP_Error('rest_trash_not_supported', __('Meta does not support trashing.'), array('status' => 501));
     }
     $parent_column = $this->get_parent_column();
     $current = get_metadata_by_mid($this->parent_type, $mid);
     if (empty($current)) {
         return new WP_Error('rest_meta_invalid_id', __('Invalid meta id.'), array('status' => 404));
     }
     if (absint($current->{$parent_column}) !== (int) $parent_id) {
         return new WP_Error('rest_meta_' . $this->parent_type . '_mismatch', __('Meta does not belong to this object'), 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)) {
         $code = $this->parent_type === 'post' ? 'rest_post_invalid_action' : 'rest_meta_invalid_action';
         return new WP_Error($code, __('Invalid existing meta data for action.'), array('status' => 400));
     }
     if (is_protected_meta($current->meta_key)) {
         return new WP_Error('rest_meta_protected', sprintf(__('%s is marked as a protected field.'), $current->meta_key), array('status' => 403));
     }
     if (!delete_metadata_by_mid($this->parent_type, $mid)) {
         return new WP_Error('rest_meta_could_not_delete', __('Could not delete meta.'), array('status' => 500));
     }
     /**
      * Fires after a meta value is deleted via the REST API.
      *
      * @param WP_REST_Request $request The request sent to the API.
      */
     do_action('rest_delete_meta', $request);
     return rest_ensure_response(array('message' => __('Deleted meta')));
 }
开发者ID:walkthenight,项目名称:walkthenight-wordpress,代码行数:42,代码来源:class-wp-rest-meta-controller.php


示例17: callback

 function callback($path = '', $blog_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     $args = $this->query_args();
     $is_eligible_for_page_handle = true;
     if ($args['number'] < 1) {
         $args['number'] = 20;
     } elseif (100 < $args['number']) {
         return new WP_Error('invalid_number', 'The NUMBER parameter must be less than or equal to 100.', 400);
     }
     if (isset($args['type']) && !$this->is_post_type_allowed($args['type'])) {
         return new WP_Error('unknown_post_type', 'Unknown post type', 404);
     }
     // Normalize post_type
     if (isset($args['type']) && 'any' == $args['type']) {
         if (version_compare($this->api->version, '1.1', '<')) {
             $args['type'] = array('post', 'page');
         } else {
             // 1.1+
             $args['type'] = $this->_get_whitelisted_post_types();
         }
     }
     // determine statuses
     $status = $args['status'];
     $status = $status ? explode(',', $status) : array('publish');
     if (is_user_logged_in()) {
         $statuses_whitelist = array('publish', 'pending', 'draft', 'future', 'private', 'trash', 'any');
         $status = array_intersect($status, $statuses_whitelist);
     } else {
         // logged-out users can see only published posts
         $statuses_whitelist = array('publish', 'any');
         $status = array_intersect($status, $statuses_whitelist);
         if (empty($status)) {
             // requested only protected statuses? nothing for you here
             return array('found' => 0, 'posts' => array());
         }
         // clear it (AKA published only) because "any" includes protected
         $status = array();
     }
     if (isset($args['type']) && !in_array($args['type'], array('post', 'page', 'revision', 'any')) && defined('IS_WPCOM') && IS_WPCOM) {
         $this->load_theme_functions();
     }
     // let's be explicit about defaulting to 'post'
     $args['type'] = isset($args['type']) ? $args['type'] : 'post';
     // make sure the user can read or edit the requested post type(s)
     if (is_array($args['type'])) {
         $allowed_types = array();
         foreach ($args['type'] as $post_type) {
             if ($this->current_user_can_access_post_type($post_type, $args['context'])) {
                 $allowed_types[] = $post_type;
             }
         }
         if (empty($allowed_types)) {
             return array('found' => 0, 'posts' => array());
         }
         $args['type'] = $allowed_types;
     } else {
         if (!$this->current_user_can_access_post_type($args['type'], $args['context'])) {
             return array('found' => 0, 'posts' => array());
         }
     }
     $query = array('posts_per_page' => $args['number'], 'order' => $args['order'], 'orderby' => $args['order_by'], 'post_type' => $args['type'], 'post_status' => $status, 'post_parent' => isset($args['parent_id']) ? $args['parent_id'] : null, 'author' => isset($args['author']) && 0 < $args['author'] ? $args['author'] : null, 's' => isset($args['search']) ? $args['search'] : null, 'fields' => 'ids');
     if (!is_user_logged_in()) {
         $query['has_password'] = false;
     }
     if (isset($args['meta_key'])) {
         $show = false;
         if ($this->is_metadata_public($args['meta_key'])) {
             $show = true;
         }
         if (current_user_can('edit_post_meta', $query['post_type'], $args['meta_key'])) {
             $show = true;
         }
         if (is_protected_meta($args['meta_key'], 'post') && !$show) {
             return new WP_Error('invalid_meta_key', 'Invalid meta key', 404);
         }
         $meta = array('key' => $args['meta_key']);
         if (isset($args['meta_value'])) {
             $meta['value'] = $args['meta_value'];
         }
         $query['meta_query'] = array($meta);
     }
     if ($args['sticky'] === 'include') {
         $query['ignore_sticky_posts'] = 1;
     } else {
         if ($args['sticky'] === 'exclude') {
             $sticky = get_option('sticky_posts');
             if (is_array($sticky)) {
                 $query['post__not_in'] = $sticky;
             }
         } else {
             if ($args['sticky'] === 'require') {
                 $sticky = get_option('sticky_posts');
                 if (is_array($sticky) && !empty($sticky)) {
                     $query['post__in'] = $sticky;
                 } else {
                     // no sticky posts exist
//.........这里部分代码省略.........
开发者ID:annbransom,项目名称:techishowl_prod_backup,代码行数:101,代码来源:class.wpcom-json-api-list-posts-v1-1-endpoint.php


示例18: callback

 function callback($path = '', $blog_id = 0)
 {
     $blog_id = $this->api->switch_to_blog_and_validate_user($this->api->get_blog_id($blog_id));
     if (is_wp_error($blog_id)) {
         return $blog_id;
     }
     $args = $this->query_args();
     if ($arg 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_proxybypass函数代码示例发布时间:2022-05-15
下一篇:
PHP is_product_taxonomy函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap