Admin_Apple_News::get_post_status PHP Метод

get_post_status() публичный статический Метод

Get post status.
public static get_post_status ( integer $post_id ) : string
$post_id integer
Результат string
    public static function get_post_status($post_id)
    {
        $key = 'apple_news_post_state_' . $post_id;
        if (false === ($state = get_transient($key))) {
            // Get the state from the API.
            // If this causes an error, display that message instead of the state.
            try {
                $action = new Apple_Actions\Index\Get(self::$settings, $post_id);
                $state = $action->get_data('state', __('N/A', 'apple-news'));
            } catch (\Apple_Push_API\Request\Request_Exception $e) {
                $state = $e->getMessage();
            }
            $cache_expiration = 'LIVE' == $state || 'TAKEN_DOWN' == $state ? 3600 : 60;
            set_transient($key, $state, apply_filters('apple_news_post_status_cache_expiration', $cache_expiration, $state));
        }
        return $state;
    }

Usage Example

 /**
  * Get the Apple News status.
  *
  * @param WP_Post $post
  * @return string
  * @access private
  */
 private function get_status_for($post)
 {
     return \Admin_Apple_News::get_post_status($post->ID);
 }
All Usage Examples Of Admin_Apple_News::get_post_status