WC_Install::create_pages()public staticWC 1.0

Create pages that the plugin relies on, storing page IDs in variables.

{} Это метод класса: WC_Install{}

Возвращает

null. Ничего.

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

$result = WC_Install::create_pages();

Код WC_Install::create_pages() WC 6.9.4

public static function create_pages() {
	include_once dirname( __FILE__ ) . '/admin/wc-admin-functions.php';

	/**
	 * Determines the cart shortcode tag used for the cart page.
	 *
	 * @since 2.1.0
	 */
	$cart_shortcode = apply_filters( 'woocommerce_cart_shortcode_tag', 'woocommerce_cart' );

	/**
	 * Determines the checkout shortcode tag used on the checkout page.
	 *
	 * @since 2.1.0
	 */
	$checkout_shortcode = apply_filters( 'woocommerce_checkout_shortcode_tag', 'woocommerce_checkout' );

	/**
	 * Determines the my account shortcode tag used on the my account page.
	 *
	 * @since 2.1.0
	 */
	$my_account_shortcode = apply_filters( 'woocommerce_my_account_shortcode_tag', 'woocommerce_my_account' );

	/**
	 * Determines which pages are created during install.
	 *
	 * @since 2.1.0
	 */
	$pages = apply_filters(
		'woocommerce_create_pages',
		array(
			'shop'           => array(
				'name'    => _x( 'shop', 'Page slug', 'woocommerce' ),
				'title'   => _x( 'Shop', 'Page title', 'woocommerce' ),
				'content' => '',
			),
			'cart'           => array(
				'name'    => _x( 'cart', 'Page slug', 'woocommerce' ),
				'title'   => _x( 'Cart', 'Page title', 'woocommerce' ),
				'content' => '<!-- wp:shortcode -->[' . $cart_shortcode . ']<!-- /wp:shortcode -->',
			),
			'checkout'       => array(
				'name'    => _x( 'checkout', 'Page slug', 'woocommerce' ),
				'title'   => _x( 'Checkout', 'Page title', 'woocommerce' ),
				'content' => '<!-- wp:shortcode -->[' . $checkout_shortcode . ']<!-- /wp:shortcode -->',
			),
			'myaccount'      => array(
				'name'    => _x( 'my-account', 'Page slug', 'woocommerce' ),
				'title'   => _x( 'My account', 'Page title', 'woocommerce' ),
				'content' => '<!-- wp:shortcode -->[' . $my_account_shortcode . ']<!-- /wp:shortcode -->',
			),
			'refund_returns' => array(
				'name'        => _x( 'refund_returns', 'Page slug', 'woocommerce' ),
				'title'       => _x( 'Refund and Returns Policy', 'Page title', 'woocommerce' ),
				'content'     => self::get_refunds_return_policy_page_content(),
				'post_status' => 'draft',
			),
		)
	);

	foreach ( $pages as $key => $page ) {
		wc_create_page(
			esc_sql( $page['name'] ),
			'woocommerce_' . $key . '_page_id',
			$page['title'],
			$page['content'],
			! empty( $page['parent'] ) ? wc_get_page_id( $page['parent'] ) : '',
			! empty( $page['post_status'] ) ? $page['post_status'] : 'publish'
		);
	}
}