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

PHP get_post_status_object函数代码示例

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

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



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

示例1: test_register_carf_post_status

 public function test_register_carf_post_status()
 {
     $post_status_object = get_post_status_object('carf');
     $this->assertNull($post_status_object);
     register_extended_post_status('carf', ['label' => 'Car']);
     $post_status_object = get_post_status_object('carf');
     $this->assertSame('Car', $post_status_object->label);
 }
开发者ID:frozzare,项目名称:wp-extended-post-status,代码行数:8,代码来源:functions-test.php


示例2: get_item

 /**
  * Get a specific post status
  *
  * @param WP_REST_Request $request
  * @return array|WP_Error
  */
 public function get_item($request)
 {
     $obj = get_post_status_object($request['status']);
     if (empty($obj)) {
         return new WP_Error('rest_status_invalid', __('Invalid status.'), array('status' => 404));
     }
     return $this->prepare_item_for_response($obj, $request);
 }
开发者ID:pristupaeugen,项目名称:wordpress_rest_api,代码行数:14,代码来源:class-wp-rest-post-statuses-controller.php


示例3: kb_tickets_post_column_id

/**
 * Output the ID row.
 *
 * @since	1.0
 * @param	int	$ticket_id	The ticket ID
 * @param	obj	$kbs_ticket	The ticket WP_Post object
 * @return	str
 */
function kb_tickets_post_column_id($ticket_id, $kbs_ticket)
{
    do_action('kb_pre_tickets_column_id', $kbs_ticket);
    $output = '<a href="' . get_edit_post_link($ticket_id) . '">#' . $ticket_id . '</a>';
    $output .= '<br />';
    $output .= get_post_status_object($kbs_ticket->post_status)->label;
    do_action('kb_post_tickets_column_id', $kbs_ticket);
    return apply_filters('kb_tickets_post_column_id', $output, $ticket_id);
}
开发者ID:KB-Support,项目名称:kb-support,代码行数:17,代码来源:tickets.php


示例4: can_react_to_post

 /**
  * Returns true if a post can be "reacted" upon, false if not
  */
 public static function can_react_to_post($post_ID)
 {
     $post = get_post($post_ID);
     if (!$post || is_wp_error($post)) {
         return false;
     }
     if ('inherit' === $post->post_status) {
         $parent_post = get_post($post->post_parent);
         $post_password = $parent_post->post_password;
         $post_status_obj = get_post_status_object($parent_post->post_status);
         $post_status = $parent_post->post_status;
     } else {
         $post_status_obj = get_post_status_object($post->post_status);
         $post_status = $post->post_status;
         $post_password = $post->post_password;
     }
     if (!$post_status_obj->public) {
         if (is_user_logged_in()) {
             if ($post_status_obj->protected) {
                 if (!current_user_can('edit_post', $post->ID)) {
                     return false;
                 }
             } elseif ($post_status_obj->private) {
                 if (!current_user_can('read_post', $post->ID)) {
                     return false;
                 }
             } else {
                 return false;
             }
         } else {
             return false;
         }
     }
     if (in_array($post_status, array('draft', 'pending', 'future', 'trash'))) {
         return false;
     }
     if (strlen($post_password) && !current_user_can('read_post', $post->ID)) {
         return false;
     }
     if ('off' === get_option('emoji_reactions_allow_guest_reactions', 'off') && !is_user_logged_in()) {
         return false;
     }
     if (is_user_logged_in()) {
         $check_count_against = array('user_id' => get_current_user_id());
     } else {
         $check_count_against = array('search' => preg_replace('/[^0-9a-fA-F:., ]/', '', $_SERVER['REMOTE_ADDR']));
     }
     $allowed_reactions_per_user = get_option('emoji_reactions_num_per_user_per_post', 10);
     if ($allowed_reactions_per_user > 0) {
         $check_count_against = array('type' => 'emoji-reaction', 'count' => true) + $check_count_against;
         $current_user_reaction_count = get_comments($check_count_against);
         if ($current_user_reaction_count >= $allowed_reactions_per_user) {
             return false;
         }
     }
     return true;
 }
开发者ID:justinshreve,项目名称:emoji-reactions,代码行数:60,代码来源:utils.php


示例5: create_comment

 public static function create_comment($entry_id, $form_id)
 {
     $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
     $post = get_post($comment_post_ID);
     if (empty($post->comment_status)) {
         return;
     }
     // get_post_status() will get the parent status for attachments.
     $status = get_post_status($post);
     $status_obj = get_post_status_object($status);
     if (!comments_open($comment_post_ID)) {
         do_action('comment_closed', $comment_post_ID);
         //wp_die( __( 'Sorry, comments are closed for this item.') );
         return;
     } else {
         if ('trash' == $status) {
             do_action('comment_on_trash', $comment_post_ID);
             return;
         } else {
             if (!$status_obj->public && !$status_obj->private) {
                 do_action('comment_on_draft', $comment_post_ID);
                 return;
             } else {
                 if (post_password_required($comment_post_ID)) {
                     do_action('comment_on_password_protected', $comment_post_ID);
                     return;
                 } else {
                     do_action('pre_comment_on_post', $comment_post_ID);
                 }
             }
         }
     }
     $comment_content = isset($_POST['comment']) ? trim($_POST['comment']) : '';
     // If the user is logged in
     $user_ID = get_current_user_id();
     if ($user_ID) {
         global $current_user;
         $display_name = !empty($current_user->display_name) ? $current_user->display_name : $current_user->user_login;
         $comment_author = $display_name;
         $comment_author_email = '';
         //get email from field
         $comment_author_url = $current_user->user_url;
     } else {
         $comment_author = isset($_POST['author']) ? trim(strip_tags($_POST['author'])) : '';
         $comment_author_email = isset($_POST['email']) ? trim($_POST['email']) : '';
         $comment_author_url = isset($_POST['url']) ? trim($_POST['url']) : '';
     }
     $comment_type = '';
     if (!$user_ID && get_option('require_name_email') && (6 > strlen($comment_author_email) || $comment_author == '')) {
         return;
     }
     if ($comment_content == '') {
         return;
     }
     $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID');
     wp_new_comment($commentdata);
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:57,代码来源:FrmProComment.php


示例6: register_post_stati

 public static function register_post_stati()
 {
     if (get_post_status_object('btb_canceled')) {
         return;
     }
     $args = array('label' => _x('Booked', 'Status General Name', 'bt-booking'), 'label_count' => _n_noop('Booked <span class="count">(%s)</a>', 'Booked <span class="count">(%s)</a>', 'bt-booking'), 'protected' => true, 'show_in_admin_status_list' => true, 'exclude_from_search' => false);
     register_post_status('btb_booked', $args);
     $args = array('label' => _x('Prebooked', 'Status General Name', 'bt-booking'), 'label_count' => _n_noop('Prebooked <span class="count">(%s)</a>', 'Prebooked <span class="count">(%s)</a>', 'bt-booking'), 'protected' => true, 'show_in_admin_status_list' => true, 'exclude_from_search' => false);
     register_post_status('btb_prebook', $args);
     $args = array('label' => _x('Canceled', 'Status General Name', 'bt-booking'), 'label_count' => _n_noop('Canceled <span class="count">(%s)</a>', 'Canceled <span class="count">(%s)</a>', 'bt-booking'), 'protected' => true, 'show_in_admin_status_list' => true, 'exclude_from_search' => false);
     register_post_status('btb_canceled', $args);
 }
开发者ID:Buschtrommel,项目名称:BTBooking,代码行数:12,代码来源:class.bt-booking.php


示例7: get_data

 function get_data($item)
 {
     $data = array('title-attr' => $item->get_permalink());
     $post = $item->get_object();
     if ('publish' != $post->post_status) {
         $status_obj = get_post_status_object($post->post_status);
         if ($status_obj) {
             $data['status']['text'] = $status_obj->label;
         }
     }
     return $data;
 }
开发者ID:Olaw2jr,项目名称:wp-posts-to-posts,代码行数:12,代码来源:field-title-post.php


示例8: render_list_table_page

 /**
  * Setup the list table and render the list table page, or call the given
  * action.
  *
  * @param string                        $page_title
  * @param WordPress\Orm\Admin\ListTable $list_table
  */
 public static function render_list_table_page($page_title, $list_table)
 {
     // We pass the class to filters & actions
     $list_table_class = get_class($list_table);
     // Get stuff
     $pagenum = $list_table->get_pagenum();
     $action = $list_table->current_action();
     if ($action) {
         check_admin_referer('bulk-posts');
         $sendback = remove_query_arg(array('trashed', 'untrashed', 'deleted', 'locked', 'ids'), wp_get_referer());
         // Comment this
         if (!$sendback) {
             $sendback = admin_url('admin.php?page=test-venues');
         }
         // Add the current page to the sendback URL
         $sendback = add_query_arg('paged', $pagenum, $sendback);
         // ?
         if (strpos($sendback, 'post.php') !== false) {
             $sendback = admin_url($post_new_file);
         }
         // Get the post ids to operate on
         if ('delete_all' == $doaction) {
             $post_status = preg_replace('/[^a-z0-9_-]+/i', '', $_REQUEST['post_status']);
             if (get_post_status_object($post_status)) {
                 $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type=%s AND post_status = %s", $post_type, $post_status));
             }
             $doaction = 'delete';
         } elseif (isset($_REQUEST['media'])) {
             $post_ids = $_REQUEST['media'];
         } elseif (isset($_REQUEST['ids'])) {
             $post_ids = explode(',', $_REQUEST['ids']);
         } elseif (!empty($_REQUEST['post'])) {
             $post_ids = array_map('intval', $_REQUEST['post']);
         }
         if (!isset($post_ids)) {
             wp_redirect($sendback);
             exit;
         }
         // Plugins need to do their thing here
         do_action('wporm:list_table:action', $action, $post_ids, $list_table, $list_table_class);
         // Redirect the user
         $sendback = remove_query_arg(['action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'], $sendback);
         wp_redirect($sendback);
         exit;
     } elseif (!empty($_REQUEST['_wp_http_referer'])) {
         wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), wp_unslash($_SERVER['REQUEST_URI'])));
         exit;
     }
     $list_table->prepare_items();
     require ABSPATH . 'wp-admin/admin-header.php';
     require __DIR__ . '/../views/list-table.php';
 }
开发者ID:brandonwamboldt,项目名称:wp-orm,代码行数:59,代码来源:AdminHelper.php


示例9: sv_render_status_column

function sv_render_status_column($column_name, $post_id)
{
    global $post;
    if ($column_name === 'status') {
        $currentPostStatus = $post->post_status;
        $statusObject = get_post_status_object($currentPostStatus);
        if ($statusObject != null) {
            printf('<mark class="%1$s tips" data-tip="%2$s">%3$s</mark>', $statusObject->name, $statusObject->label, $statusObject->label);
        } else {
            printf('<mark class="$1%s tips" data-tip="$1%s">$1%s</mark>', $currentPostStatus);
        }
    }
}
开发者ID:senviet,项目名称:VS-Status-Column,代码行数:13,代码来源:VSPost-status.php


示例10: get_comments_number

 /**
  * Hooks the WP get_comments_number filter to get the number of comments
  * across all posts in the translation group.
  *
  * @param int $count The number of comments on the single translation
  * @param int $post_id The post ID of the single translation
  * @return int The count of all comments on published posts in this translation group
  **/
 public function get_comments_number($count, $post_id)
 {
     $translations = bbl_get_post_translations($post_id);
     $count = 0;
     foreach ($translations as &$translation) {
         $post_status = get_post_status_object($translation->post_status);
         // FIXME: I'm not entirely sure about using publicly_queryable here… what I want to avoid is draft, private, etc statii.
         if ($post_status->publicly_queryable) {
             $count += $translation->comment_count;
         }
     }
     return $count;
 }
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:21,代码来源:class-comment.php


示例11: fix_table_edit_reqd_caps

 function fix_table_edit_reqd_caps($rs_reqd_caps, $orig_meta_cap, $_post, $object_type_obj)
 {
     foreach (array('edit', 'delete') as $op) {
         if (in_array($orig_meta_cap, array("{$op}_post", "{$op}_page"))) {
             $status_obj = get_post_status_object($_post->post_status);
             foreach (array('public' => 'published', 'private' => 'private') as $status_prop => $cap_suffix) {
                 if (!empty($status_obj->{$status_prop})) {
                     $cap_prop = "{$op}_{$cap_suffix}_posts";
                     $rs_reqd_caps[] = $object_type_obj->cap->{$cap_prop};
                     $GLOBALS['revisionary']->skip_revision_allowance = true;
                 }
             }
         }
     }
     return $rs_reqd_caps;
 }
开发者ID:joostrijneveld,项目名称:cscircles-wp-content,代码行数:16,代码来源:revisionary-helper_rs.php


示例12: mb_user_can

/**
 * Helper function for checking if a user can read forums, topics, or replies. We need this to handle 
 * users who are not logged in but should have permission to read (e.g, non-private forums).  This 
 * function is meant to be used in conjunction with a filter on `map_meta_cap`.
 *
 * @since  1.0.0
 * @access public
 * @param  int     $user_id
 * @param  string  $cap
 * @param  int     $post_id
 * @return bool
 */
function mb_user_can($user_id, $cap, $post_id)
{
    // @todo Check hierarchy.
    if (in_array($cap, array('read_forum', 'read_topic', 'read_reply'))) {
        if ('read_forum' === $cap) {
            $status_obj = get_post_status_object(mb_get_forum_status($post_id));
        } elseif ('read_topic' === $cap) {
            $status_obj = get_post_status_object(mb_get_topic_status($post_id));
        } elseif ('read_forum' === $cap) {
            $status_obj = get_post_status_object(mb_get_reply_status($post_id));
        }
        if (false === $status_obj->private && false === $status_obj->protected) {
            return true;
        }
    }
    return user_can($user_id, $cap, $post_id);
}
开发者ID:justintadlock,项目名称:message-board,代码行数:29,代码来源:capabilities.php


示例13: _pp_flt_map_media_meta_cap

function _pp_flt_map_media_meta_cap($caps, $cap, $user_id, $args)
{
    if (!empty($args[0])) {
        $post = is_object($args[0]) ? $args[0] : get_post($args[0]);
        if ($post && 'attachment' == $post->post_type) {
            if (!empty($post->post_parent)) {
                $post_status = get_post_status($post->ID);
            } elseif ('inherit' == $post->post_status) {
                $post_status = pp_get_option('unattached_files_private') ? 'private' : 'publish';
            } else {
                $post_status = $post->post_status;
            }
            $post_type = get_post_type_object($post->post_type);
            $post_author_id = $post->post_author;
            $caps = array_diff($caps, (array) $cap);
            switch ($cap) {
                case 'read_post':
                case 'read_page':
                    $status_obj = get_post_status_object($post_status);
                    if ($status_obj->public || $status_obj->private && $user_id == $post_author_id) {
                        $caps[] = $post_type->cap->read;
                        break;
                    }
                    // If no author set yet, default to current user for cap checks.
                    if (!$post_author_id) {
                        $post_author_id = $user_id;
                    }
                    if ($status_obj->private) {
                        $caps[] = $post_type->cap->read_private_posts;
                    } else {
                        $caps = map_meta_cap('edit_post', $user_id, $post->ID);
                    }
                    $caps = apply_filters('pp_map_attachment_read_caps', $caps, $post, $user_id);
                    break;
                default:
                    require_once dirname(__FILE__) . '/media-edit-metacap-workaround_pp.php';
                    $args = array_merge($args, compact('post', 'post_status', 'post_type', 'post_author_id'));
                    $caps = _ppff_flt_map_media_edit_meta_cap($caps, $cap, $user_id, $args);
            }
        }
    }
    return $caps;
}
开发者ID:severnrescue,项目名称:web,代码行数:43,代码来源:media-metacap-workaround_pp.php


示例14: action_manage_posts_custom_column

 /**
  * Produce the column values for the custom columns we created
  */
 function action_manage_posts_custom_column($column_name, $ticket_id)
 {
     switch ($column_name) {
         case 'updated':
             $modified_gmt = get_post_modified_time('U', true, $ticket_id);
             echo sprintf(__('%s ago', 'supportflow'), human_time_diff($modified_gmt));
             break;
         case 'sf_excerpt':
             $replies = SupportFlow()->get_ticket_replies($ticket_id, array('posts_per_page' => 1, 'order' => 'ASC'));
             if (!isset($replies[0])) {
                 echo '—';
                 break;
             }
             $first_reply = $replies[0]->post_content;
             if (strlen($first_reply) > 50) {
                 $first_reply = substr($first_reply, 0, 50);
             }
             echo $first_reply;
             break;
         case 'customers':
             $customers = SupportFlow()->get_ticket_customers($ticket_id, array('fields' => 'emails'));
             if (empty($customers)) {
                 echo '—';
                 break;
             }
             foreach ($customers as $key => $customer_email) {
                 $args = array(SupportFlow()->customers_tax => SupportFlow()->get_email_hash($customer_email), 'post_type' => SupportFlow()->post_type);
                 $customer_photo = get_avatar($customer_email, 16);
                 $customer_link = '<a class="customer_link" href="' . esc_url(add_query_arg($args, admin_url('edit.php'))) . '">' . $customer_email . '</a>';
                 $customers[$key] = $customer_photo . '&nbsp;' . $customer_link;
             }
             echo implode('<br />', $customers);
             break;
         case 'status':
             $post_status = get_post_status($ticket_id);
             $args = array('post_type' => SupportFlow()->post_type, 'post_status' => $post_status);
             $status_name = get_post_status_object($post_status)->label;
             $filter_link = add_query_arg($args, admin_url('edit.php'));
             echo '<a href="' . esc_url($filter_link) . '">' . esc_html($status_name) . '</a>';
             break;
         case 'email':
             $email_account_id = get_post_meta($ticket_id, 'email_account', true);
             $email_accounts = SupportFlow()->extend->email_accounts->get_email_accounts();
             $args = array('post_type' => SupportFlow()->post_type, 'email_account' => $email_account_id);
             if (!isset($email_accounts[$email_account_id])) {
                 echo '—';
                 break;
             }
             $email_account_username = $email_accounts[$email_account_id]['username'];
             $filter_link = add_query_arg($args, admin_url('edit.php'));
             echo '<a href="' . esc_url($filter_link) . '">' . esc_html($email_account_username) . '</a>';
             break;
         case 'sf_replies':
             $replies = SupportFlow()->get_ticket_replies_count($ticket_id);
             echo '<div class="post-com-count-wrapper">';
             echo "<span class='replies-count'>{$replies}</span>";
             echo '</div>';
             break;
         case 'created':
             $created_time = get_the_time(get_option('time_format') . ' T', $ticket_id);
             $created_date = get_the_time(get_option('date_format'), $ticket_id);
             echo sprintf(__('%s<br />%s', 'supportflow'), $created_time, $created_date);
             break;
     }
 }
开发者ID:nagyistoce,项目名称:supportflow,代码行数:68,代码来源:class-supportflow-admin.php


示例15: parse_column

 /**
  * Parsing the column based on the $column_name.
  *
  * @param string    $column_name
  * @param stdobject $rec
  *
  * @return string
  */
 protected function parse_column($column_name, $rec)
 {
     static $date_format;
     if ($date_format == null) {
         $date_format = get_option('date_format');
     }
     switch ($column_name) {
         case 'col_page_title':
             $column_value = $this->parse_page_title_column($rec);
             break;
         case 'col_page_slug':
             $permalink = get_permalink($rec->ID);
             $display_slug = str_replace(get_bloginfo('url'), '', $permalink);
             $column_value = sprintf('<a href="%2$s" target="_blank">%1$s</a>', stripslashes($display_slug), esc_url($permalink));
             break;
         case 'col_post_type':
             $post_type = get_post_type_object($rec->post_type);
             $column_value = $post_type->labels->singular_name;
             break;
         case 'col_post_status':
             $post_status = get_post_status_object($rec->post_status);
             $column_value = $post_status->label;
             break;
         case 'col_post_date':
             $column_value = date_i18n($date_format, strtotime($rec->post_date));
             break;
         case 'col_row_action':
             $column_value = sprintf('<a href="#" class="wpseo-save" data-id="%1$s">Save</a> | <a href="#" class="wpseo-save-all">Save All</a>', $rec->ID);
             break;
     }
     if (!empty($column_value)) {
         return $column_value;
     }
 }
开发者ID:KevinFairbanks,项目名称:ymbeseo,代码行数:42,代码来源:class-bulk-editor-list-table.php


示例16: _wp_translate_postdata

/**
 * Rename $_POST data from form names to DB post columns.
 *
 * Manipulates $_POST directly.
 *
 * @package WordPress
 * @since 2.6.0
 *
 * @param bool $update Are we updating a pre-existing post?
 * @param array $post_data Array of post data. Defaults to the contents of $_POST.
 * @return object|bool WP_Error on failure, true on success.
 */
function _wp_translate_postdata($update = false, $post_data = null)
{
    if (empty($post_data)) {
        $post_data =& $_POST;
    }
    if ($update) {
        $post_data['ID'] = (int) $post_data['post_ID'];
    }
    $ptype = get_post_type_object($post_data['post_type']);
    if ($update && !current_user_can('edit_post', $post_data['ID'])) {
        if ('page' == $post_data['post_type']) {
            return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to edit pages as this user.'));
        } else {
            return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to edit posts as this user.'));
        }
    } elseif (!$update && !current_user_can($ptype->cap->create_posts)) {
        if ('page' == $post_data['post_type']) {
            return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to create pages as this user.'));
        } else {
            return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to create posts as this user.'));
        }
    }
    if (isset($post_data['content'])) {
        $post_data['post_content'] = $post_data['content'];
    }
    if (isset($post_data['excerpt'])) {
        $post_data['post_excerpt'] = $post_data['excerpt'];
    }
    if (isset($post_data['parent_id'])) {
        $post_data['post_parent'] = (int) $post_data['parent_id'];
    }
    if (isset($post_data['trackback_url'])) {
        $post_data['to_ping'] = $post_data['trackback_url'];
    }
    $post_data['user_ID'] = get_current_user_id();
    if (!empty($post_data['post_author_override'])) {
        $post_data['post_author'] = (int) $post_data['post_author_override'];
    } else {
        if (!empty($post_data['post_author'])) {
            $post_data['post_author'] = (int) $post_data['post_author'];
        } else {
            $post_data['post_author'] = (int) $post_data['user_ID'];
        }
    }
    if (isset($post_data['user_ID']) && $post_data['post_author'] != $post_data['user_ID'] && !current_user_can($ptype->cap->edit_others_posts)) {
        if ($update) {
            if ('page' == $post_data['post_type']) {
                return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to edit pages as this user.'));
            } else {
                return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to edit posts as this user.'));
            }
        } else {
            if ('page' == $post_data['post_type']) {
                return new WP_Error('edit_others_pages', __('Sorry, you are not allowed to create pages as this user.'));
            } else {
                return new WP_Error('edit_others_posts', __('Sorry, you are not allowed to create posts as this user.'));
            }
        }
    }
    if (!empty($post_data['post_status'])) {
        $post_data['post_status'] = sanitize_key($post_data['post_status']);
        // No longer an auto-draft
        if ('auto-draft' === $post_data['post_status']) {
            $post_data['post_status'] = 'draft';
        }
        if (!get_post_status_object($post_data['post_status'])) {
            unset($post_data['post_status']);
        }
    }
    // What to do based on which button they pressed
    if (isset($post_data['saveasdraft']) && '' != $post_data['saveasdraft']) {
        $post_data['post_status'] = 'draft';
    }
    if (isset($post_data['saveasprivate']) && '' != $post_data['saveasprivate']) {
        $post_data['post_status'] = 'private';
    }
    if (isset($post_data['publish']) && '' != $post_data['publish'] && (!isset($post_data['post_status']) || $post_data['post_status'] != 'private')) {
        $post_data['post_status'] = 'publish';
    }
    if (isset($post_data['advanced']) && '' != $post_data['advanced']) {
        $post_data['post_status'] = 'draft';
    }
    if (isset($post_data['pending']) && '' != $post_data['pending']) {
        $post_data['post_status'] = 'pending';
    }
    if (isset($post_data['ID'])) {
        $post_id = $post_data['ID'];
    } else {
//.........这里部分代码省略.........
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:101,代码来源:post.php


示例17: meta_edit_table


//.........这里部分代码省略.........
         default:
             return false;
             break;
     }
     if ($total_objects < 1) {
         return false;
     }
     echo "\n<div class='su-meta-edit-table'>\n";
     $page_links = paginate_links(array('base' => add_query_arg($type . '_paged', '%#%') . '#' . $tab, 'format' => '', 'prev_text' => __('&laquo;'), 'next_text' => __('&raquo;'), 'total' => $num_pages, 'current' => $pagenum));
     if ($page_links) {
         $page_links_text = '<div class="tablenav"><div class="tablenav-pages">';
         $page_links_text .= sprintf('<span class="displaying-num">' . __('Displaying %s&#8211;%s of %s') . '</span>%s', number_format_i18n(($pagenum - 1) * $per_page + 1), number_format_i18n(min($pagenum * $per_page, $total_objects)), number_format_i18n($total_objects), $page_links);
         $page_links_text .= "</div></div>\n";
         echo $page_links_text;
     } else {
         $page_links_text = '';
     }
     //Get object identification headers
     $headers = array('actions' => __('Actions', 'seo-ultimate'), 'id' => __('ID', 'seo-ultimate'), 'name' => $type_label);
     //Get meta field headers
     foreach ($fields as $field) {
         $headers[$field['name']] = $field['label'];
     }
     //Output all headers
     $this->admin_wftable_start($headers);
     //Output rows
     foreach ($objects as $object) {
         switch ($genus) {
             case 'post':
                 $id = intval($object->ID);
                 $name = $object->post_title;
                 $view_url = get_permalink($id);
                 $edit_url = get_edit_post_link($id);
                 $status_obj = get_post_status_object($object->post_status);
                 switch ($object->post_status) {
                     case 'publish':
                         $status = '';
                         break;
                     case 'inherit':
                         $status = '';
                         break;
                     case 'auto-draft':
                         continue;
                         break;
                     default:
                         $status = $status_obj->label;
                         break;
                 }
                 if ($status) {
                     $name .= "<span class='su-meta-table-post-status'> &mdash; {$status}</span>";
                 }
                 break;
             case 'term':
                 $id = intval($object->term_id);
                 $name = $object->name;
                 $view_url = get_term_link($id, $type);
                 $edit_url = suwp::get_edit_term_link($id, $type);
                 break;
             default:
                 return false;
                 break;
         }
         $view_url = su_esc_attr($view_url);
         $edit_url = su_esc_attr($edit_url);
         $actions = array(sprintf('<a href="%s">%s</a>', $view_url, __('View', 'seo-ultimate')));
         if ($edit_url) {
开发者ID:grantschulte,项目名称:suna-wordpress,代码行数:67,代码来源:class.su-module.php


示例18: map_meta_cap


//.........这里部分代码省略.........
                }
            } else {
                // The user is trying to edit someone else's post.
                $caps[] = $post_type->cap->edit_others_posts;
                // The post is published, extra cap required.
                if ('publish' == $post->post_status) {
                    $caps[] = $post_type->cap->edit_published_posts;
                } elseif ('private' == $post->post_status) {
                    $caps[] = $post_type->cap->edit_private_posts;
                }
            }
            break;
        case 'read_post':
        case 'read_page':
            $post = get_post($args[0]);
            if ('revision' == $post->post_type) {
                $post = get_post($post->post_parent);
            }
            $post_type = get_post_type_object($post->post_type);
            if (!$post_type) {
                /* 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;
            }
            if (!$post_type->map_meta_cap) {
                $caps[] = $post_type->cap->{$cap};
                // Prior to 3.1 we would re-call map_meta_cap here.
                if ('read_post' == $cap) {
                    $cap = $post_type->cap->{$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 && $user_id == $post->post_author) {
                $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 'publish_post':
            $post = get_post($args[0]);
            $post_type = get_post_type_object($post->post_type);
            if (!$post_type) {
                /* 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.
开发者ID:NeftaliYagua,项目名称:WordPress,代码行数:67,代码来源:capabilities-functions.php


示例19: display_rows

 function display_rows()
 {
     $records = $this->items;
     list($columns, $hidden) = $this->get_column_info();
     if (is_array($records) && $records !== array() && (is_array($columns) && $columns !== array())) {
         foreach ($records as $rec) {
             echo '<tr id="record_' . $rec->ID . '">';
             foreach ($columns as $column_name => $column_display_name) {
                 $class = sprintf('class="%1$s column-%1$s"', $column_name);
                 $style = '';
                 if (in_array($column_name, $hidden)) {
                     $style = ' style="display:none;"';
                 }
                 $attributes = $class . $style;
                 switch ($column_name) {
                     case 'col_page_title':
                         echo sprintf('<td %2$s><strong>%1$s</strong>', stripslashes($rec->post_title), $attributes);
                         $post_type_object = get_post_type_object($rec->post_type);
                         $can_edit_post = current_user_can($post_type_object->cap->edit_post, $rec->ID);
                         $actions = array();
                         if ($can_edit_post && 'trash' != $rec->post_status) {
                             $actions['edit'] = '<a href="' . esc_url(get_edit_post_link($rec->ID, true)) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
                         }
                         if ($post_type_object->public) {
                             if (in_array($rec->post_status, array('pending', 'draft', 'future'))) {
                                 if ($can_edit_post) {
                                     $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($rec->ID))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $rec->post_title)) . '">' . __('Preview') . '</a>';
                                 }
                             } elseif ('trash' != $rec->post_status) {
                                 $actions['view'] = '<a href="' . esc_url(get_permalink($rec->ID)) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $rec->post_title)) . '" rel="bookmark">' . __('View') . '</a>';
                             }
                         }
                         echo $this->row_actions($actions);
                         echo '</td>';
                         break;
                     case 'col_page_slug':
                         $permalink = get_permalink($rec->ID);
                         $display_slug = str_replace(get_bloginfo('url'), '', $permalink);
                         echo sprintf('<td %2$s><a href="%3$s" target="_blank">%1$s</a></td>', stripslashes($display_slug), $attributes, esc_url($permalink));
                         break;
                     case 'col_post_type':
                         $post_type = get_post_type_object($rec->post_type);
                         echo sprintf('<td %2$s>%1$s</td>', $post_type->labels->singular_name, $attributes);
                         break;
                     case 'col_post_status':
                         $post_status = get_post_status_object($rec->post_status);
                         echo sprintf('<td %2$s>%1$s</td>', $post_status->label, $attributes);
                         break;
                     case 'col_existing_yoast_seo_title':
                         echo sprintf('<td %2$s id="wpseo-existing-title-%3$s">%1$s</td>', $rec->seo_title ? $rec->seo_title : '', $attributes, $rec->ID);
                         break;
                     case 'col_new_yoast_seo_title':
                         $input = sprintf('<input type="text" id="%1$s" name="%1$s" class="wpseo-new-title" data-id="%2$s" />', 'wpseo-new-title-' . $rec->ID, $rec->ID);
                         echo sprintf('<td %2$s>%1$s</td>', $input, $attributes);
                         break;
                     case 'col_row_action':
                         $actions = sprintf('<a href="#" class="wpseo-save" data-id="%1$s">Save</a> | <a href="#" class="wpseo-save-all">Save All</a>', $rec->ID);
                         echo sprintf('<td %2$s>%1$s</td>', $actions, $attributes);
                         break;
                 }
             }
             echo '</tr>';
         }
     }
 }
开发者ID:kyme-online,项目名称:Ramesh-Photography,代码行数:65,代码来源:class-bulk-title-editor-list-table.php


示例20: user_can_view_post

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP get_post_statuses函数代码示例发布时间:2022-05-15
下一篇:
PHP get_post_status函数代码示例发布时间: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