/**
  * Conditionally add a hook on posts_results if this is the main query, a preview, and singular.
  *
  * @since 4.4.0
  *
  * @param WP_Query $query
  *
  * @return WP_Query
  */
 public function maybe_display_post($query)
 {
     if ($query->is_main_query() && $query->is_preview() && $query->is_singular()) {
         add_filter('posts_results', array($this, 'set_post_to_publish'), 10, 2);
     }
     return $query;
 }