WC_Install::create_pages()
Create pages that the plugin relies on, storing page IDs in variables.
Метод класса: WC_Install{}
Хуки из метода
Возвращает
null
. Ничего (null).
Использование
$result = WC_Install::create_pages();
Код WC_Install::create_pages() WC Install::create pages WC 9.8.2
public static function create_pages() { // WordPress sets fresh_site to 0 after a page gets published. // Prevent fresh_site option from being set to 0 so that we can use it for further customizations. remove_action( 'publish_page', '_delete_option_fresh_site', 0 ); // Set the locale to the store locale to ensure pages are created in the correct language. wc_switch_to_site_locale(); include_once __DIR__ . '/admin/wc-admin-functions.php'; /** * Determines the cart shortcode tag used for the cart page. * * @since 2.1.0 * @deprecated 8.3.0 This filter is deprecated and will be removed in future versions. */ $cart_shortcode = apply_filters_deprecated( 'woocommerce_cart_shortcode_tag', array( '' ), '8.3.0', 'woocommerce_create_pages' ); $cart_page_content = empty( $cart_shortcode ) ? self::get_cart_block_content() : '<!-- wp:shortcode -->[' . $cart_shortcode . ']<!-- /wp:shortcode -->'; /** * Determines the checkout shortcode tag used on the checkout page. * * @since 2.1.0 * @deprecated 8.3.0 This filter is deprecated and will be removed in future versions. */ $checkout_shortcode = apply_filters_deprecated( 'woocommerce_checkout_shortcode_tag', array( '' ), '8.3.0', 'woocommerce_create_pages' ); $checkout_page_content = empty( $checkout_shortcode ) ? self::get_checkout_block_content() : '<!-- wp:shortcode -->[' . $checkout_shortcode . ']<!-- /wp:shortcode -->'; /** * 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' => $cart_page_content, ), 'checkout' => array( 'name' => _x( 'checkout', 'Page slug', 'woocommerce' ), 'title' => _x( 'Checkout', 'Page title', 'woocommerce' ), 'content' => $checkout_page_content, ), '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' ); } // Restore the locale to the default locale. wc_restore_locale(); }