From 01ba1c8dbbf91d85218ff182ec366e6c867d9cb0 Mon Sep 17 00:00:00 2001 From: Dekart Deploy Bot Date: Sun, 4 Oct 2026 21:20:35 +0000 Subject: [PATCH] 2026-10-04 template-parts/teachers/schema.php --- .../dekart/template-parts/teachers/schema.php | 139 +++++++++++------- 1 file changed, 85 insertions(+), 54 deletions(-) diff --git a/wp-content/themes/dekart/template-parts/teachers/schema.php b/wp-content/themes/dekart/template-parts/teachers/schema.php index 0101807..6011c53 100644 --- a/wp-content/themes/dekart/template-parts/teachers/schema.php +++ b/wp-content/themes/dekart/template-parts/teachers/schema.php @@ -1,59 +1,66 @@ 'PostalAddress' ); +$street = get_option('branch_address') ?: carbon_get_theme_option('site_address') ?: ''; +$city = dekart_branch_option('branch_city'); +$region = dekart_branch_option('branch_region'); +$zip = function_exists('dekart_schema_option') ? dekart_schema_option('schema_postal_code', 'branch_postal_code') : get_option('branch_postal_code'); +if ($street) { + $addr['streetAddress'] = wp_strip_all_tags($street); } -if (! $org_logo && carbon_get_theme_option('site_logo')) { - $org_logo = wp_get_attachment_url(carbon_get_theme_option('site_logo')); +if ($city) { + $addr['addressLocality'] = wp_strip_all_tags($city); } -if (! $org_logo && carbon_get_theme_option('logo')) { - $org_logo = wp_get_attachment_url(carbon_get_theme_option('logo')); +if ($region) { + $addr['addressRegion'] = wp_strip_all_tags($region); } -$org_addr = get_option('branch_address') ?: carbon_get_theme_option('site_address') ?: ''; -$org_phone = get_option('branch_phone') ?: carbon_get_theme_option('site_phone') ?: ''; +if (! empty($zip) && is_string($zip)) { + $addr['postalCode'] = trim($zip); +} +$addr['addressCountry'] = 'RU'; // Ответственные лица $founder_name = get_option('branch_head_name', ''); -$head_q = get_option('branch_head_position', 'Учредитель школы «Декарт»'); +$head_q = get_option('branch_head_position', 'Учредитель школы «Декарт»'); $teachers_schema = array(); - - // Руководитель if ($founder_name) { $teachers_schema[] = array( '@type' => 'Person', 'name' => $founder_name, 'jobTitle' => $head_q ?: 'Учредитель школы «Декарт»', - 'worksFor' => array( '@type' => 'EducationalOrganization', 'name' => $org_name ), + 'worksFor' => array( '@id' => $org_id ), ); } // Педагоги из CPT teacher -$schema_args = array( - 'posts_per_page' => -1, - 'post_type' => 'teacher', - 'post_status' => 'publish', - 'orderby' => 'date', - 'order' => 'ASC', - 'no_found_rows' => true, +$schema_teachers = get_posts(array( + 'posts_per_page' => -1, + 'post_type' => 'teacher', + 'post_status' => 'publish', + 'orderby' => 'date', + 'order' => 'ASC', + 'no_found_rows' => true, 'update_post_meta_cache' => true, -); -$schema_teachers = get_posts($schema_args); +)); + +$item_list = array(); +$position = 0; foreach ($schema_teachers as $st) { $tid = (int) $st->ID; @@ -61,10 +68,12 @@ foreach ($schema_teachers as $st) { $ed = carbon_get_post_meta($tid, 'teacher_education'); $img = carbon_get_post_meta($tid, 'teacher_avatar'); - // Чистый текст, обрезанный для schema description + // Чистый текст для schema description $schema_desc = ''; if ($ed) { - $schema_desc = wp_strip_all_tags($ed); + $schema_desc = wp_strip_all_tags((string) $ed); + $schema_desc = html_entity_decode($schema_desc, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + $schema_desc = str_replace(array( "\xC2\xA0", ' ' ), ' ', $schema_desc); $schema_desc = preg_replace('/\s+/u', ' ', $schema_desc); $schema_desc = trim($schema_desc); if (mb_strlen($schema_desc) > 200) { @@ -74,10 +83,10 @@ foreach ($schema_teachers as $st) { $person = array( '@type' => 'Person', - 'name' => get_the_title($tid), + 'name' => wp_strip_all_tags(get_the_title($tid)), 'url' => get_permalink($tid), 'jobTitle' => $subj ?: 'Преподаватель', - 'worksFor' => array( '@type' => 'EducationalOrganization', 'name' => $org_name ), + 'worksFor' => array( '@id' => $org_id ), 'description' => $schema_desc, ); if ($subj) { @@ -86,19 +95,17 @@ foreach ($schema_teachers as $st) { if ($img && wp_get_attachment_url($img)) { $person['image'] = wp_get_attachment_url($img); } - // aggregateRating - $rating_val = carbon_get_post_meta($tid, 'teacher_rating'); - $rating_num = is_numeric($rating_val) ? (float) $rating_val : 0.0; - $rating_cnt = function_exists('dekart_teacher_review_count') ? dekart_teacher_review_count($tid) : 0; - if ($rating_num > 0 && $rating_cnt > 0) { - $person['aggregateRating'] = array( - '@type' => 'AggregateRating', - 'ratingValue' => number_format($rating_num, 1), - 'bestRating' => '5', - 'ratingCount' => (int) $rating_cnt, - ); - } + // aggregateRating НЕ выводим — на листинге нет объектов review + $teachers_schema[] = $person; + + $position++; + $item_list[] = array( + '@type' => 'ListItem', + 'position' => $position, + 'url' => get_permalink($tid), + 'name' => wp_strip_all_tags(get_the_title($tid)), + ); } if (empty($teachers_schema)) { @@ -106,27 +113,51 @@ if (empty($teachers_schema)) { } $org_schema = array( - '@type' => 'EducationalOrganization', - 'name' => $org_name, - 'url' => $org_url, + '@type' => 'EducationalOrganization', + '@id' => $org_id, + 'name' => $org_name, + 'url' => home_url('/'), + 'address' => $addr, ); if ($org_logo) { $org_schema['logo'] = $org_logo; } -if ($org_addr) { - $org_schema['address'] = $org_addr; -} if ($org_phone) { $org_schema['telephone'] = $org_phone; } $org_schema['employee'] = $teachers_schema; + +$graph = array(); + +$collection = array( + '@type' => 'CollectionPage', + '@id' => $page_url . '#webpage', + 'url' => $page_url, + 'name' => wp_strip_all_tags(get_the_title()) ?: 'Преподаватели', +); +if (! empty($item_list)) { + $collection['mainEntity'] = array( '@id' => $list_id ); +} +$graph[] = $collection; + +if (! empty($item_list)) { + $graph[] = array( + '@type' => 'ItemList', + '@id' => $list_id, + 'name' => 'Преподаватели', + 'numberOfItems' => count($item_list), + 'itemListElement' => $item_list, + ); +} + +$graph[] = $org_schema; ?> \ No newline at end of file +