p_unslash( $_SERVER['REQUEST_URI'] ?? '' ) ); if ( ! $url ) { return false; } $normalized_path = self::get_normalized_url_path( $url ); // WC store pages. $store_pages = array( 'shop' => wc_get_page_id( 'shop' ), 'cart' => wc_get_page_id( 'cart' ), 'checkout' => wc_get_page_id( 'checkout' ), 'terms' => wc_terms_and_conditions_page_id(), 'coming_soon' => wc_get_page_id( 'coming_soon' ), ); /** * Filter the store pages array to check if a URL is a store page. * * @since 8.8.0 * @param array $store_pages The store pages array. The keys are the page slugs and the values are the page IDs. */ $store_pages = apply_filters( 'woocommerce_store_pages', $store_pages ); // If the shop page is not set, we will still show the product archive page. // Therefore, we need to check if the URL is a product archive page when the shop page is not set. if ( $store_pages['shop'] <= 0 ) { $product_post_archive_link = get_post_type_archive_link( 'product' ); if ( is_string( $product_post_archive_link ) && 0 === strpos( $normalized_path, self::get_normalized_url_path( $product_post_archive_link ) ) ) { return true; } } foreach ( $store_pages as $page => $page_id ) { if ( 0 >= $page_id ) { continue; } $permalink = get_permalink( $page_id ); if ( ! $permalink ) { continue; } if ( 0 === strpos( $normalized_path, self::get_normalized_url_path( $permalink ) ) ) { return true; } } // Check product, category and tag pages. $permalink_structure = wc_get_permalink_structure(); $permalink_keys = array( 'category_base', 'tag_base', 'product_base', ); foreach ( $permalink_keys as $key ) { if ( ! isset( $permalink_structure[ $key ] ) || ! is_string( $permalink_structure[ $key ] ) ) { continue; } // Check if the URL path starts with the matching base. if ( 0 === strpos( $normalized_path, trim( $permalink_structure[ $key ], '/' ) ) ) { return true; } // If the permalink structure contains placeholders, we need to check if the URL matches the structure using regex. if ( strpos( $permalink_structure[ $key ], '%' ) !== false ) { global $wp_rewrite; $rules = $wp_rewrite->generate_rewrite_rule( $permalink_structure[ $key ] ); if ( is_array( $rules ) && ! empty( $rules ) ) { // rule key is the regex pattern. $rule = array_keys( $rules )[0]; $rule = '#^' . str_replace( '?$', '', $rule ) . '#'; if ( preg_match( $rule, $normalized_path ) ) { return true; } } } } return false; } /** * Get normalized URL path. * 1. Only keep the path and query string (if any). * 2. Remove wp home path from the URL path if WP is installed in a subdirectory. * 3. Remove leading and trailing slashes. * * For example: * * - https://example.com/wordpress/shop/uncategorized/test/?add-to-cart=123 => shop/uncategorized/test/?add-to-cart=123 * * @param string $url URL to normalize. */ private static function get_normalized_url_path( $url ) { $query = wp_parse_url( $url, PHP_URL_QUERY ); $path = wp_parse_url( $url, PHP_URL_PATH ) . ( $query ? '?' . $query : '' ); $home_path = wp_parse_url( site_url(), PHP_URL_PATH ) ?? ''; $normalized_path = trim( substr( $path, strlen( $home_path ) ), '/' ); return $normalized_path; } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Admin\WCAdminHelper" not found in /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskList.php:400 Stack trace: #0 /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskList.php(152): Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskList::possibly_remove_reminder_bar() #1 /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskLists.php(260): Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskList->__construct(Array) #2 /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskLists.php(139): Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists::add_list(Array) #3 /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskLists.php(73): Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists::init_default_lists() #4 /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/Init.php(36): Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists::init() #5 /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/Features.php(137): Automattic\WooCommerce\Admin\Features\OnboardingTasks\Init->__construct() #6 /htdocs/wp-includes/class-wp-hook.php(324): Automattic\WooCommerce\Admin\Features\Features::load_features('') #7 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #8 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #9 /htdocs/wp-settings.php(700): do_action('init') #10 /htdocs/wp-config.php(106): require_once('/htdocs/wp-sett...') #11 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #12 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #13 /htdocs/index.php(17): require('/htdocs/wp-blog...') #14 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/Admin/Features/OnboardingTasks/TaskList.php on line 400