Skip to content

Commit

Permalink
Fix fatal error when the current page doesn't have an author term for…
Browse files Browse the repository at this point in the history
… Yoast integration
  • Loading branch information
andergmartins committed May 5, 2020
1 parent cf1075a commit ae46ada
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/modules/yoast-seo-integration/yoast-seo-integration.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,16 @@ public function __construct()

// Register the module with PublishPress
$args = [
'title' => __('Yoast SEO Integration', 'publishpress-authors'),
'title' => __('Yoast SEO Integration', 'publishpress-authors'),
'short_description' => __('Add compatibility with the Yoast SEO plugin', 'publishpress-authors'),
'module_url' => $this->module_url,
'icon_class' => 'dashicons dashicons-feedback',
'slug' => 'yoast-seo-integration',
'default_options' => [
'module_url' => $this->module_url,
'icon_class' => 'dashicons dashicons-feedback',
'slug' => 'yoast-seo-integration',
'default_options' => [
'enabled' => 'on',
],
'options_page' => false,
'autoload' => true,
'options_page' => false,
'autoload' => true,
];

// Apply a filter to the default options
Expand Down Expand Up @@ -135,10 +135,13 @@ public function overrideSEOReplacementsForAuthorsPage($replacements, $args)
foreach ($replacements as $key => &$value) {
if ($key === '%%name%%') {
$authors = get_multiple_authors(0, true, true);
$author = $authors[0];

if ($author->is_guest()) {
$value = $author->display_name;
if (is_array($authors) && !empty($authors)) {
$author = $authors[0];

if (isset($author->display_name)) {
$value = $author->display_name;
}
}
}
}
Expand Down

0 comments on commit ae46ada

Please sign in to comment.