plugin = $plugin;
}
/**
* Registers hooks.
*/
public function register(): void {
add_action( 'admin_notices', array( $this, 'render' ) );
}
/**
* Prints the notices.
*/
public function render(): void {
$channel_label = $this->plugin->channel()->label();
if ( ! current_user_can( Plugin::CAPABILITY ) ) {
return;
}
$settings = $this->plugin->settings();
$link = sprintf( '%s', esc_url( Menu::settings_url() ), esc_html__( 'Open Tidelist settings', 'tidelist' ) );
foreach ( ConnectionAlerts::problems( $this->plugin->channels()->all() ) as $id => $problem ) {
printf(
'
',
esc_html( $problem ),
esc_url( Menu::connect_url( (string) $id ) ),
esc_html__( 'Reconnect', 'tidelist' )
);
}
foreach ( $this->plugin->channels()->all() as $channel ) {
if ( $channel->connection()->secret_unreadable ) {
printf(
'',
esc_html( Text::channel( __( 'Tidelist: the saved {channel} Client Secret can no longer be decrypted (the site security keys changed). Please enter it again.', 'tidelist' ), $channel->label() ) ),
$link // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above.
);
}
}
// The pause reminder is only shown on Tidelist's own screens; the connection errors above stay everywhere because they
// say how to fix the problem and disappear once it is fixed.
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
if ( $settings->is_paused() && $screen && false !== strpos( (string) $screen->id, 'tidelist' ) ) {
printf(
'',
esc_html( Text::channel( __( 'Tidelist is paused: nothing is sent to {channel}.', 'tidelist' ), $channel_label ) ),
$link // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped above.
);
}
}
}