__( 'Display the currently playing track.', 'wp-fedistream' ), 'classname' => 'fedistream-widget fedistream-widget--now-playing', ) ); } /** * Front-end display. * * @param array $args Widget arguments. * @param array $instance Saved values from database. * @return void */ public function widget( $args, $instance ): void { $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Now Playing', 'wp-fedistream' ); $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $show_player = ! empty( $instance['show_player'] ); echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ( $title ) { echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } try { $plugin = Plugin::get_instance(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $plugin->render( 'widgets/now-playing', array( 'show_player' => $show_player, ) ); } catch ( \Exception $e ) { if ( WP_DEBUG ) { echo '

' . esc_html( $e->getMessage() ) . '

'; } } echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Back-end widget form. * * @param array $instance Previously saved values from database. * @return void */ public function form( $instance ): void { $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'Now Playing', 'wp-fedistream' ); $show_player = ! empty( $instance['show_player'] ); ?>