Skip to content

Commit

Permalink
Fix call a member function add_cap on null
Browse files Browse the repository at this point in the history
Fix issue #223.
  • Loading branch information
andergmartins committed Sep 4, 2020
1 parent 7d076b3 commit 8ec74b2
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/core/Classes/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
namespace MultipleAuthors\Classes;

use MultipleAuthors\Classes\Objects\Author;
use WP_Role;

class Installer
{
Expand Down Expand Up @@ -215,15 +216,19 @@ protected static function flush_permalinks()
private static function add_new_edit_post_authors_cap()
{
$cap = 'ppma_edit_post_authors';

$role = get_role('author');
$role->add_cap($cap);

$role = get_role('editor');
$role->add_cap($cap);

$role = get_role('contributor');
$role->add_cap($cap);
$roles = [
'author',
'editor',
'contributor',
];

foreach ($roles as $roleNmae)
{
$role = get_role($roleNmae);
if ($role instanceof WP_Role) {
$role->add_cap($cap);
}
}
}

/**
Expand Down

0 comments on commit 8ec74b2

Please sign in to comment.