// Remove Customizer CSS entirely - eliminates specificity conflicts remove_action('wp_head', 'wp_custom_css', 101); // Output our mobile CSS + preserved Customizer rules add_action('wp_head', function() { echo ''; }); // Improve robots.txt for SEO add_filter("robots_txt", function($output, $public) { $extra = "Disallow: /wp-content/plugins/\n"; $extra .= "Disallow: /checkout/\n"; $extra .= "Disallow: /kassa/\n"; $extra .= "Disallow: /varukorg/\n"; $extra .= "Disallow: /varukorgen/\n"; $extra .= "Disallow: /cart/\n"; $extra .= "Disallow: /?s=\n"; $extra .= "Disallow: /search/\n"; $extra .= "Disallow: /feed/\n"; $extra .= "Disallow: /comments/feed/\n"; $extra .= "Disallow: /tag/\n"; $extra .= "Disallow: /author/\n"; return $output . $extra; }, 10, 2); // Fix WooCommerce reviews + Enhanced Trustindex reviews on product pages // Snippet 13: WC product reviews + Trustindex widget + curated positive review cards // v3: Added Google SVG logos to WC reviews + platform SVGs to curated cards + multi-platform reviews remove_action('woocommerce_product_tabs', 'woocommerce_product_reviews_tab', 30); add_action('woocommerce_product_tabs', function($tabs = array()) { global $product; if ($product) { $count = $product->get_review_count(); $tabs['reviews'] = array( 'title' => $count > 0 ? sprintf('Recensioner (%d)', $count) : __('Reviews', 'woocommerce'), 'priority' => 30, 'callback' => 'solberga_custom_reviews_tab', ); } return $tabs; }, 30); function solberga_custom_reviews_tab() { global $product; if (!$product) return; $product_id = $product->get_id(); $reviews = get_comments(array( 'post_id' => $product_id, 'status' => 'approve', 'type' => 'review', 'orderby' => 'comment_date', 'order' => 'DESC', )); $count = count($reviews); // Google SVG logo (18px for inline use) $svg_google = ''; echo '
'; // === Section 1: Trustindex widget slider === echo '
'; echo '

Vad våra kunder säger

'; if (function_exists('solberga_get_trustindex_widget')) { echo solberga_get_trustindex_widget(); } echo '
'; // === Section 2: WC product reviews (with Google logo) === echo '
'; if ($count > 0) { echo '

' . sprintf(_n('%s recension för %s', '%s recensioner för %s', $count, 'woocommerce'), $count, get_the_title()) . '

'; echo '
    '; foreach ($reviews as $review) { $rating = intval(get_comment_meta($review->comment_ID, 'rating', true)); $author = esc_html($review->comment_author); $date = esc_html(date_i18n(get_option('date_format'), strtotime($review->comment_date))); $content = wpautop(esc_html($review->comment_content)); echo '
  1. '; echo '
    '; echo '
    '; if ($rating && wc_review_ratings_enabled()) { echo ''; } echo '

    ' . $svg_google . ' ' . $author . '

    '; echo '
    ' . $content . '
    '; echo '
  2. '; } echo '
'; } else { echo '

Det finns inga produktrecensioner än.

'; } echo '
'; // === Section 3: Trustindex review cards (curated reviews from multiple platforms with logos) === $trustindex_reviews = array( array('author' => 'Kevin Mårtensson', 'date' => 'December 8, 2024', 'text' => 'Jag älskar solberga', 'stars' => 5, 'source' => 'Google'), array('author' => 'Chris Sourlos', 'date' => 'Oktober 4, 2024', 'text' => 'Mycket nöjd! Perfekt service på allt!', 'stars' => 5, 'source' => 'Google'), array('author' => 'Bengt-Åke Pettersson', 'date' => 'September 26, 2024', 'text' => 'Fick perfekt hjälp att välja rätt fjärrkontroll. Snabb leverans.', 'stars' => 5, 'source' => 'Google'), array('author' => 'Pia Andersson', 'date' => 'September 16, 2024', 'text' => 'Enkelt att beställa, snabb leverans. Produkterna var perfekta och lätt att installera.', 'stars' => 5, 'source' => 'Google'), array('author' => 'Göran Önnegren', 'date' => 'September 14, 2024', 'text' => 'Snabb leverans och duktig kundsupport.', 'stars' => 5, 'source' => 'Google'), array('author' => 'Reine Larsson', 'date' => 'Augusti 22, 2024', 'text' => 'Kontakten med Solberga var bara så bra, inget att klaga på. Grymt snabb leverans!', 'stars' => 5, 'source' => 'Google'), array('author' => 'Daniel Johansson', 'date' => 'September 21, 2022', 'text' => 'Super bra service rekommenderas starkt', 'stars' => 5, 'source' => 'Facebook'), array('author' => 'Kjell Bjernstrand', 'date' => 'April 19, 2022', 'text' => 'snabb leverans rekommenderas 👍👍', 'stars' => 5, 'source' => 'Facebook'), array('author' => 'mats johansson', 'date' => 'November 18, 2021', 'text' => 'superbra support, snabb leverans, mycket bra bolag.', 'stars' => 5, 'source' => 'Trustpilot'), array('author' => 'Gustavo Cerrato', 'date' => 'November 17, 2021', 'text' => 'Bra service, snabb leverans och fina råd till kund. Jag är nöjd.', 'stars' => 5, 'source' => 'Trustpilot'), array('author' => 'Jan-Ulf Karlsson', 'date' => 'Oktober 26, 2021', 'text' => 'Kanonservice, mycket trevligt bemötande.', 'stars' => 5, 'source' => 'Trustpilot'), array('author' => 'Sven-Eric Iggström', 'date' => 'Oktober 11, 2021', 'text' => 'Snabba leveranser, trevligt bemötande.', 'stars' => 5, 'source' => 'Trustpilot') ); // Platform SVG logos (20px for cards) $svg_google_20 = ''; $svg_facebook_20 = ''; $svg_trustpilot_20 = ''; $svg_prisjakt_20 = 'P'; $platform_svgs = array( 'Google' => $svg_google_20, 'Facebook' => $svg_facebook_20, 'Trustpilot' => $svg_trustpilot_20, 'Prisjakt' => $svg_prisjakt_20, ); if (!empty($trustindex_reviews)) { echo '
'; echo '

Fler kundrecensioner

'; echo '
'; $shown = 0; foreach ($trustindex_reviews as $review) { if ($shown >= 12) break; $initial = function_exists('mb_substr') ? mb_substr($review['author'], 0, 1) : substr($review['author'], 0, 1); $stars_html = str_repeat('★', intval($review['stars'])) . str_repeat('☆', 5 - intval($review['stars'])); $text = $review['text']; if (function_exists('mb_strlen') && mb_strlen($text) > 200) { $text = mb_substr($text, 0, 200) . '...'; } $platform_svg = isset($platform_svgs[$review['source']]) ? $platform_svgs[$review['source']] : ''; echo '
'; echo '
'; echo '
' . esc_html($initial) . '
'; echo '
' . esc_html($review['author']) . '
' . $platform_svg . ' ' . esc_html($review['date']) . '
'; echo '
'; echo '
' . $stars_html . '
'; echo '

' . esc_html($text) . '

'; echo '
'; $shown++; } echo '
'; echo '
'; } // Review form if ($product->get_reviews_allowed()) { echo '
'; echo '
'; echo '
'; echo '

Lägg till en recension

'; echo ''; echo '
'; } echo '
'; echo '
'; }// Disable Rank Math's schema output on product pages AND blog posts // Code Snippet 5+6 handles all schema for products, Code Snippet 6 handles blog posts add_filter('rank_math/schema/output', function($schemas) { if (is_product()) { if (is_array($schemas)) { foreach ($schemas as $key => $schema) { $type = isset($schema['@type']) ? $schema['@type'] : ''; if ($type === 'Product' || $type === 'ItemPage' || $type === 'WebPage' || $key === 'product') { unset($schemas[$key]); } if (isset($schema['@graph']) && is_array($schema['@graph'])) { foreach ($schema['@graph'] as $gkey => $gitem) { if (isset($gitem['@type']) && $gitem['@type'] === 'Product') { unset($schemas[$key]['@graph'][$gkey]); } } } } } } if (is_single() && !is_product()) { if (is_array($schemas)) { foreach ($schemas as $key => $schema) { $type = isset($schema['@type']) ? $schema['@type'] : ''; if ($type === 'BlogPosting' || $type === 'Article' || $type === 'WebPage') { unset($schemas[$key]); } } } } return $schemas; }, 999); add_action('template_redirect', function() { if (is_product()) { remove_action('rank_math/head', 'RankMath\Schema\Schema_Output::output_schema', 20); remove_action('rank_math/head', 'RankMathPro\Schema\Schema_Output::output_schema', 20); } }); // Strip Rank Math schema-pro script on product pages AND blog posts add_action('wp_head', function() { if (is_product() || (is_single() && !is_product())) { ob_start(function($buffer) { $buffer = preg_replace('/