diff --git a/widget-for-co-authors.php b/widget-for-co-authors.php index cfd35da..bc59174 100644 --- a/widget-for-co-authors.php +++ b/widget-for-co-authors.php @@ -2,156 +2,148 @@ /* Plugin Name: Co-Authors Widget Dev Description: The plugin add a widget and a shortcode in order to show authors of an article. It is compatible with Co-Authors Plus. -Version: 2020.0922 +Version: 2021.1007 Author: Gianluigi Filippelli Author URI: http://dropseaofulaula.blogspot.it/ -Plugin URI: https://github.com/ulaulaman/widget-for-co-authors +Plugin URI: https://gitea.it/ulaulaman/widget-for-co-authors-dev +Gitea Plugin URI: https://gitea.it/ulaulaman/widget-for-co-authors-dev License: GPLv2 or later */ + /* ------------------------------------------------------ */ # --------------------------------------------------------- // Load translations -add_action('plugins_loaded', 'caw_load_translations'); +add_action( 'plugins_loaded', 'caw_load_translations' ); function caw_load_translations() { - load_plugin_textdomain( 'widget-for-co-authors', false, dirname( plugin_basename(__FILE__) ) . '/lang/' ); + load_plugin_textdomain( 'widget-for-co-authors', false, dirname( plugin_basename(__FILE__) ) . '/lang/' ); } -# Shortcode to show authors -add_shortcode('blog-post-coauthors', 'blog_post_coauthors'); +// Shortcode to show authors +add_shortcode( 'blog-post-coauthors', 'blog_post_coauthors' ); function blog_post_coauthors() { return coauthors_posts_links(", ", " & ", null, null, false); } -# Widget to show authors' avatars -function blog_avatars() { - $show_profile = __( 'Show profile', 'widget-for-co-authors' ); - $hide_profile = __( 'Hide profile', 'widget-for-co-authors' ); -if ( function_exists( 'get_coauthors' ) ) { - $coauthors = get_coauthors(); - $user_posts = get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); - - $i = 0; - foreach ( $coauthors as $coauthor ) { - $i++; +// Widget to show authors' avatars +function blog_avatars_wp() { + $show_profile = __( 'Show profile', 'widget-for-co-authors' ); + $hide_profile = __( 'Hide profile', 'widget-for-co-authors' ); + + if ( function_exists( 'get_coauthors' ) ) { + $coauthors = get_coauthors(); + $user_posts = get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); + + $i = 0; + foreach ( $coauthors ad $coauthor ) { + $i++; + + ?> +
+ +
+

+ ID, $coauthor->user_nicename ); ?>>display_name; ?>
description; ?>

+
+ + +
+ -
- -
-

- ID, $coauthor->user_nicename ); ?>>display_name; ?>

-

- description; ?> -

-
- - -
+
+ +
+

>

+
+ + +
-
- -
-

- >

-

- -

-
- - -
- - __( 'Show avatars and names of the authors', 'widget-for-co-authors' ), ) ); + } -// Widget ID -'blog_widget', - -// Widget name in UI -__('Authors', 'widget-for-co-authors'), - -// Widget description -array( 'description' => __( 'Show avatars and names of the authors', 'widget-for-co-authors' ), ) -); -} - -// Widget front-end -public function widget( $args, $instance ) { -$title = apply_filters( 'widget_title', $instance['title'] ); - -// before and after -echo $args['before_widget']; -if ( ! empty( $title ) ) -echo $args['before_title'] . $title . $args['after_title']; - -// output -blog_avatars(); -echo $args['after_widget']; -} + // Widget front-end + public function widget( $args, $instance ) { + $title = apply_filters( 'widget_title', $instance['title'] ); + + // before and after + echo $args['before_widget']; + if ( ! empty( $title ) ) + echo $args['before_title'] . $title . $args['after_title']; + + // output + blog_avatars(); + echo $args['after_widget']; + } -// Widget backend -public function form( $instance ) { -if ( isset( $instance[ 'title' ] ) ) { -$title = $instance[ 'title' ]; -} -else { -$title = __( 'Written by', 'widget-for-co-authors' ); + // Widget backend + public function form( $instance ) { + if ( isset( $instance[ 'title' ] ) ) { + $title = $instance[ 'title' ]; + } else { + $title = __( 'Written by', 'widget-for-co-authors' ); + } + + // Widget form + ?> +

+ + +

+ -

- - -

-