Astra_Addon_Theme_Builder::delete_custom_layout( WP_REST_Request $request )

Delete custom layout


Description


Parameters

$request

(WP_REST_Request) (Required) Full details about the request.


Return

(WP_Error|boolean)


Source

File: addons/advanced-hooks/classes/class-astra-addon-theme-builder.php

		public function delete_custom_layout( $request ) {
			$post_id = $request['id'];
			if ( get_post_status( $post_id ) ) {
				if ( ! current_user_can( 'delete_post', $post_id ) ) {
					wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.', 'astra-addon' ) );
				}
				wp_trash_post( $post_id );
				return new WP_REST_Response( array( 'message' => 'Post deleted successfully' ), 200 );
			} else {
				return new WP_Error( 'post_not_found', 'Post not found', array( 'status' => 404 ) );
			}
		}

Changelog

Changelog
Version Description
4.5.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.