@param bool $supports_trash
@param \WP_Post $post

@return bool
777546
public function overrideTrashable( $supports_trash, $post ) {

		global $wpdb;

		if ( $post->post_type === 'part' && $supports_trash ) {
			// Don't delete a part if it has chapters
			$pids = $wpdb->get_col(
				$wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_parent = %d AND (post_status != 'trash' AND post_status != 'inherit') LIMIT 1 ", $post->ID )
			);
			if ( ! empty( $pids ) ) {
				$supports_trash = false;
			}
		}

		return $supports_trash;
	}
943957
public function delete($user, Post $post)
    {
        return Gate::forUser($user)->allows('deletePosts', $post->thread) || $user->getKey() === $post->author_id;
    }
51680
public static function get_post_type_date_archive_support( $post_type ) {
		if ( is_string( $post_type ) ) {
			$post_type = get_post_type_object( $post_type );
		}

		if ( ! empty( $post_type->cptp ) && isset( $post_type->cptp['date_archive'] ) ) {
			return ! ! $post_type->cptp['date_archive'];
		}

		return true;
	}
654700
public function removePost(ForumThreadPost $post)
    {
        if ($this->posts->contains($post) === true) {
            $post->setThread(null);
            $this->posts->removeElement($post);
        }

        return $this;
    }
445467
public function can_delete_post(stdClass $user, discussion_entity $discussion, post_entity $post) : bool {
        global $CFG;

        $forum = $this->get_forum();

        if ($forum->get_type() == 'single' && $discussion->is_first_post($post)) {
            // Do not allow deleting of first post in single simple type.
            return false;
        } else {
            $context = $this->get_context();
            $ownpost = $post->is_owned_by_user($user);
            $ineditingtime = $post->get_age() < $CFG->maxeditingtime;

            return ($ownpost && $ineditingtime && has_capability('mod/forum:deleteownpost', $context, $user)) ||
                has_capability('mod/forum:deleteanypost', $context, $user);
        }
    }
1049116
public function update( $data, $where, $convert_name = true ) {
		if ( empty( $where['id'] ) && empty( $where['post_id'] ) ) {
			return false;
		}
		if ( ! empty( $where['id'] ) ) {
			$d = $this->get_data( $where['id'] );
		} else {
			$d = $this->get_related_data( $where['post_id'] );
		}
		if ( empty( $d ) ) {
			return false;
		}

		$_data              = [];
		$_data['ID']        = $d['post_id'];
		$_data['post_type'] = $this->get_post_type();
		! empty( $data['post_title'] ) and $_data['post_title'] = $data['post_title'];
		! empty( $data['post_content'] ) and $_data['post_content'] = $data['post_content'];
		! empty( $data['post_status'] ) and $_data['post_status'] = $data['post_status'];
		unset( $data['post_type'] );
		unset( $data['post_title'] );
		unset( $data['post_content'] );
		unset( $data['post_status'] );

		foreach ( $this->get_data_field_settings() as $k => $v ) {
			$name = $convert_name ? $this->get_post_field_name( $k ) : $k;
			unset( $_POST[ $name ] );
		}
		foreach ( $data as $k => $v ) {
			$name           = $convert_name ? $this->get_post_field_name( $k ) : $k;
			$_data[ $name ] = $v;
			$_POST[ $name ] = $v;
		}

		return wp_update_post( $_data );
	}
135161
public function populate_post_content_for_indexing( \WP_Post $post ) : \WP_Post {

		$module_content = $this->get_modules_content( $post );

		if ( ! empty( $module_content ) ) {
			// Fake fill the post_content with modules before SearchWP indexing.
			$post->post_content = $module_content;
		}

		return $post;
	}
979775
def blog__clean_post_parents
      post_parents = LatoBlog::PostParent.all
      post_parents.map { |pp| pp.destroy if pp.posts.empty? }
    end
580094
protected function check_delete_permission( $post ) {
		$post_type = get_post_type_object( $post->post_type );

		if ( ! $this->check_is_post_type_allowed( $post_type ) ) {
			return false;
		}

		return current_user_can( $post_type->cap->delete_post, $post->ID );
	}
199182
public function trashed()
    {
        $field = $this->getDeleteTimeField();

        if ($field && !empty($this->getOrigin($field))) {
            return true;
        }

        return false;
    }
92
public static function clearCache($postId, $post)
    {
        if (wp_is_post_revision($postId) || get_post_status($postId) != 'publish') {
            return false;
        }

        wp_cache_delete($postId, self::getKeyGroup());
        wp_cache_delete($post->post_type, self::getKeyGroup());

        // Empty post type for all sites in network (?)
        if (function_exists('is_multisite') && is_multisite() && apply_filters('Municipio\Cache\EmptyForAllBlogs', false, $post)) {
            $blogs = get_sites();

            foreach ($blogs as $blog) {
                wp_cache_delete($post->post_type, self::getKeyGroup($blog->blog_id));
            }
        }

        return true;
    }
586091
public function delete_item( $request ) {
		$id = (int) $request['id'];
		$force = isset( $request['force'] ) ? (bool) $request['force'] : false;

		$comment = get_comment( $id );
		if ( empty( $comment ) ) {
			return new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment id.' ), array( 'status' => 404 ) );
		}

		/**
		 * Filter whether a comment is trashable.
		 *
		 * Return false to disable trash support for the post.
		 *
		 * @param boolean $supports_trash Whether the post type support trashing.
		 * @param WP_Post $comment        The comment object being considered for trashing support.
		 */
		$supports_trash = apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment );

		$request->set_param( 'context', 'edit' );
		$response = $this->prepare_item_for_response( $comment, $request );

		if ( $force ) {
			$result = wp_delete_comment( $comment->comment_ID, true );
		} else {
			// If we don't support trashing for this type, error out
			if ( ! $supports_trash ) {
				return new WP_Error( 'rest_trash_not_supported', __( 'The comment does not support trashing.' ), array( 'status' => 501 ) );
			}

			if ( 'trash' === $comment->comment_approved ) {
				return new WP_Error( 'rest_already_trashed', __( 'The comment has already been trashed.' ), array( 'status' => 410 ) );
			}

			$result = wp_trash_comment( $comment->comment_ID );
		}

		if ( ! $result ) {
			return new WP_Error( 'rest_cannot_delete', __( 'The comment cannot be deleted.' ), array( 'status' => 500 ) );
		}

		/**
		 * Fires after a comment is deleted via the REST API.
		 *
		 * @param object           $comment  The deleted comment data.
		 * @param WP_REST_Response $response The response returned from the API.
		 * @param WP_REST_Request  $request  The request sent to the API.
		 */
		do_action( 'rest_delete_comment', $comment, $response, $request );

		return $response;
	}
32692
public function isSupported()
    {
        $mixer   = $this->getMixer();
        $request = $mixer->getRequest();

        // Support HTML GET requests and also form submits (so we can render errors on POST)
        if(($request->isFormSubmit() || $request->isGet()) && $request->getFormat() == 'html' && !$request->isAjax()) {
            return parent::isSupported();
        }

        return false;
    }
506294
public function filterNestedModuleShortocde($post)
    {
        if (is_admin()) {
            return $post;
        }

        if (substr($post->post_type, 0, 4) != 'mod-') {
            return $post;
        }

        $post->post_content = preg_replace('/\[modularity(.*)\]/', '', $post->post_content);
        return $post;
    }
1346782
public function index($trashed = false)
    {
        $this->authorize(PostsPolicy::PERMISSION_LIST);

        $posts = $this->post->with(['author', 'category'])->when($trashed, function ($query) {
            return $query->onlyTrashed();
        })->paginate(30);

        $title = trans('blog::posts.titles.posts-list');
        $this->setTitle($title . ($trashed ? ' - '.trans('core::generals.trashed') : ''));
        $this->addBreadcrumb($title);

        return $this->view('admin.posts.index', compact('trashed', 'posts'));
    }
1349134
public static function get_post_type_author_archive_support( $post_type ) {
		if ( is_string( $post_type ) ) {
			$post_type = get_post_type_object( $post_type );
		}

		if ( ! empty( $post_type->cptp ) && isset( $post_type->cptp['author_archive'] ) ) {
			return ! ! $post_type->cptp['author_archive'];
		}

		return true;

	}
285359
public function render(\WP_Post $post, array $args)
    {
        $args = array_merge($args['args'], [
            'metabox' => $this,
            'post' => $post,
            'screen' => $this->getScreen()
        ]);

        $response = $this->handleCallback($this->getCallback(), $args);

        if ($response instanceof Renderable) {
            echo $response->render();
        } elseif ($response instanceof Response) {
            echo $response->getContent();
        }
    }