defaults = [ 'title' => '' ]; // Widget Slug. $widgetSlug = 'aioseo-breadcrumb-widget'; // Widget basics. $widgetOps = [ 'classname' => $widgetSlug, 'description' => esc_html__( 'Display the current page breadcrumb.', 'all-in-one-seo-pack' ), ]; // Widget controls. $controlOps = [ 'id_base' => $widgetSlug, ]; // Load widget. parent::__construct( $widgetSlug, esc_html__( 'AIOSEO - Breadcrumbs', 'all-in-one-seo-pack' ), $widgetOps, $controlOps ); } /** * Widget callback. * * @since 4.1.1 * * @param array $args Widget args. * @param array $instance The widget instance options. * @return void */ public function widget( $args, $instance ) { // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped // Title. if ( ! empty( $instance['title'] ) ) { echo $args['before_title'] . apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 'widget_title', $instance['title'], $instance, $this->id_base ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } // Breadcrumb. ! empty( $_GET['legacy-widget-preview'] ) ? aioseo()->breadcrumbs->frontend->preview() : aioseo()->breadcrumbs->frontend->display(); // Workaround for a bug in the Gutenberg widget preview. echo 'a'; // TODO: remove this when the preview bug is fixed. echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } /** * Widget option update. * * @since 4.1.1 * * @param array $newInstance New instance options. * @param array $oldInstance Old instance options. * @return array Processed new instance options. */ public function update( $newInstance, $oldInstance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable $newInstance['title'] = wp_strip_all_tags( $newInstance['title'] ); return $newInstance; } /** * Widget options form. * * @since 4.1.1 * * @param array $instance The widget instance options. * @return void */ public function form( $instance ) { // Merge with defaults. $instance = wp_parse_args( (array) $instance, $this->defaults ); ?>