10up / brightcove-video-connect

A plugin to integrate your Brightcove video library or libraries with WordPress
https://www.brightcove.com/
GNU General Public License v2.0
22 stars 34 forks source link

Update condition for fetching folders and players #389

Closed oscarssanchezz closed 6 months ago

oscarssanchezz commented 6 months ago

Description of the Change

Taken from: https://github.com/10up/brightcove-video-connect/pull/388

Ensure that the get_current_screen is not null. Also check is the base is "post" and not the id. If ID can be set to "page" or "article" for custom post types. So this check for $current_screen->id === 'post' is invalid.

The conditional statements in class-bc-setup.php have been updated to improve fetching folders and players. The revised conditions not only check for user permission and page type, but they also ensure that the $current_page variable is defined before attempting to access its properties. This adds an extra layer of validation to prevent potential errors.

Closes https://github.com/10up/brightcove-video-connect/issues/387

How to test the Change

Changelog Entry

Fixed - Cannot use Brightcove block on custom post types.

Credits

Props @spacedmonkey, @jonnynews

Checklist: