예제 #1
0
 /**
  * @inheritdoc
  */
 public function init($path)
 {
     $postId = filter_input(INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT);
     $post = $postId ? get_post($postId) : false;
     if (!$post instanceof WP_Post) {
         return false;
     }
     $this->hasMeta = $this->meta->has($post->ID, $post->post_author);
     $this->path = $path;
     if (!in_array($post->post_status, ['pending', 'draft'], true) && $this->hasMeta) {
         $this->meta->delete($post->ID);
     } elseif ($post->post_status === 'pending' && (int) $post->post_author !== (int) get_current_user_id()) {
         /** @var \stdClass $postType */
         /** @var \stdClass $caps */
         $postType = get_post_type_object($post->post_type);
         $caps = $postType->cap;
         $this->inited = !user_can($post->post_author, $caps->publish_posts);
     }
     return $this->inited;
 }
예제 #2
0
 /**
  * Print the 'Rejected Status' column according to post meta.
  *
  * @param string $column
  * @param string $pid
  */
 private function columnContent($column, $pid)
 {
     if ($column !== Launcher::SLUG . '_status') {
         return;
     }
     $post = get_post($pid);
     $allowed = apply_filters(Launcher::SLUG . '_post_types', ['post']);
     if (!in_array($post->post_type, $allowed, true)) {
         return;
     }
     $has = $this->meta->has($pid);
     $status = $post->post_status;
     if (!in_array($status, ['pending', 'draft'], true)) {
         $has and $this->meta->delete($pid);
     }
     if ($status === 'pending') {
         $has ? esc_html_e('Rejected', 'reject-notify') : esc_html_e('Needs Approval', 'reject-notify');
     }
 }