| 1 |
<?php |
| 2 |
/** |
| 3 |
* Author block template |
| 4 |
* |
| 5 |
* @var $attributes - block attributes |
| 6 |
* @var $options - layout options |
| 7 |
* |
| 8 |
* @link https://codesupply.co |
| 9 |
* @since 1.0.0 |
| 10 |
* |
| 11 |
* @package PowerKit |
| 12 |
* @subpackage PowerKit/templates |
| 13 |
*/ |
| 14 |
|
| 15 |
$params = array( |
| 16 |
'title' => '', |
| 17 |
'author' => $attributes['author'], |
| 18 |
'bg_image_id' => isset( $attributes['bgImage']['id'] ) ? $attributes['bgImage']['id'] : 0, |
| 19 |
'avatar' => $attributes['showAvatar'], |
| 20 |
'description' => $attributes['showDescription'], |
| 21 |
'social_accounts' => $attributes['showSocialAccounts'], |
| 22 |
'archive_btn' => $attributes['showArchiveBtn'], |
| 23 |
'template' => 'default', |
| 24 |
'is_block' => true, |
| 25 |
'block_attrs' => $attributes, |
| 26 |
); |
| 27 |
|
| 28 |
echo '<div class="' . esc_attr( $attributes['className'] ) . '" ' . ( isset( $attributes['anchor'] ) ? ' id="' . esc_attr( $attributes['anchor'] ) . '"' : '' ) . '>'; |
| 29 |
|
| 30 |
// Title. |
| 31 |
if ( $params['title'] ) { |
| 32 |
$params['title'] = '<h5 class="pk-author-title">' . $params['title'] . '<h5>'; |
| 33 |
} |
| 34 |
|
| 35 |
$authors = array(); |
| 36 |
|
| 37 |
// Get authors. |
| 38 |
if ( 'current' === $params['author'] ) { |
| 39 |
$params['posts_only'] = true; |
| 40 |
|
| 41 |
$coauthors = array(); |
| 42 |
|
| 43 |
if ( function_exists( 'get_coauthors' ) ) { |
| 44 |
$coauthors = get_coauthors(); |
| 45 |
} |
| 46 |
|
| 47 |
if ( $coauthors ) { |
| 48 |
// Get co authors. |
| 49 |
foreach ( $coauthors as $author ) { |
| 50 |
$authors[] = $author->ID; |
| 51 |
} |
| 52 |
} else { |
| 53 |
// Get the default WP author. |
| 54 |
$authors[] = get_the_author_meta( 'ID' ); |
| 55 |
} |
| 56 |
} else { |
| 57 |
|
| 58 |
if ( get_the_author_meta( 'display_name', $params['author'] ) ) { |
| 59 |
|
| 60 |
$authors[] = $params['author']; |
| 61 |
|
| 62 |
} elseif ( current_user_can( 'editor' ) || current_user_can( 'administrator' ) ) { |
| 63 |
?> |
| 64 |
<p class="pk-alert pk-alert-warning" role="alert"> |
| 65 |
<?php esc_html_e( 'Author not found.', 'powerkit' ); ?> |
| 66 |
</p> |
| 67 |
<?php |
| 68 |
} |
| 69 |
} |
| 70 |
|
| 71 |
if ( ! empty( $authors ) ) { |
| 72 |
foreach ( $authors as $author ) { |
| 73 |
if ( ! @ is_author( $author ) ) { |
| 74 |
$args = array( |
| 75 |
'before_title' => '', |
| 76 |
'after_title' => '', |
| 77 |
'before_widget' => '', |
| 78 |
'after_widget' => '', |
| 79 |
); |
| 80 |
powerkit_widget_author_template_handler( $params['template'], $author, $args, $params, array() ); |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
|
| 85 |
echo '</div>'; |
| 86 |
|