wp/wp-includes/author-template.php
author ymh <ymh.work@gmail.com>
Wed, 21 Sep 2022 18:19:35 +0200
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
permissions -rw-r--r--
Site enmi version 09/2022
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Author Template functions for use in themes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * These functions must be used within the WordPress Loop.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
     7
 * @link https://codex.wordpress.org/Author_Templates
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 * @subpackage Template
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * Retrieve the author of the current post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    16
 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    17
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    18
 * @global WP_User $authordata The current author's data.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
 * @param string $deprecated Deprecated.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    21
 * @return string|null The author's display name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    23
function get_the_author( $deprecated = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
	global $authordata;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    26
	if ( ! empty( $deprecated ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    27
		_deprecated_argument( __FUNCTION__, '2.1.0' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    28
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    31
	 * Filters the display name of the current post's author.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
	 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    35
	 * @param string|null $display_name The author's display name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    37
	return apply_filters( 'the_author', is_object( $authordata ) ? $authordata->display_name : null );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
 * Display the name of the author of the current post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
 * The behavior of this function is based off of old functionality predating
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
 * get_the_author(). This function is not deprecated, but is designed to echo
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
 * the value from get_the_author() and as an result of any old theme that might
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
 * still use the old behavior will also pass the value from get_the_author().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
 * The normal, expected behavior of this function is to echo the author and not
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    49
 * return it. However, backward compatibility has to be maintained.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
 * @since 0.71
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    52
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
 * @see get_the_author()
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    54
 * @link https://developer.wordpress.org/reference/functions/the_author/
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    56
 * @param string $deprecated      Deprecated.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    57
 * @param bool   $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    58
 * @return string|null The author's display name, from get_the_author().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
function the_author( $deprecated = '', $deprecated_echo = true ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    61
	if ( ! empty( $deprecated ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    62
		_deprecated_argument( __FUNCTION__, '2.1.0' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    63
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    64
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    65
	if ( true !== $deprecated_echo ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    66
		_deprecated_argument(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    67
			__FUNCTION__,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    68
			'1.5.0',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    69
			sprintf(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    70
				/* translators: %s: get_the_author() */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    71
				__( 'Use %s instead if you do not want the value echoed.' ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    72
				'<code>get_the_author()</code>'
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    73
			)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    74
		);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    75
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    76
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    77
	if ( $deprecated_echo ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
		echo get_the_author();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    79
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    80
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
	return get_the_author();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
 * Retrieve the author who last edited the current post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    87
 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    88
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    89
 * @return string|void The author's display name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
function get_the_modified_author() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    92
	$last_id = get_post_meta( get_post()->ID, '_edit_last', true );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    93
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    94
	if ( $last_id ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    95
		$last_user = get_userdata( $last_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    96
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    98
		 * Filters the display name of the author who last edited the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
		 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
		 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
		 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   102
		 * @param string $display_name The author's display name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
		 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   104
		return apply_filters( 'the_modified_author', $last_user->display_name );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   109
 * Display the name of the author who last edited the current post,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   110
 * if the author's ID is available.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   111
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   112
 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
 * @see get_the_author()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
function the_modified_author() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
	echo get_the_modified_author();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   121
 * Retrieves the requested data of the author of the current post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   122
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   123
 * Valid values for the `$field` parameter include:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   124
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   125
 * - admin_color
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   126
 * - aim
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   127
 * - comment_shortcuts
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   128
 * - description
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   129
 * - display_name
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   130
 * - first_name
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   131
 * - ID
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   132
 * - jabber
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   133
 * - last_name
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   134
 * - nickname
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   135
 * - plugins_last_view
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   136
 * - plugins_per_page
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   137
 * - rich_editing
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   138
 * - syntax_highlighting
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   139
 * - user_activation_key
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   140
 * - user_description
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   141
 * - user_email
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   142
 * - user_firstname
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   143
 * - user_lastname
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   144
 * - user_level
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   145
 * - user_login
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   146
 * - user_nicename
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   147
 * - user_pass
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   148
 * - user_registered
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   149
 * - user_status
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   150
 * - user_url
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   151
 * - yim
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   152
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
 * @since 2.8.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   154
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   155
 * @global WP_User $authordata The current author's data.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   156
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   157
 * @param string    $field   Optional. The user field to retrieve. Default empty.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   158
 * @param int|false $user_id Optional. User ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   159
 * @return string The author's field from the current author's DB object, otherwise an empty string.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   160
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   161
function get_the_author_meta( $field = '', $user_id = false ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   162
	$original_user_id = $user_id;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   163
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	if ( ! $user_id ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
		global $authordata;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   166
		$user_id = isset( $authordata->ID ) ? $authordata->ID : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
		$authordata = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   171
	if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ), true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
		$field = 'user_' . $field;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   173
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
	$value = isset( $authordata->$field ) ? $authordata->$field : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   178
	 * Filters the value of the requested user metadata.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
	 * The filter name is dynamic and depends on the $field parameter of the function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
	 * @since 2.8.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   183
	 * @since 4.3.0 The `$original_user_id` parameter was added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
	 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   185
	 * @param string    $value            The value of the metadata.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   186
	 * @param int       $user_id          The user ID for the value.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   187
	 * @param int|false $original_user_id The original user ID, as passed to the function.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   189
	return apply_filters( "get_the_author_{$field}", $value, $user_id, $original_user_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   193
 * Outputs the field from the user's DB object. Defaults to current post's author.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   194
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
 * @since 2.8.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   196
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   197
 * @param string    $field   Selects the field of the users record. See get_the_author_meta()
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   198
 *                           for the list of possible fields.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   199
 * @param int|false $user_id Optional. User ID.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   200
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   201
 * @see get_the_author_meta()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
function the_author_meta( $field = '', $user_id = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
	$author_meta = get_the_author_meta( $field, $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
	 * The value of the requested user metadata.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
	 * The filter name is dynamic and depends on the $field parameter of the function.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
	 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
	 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   213
	 * @param string    $author_meta The value of the metadata.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   214
	 * @param int|false $user_id     The user ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   216
	echo apply_filters( "the_author_{$field}", $author_meta, $user_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
 * Retrieve either author's link or author's name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
 * If the author has a home page set, return an HTML link, otherwise just return the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
 * author's name.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   224
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   225
 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   226
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   227
 * @return string|null An HTML link if the author's url exist in user meta,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   228
 *                     else the result of get_the_author().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
function get_the_author_link() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   231
	if ( get_the_author_meta( 'url' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   232
		return sprintf(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   233
			'<a href="%1$s" title="%2$s" rel="author external">%3$s</a>',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   234
			esc_url( get_the_author_meta( 'url' ) ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   235
			/* translators: %s: Author's display name. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   236
			esc_attr( sprintf( __( 'Visit %s&#8217;s website' ), get_the_author() ) ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   237
			get_the_author()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   238
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
		return get_the_author();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
 * Display either author's link or author's name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
 * If the author has a home page set, echo an HTML link, otherwise just echo the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
 * author's name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   250
 * @link https://developer.wordpress.org/reference/functions/the_author_link/
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   251
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
 * @since 2.1.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
function the_author_link() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
	echo get_the_author_link();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
 * Retrieve the number of posts by the author of the current post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   261
 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   262
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
 * @return int The number of posts by the author.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
function get_the_author_posts() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   266
	$post = get_post();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   267
	if ( ! $post ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   268
		return 0;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   269
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   270
	return count_user_posts( $post->post_author, $post->post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
 * Display the number of posts by the author of the current post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   276
 * @link https://developer.wordpress.org/reference/functions/the_author_posts/
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
function the_author_posts() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
	echo get_the_author_posts();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   284
 * Retrieves an HTML link to the author page of the current post's author.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   285
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   286
 * Returns an HTML-formatted link using get_author_posts_url().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   288
 * @since 4.4.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   290
 * @global WP_User $authordata The current author's data.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   291
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   292
 * @return string An HTML link to the author page, or an empty string if $authordata isn't defined.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   294
function get_the_author_posts_link() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
	global $authordata;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   296
	if ( ! is_object( $authordata ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   297
		return '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   298
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   299
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   300
	$link = sprintf(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   301
		'<a href="%1$s" title="%2$s" rel="author">%3$s</a>',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
		esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   303
		/* translators: %s: Author's display name. */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
		esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
		get_the_author()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   309
	 * Filters the link to the author page of the author of the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
	 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
	 * @param string $link HTML link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   315
	return apply_filters( 'the_author_posts_link', $link );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   316
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   317
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   318
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   319
 * Displays an HTML link to the author page of the current post's author.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   320
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   321
 * @since 1.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   322
 * @since 4.4.0 Converted into a wrapper for get_the_author_posts_link()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   323
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   324
 * @param string $deprecated Unused.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   325
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   326
function the_author_posts_link( $deprecated = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   327
	if ( ! empty( $deprecated ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   328
		_deprecated_argument( __FUNCTION__, '2.1.0' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   329
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   330
	echo get_the_author_posts_link();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
 * Retrieve the URL to the author page for the user with the ID provided.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
 * @since 2.1.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   337
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   338
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   339
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   340
 * @param int    $author_id       Author ID.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   341
 * @param string $author_nicename Optional. The author's nicename (slug). Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
 * @return string The URL to the author's page.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   344
function get_author_posts_url( $author_id, $author_nicename = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
	$auth_ID = (int) $author_id;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   347
	$link    = $wp_rewrite->get_author_permastruct();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   349
	if ( empty( $link ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
		$file = home_url( '/' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
		$link = $file . '?author=' . $auth_ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
	} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   353
		if ( '' === $author_nicename ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   354
			$user = get_userdata( $author_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   355
			if ( ! empty( $user->user_nicename ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
				$author_nicename = $user->user_nicename;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   357
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
		}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   359
		$link = str_replace( '%author%', $author_nicename, $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
		$link = home_url( user_trailingslashit( $link ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   364
	 * Filters the URL to the author's page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
	 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
	 * @param string $link            The URL to the author's page.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   369
	 * @param int    $author_id       The author's ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
	 * @param string $author_nicename The author's nice name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
	$link = apply_filters( 'author_link', $link, $author_id, $author_nicename );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
	return $link;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   378
 * List all the authors of the site, with several options available.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   380
 * @link https://developer.wordpress.org/reference/functions/wp_list_authors/
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   381
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   382
 * @since 1.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   383
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   384
 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   385
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   386
 * @param string|array $args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   387
 *     Optional. Array or string of default arguments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   389
 *     @type string       $orderby       How to sort the authors. Accepts 'nicename', 'email', 'url', 'registered',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   390
 *                                       'user_nicename', 'user_email', 'user_url', 'user_registered', 'name',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   391
 *                                       'display_name', 'post_count', 'ID', 'meta_value', 'user_login'. Default 'name'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   392
 *     @type string       $order         Sorting direction for $orderby. Accepts 'ASC', 'DESC'. Default 'ASC'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   393
 *     @type int          $number        Maximum authors to return or display. Default empty (all authors).
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   394
 *     @type bool         $optioncount   Show the count in parenthesis next to the author's name. Default false.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   395
 *     @type bool         $exclude_admin Whether to exclude the 'admin' account, if it exists. Default true.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   396
 *     @type bool         $show_fullname Whether to show the author's full name. Default false.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   397
 *     @type bool         $hide_empty    Whether to hide any authors with no posts. Default true.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   398
 *     @type string       $feed          If not empty, show a link to the author's feed and use this text as the alt
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   399
 *                                       parameter of the link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   400
 *     @type string       $feed_image    If not empty, show a link to the author's feed and use this image URL as
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   401
 *                                       clickable anchor. Default empty.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   402
 *     @type string       $feed_type     The feed type to link to. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   403
 *                                       Default is the value of get_default_feed().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   404
 *     @type bool         $echo          Whether to output the result or instead return it. Default true.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   405
 *     @type string       $style         If 'list', each author is wrapped in an `<li>` element, otherwise the authors
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   406
 *                                       will be separated by commas.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   407
 *     @type bool         $html          Whether to list the items in HTML form or plaintext. Default true.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   408
 *     @type int[]|string $exclude       Array or comma/space-separated list of author IDs to exclude. Default empty.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   409
 *     @type int[]|string $include       Array or comma/space-separated list of author IDs to include. Default empty.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   410
 * }
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   411
 * @return void|string Void if 'echo' argument is true, list of authors if 'echo' is false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
function wp_list_authors( $args = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
	$defaults = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   417
		'orderby'       => 'name',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   418
		'order'         => 'ASC',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   419
		'number'        => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   420
		'optioncount'   => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   421
		'exclude_admin' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   422
		'show_fullname' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   423
		'hide_empty'    => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   424
		'feed'          => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   425
		'feed_image'    => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   426
		'feed_type'     => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   427
		'echo'          => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   428
		'style'         => 'list',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   429
		'html'          => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   430
		'exclude'       => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   431
		'include'       => '',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
	$args = wp_parse_args( $args, $defaults );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
	$return = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   438
	$query_args           = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
	$query_args['fields'] = 'ids';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   440
	$authors              = get_users( $query_args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
	$author_count = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   443
	foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . ' GROUP BY post_author' ) as $row ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   444
		$author_count[ $row->post_author ] = $row->count;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   445
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
	foreach ( $authors as $author_id ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   447
		$posts = isset( $author_count[ $author_id ] ) ? $author_count[ $author_id ] : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   449
		if ( ! $posts && $args['hide_empty'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
			continue;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   451
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   453
		$author = get_userdata( $author_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   455
		if ( $args['exclude_admin'] && 'admin' === $author->display_name ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
			continue;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   457
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   459
		if ( $args['show_fullname'] && $author->first_name && $author->last_name ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
			$name = "$author->first_name $author->last_name";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   461
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
			$name = $author->display_name;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   463
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   465
		if ( ! $args['html'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
			$return .= $name . ', ';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
			continue; // No need to go further to process HTML.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   471
		if ( 'list' === $args['style'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
			$return .= '<li>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   475
		$link = sprintf(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   476
			'<a href="%1$s" title="%2$s">%3$s</a>',
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   477
			esc_url( get_author_posts_url( $author->ID, $author->user_nicename ) ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   478
			/* translators: %s: Author's display name. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   479
			esc_attr( sprintf( __( 'Posts by %s' ), $author->display_name ) ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   480
			$name
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   481
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   483
		if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
			$link .= ' ';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   485
			if ( empty( $args['feed_image'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
				$link .= '(';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   489
			$link .= '<a href="' . get_author_feed_link( $author->ID, $args['feed_type'] ) . '"';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   491
			$alt = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   492
			if ( ! empty( $args['feed'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   493
				$alt  = ' alt="' . esc_attr( $args['feed'] ) . '"';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   494
				$name = $args['feed'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
			$link .= '>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   499
			if ( ! empty( $args['feed_image'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   500
				$link .= '<img src="' . esc_url( $args['feed_image'] ) . '" style="border: none;"' . $alt . ' />';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
			} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
				$link .= $name;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   503
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   504
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   505
			$link .= '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   507
			if ( empty( $args['feed_image'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
				$link .= ')';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   509
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   512
		if ( $args['optioncount'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   513
			$link .= ' (' . $posts . ')';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   514
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
		$return .= $link;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   517
		$return .= ( 'list' === $args['style'] ) ? '</li>' : ', ';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   520
	$return = rtrim( $return, ', ' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   522
	if ( $args['echo'] ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   523
		echo $return;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   524
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
		return $return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   526
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   530
 * Determines whether this site has more than one author.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
 * Checks to see if more than one author has published posts.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   534
 * For more information on this and similar theme functions, check out
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   535
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   536
 * Conditional Tags} article in the Theme Developer Handbook.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   537
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
 * @since 3.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   539
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   540
 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   541
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   542
 * @return bool Whether or not we have more than one author
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   543
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
function is_multi_author() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   547
	$is_multi_author = get_transient( 'is_multi_author' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   548
	if ( false === $is_multi_author ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   549
		$rows            = (array) $wpdb->get_col( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
		$is_multi_author = 1 < count( $rows ) ? 1 : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
		set_transient( 'is_multi_author', $is_multi_author );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   555
	 * Filters whether the site has more than one author with published posts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
	 * @since 3.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
	 * @param bool $is_multi_author Whether $is_multi_author should evaluate as true.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
	return apply_filters( 'is_multi_author', (bool) $is_multi_author );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
 * Helper function to clear the cache for number of authors.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   567
 * @since 3.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   568
 * @access private
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   570
function __clear_multi_author_cache() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
	delete_transient( 'is_multi_author' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
}