Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Y
yoast_seo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
yoast_seo
Commits
c2d138a3
Commit
c2d138a3
authored
Feb 03, 2018
by
Kingdutch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2941887
by Kingdutch: Hotfix usage of deprecated code
parent
33d1a1c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
yoast_seo.module
yoast_seo.module
+40
-40
No files found.
yoast_seo.module
View file @
c2d138a3
...
...
@@ -100,43 +100,43 @@ function yoast_seo_entity_type_build(array &$entity_types) {
* If an entity has values for the custom title or description fields then we
* use those values in place of the metatags defaults.
*/
function
yoast_seo_metatags_alter
(
array
&
$metatags
,
array
$context
)
{
// Without entity there is nothing for us to do.
if
(
empty
(
$context
[
'entity'
]))
{
return
;
}
/** @var \Drupal\Core\Entity\EntityInterface $entity */
$entity
=
$context
[
'entity'
];
/** @var \Drupal\yoast_seo\SeoManager $seo_manager */
$seo_manager
=
\
Drupal
::
service
(
'yoast_seo.manager'
);
$entity_type
=
$entity
->
getEntityTypeId
();
$bundle
=
$entity
->
bundle
();
// Abort early if we're not enabled for this entity type.
if
(
!
$seo_manager
->
isEnabledFor
(
$entity_type
,
$bundle
))
{
return
;
}
$field
=
$entity
->
get
(
'field_yoast_seo'
)
->
first
();
// If the field has no value then we're done as well.
if
(
empty
(
$field
))
{
return
;
}
$values
=
$field
->
getValue
();
if
(
$seo_manager
->
isEditingEnabledFor
(
$entity_type
,
$bundle
,
'title'
)
&&
!
empty
(
$values
[
'title'
]))
{
$metatags
[
'title'
]
=
$values
[
'title'
];
}
if
(
$seo_manager
->
isEditingEnabledFor
(
$entity_type
,
$bundle
,
'description'
)
&&
!
empty
(
$values
[
'description'
]))
{
$metatags
[
'description'
]
=
$values
[
'description'
];
}
}
//
function yoast_seo_metatags_alter(array &$metatags, array $context) {
//
// Without entity there is nothing for us to do.
//
if (empty($context['entity'])) {
//
return;
//
}
//
//
/** @var \Drupal\Core\Entity\EntityInterface $entity */
//
$entity = $context['entity'];
//
//
/** @var \Drupal\yoast_seo\SeoManager $seo_manager */
//
$seo_manager = \Drupal::service('yoast_seo.manager');
//
//
$entity_type = $entity->getEntityTypeId();
//
$bundle = $entity->bundle();
//
//
// Abort early if we're not enabled for this entity type.
//
if (!$seo_manager->isEnabledFor($entity_type, $bundle)) {
//
return;
//
}
//
//
$field = $entity->get('field_yoast_seo')->first();
//
//
// If the field has no value then we're done as well.
//
if (empty($field)) {
//
return;
//
}
//
//
$values = $field->getValue();
//
//
if ($seo_manager->isEditingEnabledFor($entity_type, $bundle, 'title') &&
//
!empty($values['title'])) {
//
$metatags['title'] = $values['title'];
//
}
//
//
if ($seo_manager->isEditingEnabledFor($entity_type, $bundle, 'description') &&
//
!empty($values['description'])) {
//
$metatags['description'] = $values['description'];
//
}
//
//
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment