Automattic\WooCommerce\Blocks

Migration::wc_blocks_update_1120_rename_cart_template()public staticWC 1.0

Rename cart template to page-cart.

Метод класса: Migration{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = Migration::wc_blocks_update_1120_rename_cart_template();

Код Migration::wc_blocks_update_1120_rename_cart_template() WC 9.5.1

public static function wc_blocks_update_1120_rename_cart_template() {
	$template = get_block_template( BlockTemplateUtils::PLUGIN_SLUG . '//cart', 'wp_template' );

	if ( $template && ! empty( $template->wp_id ) ) {
		if ( ! defined( 'WP_POST_REVISIONS' ) ) {
			// This prevents a fatal error when ran outside of admin context.
			define( 'WP_POST_REVISIONS', false );
		}
		wp_update_post(
			array(
				'ID'        => $template->wp_id,
				'post_name' => 'page-cart',
			)
		);
	}
}