varbase_seo.module in Varbase SEO 9.0.x
Same filename and directory in other branches
Contains varbase_seo.module.
File
varbase_seo.moduleView source
<?php
/**
* @file
* Contains varbase_seo.module.
*/
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\Yaml\Yaml;
use Vardot\Entity\EntityDefinitionUpdateManager;
/**
* 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)) {
$google_analytics_managed_optional_path = Drupal::service('module_handler')
->getModule('varbase_seo')
->getPath() . '/config/managed/google_analytics';
// Varbase SEO custom google analytics config settings.
$google_analytics_managed_optional_configs = [
'google_analytics.settings',
];
foreach ($google_analytics_managed_optional_configs as $config_name) {
$config_path = $google_analytics_managed_optional_path . '/' . $config_name . '.yml';
$config_content = file_get_contents($config_path);
$config_data = (array) Yaml::parse($config_content);
$config_factory = \Drupal::configFactory()
->getEditable($config_name);
$config_factory
->setData($config_data)
->save(TRUE);
}
// 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'),
];
// 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'),
];
}
Functions
Name | Description |
---|---|
varbase_seo_form_metatag_defaults_edit_form_alter | Implements hook_form_BASE_FORM_ID_alter(). |
varbase_seo_form_node_form_alter | Implements hook_form_BASE_FORM_ID_alter(). |
varbase_seo_modules_installed | Implements hook_modules_installed(). |
varbase_seo_pathauto_punctuation_chars_alter | Implements hook_pathauto_punctuation_chars_alter(). |