Ejemplo n.º 1
0
 /**
  * Get post status.
  *
  * @param int $post_id
  * @return string
  */
 public static function get_post_status($post_id)
 {
     $key = 'apple_news_post_state_' . $post_id;
     if (false === ($state = get_transient($key))) {
         $action = new Apple_Actions\Index\Get(self::$settings, $post_id);
         $state = $action->get_data('state', __('N/A', 'apple-news'));
         $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;
 }
 /**
  * Get post status.
  *
  * @param int $post_id
  * @return 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;
 }