Skip to content

Commit 009fa0b

Browse files
committed
Added new tab MicroData for pages and models. Remove wmMicroData component
1 parent be35063 commit 009fa0b

File tree

10 files changed

+97
-74
lines changed

10 files changed

+97
-74
lines changed

Plugin.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public function registerComponents(): array
9595
'Webmaxx\Seo\Components\Tags' => 'wmSeoTags',
9696
'Webmaxx\Seo\Components\GtmHead' => 'wmSeoGtmHead',
9797
'Webmaxx\Seo\Components\GtmNoScript' => 'wmSeoGtmNoScript',
98-
'Webmaxx\Seo\Components\MicroData' => 'wmMicroData',
9998
];
10099
}
101100

components/MicroData.php

Lines changed: 0 additions & 34 deletions
This file was deleted.

components/Tags.php

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class Tags extends ComponentBase
2323
protected $metaTagManager;
2424
protected $contentTagManager;
2525
protected $seoTaggableModelTags = [];
26+
protected $microdata;
2627

2728
public function componentDetails()
2829
{
@@ -50,29 +51,23 @@ public function defineProperties()
5051
];
5152
}
5253

53-
public function init()
54-
{
55-
$this->metaTagManager = app(MetaTagManager::class);
56-
$this->contentTagManager = app(ContentTagManager::class);
57-
}
58-
5954
public function onRun()
6055
{
6156
Event::listen('webmaxx.seo.component.tags.loadSeoTaggableModel', function($model) {
6257
$this->seoTaggableModelTags = data_get($model, $model->seoTaggableRelationField() . '.tags');
6358
$this->seoTaggableModelTags['page_title'] = $model->seoPageTitle();
59+
$this->modelMicrodataContent = data_get($model, $model->seoTaggableRelationField() . '.tags.microdata_content');
6460
app('wmSeoComponentTagsContentTagsPreset')->addTags($model->extendedSeoContentTags());
6561
});
6662
}
6763

6864
public function tags(): string
6965
{
70-
$this->contentTagManager
71-
->addTags(app('wmSeoComponentTagsContentTagsPreset'));
66+
$contentTagManager = $this->getContentTagManager();
7267

7368
$context = new MetaTagContext($this->page, $this->seoTaggableModelTags);
7469

75-
return $this->metaTagManager
70+
return $this->getMetaTagManager()
7671
->addTags([
7772
new TitleTag($context),
7873
new MetaDescriptionTag($context),
@@ -93,6 +88,38 @@ public function tags(): string
9388
->addTagIf($this->property('show_global_custom_og'), new RawTag(Settings::get('custom_og_tags')))
9489
->addTag(new RawTag($this->page->og_custom_tags))
9590
->addTag(new RawTag(data_get($this->seoTaggableModelTags, 'og_custom_tags', '')))
96-
->renderWithContentTags($this->contentTagManager);
91+
->renderWithContentTags($contentTagManager);
92+
}
93+
94+
public function microdata(): string
95+
{
96+
if ($this->microdata === null) {
97+
$this->microdata = $this->getContentTagManager()
98+
->render(implode("\n", [
99+
Settings::get('custom_microdata_content'),
100+
data_get($this->seoTaggableModelTags, 'microdata_content', $this->page->microdata_content),
101+
]));
102+
}
103+
104+
return $this->microdata;
105+
}
106+
107+
protected function getMetaTagManager()
108+
{
109+
if ($this->metaTagManager === null) {
110+
$this->metaTagManager = app(MetaTagManager::class);
111+
}
112+
113+
return $this->metaTagManager;
114+
}
115+
116+
protected function getContentTagManager()
117+
{
118+
if ($this->contentTagManager === null) {
119+
$this->contentTagManager = app(ContentTagManager::class);
120+
$this->contentTagManager->addTags(app('wmSeoComponentTagsContentTagsPreset'));
121+
}
122+
123+
return $this->contentTagManager;
97124
}
98125
}

components/microdata/default.htm

Lines changed: 0 additions & 1 deletion
This file was deleted.

components/tags/default.htm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
{{ __SELF__.tags|raw }}
2+
3+
{% if __SELF__.microdata %}
4+
{% put wm_microdata %}
5+
{{ __SELF__.microdata|raw }}
6+
{% endput %}
7+
{% endif %}

lang/en/lang.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
'comment' => 'Click or drag these in to the content area',
6565
],
6666
'microdata_content' => [
67-
'label' => 'MicroData content',
67+
'label' => 'Custom MicroData',
6868
],
6969
],
7070
],
@@ -75,6 +75,7 @@
7575
'site' => 'General site settings',
7676
'meta_tags' => 'Meta tags',
7777
'og_tags' => 'Open Graph',
78+
'microdata' => 'MicroData',
7879
'counters' => 'Counters',
7980
'robots_txt' => 'Robots.txt',
8081
'humans_txt' => 'Humans.txt',
@@ -120,6 +121,9 @@
120121
'custom_og_tags' => [
121122
'label' => 'Custom Open Graph tags',
122123
],
124+
'custom_microdata_content' => [
125+
'label' => 'Custom MicroData',
126+
],
123127
'gtm_code' => [
124128
'label' => 'Google Tag Manager ID',
125129
],
@@ -331,10 +335,6 @@
331335
],
332336
],
333337
],
334-
'microdata' => [
335-
'name' => 'Microdata',
336-
'description' => 'Custom microdata to display',
337-
],
338338
],
339339
'contentTags' => [
340340
'domain' => 'Domain',

lang/ru/lang.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
'comment' => 'Щелкните или перетащите их в область содержимого',
6565
],
6666
'microdata_content' => [
67-
'label' => 'Микроразметка',
67+
'label' => 'Пользовательская микроразметка',
6868
],
6969
],
7070
],
@@ -75,6 +75,7 @@
7575
'site' => 'Общие настройки сайта',
7676
'meta_tags' => 'META-теги',
7777
'og_tags' => 'Open Graph',
78+
'microdata' => 'Микроразметка',
7879
'counters' => 'Счётчики',
7980
'robots_txt' => 'Robots.txt',
8081
'humans_txt' => 'Humans.txt',
@@ -120,6 +121,9 @@
120121
'custom_og_tags' => [
121122
'label' => 'Пользовательские OpenGraph теги',
122123
],
124+
'custom_microdata_content' => [
125+
'label' => 'Пользовательская микроразметка',
126+
],
123127
'gtm_code' => [
124128
'label' => 'Google Tag Manager ID',
125129
],
@@ -327,10 +331,6 @@
327331
],
328332
],
329333
],
330-
'microdata' => [
331-
'name' => 'Микроразметка',
332-
'description' => 'Отображение пользовательской микроразметки',
333-
],
334334
],
335335
'contentTags' => [
336336
'domain' => 'Домен сайта',

models/meta/fields.yaml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fields:
6363
size: large
6464
span: full
6565

66-
meta_available_tags:
66+
_meta_available_tags:
6767
tab: webmaxx.seo::lang.models.meta.tabs.seo_meta
6868
type: partial
6969
path: $/webmaxx/seo/models/meta/_field_available_tags.htm
@@ -113,7 +113,7 @@ fields:
113113
size: large
114114
span: full
115115

116-
og_available_tags:
116+
_og_available_tags:
117117
tab: webmaxx.seo::lang.models.meta.tabs.seo_og
118118
type: partial
119119
path: $/webmaxx/seo/models/meta/_field_available_tags.htm
@@ -129,3 +129,9 @@ fields:
129129
language: html
130130
size: giant
131131
span: full
132+
133+
_microdata_available_tags:
134+
tab: webmaxx.seo::lang.models.meta.tabs.seo_microdata
135+
type: partial
136+
path: $/webmaxx/seo/models/meta/_field_available_tags.htm
137+
span: full

0 commit comments

Comments
 (0)