= 4.5) { $rating_text = __('Sehr gut', 'affililabs'); $predicate_color = '#2ecc71'; } elseif ($rating >= 3.5) { $rating_text = __('Gut', 'affililabs'); $predicate_color = '#27ae60'; } elseif ($rating >= 2.5) { $rating_text = __('Befriedigend', 'affililabs'); $predicate_color = '#f1c40f'; } elseif ($rating >= 1.5) { $rating_text = __('GenĂ¼gend', 'affililabs'); $predicate_color = '#e67e22'; } else { $rating_text = __('Nicht GenĂ¼gend', 'affililabs'); $predicate_color = '#e74c3c'; } $star_rating = AFFLProductService::get_rating_stars_html($rating, 'Rating', 'width: 14px; height: auto;'); $product_link = get_permalink($product_id); $product_url = $product_data['affiliate_link']; $short_title = $product_data['name']; $current_date = gmdate('m/Y'); $favicon_url = get_site_icon_url(); $site_url = get_site_url(); // Use the first category as the product group $product_group = ''; if (!empty($product_data['category_names'])) { $product_group = $product_data['category_names'][0]; } $host_title = wp_parse_url($site_url, PHP_URL_HOST); // If product_url is an affiliate link, we might want to show the domain of the product page or the site itself. // The original code parsed the domain from $product_url (which was get_permalink there). // Here we have $product_url as the affiliate link. // Let's stick to the site's host title for the "Favicon of..." alt text. $host_title = ucwords(str_replace('-', ' ', $host_title)); $host_title_parts = explode('.', $host_title); $host_title = $host_title_parts[0]; // Display URL (ABRUF: ...) // The original code parsed the domain from the product permalink. // Let's use the product permalink for the display URL to keep it clean. $display_url_raw = get_permalink($product_id); $display_url = ''; if(preg_match('/(?P[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})(?P\/[^?]*)?(?P\?.*)?$/i', $display_url_raw, $regs)) { $display_url_parts = array(); $display_url_parts[0] = $regs['domain']; $display_url_parts[1] = $regs['rest']; $display_url = implode('', $display_url_parts); } else { $display_url = $display_url_raw; } $abruf = esc_html__('ABRUF', 'affililabs'); $sealclass = 'affl-seal'; // Custom text option removed as it's not in AFFL settings yet. // We can use the product group (category) as a fallback or leave empty. $custom_text = ''; if (isset($options['custom_text'])) { $custom_text = $options['custom_text']; } else { $custom_text = $product_group; } $mode = ''; $small_mode_class = ''; if (isset($options['mode'])) { $mode = $options['mode']; } if ($mode == 'small') { $small_mode_class = "affl-seal-mode-small"; $output = "
Favicon of $host_title $host_title
$rating_text
$rating_score
$custom_text
"; return $output; } $output = "
Favicon of $host_title $host_title
$custom_text
$rating_text
$rating_score
Note: $rating_text
$star_rating
$short_title
"; return $output; } function affililabs_seal_shortcode($atts, $content = null) { $default = array( 'id' => null, 'mode' => null, 'custom_text' => null, ); $options = shortcode_atts($default, $atts); affililabs_seal_shortcode_assets(); ob_start(); try { affl_print(affililabs_get_seal_template($options)); } catch (Exception $e) { affl_print('Error while rendering template: ' . $e->getMessage()); } return ob_get_clean(); } add_shortcode('affl_seal', 'affililabs_seal_shortcode');