diff --git a/admin/apple-actions/index/class-channel.php b/admin/apple-actions/index/class-channel.php index 48934e1c..c3a67f3e 100644 --- a/admin/apple-actions/index/class-channel.php +++ b/admin/apple-actions/index/class-channel.php @@ -26,17 +26,21 @@ class Channel extends API_Action { */ public function perform() { $channel = get_transient( 'apple_news_channel' ); + if ( false === $channel ) { + $channel = ''; + if ( $this->is_api_configuration_valid() ) { try { $channel = $this->get_api()->get_channel( $this->get_setting( 'api_channel' ) ); } catch ( Request_Exception $e ) { - $channel = ''; + // Do nothing. + unset( $e ); } } - } - set_transient( 'apple_news_channel', $channel, 300 ); + set_transient( 'apple_news_channel', $channel, 300 ); + } if ( '' === $channel ) { // Unable to get channel information. This likely means the user entered their API credentials incorrectly. diff --git a/includes/class-apple-news.php b/includes/class-apple-news.php index f3aae9de..7036bf48 100644 --- a/includes/class-apple-news.php +++ b/includes/class-apple-news.php @@ -378,8 +378,8 @@ public function __construct() { ); add_action( - 'init', - [ $this, 'action_init' ] + 'admin_init', + [ $this, 'action_admin_init' ] ); add_filter( @@ -476,9 +476,11 @@ public function action_enqueue_block_editor_assets(): void { /** * Action hook callback for init. * - * @since 1.3.0 + * @since 2.7.0 + * @since 2.6.2 as action_init() + * @since 1.3.0 as action_plugins_loaded() */ - public function action_init(): void { + public function action_admin_init(): void { // Determine if the database version and code version are the same. $current_version = get_option( 'apple_news_version', '' );