Compare commits

...

11 Commits

Author SHA1 Message Date
ulaulaman e906f96f2b Update readme 2021-10-13 01:00:27 +02:00
ulaulaman 84aa3905d0 Update readme 2021-10-13 00:58:45 +02:00
ulaulaman cfb14707dc 2021.1013 - New version 2021-10-13 00:58:27 +02:00
ulaulaman 8c933d19f4 Update avatar style 2021-10-13 00:57:58 +02:00
ulaulaman 27632072d5 Update readme 2021-10-12 15:02:29 +02:00
ulaulaman 96904dafae Update readme 2021-10-12 15:01:18 +02:00
ulaulaman 098a784998 Add new style for avatar 2021-10-12 15:01:10 +02:00
ulaulaman 8481a5fa8a Fix sintax error 2021-10-08 22:41:20 +02:00
ulaulaman 864d9cddb4 Corretto errore di sintassi 2021-10-08 22:33:21 +02:00
ulaulaman 50d4b4c3b3 2021.1008 2021-10-08 22:28:32 +02:00
ulaulaman 27b87a65cd 2021.1007 Sistemata indentazione. Modificato lo stile. 2021-10-08 22:27:40 +02:00
4 changed files with 171 additions and 135 deletions

View File

@ -11,17 +11,25 @@ The plugin add also a slider in order to show user's profile. If you want change
3. Add the widget to your sidebar or the shortcode to your posts or pages. 3. Add the widget to your sidebar or the shortcode to your posts or pages.
# Changelog # Changelog
0.6 add author's info also in case Co-Authors Plus doesn't installed<br/> * 2021.1013
0.5.3 add the correct lang files<br/> * Add command for version number in css enqueue
0.5.2 fix error code in domain name in widget<br/> * Update style
0.5.1 fix error code in domain name for messages<br/> * 2021.1012 New style for show avatar
0.5 support for translations<br/> * 2021.1007 Best indentation and test new style
0.4 translation italian messages in english<br/>
0.3.1 test with wp 4.9.2<br/> ## 2020.0922
0.3 add profile link and css<br/> * 0.6 add author's info also in case Co-Authors Plus doesn't installed
0.2 creation of the widget to show authors' avatars<br/> * 0.5.3 add the correct lang files
0.1 creation of the shortcode to add post's authors * 0.5.2 fix error code in domain name in widget
* 0.5.1 fix error code in domain name for messages
* 0.5 support for translations
* 0.4 translation italian messages in english
* 0.3.1 test with wp 4.9.2
* 0.3 add profile link and css
* 0.2 creation of the widget to show authors' avatars
* 0.1 creation of the shortcode to add post's authors
# Screenshot # Screenshot
<div align="center"><img src="https://github.com/ulaulaman/widget-for-co-authors/blob/master/assets/screenshot-1.jpg?raw=true" /><br/>
<em>The result of the widget in a multiple authors post</em></div> ![Screenshot](assets/screenshot-1.jpg)
<div align="center"><em>The result of the widget in a multiple authors post</em></div>

View File

@ -9,3 +9,28 @@
.read-more-state:checked ~ .read-more-trigger_closed { .read-more-state:checked ~ .read-more-trigger_closed {
display: none; display: none;
} }
.avatar {
display: block;
padding: 3px;
margin-left: auto;
margin-right: auto;
vertical-align: baseline;
font: 11px/1.4em Arial, sans-serif;
text-align: center;
vertical-align: baseline;
}
.avatarimg {
vertical-align:middle;
margin-bottom: 3px;
width:92%;
}
.right {
float:right;
}
.left {
float:left;
}

View File

@ -24,13 +24,18 @@ The plugin add also a slider in order to show user's profile. If you want change
1. The result of the widget in a multiple authors post (italian language) 1. The result of the widget in a multiple authors post (italian language)
== Changelog == == Changelog ==
0.6 add author's info also in case Co-Authors Plus doesn't installed * 2021.1013
0.5.3 add the correct lang files * Add command for version number in css enqueue
0.5.2 fix error code in domain name in widget * Update style
0.5.1 fix error code in domain name for messages * 2021.1012 New style for show avatar
0.5 support for translations * 2021.1007 Best indentation and test new style
0.4 translation italian messages in english * 0.6 add author's info also in case Co-Authors Plus doesn't installed
0.3.1 test with wp 4.9.2 * 0.5.3 add the correct lang files
0.3 add profile link and css * 0.5.2 fix error code in domain name in widget
0.2 creation of the widget to show authors' avatars * 0.5.1 fix error code in domain name for messages
0.1 creation of the shortcode to add post's authors * 0.5 support for translations
* 0.4 translation italian messages in english
* 0.3.1 test with wp 4.9.2
* 0.3 add profile link and css
* 0.2 creation of the widget to show authors' avatars
* 0.1 creation of the shortcode to add post's authors

View File

@ -2,156 +2,154 @@
/* /*
Plugin Name: Co-Authors Widget Dev 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. 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.1012
Author: Gianluigi Filippelli Author: Gianluigi Filippelli
Author URI: http://dropseaofulaula.blogspot.it/ 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 License: GPLv2 or later
*/ */
/* ------------------------------------------------------ */
# ---------------------------------------------------------
// Load translations // Load translations
add_action('plugins_loaded', 'caw_load_translations'); add_action( 'plugins_loaded', 'caw_load_translations' );
function 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 // Shortcode to show authors
add_shortcode('blog-post-coauthors', 'blog_post_coauthors'); add_shortcode( 'blog-post-coauthors', 'blog_post_coauthors' );
function blog_post_coauthors() { function blog_post_coauthors() {
return coauthors_posts_links(", ", " & ", null, null, false); return coauthors_posts_links(", ", " & ", null, null, false);
} }
# Widget to show authors' avatars // Widget to show authors' avatars
function blog_avatars() { function blog_avatars() {
$show_profile = __( 'Show profile', 'widget-for-co-authors' ); $show_profile = __( 'Show profile', 'widget-for-co-authors' );
$hide_profile = __( 'Hide profile', 'widget-for-co-authors' ); $hide_profile = __( 'Hide profile', 'widget-for-co-authors' );
if ( function_exists( 'get_coauthors' ) ) {
$coauthors = get_coauthors(); if ( function_exists( 'get_coauthors' ) ) {
$user_posts = get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); $coauthors = get_coauthors();
$user_posts = get_author_posts_url( $coauthor->ID, $coauthor->user_nicename );
$i = 0;
foreach ( $coauthors as $coauthor ) { $i = 0;
$i++; foreach ( $coauthors as $coauthor ) {
$i++;
?>
<div class="block-item-text">
<input type="checkbox" hidden class="read-more-state" id="<?php echo $i; ?>" />
<div class="read-more-wrap">
<div class="avatar">
<div class="avatarimg left" style="width:50%;"><?php echo coauthors_get_avatar( $coauthor, 65 ); ?>
<a href="<?php echo get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); ?>"><?php echo $coauthor->display_name; ?></a>
</div>
<span class="read-more-target"><?php echo $coauthor->description; ?></span>
</div>
</div>
<label for="<?php echo $i; ?>" class="read-more-trigger_closed">
<strong>+ <?php printf( $show_profile ); ?></strong>
</label>
<label for="<?php echo $i; ?>" class="read-more-trigger_opened">
<strong>- <?php printf( $hide_profile ); ?></strong>
</label>
</div>
<?php
}
} else {
$i = 0;
?> ?>
<div class="block-item-text"> <div class="block-item-text">
<input type="checkbox" hidden class="read-more-state" id="<?php echo $i; ?>"> <input type="checkbox" hidden class="read-more-state" id="<?php echo $i; ?>" />
<div class="read-more-wrap"> <div class="read-more-wrap">
<p><?php echo coauthors_get_avatar( $coauthor, 65 ); ?> <div class="avatar">
<a href=<?php echo get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); ?>><?php echo $coauthor->display_name; ?></a></p> <div class="avatarimg left"><?php echo get_avatar( get_the_author_meta( 'user_email' ), 65 ); ?>
<p class="read-more-target"> <a href="<?php echo get_the_author_meta( 'user_url' ); ?>"><?php echo get_the_author_meta( 'display_name' ); ?></a>
<?php echo $coauthor->description; ?> </div>
</p> <span class="read-more-target"><?php echo get_the_author_meta( 'description' ); ?></span>
</div> </div>
<label for="<?php echo $i; ?>" class="read-more-trigger_closed"> </div>
<strong>+ <?php printf( $show_profile ); ?></strong> <label for="<?php echo $i; ?>" class="read-more-trigger_closed">
</label> <strong>+ <?php printf( $show_profile ); ?></strong>
<label for="<?php echo $i; ?>" class="read-more-trigger_opened"> </label>
<strong>- <?php printf( $hide_profile ); ?></strong> <label for="<?php echo $i; ?>" class="read-more-trigger_opened">
</label> <strong>- <?php printf( $hide_profile ); ?></strong>
</div> </label>
</div>
<?php <?php
} }
//
} else {
$i = 0;
?>
<div class="block-item-text">
<input type="checkbox" hidden class="read-more-state" id="<?php echo $i; ?>">
<div class="read-more-wrap">
<p><?php echo get_avatar( get_the_author_meta( 'user_email' ), 65 ); ?>
<a href=<?php echo get_the_author_meta( 'user_url' ); ?>><?php echo get_the_author_meta( 'display_name' ); ?></a></p>
<p class="read-more-target">
<?php echo get_the_author_meta( 'description' ); ?>
</p>
</div>
<label for="<?php echo $i; ?>" class="read-more-trigger_closed">
<strong>+ <?php printf( $show_profile ); ?></strong>
</label>
<label for="<?php echo $i; ?>" class="read-more-trigger_opened">
<strong>- <?php printf( $hide_profile ); ?></strong>
</label>
</div>
<?php
}
} }
function blog_enqueue() { function blog_enqueue() {
wp_register_style( 'blog-spoiler-style', plugins_url('/blog-spoiler.css', __FILE__) ); wp_register_style( 'blog-spoiler-style', plugins_url('/blog-spoiler.css', __FILE__), rand(111,9999), '1' );
wp_enqueue_style( 'blog-spoiler-style' ); wp_enqueue_style( 'blog-spoiler-style' );
} }
add_action( 'wp_enqueue_scripts', 'blog_enqueue' ); add_action( 'wp_enqueue_scripts', 'blog_enqueue' );
# Shortcode authors' avatars // Shortcode authors' avatars
add_shortcode('blog-coauthors-avatars', 'blog_coauthors_avatars'); add_shortcode('blog-coauthors-avatars', 'blog_coauthors_avatars');
function blog_coauthors_avatars() { function blog_coauthors_avatars() {
return blog_avatars(); return blog_avatars();
} }
// Widget register // Widget register
function blog_load_widget() { function blog_load_widget() {
register_widget( 'blog_widget' ); register_widget( 'blog_widget' );
} }
add_action( 'widgets_init', 'blog_load_widget' ); add_action( 'widgets_init', 'blog_load_widget' );
// Widget load // Widget load
class blog_widget extends WP_Widget { class blog_widget extends WP_Widget {
function __construct() { function __construct() {
parent::__construct( parent::__construct(
// 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 ID // Widget front-end
'blog_widget', public function widget( $args, $instance ) {
$title = apply_filters( 'widget_title', $instance['title'] );
// Widget name in UI
__('Authors', 'widget-for-co-authors'), // before and after
echo $args['before_widget'];
// Widget description if ( ! empty( $title ) )
array( 'description' => __( 'Show avatars and names of the authors', 'widget-for-co-authors' ), ) echo $args['before_title'] . $title . $args['after_title'];
);
} // output
blog_avatars();
// Widget front-end echo $args['after_widget'];
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 // Widget backend
public function form( $instance ) { public function form( $instance ) {
if ( isset( $instance[ 'title' ] ) ) { if ( isset( $instance[ 'title' ] ) ) {
$title = $instance[ 'title' ]; $title = $instance[ 'title' ];
} } else {
else { $title = __( 'Written by', 'widget-for-co-authors' );
$title = __( 'Written by', 'widget-for-co-authors' ); }
// Widget form
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<?php
}
// Widget update
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
} }
// Widget form
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<?php
}
// Widget update
public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
return $instance;
}
}
/* ------------------------------------------------------ */
?> ?>