PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / trunk
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites vtrunk
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / inc / block-posts-config / class-multiauthor-frontend.php

class-multiauthor-frontend.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites trunk, at inc/block-posts-config/class-multiauthor-frontend.php

82 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if(!class_exists('BlocksapreMultiAuthorForFrontend')){
3 class BlocksapreMultiAuthorForFrontend{
4
5 function blockspare_front_by_author($post_id,$authorIcon,$xauthor_id){
6
7 if(class_exists('WP_Post_Author')){
8
9
10 $awpa_post_authors = get_post_meta($post_id, 'wpma_author');
11 $enable_author_metabox_for_post = get_option('awpa_author_metabox_integration');
12 $multiauthor_settings = false;
13 if($enable_author_metabox_for_post && $enable_author_metabox_for_post['enable_author_metabox']==true){
14 $multiauthor_settings = true;
15 }
16
17 if(isset($awpa_post_authors) && !empty($awpa_post_authors) && $multiauthor_settings == true){
18 foreach ($awpa_post_authors as $key=>$author_id) {
19
20 $needle = 'guest-';
21 if (strpos($author_id, $needle) !== false) {
22 $filter_id = substr($author_id, strpos($author_id, "-") + 1);
23 $author_id = $filter_id;
24 $author_type = 'guest';
25 } else {
26 $author_id = $author_id;
27 $author_type = 'default';
28 }
29
30 $this->blockspare_front_author_list($authorIcon,$key,$awpa_post_authors,$post_id,$author_id,$author_type);
31
32 }
33 }else{
34 $author_id = $xauthor_id;
35
36 ?>
37 <a class="blockspare-posts-block-text-link" href="<?php echo esc_url(get_author_posts_url($xauthor_id));?>" itemprop="url" rel="author">
38 <span itemprop="name"><i class="<?php echo $authorIcon;?>"></i><?php echo esc_html(get_the_author_meta('display_name', $xauthor_id));?></span>
39 </a>
40 <?php
41
42
43 }
44 }else{
45 $author_id = $xauthor_id;?>
46 <a class="blockspare-posts-block-text-link" href="<?php echo esc_url(get_author_posts_url($xauthor_id));?>" itemprop="url" rel="author">
47 <span itemprop="name"><i class="<?php echo $authorIcon;?>"></i><?php echo esc_html(get_the_author_meta('display_name', $xauthor_id));?></span>
48 </a>
49 <?php }
50
51 }
52
53
54
55
56 function blockspare_front_author_list($authorIcon,$key,$awpa_post_authors,$post_id='',$author_id='',$author_type=''){
57
58 if($author_type == 'default'){
59 $default_author_id = get_post_field('post_author', $post_id);
60 $author_name = get_userdata( $author_id);
61 ?>
62
63 <a class="blockspare-posts-block-text-link" href="<?php echo esc_url(get_author_posts_url($author_id));?>" itemprop="url" rel="author">
64 <span itemprop="name"><?php if($key<1){?><i class="<?php echo $authorIcon;?>"></i><?php } ?><?php echo esc_html(get_the_author_meta('display_name', $author_id));?><?php if( $key != ( count( $awpa_post_authors ) - 1 ) ){echo ",";} ?></span>
65 </a>
66 <?php
67 }
68 if($author_type == 'guest'){
69 $wp_amulti_authors = new WPAMultiAuthors();
70 $guest_user_data = $wp_amulti_authors->get_guest_by_id($author_id);?>
71
72 <a class="blockspare-posts-block-text-link">
73 <span itemprop="name"><?php if($key<1){?><i class="<?php echo esc_attr($authorIcon);?>"></i><?php } ?><?php echo esc_html($guest_user_data->display_name);?><?php if( $key != ( count( $awpa_post_authors ) - 1 ) ){echo ",";} ?></span>
74 </a>
75
76 <?php } ?>
77
78 <?php
79 }
80
81 }
82 }