Widgets */ add_action( 'widgets_init', 'joy_about_me_widget_init' ); function joy_about_me_widget_init() { register_widget( 'JoyAboutMeWidget' ); } endif; if ( ! class_exists( 'JoyAboutMeWidget' ) ) : class JoyAboutMeWidget extends WP_Widget { var $default_title = ''; /** * Register widget with WordPress. */ public function __construct() { parent::__construct( 'joy-about-me', apply_filters( 'joy_widget_name', esc_html__( 'Brunch Pro: About Me', 'brunch-lite' ) ), array( 'classname' => 'widget_joy_about_me', 'description' => esc_html__( 'Display some info about you with an image.', 'brunch-lite' ) ) ); $this->default_title = esc_html__( 'About Me', 'brunch-lite' ); add_action( 'admin_init', array( $this, 'admin_init' ) ); } /** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget( $args, $instance ) { $instance = wp_parse_args( $instance, array( 'title' => '', 'name' => '', 'text' => '', ) ); $args['before_widget'] = substr( $args['before_widget'], 0, -1 ) . ' tabindex="0">'; echo $args['before_widget'] . "\n"; // The Background Image - empty string in case of error $thumb = wp_get_attachment_image_src( $instance['image_id'], 'joy-post-thumbnail-square-big' ); if ( false !== $thumb ) { $thumb = $thumb[0]; } else { $thumb = ''; } // The widget title $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); if ( ! empty( $title ) ) { echo $args['before_title'] . $title . $args['after_title'] . "\n"; } echo '