Skip to content

Commit

Permalink
release: fixes
Browse files Browse the repository at this point in the history
### Fixes
- **Updated internal dependencies:** Enhanced performance and security.
  • Loading branch information
vytisbulkevicius authored Apr 15, 2024
2 parents 94ad4b2 + 41397d3 commit 32f1b17
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion includes/abstract/feedzy-rss-feeds-admin-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function feedzy_default_error_notice( $errors, $feed, $feed_url ) {
// Show the error message only if the user who has created this post (which contains the feed) is logged in and the user has admin privileges.
// Or if this is in the dry run window.
// phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison
$show_error = is_admin() || ( is_user_logged_in() && $post && current_user_can( 'manage_options' ) && get_current_user_id() == $post->post_author );
$show_error = ( is_admin() || ( is_user_logged_in() && $post && get_current_user_id() == $post->post_author ) ) && current_user_can( 'manage_options' );
$error_msg = '';

if ( is_array( $errors ) ) {
Expand Down
21 changes: 21 additions & 0 deletions tests/test-post-access.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,27 @@ public function test_contributor_user_with_errors() {

$actual_output = $feedzy->feedzy_default_error_notice( $errors, $feed, 'http://example.com/feed' );

$this->assertEquals( '', $actual_output );
}
public function test_author_user_with_errors_admin_screen() {
$feedzy = new Feedzy_Rss_Feeds_Admin('feedzy', 'latest');

$contributor_id = $this->factory->user->create(
array(
'role' => 'author',
)
);
wp_set_current_user( $contributor_id );

$post_id = $this->factory->post->create( array( 'post_author' => get_current_user_id() ) );
$GLOBALS['post'] = get_post( $post_id );
// Mock feed object and errors.
$feed = (object) array( 'multifeed_url' => array( 'http://example.com/feed' ) );
$errors = array( 'Error 1' );

set_current_screen('admin.php');
$actual_output = $feedzy->feedzy_default_error_notice( $errors, $feed, 'http://example.com/feed' );

$this->assertEquals( '', $actual_output );
}
}

0 comments on commit 32f1b17

Please sign in to comment.