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


PHP get_post_status函数代码示例

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


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

示例1: sp_google_maps_shortcode_meta

function sp_google_maps_shortcode_meta()
{
    global $post;
    ?>
	<p>
		<strong>
			<label for="map_shortcode"><?php 
    _e("ShortCode For This Map", 'sp_google_maps');
    ?>
</label>
		</strong>
	</p>
	<?php 
    if (get_post_status($post->ID) === "publish") {
        ?>
	<input type="text" id="map_shortcode" value='[SPGM id="<?php 
        echo $post->ID;
        ?>
"]' onclick="select();" />
	<br>
	<code><?php 
        _e('Copy and Paste This ShortCode To Use This Map', 'sp_google_maps');
        ?>
</code>
	<?php 
    } else {
        ?>
	<p><small><?php 
        _e('ShortCode will apear after first save.', 'sp_google_maps');
        ?>
</small></p>
	<?php 
    }
}
开发者ID:samepage33,项目名称:SP-Google-Maps,代码行数:34,代码来源:metaboxes.php

示例2: kamino_sanitize_dropdown_pages

/**
 * Drop-down Pages sanitization callback example.
 *
 * - Sanitization: dropdown-pages
 * - Control: dropdown-pages
 *
 * Sanitization callback for 'dropdown-pages' type controls. This callback sanitizes `$page_id`
 * as an absolute integer, and then validates that $input is the ID of a published page.
 *
 * @see absint() https://developer.wordpress.org/reference/functions/absint/
 * @see get_post_status() https://developer.wordpress.org/reference/functions/get_post_status/
 *
 * @param int $page Page ID.
 * @param WP_Customize_Setting $setting Setting instance.
 *
 * @return int|string Page ID if the page is published; otherwise, the setting default.
 */
function kamino_sanitize_dropdown_pages($page_id, $setting)
{
    // Ensure $input is an absolute integer.
    $page_id = absint($page_id);
    // If $page_id is an ID of a published page, return it; otherwise, return the default.
    return 'publish' == get_post_status($page_id) ? $page_id : $setting->default;
}
开发者ID:sixteenbit,项目名称:kamino,代码行数:24,代码来源:sanitization.php

示例3: x_shortcode_toc_item

function x_shortcode_toc_item($atts)
{
    extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'title' => '', 'page' => ''), $atts, 'x_toc_item'));
    $id = $id != '' ? 'id="' . esc_attr($id) . '"' : '';
    $class = $class != '' ? 'x-toc-item ' . esc_attr($class) : 'x-toc-item';
    $style = $style != '' ? 'style="' . $style . '"' : '';
    $title = $title != '' ? $title : '';
    switch ($page) {
        case 0:
            $page = '';
            break;
        case 1:
            $page = '';
            break;
        default:
            $page = $page;
            if (get_post_status(get_the_ID()) == "draft") {
                $page = '&page=' . $page;
            } else {
                $page = get_the_ID() == get_option('page_on_front') ? 'page/' . $page . '/' : $page . '/';
            }
    }
    $link = esc_url(get_permalink());
    $output = "<li {$id} class=\"{$class}\" {$style}><a href=" . $link . $page . " title=\"Go to {$title}\">" . $title . '</a></li>';
    return $output;
}
开发者ID:elinberg,项目名称:ericlinberg,代码行数:26,代码来源:toc.php

示例4: problogger_jumbotron

 static function problogger_jumbotron()
 {
     global $post;
     if (!$post) {
         return false;
     }
     $show = get_post_meta($post->ID, '_problogger_meta_jumbotron_show_key', true);
     if ($show == '2') {
         return false;
     }
     $the_post_id = get_post_meta($post->ID, '_problogger_meta_jumbotron_post_id', true);
     if (!get_post_status($the_post_id)) {
         return false;
     }
     $the_post = get_post($the_post_id);
     $width = problogger_option('jumbotron_width', 'container');
     $the_bg_color = get_post_meta($the_post->ID, '_jumbotron_meta_color_key', true);
     $the_styles = 'style="' . ($the_bg_color ? 'background-color: ' . $the_bg_color . '; ' : '') . 'border-radius: 0;"';
     $the_content = apply_filters('the_content', $the_post->post_content);
     $output = $the_content;
     switch ($width) {
         case 'full':
             $output = sprintf('<section class="jumbotron" %s>%s</section>', $the_styles, $the_content);
             break;
         case 'fullcontain':
             $output = sprintf('<section class="jumbotron" %s><div class="container">%s</div></section>', $the_styles, $the_content);
             break;
         case 'container':
         default:
             $output = sprintf('<section class="jumbotron container" %s>%s</section>', $the_styles, $the_content);
             break;
     }
     return print $output;
 }
开发者ID:nlk-sites,项目名称:nectar7,代码行数:34,代码来源:class.problogger_partials.php

示例5: medium_save_video_meta

/**
 * Saves the video embed code on post save
 *
 * @since 4.0
 */
function medium_save_video_meta($post_id)
{
    global $post;
    // Return early if this is a newly created post that hasn't been saved yet.
    if ('auto-draft' == get_post_status($post_id)) {
        return $post_id;
    }
    // Check if the user intended to change this value.
    if (!isset($_POST['medium_video_box_nonce']) || !wp_verify_nonce($_POST['medium_video_box_nonce'], plugin_basename(__FILE__))) {
        return $post_id;
    }
    // Get post type object
    $post_type = get_post_type_object($post->post_type);
    // Check if user has permission
    if (!current_user_can($post_type->cap->edit_post, $post_id)) {
        return $post_id;
    }
    // Get posted data and sanitize it
    $new_video = isset($_POST['medium_video_field']) ? $_POST['medium_video_field'] : '';
    // Get existing video
    $video = get_post_meta($post_id, 'video', true);
    // If a new video was submitted and there was no previous one, add it
    if ($new_video && '' == $video) {
        add_post_meta($post_id, 'video', $new_video, true);
    } elseif ($new_video && $new_video != $video) {
        update_post_meta($post_id, 'video', $new_video);
    } elseif ('' == $new_video && $video) {
        delete_post_meta($post_id, 'video', $video);
    }
}
开发者ID:newscloud,项目名称:medium,代码行数:35,代码来源:metabox.php

示例6: ajax_post

 function ajax_post()
 {
     require_once ABSPATH . '/wp-admin/includes/post.php';
     if (!wp_verify_nonce($_POST['_wpnonce'], 'update-post_' . $_POST['post_ID'])) {
         wp_send_json_error(array('message' => __('You are not allowed to edit this item.')));
     }
     $_POST['post_title'] = strip_tags($_POST['post_title']);
     $post_id = edit_post();
     if (isset($_POST['save']) || isset($_POST['publish'])) {
         $status = get_post_status($post_id);
         if (isset($_POST['publish'])) {
             switch ($status) {
                 case 'pending':
                     $message = 8;
                     break;
                 case 'future':
                     $message = 9;
                     break;
                 default:
                     $message = 6;
             }
         } else {
             $message = 'draft' == $status ? 10 : 1;
         }
     } else {
         $message = 4;
     }
     $post = get_post($post_id);
     wp_send_json_success(array('message' => $this->get_message($post, $message), 'post' => $post, 'processedPostContent' => apply_filters('the_content', $post->post_content)));
 }
开发者ID:foxpcteam,项目名称:wp-front-end-editor,代码行数:30,代码来源:class-fee.php

示例7: redirect_post

/**
 * Redirect to previous page.
 *
 * @param int $post_id Optional. Post ID.
 */
function redirect_post($post_id = '', $_url)
{
    $_url = esc_url(add_query_arg('form', $post_id, $_url));
    if (isset($_POST['save']) || isset($_POST['publish'])) {
        $status = get_post_status($post_id);
        if (isset($_POST['publish'])) {
            switch ($status) {
                case 'pending':
                    $message = 8;
                    break;
                case 'future':
                    $message = 9;
                    break;
                default:
                    $message = 6;
            }
        } else {
            $message = 'draft' == $status ? 10 : 1;
        }
        $location = add_query_arg('message', $message, $_url);
    } else {
        $location = add_query_arg('message', 4, $_url);
    }
    wp_redirect(esc_url($location));
    exit;
}
开发者ID:rebeccayshen,项目名称:kitlist,代码行数:31,代码来源:edit-form.php

示例8: send_with_donation_id

 /**
  * Static method that is fired right after a donation is completed, sending the donation receipt.
  *
  * @param   int     $donation_id
  * @return  boolean
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function send_with_donation_id($donation_id)
 {
     if (!charitable_get_helper('emails')->is_enabled_email(self::get_email_id())) {
         return false;
     }
     if (!charitable_is_approved_status(get_post_status($donation_id))) {
         return false;
     }
     $donation = charitable_get_donation($donation_id);
     if (!is_object($donation) || 0 == count($donation->get_campaign_donations())) {
         return false;
     }
     if (!apply_filters('charitable_send_' . self::get_email_id(), true, $donation)) {
         return false;
     }
     $email = new Charitable_Email_New_Donation(array('donation' => $donation));
     /**
      * Don't resend the email.
      */
     if ($email->is_sent_already($donation_id)) {
         return false;
     }
     $sent = $email->send();
     /**
      * Log that the email was sent.
      */
     if (apply_filters('charitable_log_email_send', true, self::get_email_id(), $email)) {
         $email->log($donation_id, $sent);
     }
     return true;
 }
开发者ID:helgatheviking,项目名称:Charitable,代码行数:40,代码来源:class-charitable-email-new-donation.php

示例9: rockAjax_save

 function rockAjax_save()
 {
     if (!isset($_POST['serializedArray'])) {
         return;
     }
     if (!is_admin()) {
         return;
     }
     // get the submitted parameters
     $postID = (int) $_POST['postID'];
     if (!is_string(get_post_status($postID))) {
         return;
     }
     $array = $_POST['serializedArray'];
     $_builder_in_use = isset($_POST['_builder_in_use']) ? $_POST['_builder_in_use'] : 'false';
     $_featured_image_in_builder = $_POST['featuredInBuilder'];
     update_post_meta($postID, '_this_r_content', addslashes($array));
     update_post_meta($postID, '_builder_in_use', $_builder_in_use);
     update_post_meta($postID, '_featured_image_in_builder', $_featured_image_in_builder);
     // generate the response
     $response = json_encode(array('success' => true));
     // response output
     echo $response;
     exit;
 }
开发者ID:Neminath,项目名称:lastmile,代码行数:25,代码来源:builder-functions.php

示例10: show_pending_post_notice

 function show_pending_post_notice($user_id, $post_id)
 {
     if (get_post_status($post_id) == 'pending') {
         add_action('admin_footer', 'disable_review_button');
         add_action('admin_head', 'disable_review_button_styles');
     }
 }
开发者ID:developmentDM2,项目名称:The-Haute-Mess,代码行数:7,代码来源:contributor-settings.php

示例11: save

 public function save()
 {
     $parent = get_post($this->parent_id);
     $post_to_save = get_object_vars($parent);
     unset($post_to_save['ID']);
     unset($post_to_save['guid']);
     $post_to_save['post_parent'] = $parent->ID;
     $post_to_save['post_name'] = $parent->post_name . '-' . $this->start_date->format('Y-m-d');
     $duration = $this->get_duration();
     $end_date = $this->get_end_date();
     if (!empty($this->post_id)) {
         // update the existing post
         $post_to_save['ID'] = $this->post_id;
         if (get_post_status($this->post_id) == 'trash') {
             $post_to_save['post_status'] = get_post_status($this->post_id);
         }
         $this->post_id = wp_update_post($post_to_save);
         update_post_meta($this->post_id, '_EventStartDate', $this->start_date->format(DateSeriesRules::DATE_FORMAT));
         update_post_meta($this->post_id, '_EventEndDate', $end_date->format(DateSeriesRules::DATE_FORMAT));
         update_post_meta($this->post_id, '_EventDuration', $duration);
     } else {
         // add a new post
         $post_to_save['guid'] = esc_url(add_query_arg(array('eventDate' => $this->start_date->format('Y-m-d')), $parent->guid));
         $this->post_id = wp_insert_post($post_to_save);
         // save several queries by calling add_post_meta when we have a new post
         add_post_meta($this->post_id, '_EventStartDate', $this->start_date->format(DateSeriesRules::DATE_FORMAT));
         add_post_meta($this->post_id, '_EventEndDate', $end_date->format(DateSeriesRules::DATE_FORMAT));
         add_post_meta($this->post_id, '_EventDuration', $duration);
     }
     $this->copy_meta();
     // everything else
     $this->set_terms();
 }
开发者ID:pellio11,项目名称:ns-select-project,代码行数:33,代码来源:tribeeventspro-recurrenceinstance.php

示例12: valid

 public function valid()
 {
     if (!defined('WPDDL_DEVELOPMENT') && !defined('WPDDL_PRODUCTION')) {
         return false;
     }
     $type = self::get_type_name();
     if (isset(self::$layout_id[$type]) && self::$layout_id[$type] !== null && self::$layout_id !== false) {
         return true;
     }
     global $wpdb;
     $layouts_per_post_type = $wpdb->get_results("SELECT meta_value, post_id FROM {$wpdb->postmeta} WHERE meta_key = '_ddl_post_types_was_batched'");
     foreach ($layouts_per_post_type as $setting) {
         $setting->meta_value = unserialize($setting->meta_value);
         if (is_array($setting->meta_value) && in_array($type, $setting->meta_value)) {
             if (get_post_status($setting->post_id) == 'trash') {
                 continue;
             }
             $title = get_the_title($setting->post_id);
             self::$layout_id[$type] = $setting->post_id;
             self::$layout_name[$type] = $title;
             return true;
         }
     }
     self::$layout_id[$type] = false;
     self::$layout_name[$type] = false;
     return false;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:27,代码来源:template_exists.php

示例13: form_init

 function form_init()
 {
     global $ultimatemember;
     $http_post = 'POST' == $_SERVER['REQUEST_METHOD'];
     if ($http_post && !is_admin() && isset($_POST['form_id']) && is_numeric($_POST['form_id'])) {
         $this->form_id = $_POST['form_id'];
         $this->form_status = get_post_status($this->form_id);
         if ($this->form_status == 'publish') {
             /* save entire form as global */
             $this->post_form = $_POST;
             $this->post_form = $this->beautify($this->post_form);
             $this->form_data = $ultimatemember->query->post_data($this->form_id);
             $this->post_form['submitted'] = $this->post_form;
             $this->post_form = array_merge($this->form_data, $this->post_form);
             if ($_POST[$ultimatemember->honeypot] != '') {
                 wp_die('Hello, spam bot!');
             }
             if (!in_array($this->form_data['mode'], array('login'))) {
                 $form_timestamp = trim($_POST['timestamp']);
                 $live_timestamp = current_time('timestamp');
                 if ($form_timestamp == '' && um_get_option('enable_timebot') == 1) {
                     wp_die(__('Hello, spam bot!'));
                 }
                 if ($live_timestamp - $form_timestamp < 6 && um_get_option('enable_timebot') == 1) {
                     wp_die(__('Whoa, slow down! You\'re seeing this message because you tried to submit a form too fast and we think you might be a spam bot. If you are a real human being please wait a few seconds before submitting the form. Thanks!'));
                 }
             }
             /* Continue based on form mode - pre-validation */
             do_action('um_submit_form_errors_hook', $this->post_form);
             do_action("um_submit_form_{$this->post_form['mode']}", $this->post_form);
         }
     }
 }
开发者ID:smithsa,项目名称:daily-job-hunter,代码行数:33,代码来源:um-form.php

示例14: fnt_dashboard_widget

function fnt_dashboard_widget()
{
    $clientid = '9f690b3117f0c43767528e2b60bc70ce';
    $args = array('posts_per_page' => -1, 'offset' => 0, 'post_status' => array('publish', 'draft'), 'post_type' => 'tracks');
    $errors = 0;
    $query = new WP_Query($args);
    while ($query->have_posts()) {
        $query->the_post();
        $id = get_the_ID();
        $track_url = get_post_meta($id, 'track_url', true);
        $errored = 0;
        if (get_post_status() == 'draft') {
            $errored = 1;
        } else {
            $soundcloud_url = 'https://api.soundcloud.com/resolve?url=' . $track_url . '&format=json&consumer_key=' . $clientid;
            $track_json = file_get_contents($soundcloud_url);
            $track = json_decode($track_json);
            if ($track == null || isset($track->errors) && isset($track->errors[0]) && $track->errors[0]->error_message == '404 - Not Found' || $track->errors[0]->error_message == 'HTTP Error: 403') {
                $errored = 1;
                $update = array('ID' => $id, 'post_status' => 'draft');
                wp_update_post($update);
            }
        }
        if ($errored > 0) {
            echo '<span style="color:red;">SC Track is private & won\'t play: </span>&nbsp;' . '<a href="' . get_edit_post_link() . '" target="_blank">' . get_the_title() . '</a><br/>';
            $errors++;
        }
    }
    if ($errors > 0) {
        echo '<br/><em>These ' . $errors . ' posts are all drafts, but should probably be fixed or removed.</em>';
    } else {
        echo 'There are no broken tracks! That is SHOCKING :)';
    }
}
开发者ID:jacobraccuia,项目名称:dailybeatmedia,代码行数:34,代码来源:admin_functions.php

示例15: __construct

 /**
  * Constructor.
  */
 public function __construct()
 {
     add_action('wp', array($this, 'process'));
     $this->steps = (array) apply_filters('submit_resume_steps', array('submit' => array('name' => __('Submit Details', 'wp-job-manager-resumes'), 'view' => array($this, 'submit'), 'handler' => array($this, 'submit_handler'), 'priority' => 10), 'preview' => array('name' => __('Preview', 'wp-job-manager-resumes'), 'view' => array($this, 'preview'), 'handler' => array($this, 'preview_handler'), 'priority' => 20), 'done' => array('name' => __('Done', 'wp-job-manager-resumes'), 'view' => array($this, 'done'), 'handler' => '', 'priority' => 30)));
     uasort($this->steps, array($this, 'sort_by_priority'));
     // Get step/resume
     if (!empty($_REQUEST['step'])) {
         $this->step = is_numeric($_REQUEST['step']) ? max(absint($_REQUEST['step']), 0) : array_search($_REQUEST['step'], array_keys($this->steps));
     }
     $this->resume_id = !empty($_REQUEST['resume_id']) ? absint($_REQUEST['resume_id']) : 0;
     $this->job_id = !empty($_REQUEST['job_id']) ? absint($_REQUEST['job_id']) : 0;
     // Load resume details
     if ($this->resume_id) {
         $resume_status = get_post_status($this->resume_id);
         if ('expired' === $resume_status) {
             if (!resume_manager_user_can_edit_resume($this->resume_id)) {
                 $this->resume_id = 0;
                 $this->job_id = 0;
                 $this->step = 0;
             }
         } elseif (0 === $this->step && !in_array($resume_status, apply_filters('resume_manager_valid_submit_resume_statuses', array('preview'))) && empty($_POST['resume_application_submit_button'])) {
             $this->resume_id = 0;
             $this->job_id = 0;
             $this->step = 0;
         }
     }
 }
开发者ID:vinodhip,项目名称:Function-22-Website,代码行数:30,代码来源:class-wp-resume-manager-form-submit-resume-working.php


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