Main Menu
', 'Main Menu
', $html); $html = str_replace('Browse Categories
', 'Browse Categories
', $html); $html = preg_replace('/(get_permalink();
if (!$product_url) return $html;
$label = 'Shop Now';
$name = $product->get_name();
return sprintf('%3$s', esc_url($product_url), esc_attr($name ? $label . ': ' . $name : $label), esc_html($label));
}, 99, 3);
/** Permanent redirects for retired and renamed FM Electronic Store category/product URLs. */
add_action('template_redirect', function() {
$map = get_option('fm_audit_redirect_map_20261109', []);
if (!is_array($map) || empty($_SERVER['REQUEST_URI'])) return;
$path = untrailingslashit((string) parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
if (!isset($map[$path])) return;
$target_path = (string) $map[$path];
$target_path = preg_match('/\\.[a-z0-9]{2,5}$/i', $target_path) ? $target_path : trailingslashit($target_path);
$target = home_url($target_path);
wp_safe_redirect($target, 301, 'FM Electronic Store SEO redirects');
exit;
}, 1);
/** Remove article-style author/read-time Twitter card labels from the storefront homepage. */
add_filter('rank_math/opengraph/slack_enhanced_data', function($data) {
if (is_front_page()) return [];
return $data;
}, 20);
/** FM_ADD_IMAGE_DIMENSIONS_FOR_ELEMENTOR_WIDGETS: add intrinsic dimensions to Elementor image tags to reduce layout shifts. */
add_filter('elementor/widget/render_content', function($content, $widget) {
if (!is_string($content) || stripos($content, 'next_tag('img')) {
$width = $processor->get_attribute('width');
$height = $processor->get_attribute('height');
if ($width && $height) continue;
$url = $processor->get_attribute('data-src');
if (!is_string($url) || strpos($url, 'http') !== 0) $url = $processor->get_attribute('src');
if (!is_string($url) || strpos($url, 'http') !== 0) continue;
$attachment_id = attachment_url_to_postid($url);
if (!$attachment_id) continue;
$meta = wp_get_attachment_metadata($attachment_id);
if (empty($meta['width']) || empty($meta['height'])) continue;
if (!$width) $processor->set_attribute('width', (string) absint($meta['width']));
if (!$height) $processor->set_attribute('height', (string) absint($meta['height']));
$changed = true;
}
return $changed ? (string) $processor : $content;
}, 20, 2);
/** FM_THEME_DECORATIVE_IMAGE_DIMENSIONS: preserve intrinsic dimensions for the Shopire decorative footer asset. */
add_filter('elementor/widget/render_content', function($content) {
if (!is_string($content) || stripos($content, 'footer-shape.png') === false || !class_exists('WP_HTML_Tag_Processor')) return $content;
$p = new WP_HTML_Tag_Processor($content);
$changed = false;
while ($p->next_tag('img')) {
$src = (string) $p->get_attribute('src');
$data = (string) $p->get_attribute('data-src');
if (strpos($src, 'footer-shape.png') === false && strpos($data, 'footer-shape.png') === false) continue;
if (!$p->get_attribute('width')) $p->set_attribute('width', '435');
if (!$p->get_attribute('height')) $p->set_attribute('height', '592');
$changed = true;
}
return $changed ? (string) $p : $content;
}, 21, 1);
/** FM_FOOTER_CONTACT_HEADING_SEMANTICS: use logical h3 headings for footer service features beneath homepage sections. */
add_action('template_redirect', function() {
if (!is_front_page()) return;
ob_start(function($html) {
foreach (['Fast Delivery','Secured Payment','Money Back','24/7 Support'] as $label) {
$old = '
Main Menu
', $html); $html = str_replace('Browse Categories
', $html); $html = preg_replace('/(