temaplte fixes in app and in plugin

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-10 06:17:38 +00:00
parent 975eab46cf
commit 9e785f141c
11 changed files with 311 additions and 173 deletions

View File

@@ -208,6 +208,8 @@ function igny8_parse_keywords($keywords) {
* @return array Array of badges with 'text' and 'type' keys
*/
function igny8_get_section_badges($heading, $post_id) {
static $used_keywords = [];
$badges = [];
$heading_lower = strtolower($heading);
@@ -217,39 +219,44 @@ function igny8_get_section_badges($heading, $post_id) {
$primary_kw = get_post_meta($post_id, '_igny8_primary_keyword', true);
$secondary_kws = get_post_meta($post_id, '_igny8_secondary_keywords', true);
// Priority 1: Primary keyword
if ($primary_kw && stripos($heading_lower, strtolower($primary_kw)) !== false) {
// Priority 1: Primary keyword (if not used)
if ($primary_kw && !in_array(strtolower($primary_kw), $used_keywords) && stripos($heading_lower, strtolower($primary_kw)) !== false) {
$badges[] = ['text' => $primary_kw, 'type' => 'primary'];
$used_keywords[] = strtolower($primary_kw);
return $badges; // Return only 1 badge
}
// Priority 2: Tags
if ($tags && !is_wp_error($tags) && count($badges) < 2) {
// Priority 2: Tags (if not used)
if ($tags && !is_wp_error($tags)) {
foreach ($tags as $tag) {
if (stripos($heading_lower, strtolower($tag->name)) !== false) {
if (!in_array(strtolower($tag->name), $used_keywords) && stripos($heading_lower, strtolower($tag->name)) !== false) {
$badges[] = ['text' => $tag->name, 'type' => 'tag'];
if (count($badges) >= 2) break;
$used_keywords[] = strtolower($tag->name);
return $badges; // Return only 1 badge
}
}
}
// Priority 3: Categories
if ($categories && !is_wp_error($categories) && count($badges) < 2) {
// Priority 3: Categories (if not used)
if ($categories && !is_wp_error($categories)) {
foreach ($categories as $cat) {
if (stripos($heading_lower, strtolower($cat->name)) !== false) {
if (!in_array(strtolower($cat->name), $used_keywords) && stripos($heading_lower, strtolower($cat->name)) !== false) {
$badges[] = ['text' => $cat->name, 'type' => 'category'];
if (count($badges) >= 2) break;
$used_keywords[] = strtolower($cat->name);
return $badges; // Return only 1 badge
}
}
}
// Priority 4: Secondary keywords
if ($secondary_kws && count($badges) < 2) {
// Priority 4: Secondary keywords (if not used)
if ($secondary_kws) {
$kw_array = is_array($secondary_kws) ? $secondary_kws : explode(',', $secondary_kws);
foreach ($kw_array as $kw) {
$kw = trim($kw);
if (!empty($kw) && stripos($heading_lower, strtolower($kw)) !== false) {
if (!empty($kw) && !in_array(strtolower($kw), $used_keywords) && stripos($heading_lower, strtolower($kw)) !== false) {
$badges[] = ['text' => $kw, 'type' => 'keyword'];
if (count($badges) >= 2) break;
$used_keywords[] = strtolower($kw);
return $badges; // Return only 1 badge
}
}
}