Automattic\WooCommerce\Blocks\Assets
AssetDataRegistry::format_page_resource()
Format a page object into a standard array of data.
Method of the class: AssetDataRegistry{}
No Hooks.
Return
Array
.
Usage
// protected - for code of main (parent) or child class $result = $this->format_page_resource( $page );
- $page(WP_Post|int) (required)
- Page object or ID.
AssetDataRegistry::format_page_resource() AssetDataRegistry::format page resource code WC 8.7.0
protected function format_page_resource( $page ) { if ( is_numeric( $page ) && $page > 0 ) { $page = get_post( $page ); } if ( ! is_a( $page, '\WP_Post' ) || 'publish' !== $page->post_status ) { return [ 'id' => 0, 'title' => '', 'permalink' => false, ]; } return [ 'id' => $page->ID, 'title' => $page->post_title, 'permalink' => get_permalink( $page->ID ), ]; }