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


PHP get_default_comment_status函数代码示例

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


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

示例1: wp_insert_post


//.........这里部分代码省略.........
        if (!in_array($post_status, array('draft', 'pending', 'auto-draft'))) {
            $post_date_gmt = get_gmt_from_date($post_date);
        } else {
            $post_date_gmt = '0000-00-00 00:00:00';
        }
    } else {
        $post_date_gmt = $postarr['post_date_gmt'];
    }
    if ($update || '0000-00-00 00:00:00' == $post_date) {
        $post_modified = current_time('mysql');
        $post_modified_gmt = current_time('mysql', 1);
    } else {
        $post_modified = $post_date;
        $post_modified_gmt = $post_date_gmt;
    }
    if ('attachment' !== $post_type) {
        if ('publish' == $post_status) {
            $now = gmdate('Y-m-d H:i:59');
            if (mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false)) {
                $post_status = 'future';
            }
        } elseif ('future' == $post_status) {
            $now = gmdate('Y-m-d H:i:59');
            if (mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false)) {
                $post_status = 'publish';
            }
        }
    }
    // Comment status.
    if (empty($postarr['comment_status'])) {
        if ($update) {
            $comment_status = 'closed';
        } else {
            $comment_status = get_default_comment_status($post_type);
        }
    } else {
        $comment_status = $postarr['comment_status'];
    }
    // These variables are needed by compact() later.
    $post_content_filtered = $postarr['post_content_filtered'];
    $post_author = isset($postarr['post_author']) ? $postarr['post_author'] : $user_id;
    $ping_status = empty($postarr['ping_status']) ? get_default_comment_status($post_type, 'pingback') : $postarr['ping_status'];
    $to_ping = isset($postarr['to_ping']) ? sanitize_trackback_urls($postarr['to_ping']) : '';
    $pinged = isset($postarr['pinged']) ? $postarr['pinged'] : '';
    $import_id = isset($postarr['import_id']) ? $postarr['import_id'] : 0;
    /*
     * The 'wp_insert_post_parent' filter expects all variables to be present.
     * Previously, these variables would have already been extracted
     */
    if (isset($postarr['menu_order'])) {
        $menu_order = (int) $postarr['menu_order'];
    } else {
        $menu_order = 0;
    }
    $post_password = isset($postarr['post_password']) ? $postarr['post_password'] : '';
    if ('private' == $post_status) {
        $post_password = '';
    }
    if (isset($postarr['post_parent'])) {
        $post_parent = (int) $postarr['post_parent'];
    } else {
        $post_parent = 0;
    }
    /**
     * Filter the post parent -- used to check for and prevent hierarchy loops.
     *
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:67,代码来源:post.php

示例2: get_default_post_to_edit

/**
 * Default post information to use when populating the "Write Post" form.
 *
 * @since 2.0.0
 *
 * @param string $post_type    Optional. A post type string. Default 'post'.
 * @param bool   $create_in_db Optional. Whether to insert the post into database. Default false.
 * @return WP_Post Post object containing all the default post data as attributes
 */
function get_default_post_to_edit($post_type = 'post', $create_in_db = false)
{
    $post_title = '';
    if (!empty($_REQUEST['post_title'])) {
        $post_title = esc_html(wp_unslash($_REQUEST['post_title']));
    }
    $post_content = '';
    if (!empty($_REQUEST['content'])) {
        $post_content = esc_html(wp_unslash($_REQUEST['content']));
    }
    $post_excerpt = '';
    if (!empty($_REQUEST['excerpt'])) {
        $post_excerpt = esc_html(wp_unslash($_REQUEST['excerpt']));
    }
    if ($create_in_db) {
        $post_id = wp_insert_post(array('post_title' => __('Auto Draft'), 'post_type' => $post_type, 'post_status' => 'auto-draft'));
        $post = get_post($post_id);
        if (current_theme_supports('post-formats') && post_type_supports($post->post_type, 'post-formats') && get_option('default_post_format')) {
            set_post_format($post, get_option('default_post_format'));
        }
    } else {
        $post = new stdClass();
        $post->ID = 0;
        $post->post_author = '';
        $post->post_date = '';
        $post->post_date_gmt = '';
        $post->post_password = '';
        $post->post_name = '';
        $post->post_type = $post_type;
        $post->post_status = 'draft';
        $post->to_ping = '';
        $post->pinged = '';
        $post->comment_status = get_default_comment_status($post_type);
        $post->ping_status = get_default_comment_status($post_type, 'pingback');
        $post->post_pingback = get_option('default_pingback_flag');
        $post->post_category = get_option('default_category');
        $post->page_template = 'default';
        $post->post_parent = 0;
        $post->menu_order = 0;
        $post = new WP_Post($post);
    }
    /**
     * Filters the default post content initially used in the "Write Post" form.
     *
     * @since 1.5.0
     *
     * @param string  $post_content Default post content.
     * @param WP_Post $post         Post object.
     */
    $post->post_content = apply_filters('default_content', $post_content, $post);
    /**
     * Filters the default post title initially used in the "Write Post" form.
     *
     * @since 1.5.0
     *
     * @param string  $post_title Default post title.
     * @param WP_Post $post       Post object.
     */
    $post->post_title = apply_filters('default_title', $post_title, $post);
    /**
     * Filters the default post excerpt initially used in the "Write Post" form.
     *
     * @since 1.5.0
     *
     * @param string  $post_excerpt Default post excerpt.
     * @param WP_Post $post         Post object.
     */
    $post->post_excerpt = apply_filters('default_excerpt', $post_excerpt, $post);
    return $post;
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:79,代码来源:post.php

示例3: mw_editPost


//.........这里部分代码省略.........
     }
     $post_author = $postdata['post_author'];
     // Only set the post_author if one is set.
     if (isset($content_struct['wp_author_id'])) {
         // Check permissions if attempting to switch author to or from another user.
         if ($user->ID != $content_struct['wp_author_id'] || $user->ID != $post_author) {
             switch ($post_type) {
                 case 'post':
                     if (!current_user_can('edit_others_posts')) {
                         return new IXR_Error(401, __('You are not allowed to change the post author as this user.'));
                     }
                     break;
                 case 'page':
                     if (!current_user_can('edit_others_pages')) {
                         return new IXR_Error(401, __('You are not allowed to change the page author as this user.'));
                     }
                     break;
                 default:
                     return new IXR_Error(401, __('Invalid post type'));
             }
             $post_author = $content_struct['wp_author_id'];
         }
     }
     if (isset($content_struct['mt_allow_comments'])) {
         if (!is_numeric($content_struct['mt_allow_comments'])) {
             switch ($content_struct['mt_allow_comments']) {
                 case 'closed':
                     $comment_status = 'closed';
                     break;
                 case 'open':
                     $comment_status = 'open';
                     break;
                 default:
                     $comment_status = get_default_comment_status($post_type);
                     break;
             }
         } else {
             switch ((int) $content_struct['mt_allow_comments']) {
                 case 0:
                 case 2:
                     $comment_status = 'closed';
                     break;
                 case 1:
                     $comment_status = 'open';
                     break;
                 default:
                     $comment_status = get_default_comment_status($post_type);
                     break;
             }
         }
     }
     if (isset($content_struct['mt_allow_pings'])) {
         if (!is_numeric($content_struct['mt_allow_pings'])) {
             switch ($content_struct['mt_allow_pings']) {
                 case 'closed':
                     $ping_status = 'closed';
                     break;
                 case 'open':
                     $ping_status = 'open';
                     break;
                 default:
                     $ping_status = get_default_comment_status($post_type, 'pingback');
                     break;
             }
         } else {
             switch ((int) $content_struct["mt_allow_pings"]) {
开发者ID:prettygenuis,项目名称:PURPLE-Co.,代码行数:67,代码来源:class-wp-xmlrpc-server.php

示例4: __

     $error_msg = false;
     // For output of the quickdraft dashboard widget
     require_once ABSPATH . 'wp-admin/includes/dashboard.php';
     if (!wp_verify_nonce($nonce, 'add-post')) {
         $error_msg = __('Unable to submit this form, please refresh and try again.');
     }
     if (!current_user_can(get_post_type_object('post')->cap->create_posts)) {
         exit;
     }
     if ($error_msg) {
         return wp_dashboard_quick_press($error_msg);
     }
     $post = get_post($_REQUEST['post_ID']);
     check_admin_referer('add-' . $post->post_type);
     $_POST['comment_status'] = get_default_comment_status($post->post_type);
     $_POST['ping_status'] = get_default_comment_status($post->post_type, 'pingback');
     edit_post();
     wp_dashboard_quick_press();
     exit;
 case 'postajaxpost':
 case 'post':
     check_admin_referer('add-' . $post_type);
     $post_id = 'postajaxpost' == $action ? edit_post() : write_post();
     redirect_post($post_id);
     exit;
 case 'edit':
     $editing = true;
     if (empty($post_id)) {
         wp_redirect(admin_url('post.php'));
         exit;
     }
开发者ID:pbearne,项目名称:contrib2core,代码行数:31,代码来源:post.php

示例5: get_default_comment_status

    }
}
// Comment status.
if (empty($postarr['comment_status'])) {
    if ($update) {
        $comment_status = 'closed';
    } else {
        $comment_status = get_default_comment_status($post_type);
    }
} else {
    $comment_status = $postarr['comment_status'];
}
// These variables are needed by compact() later.
$post_content_filtered = $postarr['post_content_filtered'];
$post_author = isset($postarr['post_author']) ? $postarr['post_author'] : $user_id;
$ping_status = empty($postarr['ping_status']) ? get_default_comment_status($post_type, 'pingback') : $postarr['ping_status'];
$to_ping = isset($postarr['to_ping']) ? sanitize_trackback_urls($postarr['to_ping']) : '';
$pinged = isset($postarr['pinged']) ? $postarr['pinged'] : '';
$import_id = isset($postarr['import_id']) ? $postarr['import_id'] : 0;
/*
 * The 'wp_insert_post_parent' filter expects all variables to be present.
 * Previously, these variables would have already been extracted
 */
if (isset($postarr['menu_order'])) {
    $menu_order = (int) $postarr['menu_order'];
} else {
    $menu_order = 0;
}
$post_password = isset($postarr['post_password']) ? $postarr['post_password'] : '';
if ('private' == $post_status) {
    $post_password = '';
开发者ID:supermt,项目名称:WordPressAPI,代码行数:31,代码来源:postin.php


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