2021.1007 Sistemata indentazione. Modificato lo stile.

This commit is contained in:
ulaulaman 2021-10-08 22:27:40 +02:00
parent e912ffd2f5
commit 27b87a65cd
1 changed files with 104 additions and 112 deletions

View File

@ -2,12 +2,14 @@
/* /*
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.1007
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
*/ */
/* ------------------------------------------------------ */ /* ------------------------------------------------------ */
# --------------------------------------------------------- # ---------------------------------------------------------
@ -17,32 +19,31 @@ 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_wp() {
$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' ) ) { if ( function_exists( 'get_coauthors' ) ) {
$coauthors = get_coauthors(); $coauthors = get_coauthors();
$user_posts = get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); $user_posts = get_author_posts_url( $coauthor->ID, $coauthor->user_nicename );
$i = 0; $i = 0;
foreach ( $coauthors as $coauthor ) { foreach ( $coauthors ad $coauthor ) {
$i++; $i++;
?> ?>
<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 ); ?> <p><div style="float:left; padding: 5px;"><?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></p> <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></p>
<p class="read-more-target">
<?php echo $coauthor->description; ?>
</p>
</div> </div>
<label for="<?php echo $i; ?>" class="read-more-trigger_closed"> <label for="<?php echo $i; ?>" class="read-more-trigger_closed">
<strong>+ <?php printf( $show_profile ); ?></strong> <strong>+ <?php printf( $show_profile ); ?></strong>
@ -53,18 +54,13 @@ if ( function_exists( 'get_coauthors' ) ) {
</div> </div>
<?php <?php
} }
//
} else { } else {
$i = 0; $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 get_avatar( get_the_author_meta( 'user_email' ), 65 ); ?> <p><div style="float:left; padding: 5px;"><?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></div><span class="read-more-target"><?php echo get_the_author_meta( 'description' ); ?></span></p>
<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> </div>
<label for="<?php echo $i; ?>" class="read-more-trigger_closed"> <label for="<?php echo $i; ?>" class="read-more-trigger_closed">
<strong>+ <?php printf( $show_profile ); ?></strong> <strong>+ <?php printf( $show_profile ); ?></strong>
@ -73,7 +69,6 @@ if ( function_exists( 'get_coauthors' ) ) {
<strong>- <?php printf( $hide_profile ); ?></strong> <strong>- <?php printf( $hide_profile ); ?></strong>
</label> </label>
</div> </div>
<?php <?php
} }
} }
@ -84,7 +79,7 @@ function blog_enqueue() {
} }
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();
@ -109,8 +104,7 @@ parent::__construct(
__('Authors', 'widget-for-co-authors'), __('Authors', 'widget-for-co-authors'),
// Widget description // Widget description
array( 'description' => __( 'Show avatars and names of the authors', 'widget-for-co-authors' ), ) array( 'description' => __( 'Show avatars and names of the authors', 'widget-for-co-authors' ), ) );
);
} }
// Widget front-end // Widget front-end
@ -131,8 +125,7 @@ echo $args['after_widget'];
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' );
} }
@ -153,5 +146,4 @@ return $instance;
} }
} }
/* ------------------------------------------------------ */
?> ?>