$cached_code, 'i18n' => array( 'videoLoadError' => __('Napaka pri nalaganju videa. Poskusite znova.', 'aboutbuzz-stories-embed'), 'alreadyLiked' => __('Že ste označili kot uporabno', 'aboutbuzz-stories-embed'), 'voteError' => __('Napaka pri glasovanju. Poskusite znova.', 'aboutbuzz-stories-embed'), 'voteErrorPrefix' => __('Napaka pri glasovanju:', 'aboutbuzz-stories-embed'), ), ) ); } add_action('wp_enqueue_scripts', 'aboutbuzz_enqueue_assets'); function aboutbuzz_resource_hints($urls, $relation_type) { if ($relation_type === 'preconnect') { $urls[] = 'https://aboutbuzz.com'; } return $urls; } add_filter('wp_resource_hints', 'aboutbuzz_resource_hints', 10, 2); function aboutbuzz_activation_menu() { add_options_page( 'AboutBuzz Activation', 'AboutBuzz Activation', 'manage_options', 'aboutbuzz-activation', 'aboutbuzz_activation_page' ); } add_action('admin_menu', 'aboutbuzz_activation_menu'); function aboutbuzz_activation_page() { if (!current_user_can('manage_options')) { wp_die('Unauthorized user'); } ?>

AboutBuzz Activation

For setup or help, please contact info@aboutbuzz.com and visit aboutbuzz.com.

If you are subscribed to an AboutBuzz plan, you will find your setup instructions directly inside your client dashboard area on AboutBuzz.com.

Loading...' ); } function aboutbuzz_is_mobile() { return wp_is_mobile() || (isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i', sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])))); } function aboutbuzz_get_user_identifier() { $user_id = get_current_user_id(); if ($user_id) { return 'user_' . $user_id; } $ip = isset($_SERVER['REMOTE_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])) : 'unknown'; return 'anon_' . md5($ip . NONCE_SALT); } function aboutbuzz_get_detailed_error($response_code, $response_body) { switch ($response_code) { case 401: return 'Invalid secret code. Please check your activation settings.'; case 403: return 'Access forbidden. Your secret code may be expired.'; case 404: return 'Brand not found. Please check your activation code.'; case 429: return ''; case 500: return 'Server error. Please try again later.'; default: $data = json_decode($response_body, true); if (isset($data['message'])) { return 'API Error: ' . $data['message']; } return 'Unknown API error (Code: ' . $response_code . ')'; } } function aboutbuzz_render_stars($rating) { $rating = max(0, min(5, intval($rating))); $path = 'M 189.410156 10.039062 L 229.1875 90.308594 C 230.976562 94.25 234.921875 97.117188 239.21875 97.476562 L 328.089844 110.375 C 338.84375 112.167969 343.5 125.425781 335.617188 133.3125 L 271.113281 195.664062 C 267.886719 198.890625 266.453125 203.191406 267.171875 207.488281 L 282.222656 295.644531 C 284.015625 306.394531 272.546875 314.996094 262.871094 309.621094 L 183.675781 268.050781 C 179.734375 265.902344 175.074219 265.902344 171.132812 268.050781 L 91.9375 309.980469 C 82.261719 314.996094 70.792969 306.753906 72.585938 296.003906 L 87.636719 207.847656 C 88.355469 203.546875 86.921875 199.246094 83.695312 196.023438 L 19.550781 133.3125 C 11.667969 125.425781 15.96875 112.167969 27.074219 110.375 L 115.945312 97.476562 C 120.246094 96.757812 124.1875 94.25 125.980469 90.308594 L 165.398438 10.039062 C 170.417969 0.00390625 184.390625 0.00390625 189.410156 10.039062 Z'; $out = ''; for ($i = 1; $i <= 5; $i++) { $filled = $i <= $rating; $class = 'aboutbutzz-star-icon aboutbutzz-star-size aboutbutzz-star-' . ($filled ? 'filled' : 'empty'); $out .= ''; } return $out; } function aboutbuzz_site_language() { $locale = function_exists('determine_locale') ? determine_locale() : get_locale(); return aboutbuzz_normalize_language(is_string($locale) ? $locale : ''); } function aboutbuzz_ui_language($review_language = '') { $review_language = aboutbuzz_normalize_language($review_language); if ($review_language !== '') { return $review_language; } return aboutbuzz_site_language(); } function aboutbuzz_get_source_badge_url($value, $language = '') { if (!is_string($value) || $value === '') { return []; } $trimmed = ltrim($value); $key = strtolower($trimmed); $language = aboutbuzz_ui_language($language); $base = plugin_dir_url(__FILE__) . 'assets/icons/'; if (strpos($key, 'verified purchase') === 0 || strpos($key, 'verifizierter kauf') === 0) { $de = plugin_dir_path(__FILE__) . 'assets/icons/badge-verified-purchase-de.png'; if ($language === 'de' && file_exists($de)) { return [ 'url' => $base . 'badge-verified-purchase-de.png', 'alt' => 'Verifizierter Kauf', ]; } return [ 'url' => $base . 'badge-verified-purchase.png', 'alt' => 'Authentic Verified Purchase', ]; } if (strpos($key, 'verified tester') === 0 || strpos($key, 'kostenloses testprodukt') === 0) { $de = plugin_dir_path(__FILE__) . 'assets/icons/badge-verified-tester-de.png'; if ($language === 'de' && file_exists($de)) { return [ 'url' => $base . 'badge-verified-tester-de.png', 'alt' => 'Kostenloses Testprodukt', ]; } return [ 'url' => $base . 'badge-verified-tester.png', 'alt' => 'Authentic Verified Tester', ]; } return []; } function aboutbuzz_review_origin_notice($language) { if ($language !== 'de') { return ''; } return 'Herkunft der Video-Bewertungen: Die angezeigten Videos stammen von Personen, die das Produkt gekauft haben (Verifizierter Kauf) oder es als kostenloses Testprodukt erhalten haben (Kostenloses Testprodukt). aboutbuzz prüft die Angaben zur Herkunft. Für den Inhalt der Bewertung wird keine Gegenleistung gezahlt.'; } function aboutbuzz_normalize_language($value) { if (!is_string($value) || $value === '') { return ''; } $key = strtolower(trim($value)); static $map = [ 'slovenščina' => 'sl', 'slovenscina' => 'sl', 'slovenian' => 'sl', 'sl' => 'sl', 'sl_si' => 'sl', 'angleščina' => 'en', 'anglescina' => 'en', 'english' => 'en', 'en' => 'en', 'en_us' => 'en', 'en_gb' => 'en', 'ruščina' => 'ru', 'ruscina' => 'ru', 'russian' => 'ru', 'ru' => 'ru', 'ru_ru' => 'ru', 'nemščina' => 'de', 'nemscina' => 'de', 'german' => 'de', 'de' => 'de', 'de_de' => 'de', 'de_at' => 'de', 'de_ch' => 'de', 'latviščina' => 'lv', 'latviscina' => 'lv', 'latvian' => 'lv', 'lv' => 'lv', 'lv_lv' => 'lv', 'turščina' => 'tr', 'turscina' => 'tr', 'turkish' => 'tr', 'tr' => 'tr', 'tr_tr' => 'tr', ]; return $map[$key] ?? ''; } function aboutbuzz_verified_review_label($language) { static $labels = [ 'sl' => 'Ocena testiranega izdelka', 'en' => 'Verified product review', 'ru' => 'Проверенный отзыв о товаре', 'de' => 'Verifizierte Produktbewertung', 'lv' => 'Apstiprināta produkta atsauksme', 'tr' => 'Doğrulanmış ürün yorumu', ]; if (isset($labels[$language])) { return $labels[$language]; } return __('Verified product review', 'aboutbuzz-stories-embed'); } function aboutbuzz_footer_caption($language, $average_rating) { $rating = (string) $average_rating; static $tpl = [ 'sl' => 'Skupna ocena: %s/5 – iskrena mnenja resničnih ljudi!', 'en' => 'Average rating: %s/5 – honest reviews from real people!', 'de' => 'Gesamtbewertung: %s/5 – ehrliche Meinungen echter Menschen!', 'ru' => 'Общая оценка: %s/5 – честные отзывы реальных людей!', 'lv' => 'Vidējais vērtējums: %s/5 – godīgas atsauksmes no īstiem cilvēkiem!', 'tr' => 'Ortalama puan: %s/5 – gerçek insanlardan dürüst yorumlar!', ]; $template = $tpl[$language] ?? $tpl['en']; return sprintf($template, $rating); } function aboutbuzz_clean_story_text($value) { if (is_array($value)) { if (!array_key_exists(0, $value) || is_array($value[0]) || is_object($value[0])) { return ''; } $value = $value[0]; } if (!is_string($value)) { return ''; } $value = trim(sanitize_text_field($value)); if ($value === '' || $value === '0') { return ''; } return $value; } function aboutbuzz_story_product_name($story) { if (!is_array($story)) { return ''; } $acf = (isset($story['acf']) && is_array($story['acf'])) ? $story['acf'] : []; $meta = (isset($story['meta']) && is_array($story['meta'])) ? $story['meta'] : []; $candidates = [ $acf['product'] ?? null, $acf['product_name'] ?? null, $acf['izdelek'] ?? null, $acf['product_title'] ?? null, ]; if (isset($meta['product']) && is_array($meta['product'])) { $candidates[] = $meta['product'][0] ?? null; } foreach ($candidates as $candidate) { $label = aboutbuzz_clean_story_text($candidate); if ($label !== '') { return $label; } } return ''; } function aboutbuzz_smart_brand_stories_shortcode($atts) { $atts = shortcode_atts(['code' => '', 'lang' => ''], $atts); $activation_code = !empty($atts['code']) ? sanitize_text_field($atts['code']) : ''; if (empty($activation_code)) { return '
Activation code required in shortcode: [aboutbuzz_reviews code="ABZ-XXXX-XXXX"]
'; } if (strlen($activation_code) > 255) { return '
Invalid activation code format.
'; } if (!empty($activation_code)) { update_option('aboutbuzz_activation_code_cache', $activation_code); } $cache_key = 'aboutbuzz_stories_bycode_' . md5($activation_code); $admin_nocache = isset($_GET['abz_nocache']) && current_user_can('manage_options'); $cached_body = $admin_nocache ? false : get_transient($cache_key); $from_cache = ($cached_body !== false); if ($from_cache && is_string($cached_body)) { $from_cache = false; delete_transient($cache_key); $cached_body = false; } if ($from_cache && is_array($cached_body) && !empty($cached_body)) { $cached_story = $cached_body[0]; $has_language = is_array($cached_story) && array_key_exists('language', $cached_story); $has_product = $has_language && isset($cached_story['acf']) && is_array($cached_story['acf']) && array_key_exists('product', $cached_story['acf']); if (!$has_language || !$has_product) { $from_cache = false; delete_transient($cache_key); $cached_body = false; } } $sanitized_posts = ($from_cache && is_array($cached_body)) ? $cached_body : []; if (!$from_cache) { $api_rate_limit_key = 'aboutbuzz_api_rate_' . aboutbuzz_get_user_identifier(); $api_rate_count = get_transient($api_rate_limit_key); if ($api_rate_count && $api_rate_count >= 60) { if (current_user_can('manage_options')) { return '
AboutBuzz: API rate limit reached (>60 uncached requests/hour). Visible to admins only. Non-admin visitors see no output.
'; } return ''; } $response = wp_remote_post('https://aboutbuzz.com/wp-json/aboutbuzz/v1/stories/by-code', [ 'timeout' => 10, 'headers' => [ 'Content-Type' => 'application/json', 'User-Agent' => 'AboutBuzz-WordPress-Plugin/' . ABOUTBUZZ_EMBED_VERSION, 'Accept' => 'application/json', ], 'body' => wp_json_encode(['code' => $activation_code]), 'sslverify' => true, ]); $new_api_count = $api_rate_count ? $api_rate_count + 1 : 1; set_transient($api_rate_limit_key, $new_api_count, 3600); if (is_wp_error($response)) { if (current_user_can('manage_options')) { return '
AboutBuzz: network error fetching stories: ' . esc_html($response->get_error_message()) . ' — visible to admins only.
'; } return ''; } $response_code = wp_remote_retrieve_response_code($response); $response_body = wp_remote_retrieve_body($response); if ($response_code !== 200) { $error_message = aboutbuzz_get_detailed_error($response_code, $response_body); if ($response_code === 429) { $error_message = 'Rate limit reached. Please try again in a few minutes.'; } if ($error_message === '') { $error_message = 'Unable to load reviews right now. Please try again soon.'; } if (current_user_can('manage_options')) { return '
AboutBuzz: API error (HTTP ' . intval($response_code) . '): ' . esc_html($error_message) . ' — visible to admins only. Non-admin visitors see no output.
'; } return ''; } $data = json_decode($response_body, true); if (json_last_error() !== JSON_ERROR_NONE || !is_array($data)) { if (current_user_can('manage_options')) { return '
AboutBuzz: invalid response format from API — visible to admins only.
'; } return ''; } foreach ($data as $story) { if (!is_array($story) || empty($story['id'])) { continue; } $video_url = $story['content'] ?? $story['link'] ?? ''; $rating = intval($story['acf']['rating'] ?? $story['meta']['rating'][0] ?? 5); $vote_count = intval($story['acf']['vote_count'] ?? $story['meta']['vote_count'][0] ?? 0); $watermark = $story['acf']['watermark_video'] ?? $story['meta']['watermark_video'][0] ?? ''; $product_source = $story['acf']['product_source'] ?? $story['meta']['product_source'][0] ?? ''; $product_source = is_string($product_source) ? sanitize_text_field($product_source) : ''; $brand_name = $story['acf']['brand'] ?? $story['meta']['brand'][0] ?? ''; $brand_name = is_string($brand_name) ? sanitize_text_field($brand_name) : ''; $product_name = aboutbuzz_story_product_name($story); $jezik = $story['acf']['jezik'] ?? ''; $language = aboutbuzz_normalize_language(is_string($jezik) ? $jezik : ''); $sanitized_posts[] = [ 'ID' => intval($story['id']), 'meta' => [ 'story' => [esc_url_raw($video_url)], 'rating' => [$rating], 'vote_count' => [$vote_count], 'watermark_video' => [esc_url_raw(is_array($watermark) ? ($watermark[0] ?? '') : $watermark)], 'product_source' => [$product_source], 'brand' => [$brand_name], 'product' => [$product_name], ], 'acf' => [ 'watermark_video' => esc_url_raw(is_array($watermark) ? ($watermark[0] ?? '') : $watermark), 'story' => esc_url_raw($video_url), 'rating' => $rating, 'vote_count' => $vote_count, 'product_source' => $product_source, 'brand' => $brand_name, 'product' => $product_name, ], 'language' => $language, ]; } set_transient($cache_key, $sanitized_posts, 5 * MINUTE_IN_SECONDS); } if (empty($sanitized_posts)) { return '
' . esc_html__('Ni video ocen', 'aboutbuzz-stories-embed') . '
'; } $total_rating = 0; $rating_count = 0; foreach ($sanitized_posts as $post) { $rating = $post['meta']['rating'][0] ?? $post['acf']['rating'] ?? 0; if ($rating > 0) { $total_rating += $rating; $rating_count++; } } $average_rating = $rating_count > 0 ? round($total_rating / $rating_count, 2) : 0; $widget_nonce = wp_create_nonce('aboutbuzz_widget_' . md5($activation_code)); $video_count = count($sanitized_posts); $has_many_videos = ' aboutbutzz-has-many-videos'; $widget_lang = aboutbuzz_site_language(); if (!empty($atts['lang'])) { $forced_lang = aboutbuzz_normalize_language($atts['lang']); if ($forced_lang !== '') { $widget_lang = $forced_lang; } } ob_start(); ?>
$post_id, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'posts_per_page' => 1, )); if ($kids) { $screenshot = wp_get_attachment_url($kids[0]->ID); } else { $directory = dirname($video_url); $screenshot = $directory . '/screenshot-' . $post_id . '.jpg'; } } } } if (empty($video_url)) { continue; } if (empty($screenshot) || !filter_var($screenshot, FILTER_VALIDATE_URL)) { $screenshot = aboutbuzz_get_fallback_image(); } $vote_count = is_array($video_data['vote_count']) ? ($video_data['vote_count'][0] ?? 0) : ($video_data['vote_count'] ?? 0); $rating = is_array($video_data['rating']) ? ($video_data['rating'][0] ?? 0) : ($video_data['rating'] ?? 0); $product_source_value = isset($video_data['product_source']) ? (is_array($video_data['product_source']) ? ($video_data['product_source'][0] ?? '') : $video_data['product_source']) : ''; $source_badge = aboutbuzz_get_source_badge_url($product_source_value, $widget_lang); $brand_label = aboutbuzz_clean_story_text($video_data['brand'] ?? ''); $product_label = aboutbuzz_clean_story_text($video_data['product'] ?? ''); $under_video_label = $product_label ?: $brand_label ?: aboutbuzz_verified_review_label($widget_lang); $is_mobile = aboutbuzz_is_mobile(); $is_first = ($index === 0); ?>
<?php echo esc_attr(__('Predogled video ocene', 'aboutbuzz-stories-embed')); ?> <?php echo esc_attr(__('Predogled video ocene', 'aboutbuzz-stories-embed')); ?>
Play
<?php echo esc_attr(__('Predogled video ocene', 'aboutbuzz-stories-embed')); ?> <?php echo esc_attr(__('Predogled video ocene', 'aboutbuzz-stories-embed')); ?>
Play
<?php echo esc_attr($source_badge['alt']); ?>

400)); } $nonce = sanitize_text_field(wp_unslash($_POST['nonce'])); $post_id = intval(wp_unslash($_POST['post_id'])); $activation_code = get_option('aboutbuzz_activation_code_cache', ''); if (empty($activation_code)) { wp_die('Plugin not configured', 'Error', array('response' => 403)); } if (!wp_verify_nonce($nonce, 'aboutbuzz_widget_' . md5($activation_code))) { wp_die('Security check failed'); } $user_id = aboutbuzz_get_user_identifier(); $like_key = 'aboutbuzz_liked_' . $post_id . '_' . $user_id; if (get_transient($like_key)) { wp_send_json_error(['message' => 'Already liked']); return; } $rate_limit_key = 'aboutbuzz_like_rate_' . $user_id; $rate_count = get_transient($rate_limit_key); if ($rate_count && $rate_count >= 5) { wp_send_json_error(['message' => 'Too many likes']); return; } $new_rate_count = $rate_count ? $rate_count + 1 : 1; set_transient($rate_limit_key, $new_rate_count, 3600); $secret_code = get_option('aboutbuzz_activation_code_cache', ''); if (empty($secret_code)) { wp_send_json_error(['message' => 'Plugin not configured. Please use the shortcode first.']); return; } $response = wp_remote_post('https://aboutbuzz.com/wp-json/aboutbuzz/v1/like/', [ 'timeout' => 8, 'headers' => [ 'Content-Type' => 'application/json', 'User-Agent' => 'AboutBuzz-WordPress-Plugin/' . ABOUTBUZZ_EMBED_VERSION ], 'body' => wp_json_encode([ 'code' => sanitize_text_field($secret_code), 'post_id' => $post_id ]) ]); if (is_wp_error($response)) { wp_send_json_error(['message' => 'API error']); return; } $response_code = wp_remote_retrieve_response_code($response); $response_body = wp_remote_retrieve_body($response); if ($response_code !== 200) { wp_send_json_error(['message' => 'API error']); return; } $data = json_decode($response_body, true); if (!$data || !isset($data['success']) || !$data['success']) { wp_send_json_error(['message' => 'API error']); return; } set_transient($like_key, true, 86400); wp_send_json_success([ 'vote_count' => intval($data['vote_count'] ?? 0) ]); } add_action('wp_ajax_aboutbuzz_like_post', 'aboutbuzz_like_post'); add_action('wp_ajax_nopriv_aboutbuzz_like_post', 'aboutbuzz_like_post'); register_uninstall_hook(__FILE__, 'aboutbuzz_uninstall'); function aboutbuzz_uninstall() { try { delete_option('aboutbuzz_secret_code'); delete_option('aboutbuzz_activation_code_cache'); $transient_keys = [ 'aboutbuzz_validation_', 'aboutbuzz_rate_limit_', 'aboutbuzz_cache_', 'aboutbuzz_stories_bycode_' ]; foreach ($transient_keys as $key) { wp_cache_delete($key, 'transient'); } wp_cache_flush(); } catch (Exception $e) { } } register_activation_hook(__FILE__, 'aboutbuzz_activate'); function aboutbuzz_activate() { if (version_compare(PHP_VERSION, '7.4', '<')) { deactivate_plugins(plugin_basename(__FILE__)); wp_die('This plugin requires PHP 7.4 or higher.'); } add_option('aboutbuzz_secret_code', ''); wp_cache_flush(); } register_deactivation_hook(__FILE__, 'aboutbuzz_deactivate'); function aboutbuzz_deactivate() { $transient_keys = [ 'aboutbuzz_validation_', 'aboutbuzz_rate_limit_', 'aboutbuzz_cache_', 'aboutbuzz_stories_bycode_' ]; foreach ($transient_keys as $key) { wp_cache_delete($key, 'transient'); } wp_cache_flush(); }