【发布时间】:2020-02-28 18:30:54
【问题描述】:
我正在通过代码寻找一种万无一失的方法来判断电子商务平台 ID 是否在 woocommerce 或 shopify 上运行。
ATM,我想出了下面的代码来检查是否有带有“wp-admin”或“admin”的 URL,但它不是万无一失的。
$url1 = "https://www." . $_POST['domain'] . "/wp-admin";
$url2 = "https://www." . $_POST['domain'] . "/admin";
// Use get_header() function
$headers1 = @get_headers($url1);
$headers2 = @get_headers($url2);
// Use conditio to check existence of URL
if($headers1 && strpos($headers1[0], '200'))
{
$eCommercePlatform = "WordPress/Woocommerce";
}
elseif($headers2 && strpos($headers2[0], '200'))
{
$eCommercePlatform = "Shopify";
}
else
{
$eCommercePlatform = "Not Shopify or Woocommerce";
}
还有其他好的技巧/建议吗?
【问题讨论】:
-
wp-admin应该始终是某种 Wordpress,但admin有点通用登录名/术语,所以不仅仅是 Shopify。
标签: php woocommerce shopify