-
Notifications
You must be signed in to change notification settings - Fork 1
/
varbase_seo.module
164 lines (152 loc) · 4.64 KB
/
varbase_seo.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
/**
* @file
* Contains varbase_seo.module.
*/
use Drupal\Core\Form\FormStateInterface;
use Vardot\Entity\EntityDefinitionUpdateManager;
use Vardot\Installer\ModuleInstallerFactory;
/**
* Implements hook_form_BASE_FORM_ID_alter().
*
* Alter node form.
*/
function varbase_seo_form_node_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (isset($form['field_yoast_seo']) &&
isset($form['field_yoast_seo']['widget']) &&
isset($form['field_yoast_seo']['widget']['0']) &&
isset($form['field_yoast_seo']['widget']['0']['yoast_seo'])) {
$form['field_yoast_seo']['widget']['0']['yoast_seo']['#title'] = t('Real-time SEO analyzer');
}
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
*
* Alter Metatag defaults edit form.
*/
function varbase_seo_form_metatag_defaults_edit_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Override Entity type / Group Mapping will be reflected on
// Metatags General form.
$metatag_defaults = $form_state->getformObject()->getEntity();
$metatag_manager = \Drupal::service('metatag.manager');
$values = $metatag_defaults->get('tags');
$form = $metatag_manager->form($values, $form);
// Move Active checkbox to the bottom of the form.
$status = $form['status'];
unset($form['status']);
$form['status'] = $status;
}
/**
* Implements hook_modules_installed().
*/
function varbase_seo_modules_installed($modules) {
// When we enable the Google Analytics module we load the custom GA settings.
if (in_array('google_analytics', $modules)) {
// Varbase SEO custom google analytics config settings.
$google_analytics_managed_optional_configs = [
'google_analytics.settings',
];
ModuleInstallerFactory::importConfigsFromList('varbase_seo', $google_analytics_managed_optional_configs, 'config/managed/google_analytics');
// Entity updates to clear up any mismatched entity and/or field definitions
// And Fix changes were detected in the entity type and field definitions.
\Drupal::classResolver()
->getInstanceFromDefinition(EntityDefinitionUpdateManager::class)
->applyUpdates();
}
}
/**
* Implements hook_pathauto_punctuation_chars_alter().
*
* Alter the list of punctuation characters for Pathauto control.
*
* array $punctuation
* An array of punctuation to be controlled by Pathauto during replacement
* keyed by punctuation name. Each punctuation record should be an array
* with the following key/value pairs:
* - value: The raw value of the punctuation mark.
* - name: The human-readable name of the punctuation mark. This must be
* translated using t() already.
*/
function varbase_seo_pathauto_punctuation_chars_alter(array &$punctuation) {
$punctuation['copyright'] = [
'value' => '©',
'name' => t('Copyright symbol'),
];
$punctuation['trademark'] = [
'value' => '™',
'name' => t('Trademark'),
];
$punctuation['registered_trademark'] = [
'value' => '®',
'name' => t('Registered trademark'),
];
$punctuation['left_double_quotation'] = [
'value' => '”',
'name' => t('Left double quotation'),
];
$punctuation['right_double_quotation'] = [
'value' => '“',
'name' => t('Right double quotation'),
];
$punctuation['en_dash'] = [
'value' => '–',
'name' => t('En dash'),
];
$punctuation['em_dash'] = [
'value' => '—',
'name' => t('Em dash'),
];
// Add the Arabic diacritics and special symbols.
$punctuation['fatha'] = [
'value' => 'َ',
'name' => t('Fatha symbol'),
];
$punctuation['damma'] = [
'value' => 'ُ',
'name' => t('Damma symbol'),
];
$punctuation['ksrah'] = [
'value' => 'ِ',
'name' => t('Ksrah symbol'),
];
$punctuation['tanween_fateh'] = [
'value' => 'ًِ',
'name' => t('Tanween fateh symbol'),
];
$punctuation['tanween_dumm'] = [
'value' => 'ٌِ',
'name' => t('Tanween dumm symbol'),
];
$punctuation['tanween_kser'] = [
'value' => 'ٍِ',
'name' => t('Tanween kser symbol'),
];
$punctuation['shaddah'] = [
'value' => 'ّ',
'name' => t('Shaddah symbol'),
];
$punctuation['sokon'] = [
'value' => 'ْ',
'name' => t('Sokoon symbol'),
];
$punctuation['maddah'] = [
'value' => 'ِ~',
'name' => t('Maddah symbol'),
];
$punctuation['tamdeed'] = [
'value' => 'ِـ',
'name' => t('Tamdeed symbol'),
];
$punctuation['right_guillemet'] = [
'value' => '»',
'name' => t('Right Guillemet symbol'),
];
$punctuation['left_guillemet'] = [
'value' => '«',
'name' => t('Left Guillemet symbol'),
];
$punctuation['question_mark_rtl'] = [
'value' => '؟',
'name' => t('Question mark rtl'),
];
}