PluginProbe
WPSSO Core – Complete Schema Markup and Meta Tags / 22.7.0
WPSSO Core – Complete Schema Markup and Meta Tags v22.7.0
22.7.0 22.6.1 22.6.0 22.5.3 22.5.2 22.5.1 22.4.0 22.3.0 22.2.1 22.2.0 22.1.3 22.1.2 22.1.1 22.1.0 22.0.0 21.13.3 21.13.2 trunk 21.13.1
wpsso / lib / integ / user / publishpress-authors.php

publishpress-authors.php in WPSSO Core – Complete Schema Markup and Meta Tags 22.7.0, at lib/integ/user/publishpress-authors.php

109 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 * License: GPLv3
4 * License URI: https://www.gnu.org/licenses/gpl.txt
5 * Copyright 2012-2026 Jean-Sebastien Morisset (https://wpsso.com/)
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9
10 die( 'These aren\'t the droids you\'re looking for.' );
11 }
12
13 if ( ! class_exists( 'WpssoIntegUserPublishPressAuthors' ) ) {
14
15 class WpssoIntegUserPublishPressAuthors {
16
17 private $p; // Wpsso class object.
18
19 public function __construct( &$plugin ) {
20
21 $this->p =& $plugin;
22
23 if ( $this->p->debug->enabled ) {
24
25 $this->p->debug->mark();
26 }
27
28 $this->p->util->add_plugin_filters( $this, array(
29 'get_post_mod' => 2,
30 ) );
31 }
32
33 public function filter_get_post_mod( $mod, $mod_id ) {
34
35 if ( $this->p->debug->enabled ) {
36
37 $this->p->debug->mark();
38 }
39
40 /*
41 * Array (
42 * [0] => MultipleAuthors\Classes\Objects\Author Object (
43 * [term_id] => 770
44 * [term:MultipleAuthors\Classes\Objects\Author:private] =>
45 * [metaCache:MultipleAuthors\Classes\Objects\Author:private] =>
46 * [userObject:MultipleAuthors\Classes\Objects\Author:private] =>
47 * [hasCustomAvatar:MultipleAuthors\Classes\Objects\Author:private] =>
48 * [customAvatarUrl:MultipleAuthors\Classes\Objects\Author:private] =>
49 * [avatarUrl:MultipleAuthors\Classes\Objects\Author:private] =>
50 * [avatarBySize:MultipleAuthors\Classes\Objects\Author:private] => Array ()
51 * )
52 * )
53 */
54 $post_authors = get_post_authors( $mod_id );
55
56 if ( empty( $post_authors ) || ! is_array( $post_authors ) ) {
57
58 if ( $this->p->debug->enabled ) {
59
60 $this->p->debug->log( 'no coauthors found for post ID ' . $mod_id );
61 }
62
63 return $mod;
64 }
65
66 foreach ( $post_authors as $author_num => $post_author ) {
67
68 if ( empty( $post_author->user_id ) ) {
69
70 if ( $this->p->debug->enabled ) {
71
72 $this->p->debug->log( 'skipping coauthor #' . $author_num . ' (user_id is empty)' );
73 }
74
75 } elseif ( (int) $post_author->user_id === $mod[ 'post_author' ] ) {
76
77 if ( $this->p->debug->enabled ) {
78
79 $this->p->debug->log( 'skipping coauthor #' . $author_num . ' id ' . $post_author->user_id . ' (already primary author)' );
80 }
81
82 /*
83 * Make sure the first (top) author listed is the post/page author.
84 */
85 } elseif ( 0 === $author_num ) {
86
87 if ( $this->p->debug->enabled ) {
88
89 $this->p->debug->log( 'setting coauthor #' . $author_num . ' id ' . $post_author->user_id . ' as primary author' );
90 }
91
92 $mod[ 'post_author' ] = (int) $post_author->user_id;
93
94 } else {
95
96 if ( $this->p->debug->enabled ) {
97
98 $this->p->debug->log( 'adding coauthor #' . $author_num . ' id ' . $post_author->user_id );
99 }
100
101 $mod[ 'post_coauthors' ][] = (int) $post_author->user_id;
102 }
103 }
104
105 return $mod;
106 }
107 }
108 }
109