Hey guys thanks in advance to all,
So Iv made a conditional
statement for a plugin that runs on woocommerce, to target the URL
so I can inject custom css via php or whatever.
the code works fine, but I trying to make it cleaner using an array
instead of rewriting the statment every time
this is the code hope you guys could help cheers,
//add css if uri contains product base number
add_action('init', 'do_stuff');
function do_stuff()
{
$url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
if (false !== strpos($url, 'product_base=22')) {
echo '<style type="text/css"></style>';
}
}
this is the array I was thinking about looping over there are two options one with the full path and the other a constant path of product_base
with a dynamic number from the array
$product_base = array('product_base=21','product_base=22','product_base=23');
$product_key = array('21','22','23');
cheers again,