default_settings = apply_filters( 'powerkit_widget_author_settings', array( 'title' => esc_html__( 'Author', 'powerkit' ), 'author' => 'current', 'template' => 'default', 'bg_image_id' => false, 'avatar' => true, 'description' => true, 'description_override' => '', 'description_length' => 100, 'social_accounts' => true, 'posts_only' => false, 'archive_btn' => false, ) ); $widget_details = array( 'classname' => 'powerkit_widget_author', 'description' => '', ); // Actions. add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); parent::__construct( 'powerkit_widget_author', esc_html__( 'Author', 'powerkit' ), $widget_details ); } /** * Outputs the content for the current widget instance. * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. * @param array $instance Settings for the current widget instance. */ public function widget( $args, $instance ) { $params = array_merge( $this->default_settings, $instance ); $authors = array(); // Get authors. if ( 'current' === $params['author'] || 'сurrent' === $params['author'] ) { if ( is_single() ) { $params['posts_only'] = true; $coauthors = array(); if ( function_exists( 'get_coauthors' ) ) { $coauthors = get_coauthors(); } if ( $coauthors ) { // Get co authors. foreach ( $coauthors as $author ) { $authors[] = $author->ID; } } else { // Get the default WP author. $authors[] = get_the_author_meta( 'ID' ); } } } else { if ( get_the_author_meta( 'display_name', $params['author'] ) ) { $authors[] = $params['author']; } elseif ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) { ?> default_settings, $instance ); $bg_image_url = $params['bg_image_id'] ? wp_get_attachment_image_url( intval( $params['bg_image_id'] ), 'large' ) : ''; $templates = apply_filters( 'powerkit_widget_author_templates', array() ); ?>

1 ) { ?>

/>

/>

/>

/>

/>

', '' ), '', ob_get_clean() ) ); } } } /** * Register Widget */ function powerkit_widget_author_init() { register_widget( 'Powerkit_Widget_Author_Init' ); } add_action( 'widgets_init', 'powerkit_widget_author_init' );