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-backend.php

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

73 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if(!class_exists('BlocksapreMultiAuthorForBackend')){
4 class BlocksapreMultiAuthorForBackend{
5
6 function blockspare_by_author($post){
7
8 if(class_exists('WP_Post_Author')){
9 $data = array();
10 $post_id = $post->ID;
11 $awpa_post_authors = get_post_meta($post_id, 'wpma_author');
12 $enable_author_metabox_for_post = get_option('awpa_author_metabox_integration');
13 $multiauthor_settings = false;
14 if($enable_author_metabox_for_post && $enable_author_metabox_for_post['enable_author_metabox']==true){
15 $multiauthor_settings = true;
16 }
17
18 if(isset($awpa_post_authors) && !empty($awpa_post_authors) && $multiauthor_settings == true){
19 $data = array();
20 foreach ($awpa_post_authors as $key=>$author_id) {
21
22 $needle = 'guest-';
23 if (strpos($author_id, $needle) !== false) {
24 $filter_id = substr($author_id, strpos($author_id, "-") + 1);
25 $author_id = $filter_id;
26 $author_type = 'guest';
27 } else {
28 $author_id = $author_id;
29 $author_type = 'default';
30 }
31
32 $data['info'][] = $this->blockspare_author_list($post,$post_id,$author_id,$author_type, $author_avatar=false);
33
34
35
36
37 }
38 }else{
39 $data['info'][] = get_the_author_meta( 'display_name', absint( $post->post_author ) );
40
41
42 }
43
44 }else{
45 $data['info'][] = get_the_author_meta( 'display_name', absint( $post->post_author ) );
46
47 }
48 return $data;
49 }
50 public function blockspare_author_list($post,$post_id='',$author_id='',$author_type='',$author_avatar=false){
51 ob_start();
52 if($author_type == 'default'){
53 $default_author_id = get_post_field('post_author', $post_id);
54 $author_name = get_userdata( $author_id);
55 ?><?php echo esc_html($author_name->display_name);?>
56
57 <?php }
58 if($author_type == 'guest'){
59 $wp_amulti_authors = new WPAMultiAuthors();
60 $guest_user_data = $wp_amulti_authors->get_guest_by_id($author_id);
61 $author_data['display_name']= $guest_user_data->display_name;
62 ?>
63 <?php echo $guest_user_data->display_name;?>
64 <?php
65
66 }
67
68 return ob_get_clean();
69 }
70
71
72 }
73 }