Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure check_url_match function is defined only once #355

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions includes/ECommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -712,21 +712,23 @@ public function show_store_setup() {

$brand = $this->container->plugin()->id;

/**
* Verifies if the url is matching with the regex
*
* @param string $brand_name id of the brand
*
* @param string $site_url siteurl
*/
function check_url_match( $brand_name, $site_url ) {
switch ( $brand_name ) {
case 'bluehost':
return ! preg_match( '/\b\w+(\.\w+)*\.mybluehost\.me\b/', $site_url );
case 'hostgator':
return ! preg_match( '/\b\w+(\.\w+)*\.temporary\.site\b/', $site_url );
default:
return true;
if ( ! function_exists( __NAMESPACE__ . '\check_url_match' ) ) {
/**
* Verifies if the url is matching with the regex
*
* @param string $brand_name id of the brand
*
* @param string $site_url siteurl
*/
function check_url_match( $brand_name, $site_url ) {
switch ( $brand_name ) {
case 'bluehost':
return ! preg_match( '/\b\w+(\.\w+)*\.mybluehost\.me\b/', $site_url );
case 'hostgator':
return ! preg_match( '/\b\w+(\.\w+)*\.temporary\.site\b/', $site_url );
default:
return true;
}
}
}
if ( check_url_match( $brand, $site_url ) ) {
Expand Down