wp/wp-includes/link-template.php
author ymh <ymh.work@gmail.com>
Fri, 05 Sep 2025 18:40:08 +0200
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
child 22 8c2e4d02f4ef
permissions -rw-r--r--
Add CLAUDE.md documentation and sync WordPress core files - Add comprehensive CLAUDE.md documentation file with project architecture, development setup, database operations, WordPress CLI usage, file sync procedures, and Mercurial commands - Update WordPress core files from wordpress/ to wp/ directory - Sync latest WordPress admin interface, includes, and core functionality - Update plugins: portfolio plugin with latest BWS framework and fancybox integration - Maintain custom configuration and theme files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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
 * WordPress Link Template Functions
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage Template
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    10
 * Displays the permalink for the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 * @since 1.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    13
 * @since 4.4.0 Added the `$post` parameter.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    14
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    15
 * @param int|WP_Post $post Optional. Post ID or post object. Default is the global `$post`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    17
function the_permalink( $post = 0 ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    18
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    19
	 * Filters the display of the permalink for the current post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
	 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    22
	 * @since 4.4.0 Added the `$post` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    24
	 * @param string      $permalink The permalink for the current post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    25
	 * @param int|WP_Post $post      Post ID, WP_Post object, or 0. Default 0.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    27
	echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
}
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
 * Retrieves a trailing-slashed string if the site is set for adding trailing slashes.
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
 * Conditionally adds a trailing slash if the permalink structure has a trailing
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
 * slash, strips the trailing slash if not. The string is passed through the
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    35
 * {@see 'user_trailingslashit'} filter. Will remove trailing slash from string, if
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    36
 * site is not set to have them.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
 * @since 2.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    39
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    40
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    41
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    42
 * @param string $url         URL with or without a trailing slash.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    43
 * @param string $type_of_url Optional. The type of URL being considered (e.g. single, category, etc)
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    44
 *                            for use in the filter. Default empty string.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
 * @return string The URL with the trailing slash appended or stripped.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    47
function user_trailingslashit( $url, $type_of_url = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
	global $wp_rewrite;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    49
	if ( $wp_rewrite->use_trailing_slashes ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    50
		$url = trailingslashit( $url );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    51
	} else {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    52
		$url = untrailingslashit( $url );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    53
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    55
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    56
	 * Filters the trailing-slashed string, depending on whether the site is set to use trailing slashes.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    58
	 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    59
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    60
	 * @param string $url         URL with or without a trailing slash.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
	 * @param string $type_of_url The type of URL being considered. Accepts 'single', 'single_trackback',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    62
	 *                            'single_feed', 'single_paged', 'commentpaged', 'paged', 'home', 'feed',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    63
	 *                            'category', 'page', 'year', 'month', 'day', 'post_type_archive'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    64
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    65
	return apply_filters( 'user_trailingslashit', $url, $type_of_url );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    69
 * Displays the permalink anchor for the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
 * The permalink mode title will use the post title for the 'a' element 'id'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
 * attribute. The id mode uses 'post-' with the post ID for the 'id' attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    76
 * @param string $mode Optional. Permalink mode. Accepts 'title' or 'id'. Default 'id'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
function permalink_anchor( $mode = 'id' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
	$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
	switch ( strtolower( $mode ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
		case 'title':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
			$title = sanitize_title( $post->post_title ) . '-' . $post->ID;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    83
			echo '<a id="' . $title . '"></a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
		case 'id':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
			echo '<a id="post-' . $post->ID . '"></a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    92
/**
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    93
 * Determine whether post should always use a plain permalink structure.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    94
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    95
 * @since 5.7.0
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    96
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    97
 * @param WP_Post|int|null $post   Optional. Post ID or post object. Defaults to global $post.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    98
 * @param bool|null        $sample Optional. Whether to force consideration based on sample links.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    99
 *                                 If omitted, a sample link is generated if a post object is passed
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   100
 *                                 with the filter property set to 'sample'.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   101
 * @return bool Whether to use a plain permalink structure.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   102
 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   103
function wp_force_plain_post_permalink( $post = null, $sample = null ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   104
	if (
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   105
		null === $sample &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   106
		is_object( $post ) &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   107
		isset( $post->filter ) &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   108
		'sample' === $post->filter
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   109
	) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   110
		$sample = true;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   111
	} else {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   112
		$post   = get_post( $post );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   113
		$sample = null !== $sample ? $sample : false;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   114
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   115
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   116
	if ( ! $post ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   117
		return true;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   118
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   119
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   120
	$post_status_obj = get_post_status_object( get_post_status( $post ) );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   121
	$post_type_obj   = get_post_type_object( get_post_type( $post ) );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   122
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   123
	if ( ! $post_status_obj || ! $post_type_obj ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   124
		return true;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   125
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   126
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   127
	if (
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   128
		// Publicly viewable links never have plain permalinks.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   129
		is_post_status_viewable( $post_status_obj ) ||
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   130
		(
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   131
			// Private posts don't have plain permalinks if the user can read them.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   132
			$post_status_obj->private &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   133
			current_user_can( 'read_post', $post->ID )
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   134
		) ||
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   135
		// Protected posts don't have plain links if getting a sample URL.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   136
		( $post_status_obj->protected && $sample )
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   137
	) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   138
		return false;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   139
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   140
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   141
	return true;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   142
}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   143
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   144
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   145
 * Retrieves the full permalink for the current post or post ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   147
 * This function is an alias for get_permalink().
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   148
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   149
 * @since 3.9.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   150
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
 * @see get_permalink()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   152
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   153
 * @param int|WP_Post $post      Optional. Post ID or post object. Default is the global `$post`.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
 * @param bool        $leavename Optional. Whether to keep post name or page name. Default false.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   155
 * @return string|false The permalink URL. False if the post does not exist.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   156
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   157
function get_the_permalink( $post = 0, $leavename = false ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   158
	return get_permalink( $post, $leavename );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   159
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   160
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   161
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   162
 * Retrieves the full permalink for the current post or post ID.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   163
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   166
 * @param int|WP_Post $post      Optional. Post ID or post object. Default is the global `$post`.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   167
 * @param bool        $leavename Optional. Whether to keep post name or page name. Default false.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   168
 * @return string|false The permalink URL. False if the post does not exist.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   170
function get_permalink( $post = 0, $leavename = false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
	$rewritecode = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
		'%year%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
		'%monthnum%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
		'%day%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
		'%hour%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
		'%minute%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
		'%second%',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   178
		$leavename ? '' : '%postname%',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
		'%post_id%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
		'%category%',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
		'%author%',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   182
		$leavename ? '' : '%pagename%',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   185
	if ( is_object( $post ) && isset( $post->filter ) && 'sample' === $post->filter ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
		$sample = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
	} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   188
		$post   = get_post( $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
		$sample = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   192
	if ( empty( $post->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   194
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   195
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   196
	if ( 'page' === $post->post_type ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   197
		return get_page_link( $post, $leavename, $sample );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   198
	} elseif ( 'attachment' === $post->post_type ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   199
		return get_attachment_link( $post, $leavename );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   200
	} elseif ( in_array( $post->post_type, get_post_types( array( '_builtin' => false ) ), true ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   201
		return get_post_permalink( $post, $leavename, $sample );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   202
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   203
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   204
	$permalink = get_option( 'permalink_structure' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   207
	 * Filters the permalink structure for a post before token replacement occurs.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
	 * Only applies to posts with post_type of 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   211
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   212
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   213
	 * @param string  $permalink The site's permalink structure.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   214
	 * @param WP_Post $post      The post in question.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   215
	 * @param bool    $leavename Whether to keep the post name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   216
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   217
	$permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   218
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   219
	if (
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   220
		$permalink &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   221
		! wp_force_plain_post_permalink( $post )
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   222
	) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
		$category = '';
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   225
		if ( str_contains( $permalink, '%category%' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   226
			$cats = get_the_category( $post->ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
			if ( $cats ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   228
				$cats = wp_list_sort(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   229
					$cats,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   230
					array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   231
						'term_id' => 'ASC',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   232
					)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   233
				);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   234
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   235
				/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   236
				 * Filters the category that gets used in the %category% permalink token.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   237
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   238
				 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   239
				 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   240
				 * @param WP_Term  $cat  The category to use in the permalink.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   241
				 * @param array    $cats Array of all categories (WP_Term objects) associated with the post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   242
				 * @param WP_Post  $post The post in question.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   243
				 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
				$category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   245
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
				$category_object = get_term( $category_object, 'category' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   247
				$category        = $category_object->slug;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   248
				if ( $category_object->parent ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   249
					$category = get_category_parents( $category_object->parent, false, '/', true ) . $category;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   250
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
			}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   252
			/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   253
			 * Show default category in permalinks,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   254
			 * without having to assign it explicitly.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   255
			 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   256
			if ( empty( $category ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
				$default_category = get_term( get_option( 'default_category' ), 'category' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   258
				if ( $default_category && ! is_wp_error( $default_category ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   259
					$category = $default_category->slug;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   260
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
		$author = '';
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   265
		if ( str_contains( $permalink, '%author%' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   266
			$authordata = get_userdata( $post->post_author );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   267
			$author     = $authordata->user_nicename;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   270
		/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   271
		 * This is not an API call because the permalink is based on the stored post_date value,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   272
		 * which should be parsed as local time regardless of the default PHP timezone.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   273
		 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   274
		$date = explode( ' ', str_replace( array( '-', ':' ), ' ', $post->post_date ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   275
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   276
		$rewritereplace = array(
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
			$date[0],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
			$date[1],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
			$date[2],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
			$date[3],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
			$date[4],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
			$date[5],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
			$post->post_name,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
			$post->ID,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
			$category,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
			$author,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
			$post->post_name,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
		);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   289
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   290
		$permalink = home_url( str_replace( $rewritecode, $rewritereplace, $permalink ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   291
		$permalink = user_trailingslashit( $permalink, 'single' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   292
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   293
	} else { // If they're not using the fancy permalink option.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   294
		$permalink = home_url( '?p=' . $post->ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   296
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   297
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   298
	 * Filters the permalink for a post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   299
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   300
	 * Only applies to posts with post_type of 'post'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   301
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   302
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   303
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   304
	 * @param string  $permalink The post's permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   305
	 * @param WP_Post $post      The post in question.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   306
	 * @param bool    $leavename Whether to keep the post name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   307
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   308
	return apply_filters( 'post_link', $permalink, $post, $leavename );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   312
 * Retrieves the permalink for a post of a custom post type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
 * @since 3.0.0
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   315
 * @since 6.1.0 Returns false if the post does not exist.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   317
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   318
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   319
 * @param int|WP_Post $post      Optional. Post ID or post object. Default is the global `$post`.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   320
 * @param bool        $leavename Optional. Whether to keep post name. Default false.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   321
 * @param bool        $sample    Optional. Is it a sample permalink. Default false.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   322
 * @return string|false The post permalink URL. False if the post does not exist.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   324
function get_post_permalink( $post = 0, $leavename = false, $sample = false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   327
	$post = get_post( $post );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   328
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   329
	if ( ! $post ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   330
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   331
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   332
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   333
	$post_link = $wp_rewrite->get_extra_permastruct( $post->post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
	$slug = $post->post_name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   337
	$force_plain_link = wp_force_plain_post_permalink( $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   339
	$post_type = get_post_type_object( $post->post_type );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   341
	if ( $post_type->hierarchical ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   342
		$slug = get_page_uri( $post );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   343
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   344
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   345
	if ( ! empty( $post_link ) && ( ! $force_plain_link || $sample ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
		if ( ! $leavename ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   347
			$post_link = str_replace( "%$post->post_type%", $slug, $post_link );
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
		$post_link = home_url( user_trailingslashit( $post_link ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
	} else {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   351
		if ( $post_type->query_var && ( isset( $post->post_status ) && ! $force_plain_link ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   352
			$post_link = add_query_arg( $post_type->query_var, $slug, '' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   353
		} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   354
			$post_link = add_query_arg(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   355
				array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   356
					'post_type' => $post->post_type,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   357
					'p'         => $post->ID,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   358
				),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   359
				''
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   360
			);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   361
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   362
		$post_link = home_url( $post_link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   365
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   366
	 * Filters the permalink for a post of a custom post type.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   367
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   368
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   369
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   370
	 * @param string  $post_link The post's permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   371
	 * @param WP_Post $post      The post in question.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   372
	 * @param bool    $leavename Whether to keep the post name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   373
	 * @param bool    $sample    Is it a sample permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   374
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   375
	return apply_filters( 'post_type_link', $post_link, $post, $leavename, $sample );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   379
 * Retrieves the permalink for the current page or page ID.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
 * Respects page_on_front. Use this one.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   385
 * @param int|WP_Post $post      Optional. Post ID or object. Default uses the global `$post`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   386
 * @param bool        $leavename Optional. Whether to keep the page name. Default false.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   387
 * @param bool        $sample    Optional. Whether it should be treated as a sample permalink.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   388
 *                               Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   389
 * @return string The page permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
function get_page_link( $post = false, $leavename = false, $sample = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
	$post = get_post( $post );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   394
	if ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   395
		$link = home_url( '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   396
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
		$link = _get_page_link( $post, $leavename, $sample );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   398
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   400
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   401
	 * Filters the permalink for a page.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   402
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   403
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   404
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   405
	 * @param string $link    The page's permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   406
	 * @param int    $post_id The ID of the page.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   407
	 * @param bool   $sample  Is it a sample permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   408
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
	return apply_filters( 'page_link', $link, $post->ID, $sample );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   411
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   413
 * Retrieves the page permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
 * Ignores page_on_front. Internal use only.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   420
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   421
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   422
 * @param int|WP_Post $post      Optional. Post ID or object. Default uses the global `$post`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   423
 * @param bool        $leavename Optional. Whether to keep the page name. Default false.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   424
 * @param bool        $sample    Optional. Whether it should be treated as a sample permalink.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   425
 *                               Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   426
 * @return string The page permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
function _get_page_link( $post = false, $leavename = false, $sample = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
	$post = get_post( $post );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   433
	$force_plain_link = wp_force_plain_post_permalink( $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
	$link = $wp_rewrite->get_page_permastruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   437
	if ( ! empty( $link ) && ( ( isset( $post->post_status ) && ! $force_plain_link ) || $sample ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
		if ( ! $leavename ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   439
			$link = str_replace( '%pagename%', get_page_uri( $post ), $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   442
		$link = home_url( $link );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   443
		$link = user_trailingslashit( $link, 'page' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
		$link = home_url( '?page_id=' . $post->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   448
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   449
	 * Filters the permalink for a non-page_on_front page.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   450
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   451
	 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   452
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   453
	 * @param string $link    The page's permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   454
	 * @param int    $post_id The ID of the page.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   455
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
	return apply_filters( '_get_page_link', $link, $post->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   460
 * Retrieves the permalink for an attachment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
 * This can be used in the WordPress Loop or outside of it.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   466
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   467
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   468
 * @param int|WP_Post $post      Optional. Post ID or object. Default uses the global `$post`.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   469
 * @param bool        $leavename Optional. Whether to keep the page name. Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   470
 * @return string The attachment permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
function get_attachment_link( $post = null, $leavename = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
	$link = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   477
	$post             = get_post( $post );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   478
	$force_plain_link = wp_force_plain_post_permalink( $post );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   479
	$parent_id        = $post->post_parent;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   480
	$parent           = $parent_id ? get_post( $parent_id ) : false;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   481
	$parent_valid     = true; // Default for no parent.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   482
	if (
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   483
		$parent_id &&
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   484
		(
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   485
			$post->post_parent === $post->ID ||
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   486
			! $parent ||
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   487
			! is_post_type_viewable( get_post_type( $parent ) )
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   488
		)
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   489
	) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   490
		// Post is either its own parent or parent post unavailable.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   491
		$parent_valid = false;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   492
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   494
	if ( $force_plain_link || ! $parent_valid ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   495
		$link = false;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   496
	} elseif ( $wp_rewrite->using_permalinks() && $parent ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   497
		if ( 'page' === $parent->post_type ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   498
			$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   499
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
			$parentlink = get_permalink( $post->post_parent );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   501
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   502
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   503
		if ( is_numeric( $post->post_name ) || str_contains( get_option( 'permalink_structure' ), '%category%' ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   504
			$name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   505
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
			$name = $post->post_name;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   507
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   508
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   509
		if ( ! str_contains( $parentlink, '?' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   510
			$link = user_trailingslashit( trailingslashit( $parentlink ) . '%postname%' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   511
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   512
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   513
		if ( ! $leavename ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
			$link = str_replace( '%postname%', $name, $link );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   515
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   516
	} elseif ( $wp_rewrite->using_permalinks() && ! $leavename ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   517
		$link = home_url( user_trailingslashit( $post->post_name ) );
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
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   520
	if ( ! $link ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
		$link = home_url( '/?attachment_id=' . $post->ID );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   522
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   524
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   525
	 * Filters the permalink for an attachment.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   526
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   527
	 * @since 2.0.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   528
	 * @since 5.6.0 Providing an empty string will now disable
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   529
	 *              the view attachment page link on the media modal.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   530
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   531
	 * @param string $link    The attachment's permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   532
	 * @param int    $post_id Attachment ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   533
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
	return apply_filters( 'attachment_link', $link, $post->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   538
 * Retrieves the permalink for the year archives.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   542
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   543
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   544
 * @param int|false $year Integer of year. False for current year.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   545
 * @return string The permalink for the specified year archive.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   547
function get_year_link( $year ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
	global $wp_rewrite;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   549
	if ( ! $year ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   550
		$year = current_time( 'Y' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   551
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
	$yearlink = $wp_rewrite->get_year_permastruct();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   553
	if ( ! empty( $yearlink ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   554
		$yearlink = str_replace( '%year%', $year, $yearlink );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   555
		$yearlink = home_url( user_trailingslashit( $yearlink, 'year' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
	} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   557
		$yearlink = home_url( '?m=' . $year );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   559
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   560
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   561
	 * Filters the year archive permalink.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   562
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   563
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   564
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   565
	 * @param string $yearlink Permalink for the year archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   566
	 * @param int    $year     Year for the archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   567
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   568
	return apply_filters( 'year_link', $yearlink, $year );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   572
 * Retrieves the permalink for the month archives with year.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   576
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   577
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   578
 * @param int|false $year  Integer of year. False for current year.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   579
 * @param int|false $month Integer of month. False for current month.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   580
 * @return string The permalink for the specified month and year archive.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   582
function get_month_link( $year, $month ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
	global $wp_rewrite;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   584
	if ( ! $year ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   585
		$year = current_time( 'Y' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   586
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   587
	if ( ! $month ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   588
		$month = current_time( 'm' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   589
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   590
	$monthlink = $wp_rewrite->get_month_permastruct();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   591
	if ( ! empty( $monthlink ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   592
		$monthlink = str_replace( '%year%', $year, $monthlink );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   593
		$monthlink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $monthlink );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
		$monthlink = home_url( user_trailingslashit( $monthlink, 'month' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
	} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
		$monthlink = home_url( '?m=' . $year . zeroise( $month, 2 ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   600
	 * Filters the month archive permalink.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   602
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   603
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   604
	 * @param string $monthlink Permalink for the month archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   605
	 * @param int    $year      Year for the archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   606
	 * @param int    $month     The month for the archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   607
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   608
	return apply_filters( 'month_link', $monthlink, $year, $month );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   612
 * Retrieves the permalink for the day archives with year and month.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   613
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   616
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   617
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   618
 * @param int|false $year  Integer of year. False for current year.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   619
 * @param int|false $month Integer of month. False for current month.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   620
 * @param int|false $day   Integer of day. False for current day.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   621
 * @return string The permalink for the specified day, month, and year archive.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   622
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   623
function get_day_link( $year, $month, $day ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
	global $wp_rewrite;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   625
	if ( ! $year ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   626
		$year = current_time( 'Y' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   627
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   628
	if ( ! $month ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   629
		$month = current_time( 'm' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   630
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   631
	if ( ! $day ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   632
		$day = current_time( 'j' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   633
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   634
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
	$daylink = $wp_rewrite->get_day_permastruct();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   636
	if ( ! empty( $daylink ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   637
		$daylink = str_replace( '%year%', $year, $daylink );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   638
		$daylink = str_replace( '%monthnum%', zeroise( (int) $month, 2 ), $daylink );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   639
		$daylink = str_replace( '%day%', zeroise( (int) $day, 2 ), $daylink );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   640
		$daylink = home_url( user_trailingslashit( $daylink, 'day' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   641
	} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   642
		$daylink = home_url( '?m=' . $year . zeroise( $month, 2 ) . zeroise( $day, 2 ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   644
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   645
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   646
	 * Filters the day archive permalink.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   647
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   648
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   649
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   650
	 * @param string $daylink Permalink for the day archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   651
	 * @param int    $year    Year for the archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   652
	 * @param int    $month   Month for the archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   653
	 * @param int    $day     The day for the archive.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   654
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   655
	return apply_filters( 'day_link', $daylink, $year, $month, $day );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   659
 * Displays the permalink for the feed type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
 * @param string $anchor The link's anchor text.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   664
 * @param string $feed   Optional. Feed type. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   665
 *                       Default is the value of get_default_feed().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
function the_feed_link( $anchor, $feed = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
	$link = '<a href="' . esc_url( get_feed_link( $feed ) ) . '">' . $anchor . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   669
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   670
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   671
	 * Filters the feed link anchor tag.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   672
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   673
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   674
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   675
	 * @param string $link The complete anchor tag for a feed link.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   676
	 * @param string $feed The feed type. Possible values include 'rss2', 'atom',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   677
	 *                     or an empty string for the default feed type.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   678
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   679
	echo apply_filters( 'the_feed_link', $link, $feed );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   681
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   683
 * Retrieves the permalink for the feed type.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   687
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   688
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   689
 * @param string $feed Optional. Feed type. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   690
 *                     Default is the value of get_default_feed().
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   691
 * @return string The feed permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   693
function get_feed_link( $feed = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
	$permalink = $wp_rewrite->get_feed_permastruct();
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   697
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   698
	if ( $permalink ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   699
		if ( str_contains( $feed, 'comments_' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   700
			$feed      = str_replace( 'comments_', '', $feed );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
			$permalink = $wp_rewrite->get_comment_feed_permastruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   704
		if ( get_default_feed() === $feed ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
			$feed = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   706
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   707
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   708
		$permalink = str_replace( '%feed%', $feed, $permalink );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   709
		$permalink = preg_replace( '#/+#', '/', "/$permalink" );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   710
		$output    = home_url( user_trailingslashit( $permalink, 'feed' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
	} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   712
		if ( empty( $feed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
			$feed = get_default_feed();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   714
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   715
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   716
		if ( str_contains( $feed, 'comments_' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   717
			$feed = str_replace( 'comments_', 'comments-', $feed );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   718
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   719
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   720
		$output = home_url( "?feed={$feed}" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   723
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   724
	 * Filters the feed type permalink.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   725
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   726
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   727
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   728
	 * @param string $output The feed permalink.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   729
	 * @param string $feed   The feed type. Possible values include 'rss2', 'atom',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   730
	 *                       or an empty string for the default feed type.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   731
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   732
	return apply_filters( 'feed_link', $output, $feed );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   733
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   736
 * Retrieves the permalink for the post comments feed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   740
 * @param int    $post_id Optional. Post ID. Default is the ID of the global `$post`.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   741
 * @param string $feed    Optional. Feed type. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   742
 *                        Default is the value of get_default_feed().
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   743
 * @return string The permalink for the comments feed for the given post on success, empty string on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   745
function get_post_comments_feed_link( $post_id = 0, $feed = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
	$post_id = absint( $post_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   748
	if ( ! $post_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
		$post_id = get_the_ID();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   750
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   751
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   752
	if ( empty( $feed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   753
		$feed = get_default_feed();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   754
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   755
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   756
	$post = get_post( $post_id );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   757
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   758
	// Bail out if the post does not exist.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   759
	if ( ! $post instanceof WP_Post ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   760
		return '';
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   761
	}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   762
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   763
	$unattached = 'attachment' === $post->post_type && 0 === (int) $post->post_parent;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   764
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   765
	if ( get_option( 'permalink_structure' ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   766
		if ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
			$url = _get_page_link( $post_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   768
		} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   769
			$url = get_permalink( $post_id );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   770
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   772
		if ( $unattached ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   773
			$url = home_url( '/feed/' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   774
			if ( get_default_feed() !== $feed ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   775
				$url .= "$feed/";
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   776
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   777
			$url = add_query_arg( 'attachment_id', $post_id, $url );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   778
		} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   779
			$url = trailingslashit( $url ) . 'feed';
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   780
			if ( get_default_feed() !== $feed ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   781
				$url .= "/$feed";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   782
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   783
			$url = user_trailingslashit( $url, 'single_feed' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   784
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   785
	} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   786
		if ( $unattached ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   787
			$url = add_query_arg(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   788
				array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   789
					'feed'          => $feed,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   790
					'attachment_id' => $post_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   791
				),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   792
				home_url( '/' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   793
			);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   794
		} elseif ( 'page' === $post->post_type ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   795
			$url = add_query_arg(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   796
				array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   797
					'feed'    => $feed,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   798
					'page_id' => $post_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   799
				),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   800
				home_url( '/' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   801
			);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   802
		} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   803
			$url = add_query_arg(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   804
				array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   805
					'feed' => $feed,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   806
					'p'    => $post_id,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   807
				),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   808
				home_url( '/' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   809
			);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   810
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   811
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   812
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   813
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   814
	 * Filters the post comments feed permalink.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   815
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   816
	 * @since 1.5.1
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   817
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   818
	 * @param string $url Post comments feed permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   819
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   820
	return apply_filters( 'post_comments_feed_link', $url );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   824
 * Displays the comment feed link for a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
 * Prints out the comment feed link for a post. Link text is placed in the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
 * anchor. If no link text is specified, default text is used. If no post ID is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   828
 * specified, the current post is used.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   829
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   830
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   831
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   832
 * @param string $link_text Optional. Descriptive link text. Default 'Comments Feed'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   833
 * @param int    $post_id   Optional. Post ID. Default is the ID of the global `$post`.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   834
 * @param string $feed      Optional. Feed type. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   835
 *                          Default is the value of get_default_feed().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   836
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   837
function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   838
	$url = get_post_comments_feed_link( $post_id, $feed );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   839
	if ( empty( $link_text ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   840
		$link_text = __( 'Comments Feed' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   841
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   842
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   843
	$link = '<a href="' . esc_url( $url ) . '">' . $link_text . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   844
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   845
	 * Filters the post comment feed link anchor tag.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   846
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   847
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   848
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   849
	 * @param string $link    The complete anchor tag for the comment feed link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   850
	 * @param int    $post_id Post ID.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   851
	 * @param string $feed    The feed type. Possible values include 'rss2', 'atom',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   852
	 *                        or an empty string for the default feed type.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   853
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   854
	echo apply_filters( 'post_comments_feed_link_html', $link, $post_id, $feed );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   856
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   858
 * Retrieves the feed link for a given author.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   859
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   860
 * Returns a link to the feed for all posts by a given author. A specific feed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   861
 * can be requested or left blank to get the default feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   862
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   865
 * @param int    $author_id Author ID.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   866
 * @param string $feed      Optional. Feed type. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   867
 *                          Default is the value of get_default_feed().
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
 * @return string Link to the feed for the author specified by $author_id.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   869
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
function get_author_feed_link( $author_id, $feed = '' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   871
	$author_id           = (int) $author_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   872
	$permalink_structure = get_option( 'permalink_structure' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   873
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   874
	if ( empty( $feed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   875
		$feed = get_default_feed();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   876
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   878
	if ( ! $permalink_structure ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   879
		$link = home_url( "?feed=$feed&amp;author=" . $author_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
	} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   881
		$link = get_author_posts_url( $author_id );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   882
		if ( get_default_feed() === $feed ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
			$feed_link = 'feed';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   884
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   885
			$feed_link = "feed/$feed";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   886
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   887
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   888
		$link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   889
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   890
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   891
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   892
	 * Filters the feed link for a given author.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   893
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   894
	 * @since 1.5.1
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   895
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   896
	 * @param string $link The author feed link.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   897
	 * @param string $feed Feed type. Possible values include 'rss2', 'atom'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   898
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   899
	$link = apply_filters( 'author_feed_link', $link, $feed );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   900
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   901
	return $link;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   903
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   904
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   905
 * Retrieves the feed link for a category.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
 * Returns a link to the feed for all posts in a given category. A specific feed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
 * can be requested or left blank to get the default feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   910
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   911
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   912
 * @param int|WP_Term|object $cat  The ID or category object whose feed link will be retrieved.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   913
 * @param string             $feed Optional. Feed type. Possible values include 'rss2', 'atom'.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   914
 *                                 Default is the value of get_default_feed().
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   915
 * @return string Link to the feed for the category specified by `$cat`.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   916
 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   917
function get_category_feed_link( $cat, $feed = '' ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   918
	return get_term_feed_link( $cat, 'category', $feed );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   922
 * Retrieves the feed link for a term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   923
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
 * Returns a link to the feed for all posts in a given term. A specific feed
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   925
 * can be requested or left blank to get the default feed.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   927
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   928
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   929
 * @param int|WP_Term|object $term     The ID or term object whose feed link will be retrieved.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   930
 * @param string             $taxonomy Optional. Taxonomy of `$term_id`.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   931
 * @param string             $feed     Optional. Feed type. Possible values include 'rss2', 'atom'.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   932
 *                                     Default is the value of get_default_feed().
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   933
 * @return string|false Link to the feed for the term specified by `$term` and `$taxonomy`.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   934
 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   935
function get_term_feed_link( $term, $taxonomy = '', $feed = '' ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   936
	if ( ! is_object( $term ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   937
		$term = (int) $term;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   938
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   939
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   940
	$term = get_term( $term, $taxonomy );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   941
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   942
	if ( empty( $term ) || is_wp_error( $term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   944
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   945
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   946
	$taxonomy = $term->taxonomy;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   947
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   948
	if ( empty( $feed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
		$feed = get_default_feed();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   950
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   951
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
	$permalink_structure = get_option( 'permalink_structure' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   954
	if ( ! $permalink_structure ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   955
		if ( 'category' === $taxonomy ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   956
			$link = home_url( "?feed=$feed&amp;cat=$term->term_id" );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   957
		} elseif ( 'post_tag' === $taxonomy ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   958
			$link = home_url( "?feed=$feed&amp;tag=$term->slug" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
		} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   960
			$t    = get_taxonomy( $taxonomy );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   961
			$link = home_url( "?feed=$feed&amp;$t->query_var=$term->slug" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   963
	} else {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   964
		$link = get_term_link( $term, $term->taxonomy );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   965
		if ( get_default_feed() === $feed ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
			$feed_link = 'feed';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   967
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
			$feed_link = "feed/$feed";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   969
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   970
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   971
		$link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   972
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   974
	if ( 'category' === $taxonomy ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   975
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   976
		 * Filters the category feed link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   977
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   978
		 * @since 1.5.1
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   979
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   980
		 * @param string $link The category feed link.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   981
		 * @param string $feed Feed type. Possible values include 'rss2', 'atom'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   982
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
		$link = apply_filters( 'category_feed_link', $link, $feed );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   984
	} elseif ( 'post_tag' === $taxonomy ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   985
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   986
		 * Filters the post tag feed link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   987
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   988
		 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   989
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   990
		 * @param string $link The tag feed link.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   991
		 * @param string $feed Feed type. Possible values include 'rss2', 'atom'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   992
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
		$link = apply_filters( 'tag_feed_link', $link, $feed );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   994
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   995
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   996
		 * Filters the feed link for a taxonomy other than 'category' or 'post_tag'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   997
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   998
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   999
		 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1000
		 * @param string $link     The taxonomy feed link.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1001
		 * @param string $feed     Feed type. Possible values include 'rss2', 'atom'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1002
		 * @param string $taxonomy The taxonomy name.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1003
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1004
		$link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1005
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1006
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1007
	return $link;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1008
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1009
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1010
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1011
 * Retrieves the permalink for a tag feed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1013
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1014
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1015
 * @param int|WP_Term|object $tag  The ID or term object whose feed link will be retrieved.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1016
 * @param string             $feed Optional. Feed type. Possible values include 'rss2', 'atom'.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1017
 *                                 Default is the value of get_default_feed().
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1018
 * @return string                  The feed permalink for the given tag.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1019
 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1020
function get_tag_feed_link( $tag, $feed = '' ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1021
	return get_term_feed_link( $tag, 'post_tag', $feed );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1022
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1023
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1024
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1025
 * Retrieves the edit link for a tag.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1026
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1027
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1028
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1029
 * @param int|WP_Term|object $tag      The ID or term object whose edit link will be retrieved.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1030
 * @param string             $taxonomy Optional. Taxonomy slug. Default 'post_tag'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1031
 * @return string The edit tag link URL for the given tag.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1033
function get_edit_tag_link( $tag, $taxonomy = 'post_tag' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1034
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1035
	 * Filters the edit link for a tag (or term in another taxonomy).
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1036
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1037
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1038
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1039
	 * @param string $link The term edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1040
	 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1041
	return apply_filters( 'get_edit_tag_link', get_edit_term_link( $tag, $taxonomy ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1042
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1043
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1044
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1045
 * Displays or retrieves the edit link for a tag with formatting.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1046
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1047
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1048
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1049
 * @param string  $link   Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1050
 * @param string  $before Optional. Display before edit link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1051
 * @param string  $after  Optional. Display after edit link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1052
 * @param WP_Term $tag    Optional. Term object. If null, the queried object will be inspected.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1053
 *                        Default null.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
function edit_tag_link( $link = '', $before = '', $after = '', $tag = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
	$link = edit_term_link( $link, '', '', $tag, false );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1057
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1058
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1059
	 * Filters the anchor tag for the edit link for a tag (or term in another taxonomy).
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1060
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1061
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1062
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1063
	 * @param string $link The anchor tag for the edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1064
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1065
	echo $before . apply_filters( 'edit_tag_link', $link ) . $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1066
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1067
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1068
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1069
 * Retrieves the URL for editing a given term.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1071
 * @since 3.1.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1072
 * @since 4.5.0 The `$taxonomy` parameter was made optional.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1073
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1074
 * @param int|WP_Term|object $term        The ID or term object whose edit link will be retrieved.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1075
 * @param string             $taxonomy    Optional. Taxonomy. Defaults to the taxonomy of the term identified
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1076
 *                                        by `$term`.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1077
 * @param string             $object_type Optional. The object type. Used to highlight the proper post type
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1078
 *                                        menu on the linked page. Defaults to the first object_type associated
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1079
 *                                        with the taxonomy.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1080
 * @return string|null The edit term link URL for the given term, or null on failure.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1081
 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1082
function get_edit_term_link( $term, $taxonomy = '', $object_type = '' ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1083
	$term = get_term( $term, $taxonomy );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1084
	if ( ! $term || is_wp_error( $term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1085
		return;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1086
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1087
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1088
	$tax     = get_taxonomy( $term->taxonomy );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1089
	$term_id = $term->term_id;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1090
	if ( ! $tax || ! current_user_can( 'edit_term', $term_id ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1091
		return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1092
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
	$args = array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
		'taxonomy' => $taxonomy,
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1096
		'tag_ID'   => $term_id,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1098
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1099
	if ( $object_type ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
		$args['post_type'] = $object_type;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1101
	} elseif ( ! empty( $tax->object_type ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1102
		$args['post_type'] = reset( $tax->object_type );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1103
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1104
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1105
	if ( $tax->show_ui ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1106
		$location = add_query_arg( $args, admin_url( 'term.php' ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1107
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1108
		$location = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1109
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1111
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1112
	 * Filters the edit link for a term.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1113
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1114
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1115
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1116
	 * @param string $location    The edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1117
	 * @param int    $term_id     Term ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1118
	 * @param string $taxonomy    Taxonomy name.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1119
	 * @param string $object_type The object type.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1120
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1121
	return apply_filters( 'get_edit_term_link', $location, $term_id, $taxonomy, $object_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1122
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1123
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1125
 * Displays or retrieves the edit term link with formatting.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1126
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1127
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1128
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1129
 * @param string           $link    Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1130
 * @param string           $before  Optional. Display before edit link. Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1131
 * @param string           $after   Optional. Display after edit link. Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1132
 * @param int|WP_Term|null $term    Optional. Term ID or object. If null, the queried object will be inspected. Default null.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1133
 * @param bool             $display Optional. Whether or not to echo the return. Default true.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1134
 * @return string|void HTML content.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1135
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1136
function edit_term_link( $link = '', $before = '', $after = '', $term = null, $display = true ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1137
	if ( is_null( $term ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1138
		$term = get_queried_object();
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1139
	} else {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1140
		$term = get_term( $term );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1141
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1142
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1143
	if ( ! $term ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1144
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1145
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1146
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1147
	$tax = get_taxonomy( $term->taxonomy );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1148
	if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1149
		return;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1150
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1151
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1152
	if ( empty( $link ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1153
		$link = __( 'Edit This' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1154
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1155
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
	$link = '<a href="' . get_edit_term_link( $term->term_id, $term->taxonomy ) . '">' . $link . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1157
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1158
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1159
	 * Filters the anchor tag for the edit link of a term.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1160
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1161
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1162
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1163
	 * @param string $link    The anchor tag for the edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1164
	 * @param int    $term_id Term ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1165
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1166
	$link = $before . apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1167
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1168
	if ( $display ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1169
		echo $link;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1170
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
		return $link;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1172
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1173
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1175
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1176
 * Retrieves the permalink for a search.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1177
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1178
 * @since 3.0.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1179
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1180
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1181
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1182
 * @param string $query Optional. The query string to use. If empty the current query is used. Default empty.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1183
 * @return string The search permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1184
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1185
function get_search_link( $query = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1186
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1187
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1188
	if ( empty( $query ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1189
		$search = get_search_query( false );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1190
	} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1191
		$search = stripslashes( $query );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1192
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1193
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1194
	$permastruct = $wp_rewrite->get_search_permastruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1195
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1196
	if ( empty( $permastruct ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1197
		$link = home_url( '?s=' . urlencode( $search ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1198
	} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1199
		$search = urlencode( $search );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1200
		$search = str_replace( '%2F', '/', $search ); // %2F(/) is not valid within a URL, send it un-encoded.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1201
		$link   = str_replace( '%search%', $search, $permastruct );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1202
		$link   = home_url( user_trailingslashit( $link, 'search' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1203
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1204
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1205
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1206
	 * Filters the search permalink.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1207
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1208
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1209
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1210
	 * @param string $link   Search permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1211
	 * @param string $search The URL-encoded search term.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1212
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1213
	return apply_filters( 'search_link', $link, $search );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1214
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1215
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1216
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1217
 * Retrieves the permalink for the search results feed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1218
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1219
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1220
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1221
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1222
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1223
 * @param string $search_query Optional. Search query. Default empty.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1224
 * @param string $feed         Optional. Feed type. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1225
 *                             Default is the value of get_default_feed().
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1226
 * @return string The search results feed permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1227
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1228
function get_search_feed_link( $search_query = '', $feed = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1229
	global $wp_rewrite;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1230
	$link = get_search_link( $search_query );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1231
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1232
	if ( empty( $feed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1233
		$feed = get_default_feed();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1234
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1235
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
	$permastruct = $wp_rewrite->get_search_permastruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1238
	if ( empty( $permastruct ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1239
		$link = add_query_arg( 'feed', $feed, $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1240
	} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1241
		$link  = trailingslashit( $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1242
		$link .= "feed/$feed/";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1243
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1244
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1245
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1246
	 * Filters the search feed link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1247
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1248
	 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1249
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1250
	 * @param string $link Search feed link.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1251
	 * @param string $feed Feed type. Possible values include 'rss2', 'atom'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1252
	 * @param string $type The search type. One of 'posts' or 'comments'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1253
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1254
	return apply_filters( 'search_feed_link', $link, $feed, 'posts' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1255
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1256
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1257
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1258
 * Retrieves the permalink for the search results comments feed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1259
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1260
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1262
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1263
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1264
 * @param string $search_query Optional. Search query. Default empty.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1265
 * @param string $feed         Optional. Feed type. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1266
 *                             Default is the value of get_default_feed().
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1267
 * @return string The comments feed search results permalink.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1268
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1269
function get_search_comments_feed_link( $search_query = '', $feed = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1270
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1271
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1272
	if ( empty( $feed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1273
		$feed = get_default_feed();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1274
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1275
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1276
	$link = get_search_feed_link( $search_query, $feed );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1277
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1278
	$permastruct = $wp_rewrite->get_search_permastruct();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1279
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1280
	if ( empty( $permastruct ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1281
		$link = add_query_arg( 'feed', 'comments-' . $feed, $link );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1282
	} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1283
		$link = add_query_arg( 'withcomments', 1, $link );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1284
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1285
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1286
	/** This filter is documented in wp-includes/link-template.php */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1287
	return apply_filters( 'search_feed_link', $link, $feed, 'comments' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1288
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1289
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1290
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1291
 * Retrieves the permalink for a post type archive.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1292
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1293
 * @since 3.1.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1294
 * @since 4.5.0 Support for posts was added.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1295
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1296
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1297
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1298
 * @param string $post_type Post type.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1299
 * @return string|false The post type archive permalink. False if the post type
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1300
 *                      does not exist or does not have an archive.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1301
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1302
function get_post_type_archive_link( $post_type ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1303
	global $wp_rewrite;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1304
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1305
	$post_type_obj = get_post_type_object( $post_type );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1306
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1307
	if ( ! $post_type_obj ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1308
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1309
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1310
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1311
	if ( 'post' === $post_type ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1312
		$show_on_front  = get_option( 'show_on_front' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1313
		$page_for_posts = get_option( 'page_for_posts' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1314
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1315
		if ( 'page' === $show_on_front && $page_for_posts ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1316
			$link = get_permalink( $page_for_posts );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1317
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1318
			$link = get_home_url();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1319
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1320
		/** This filter is documented in wp-includes/link-template.php */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1321
		return apply_filters( 'post_type_archive_link', $link, $post_type );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1322
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1323
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1324
	if ( ! $post_type_obj->has_archive ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1325
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1326
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1327
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1328
	if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
		$struct = ( true === $post_type_obj->has_archive ) ? $post_type_obj->rewrite['slug'] : $post_type_obj->has_archive;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1330
		if ( $post_type_obj->rewrite['with_front'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1331
			$struct = $wp_rewrite->front . $struct;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1332
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1333
			$struct = $wp_rewrite->root . $struct;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1334
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1335
		$link = home_url( user_trailingslashit( $struct, 'post_type_archive' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1336
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1337
		$link = home_url( '?post_type=' . $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1339
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1340
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1341
	 * Filters the post type archive permalink.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1342
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1343
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1344
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1345
	 * @param string $link      The post type archive permalink.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1346
	 * @param string $post_type Post type name.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1347
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1348
	return apply_filters( 'post_type_archive_link', $link, $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1349
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1350
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1351
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1352
 * Retrieves the permalink for a post type archive feed.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1353
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1354
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1355
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1356
 * @param string $post_type Post type.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1357
 * @param string $feed      Optional. Feed type. Possible values include 'rss2', 'atom'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1358
 *                          Default is the value of get_default_feed().
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1359
 * @return string|false The post type feed permalink. False if the post type
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1360
 *                      does not exist or does not have an archive.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1362
function get_post_type_archive_feed_link( $post_type, $feed = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1363
	$default_feed = get_default_feed();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1364
	if ( empty( $feed ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1365
		$feed = $default_feed;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1366
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1367
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1368
	$link = get_post_type_archive_link( $post_type );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1369
	if ( ! $link ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1370
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1371
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1372
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
	$post_type_obj = get_post_type_object( $post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1374
	if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1375
		$link  = trailingslashit( $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1376
		$link .= 'feed/';
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1377
		if ( $feed !== $default_feed ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1378
			$link .= "$feed/";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1379
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1380
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1381
		$link = add_query_arg( 'feed', $feed, $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1382
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1383
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1384
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1385
	 * Filters the post type archive feed link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1386
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1387
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1388
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1389
	 * @param string $link The post type archive feed link.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1390
	 * @param string $feed Feed type. Possible values include 'rss2', 'atom'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1391
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1392
	return apply_filters( 'post_type_archive_feed_link', $link, $feed );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1393
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1394
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1395
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1396
 * Retrieves the URL used for the post preview.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1397
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1398
 * Allows additional query args to be appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1399
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1400
 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1401
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1402
 * @param int|WP_Post $post         Optional. Post ID or `WP_Post` object. Defaults to global `$post`.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1403
 * @param array       $query_args   Optional. Array of additional query args to be appended to the link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1404
 *                                  Default empty array.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1405
 * @param string      $preview_link Optional. Base preview link to be used if it should differ from the
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1406
 *                                  post permalink. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1407
 * @return string|null URL used for the post preview, or null if the post does not exist.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1408
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1409
function get_preview_post_link( $post = null, $query_args = array(), $preview_link = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1410
	$post = get_post( $post );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1411
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1412
	if ( ! $post ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1413
		return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1414
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1415
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1416
	$post_type_object = get_post_type_object( $post->post_type );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1417
	if ( is_post_type_viewable( $post_type_object ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1418
		if ( ! $preview_link ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1419
			$preview_link = set_url_scheme( get_permalink( $post ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1420
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1421
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1422
		$query_args['preview'] = 'true';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1423
		$preview_link          = add_query_arg( $query_args, $preview_link );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1424
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1425
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1426
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1427
	 * Filters the URL used for a post preview.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1428
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1429
	 * @since 2.0.5
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1430
	 * @since 4.0.0 Added the `$post` parameter.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1431
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1432
	 * @param string  $preview_link URL used for the post preview.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1433
	 * @param WP_Post $post         Post object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1434
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1435
	return apply_filters( 'preview_post_link', $preview_link, $post );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1436
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1437
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1438
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1439
 * Retrieves the edit post link for post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1440
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1441
 * Can be used within the WordPress loop or outside of it. Can be used with
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1442
 * pages, posts, attachments, revisions, global styles, templates, and template parts.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1443
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1444
 * @since 2.3.0
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1445
 * @since 6.3.0 Adds custom link for wp_navigation post types.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1446
 *              Adds custom links for wp_template_part and wp_template post types.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1447
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1448
 * @param int|WP_Post $post    Optional. Post ID or post object. Default is the global `$post`.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1449
 * @param string      $context Optional. How to output the '&' character. Default '&amp;'.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1450
 * @return string|null The edit post link for the given post. Null if the post type does not exist
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1451
 *                     or does not allow an editing UI.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1453
function get_edit_post_link( $post = 0, $context = 'display' ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1454
	$post = get_post( $post );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1455
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1456
	if ( ! $post ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1458
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1459
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1460
	if ( 'revision' === $post->post_type ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
		$action = '';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1462
	} elseif ( 'display' === $context ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
		$action = '&amp;action=edit';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1464
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1465
		$action = '&action=edit';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1466
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1468
	$post_type_object = get_post_type_object( $post->post_type );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1469
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1470
	if ( ! $post_type_object ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1471
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1472
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1473
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1474
	if ( ! current_user_can( 'edit_post', $post->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1475
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1476
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1478
	$link = '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1479
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1480
	if ( 'wp_template' === $post->post_type || 'wp_template_part' === $post->post_type ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1481
		$slug = urlencode( get_stylesheet() . '//' . $post->post_name );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1482
		$link = admin_url( sprintf( $post_type_object->_edit_link, $post->post_type, $slug ) );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1483
	} elseif ( 'wp_navigation' === $post->post_type ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1484
		$link = admin_url( sprintf( $post_type_object->_edit_link, (string) $post->ID ) );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1485
	} elseif ( $post_type_object->_edit_link ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1486
		$link = admin_url( sprintf( $post_type_object->_edit_link . $action, $post->ID ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1487
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1488
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1489
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1490
	 * Filters the post edit link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1491
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1492
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1493
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1494
	 * @param string $link    The edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1495
	 * @param int    $post_id Post ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1496
	 * @param string $context The link context. If set to 'display' then ampersands
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1497
	 *                        are encoded.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1498
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1499
	return apply_filters( 'get_edit_post_link', $link, $post->ID, $context );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1500
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1501
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1502
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1503
 * Displays the edit post link for post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1504
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1505
 * @since 1.0.0
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1506
 * @since 4.4.0 The `$css_class` argument was added.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1507
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1508
 * @param string      $text      Optional. Anchor text. If null, default is 'Edit This'. Default null.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1509
 * @param string      $before    Optional. Display before edit link. Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1510
 * @param string      $after     Optional. Display after edit link. Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1511
 * @param int|WP_Post $post      Optional. Post ID or post object. Default is the global `$post`.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1512
 * @param string      $css_class Optional. Add custom class to link. Default 'post-edit-link'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1513
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1514
function edit_post_link( $text = null, $before = '', $after = '', $post = 0, $css_class = 'post-edit-link' ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1515
	$post = get_post( $post );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1516
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1517
	if ( ! $post ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1518
		return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1519
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1520
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1521
	$url = get_edit_post_link( $post->ID );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1522
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1523
	if ( ! $url ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1524
		return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1525
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1526
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1527
	if ( null === $text ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1528
		$text = __( 'Edit This' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1529
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1530
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1531
	$link = '<a class="' . esc_attr( $css_class ) . '" href="' . esc_url( $url ) . '">' . $text . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1532
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1533
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1534
	 * Filters the post edit link anchor tag.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1535
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1536
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1537
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1538
	 * @param string $link    Anchor tag for the edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1539
	 * @param int    $post_id Post ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1540
	 * @param string $text    Anchor text.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1541
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1542
	echo $before . apply_filters( 'edit_post_link', $link, $post->ID, $text ) . $after;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1543
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1544
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1545
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1546
 * Retrieves the delete posts link for post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1547
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1548
 * Can be used within the WordPress loop or outside of it, with any post type.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1549
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1550
 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1551
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1552
 * @param int|WP_Post $post         Optional. Post ID or post object. Default is the global `$post`.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1553
 * @param string      $deprecated   Not used.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1554
 * @param bool        $force_delete Optional. Whether to bypass Trash and force deletion. Default false.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1555
 * @return string|void The delete post link URL for the given post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1556
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1557
function get_delete_post_link( $post = 0, $deprecated = '', $force_delete = false ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1558
	if ( ! empty( $deprecated ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1559
		_deprecated_argument( __FUNCTION__, '3.0.0' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1560
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1561
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1562
	$post = get_post( $post );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1563
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1564
	if ( ! $post ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1565
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1566
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1567
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1568
	$post_type_object = get_post_type_object( $post->post_type );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1569
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1570
	if ( ! $post_type_object ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1572
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1573
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1574
	if ( ! current_user_can( 'delete_post', $post->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1575
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1576
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1577
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1578
	$action = ( $force_delete || ! EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1579
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1580
	$delete_link = add_query_arg( 'action', $action, admin_url( sprintf( $post_type_object->_edit_link, $post->ID ) ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1581
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1582
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1583
	 * Filters the post delete link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1584
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1585
	 * @since 2.9.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1586
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1587
	 * @param string $link         The delete link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1588
	 * @param int    $post_id      Post ID.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1589
	 * @param bool   $force_delete Whether to bypass the Trash and force deletion. Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1590
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1591
	return apply_filters( 'get_delete_post_link', wp_nonce_url( $delete_link, "$action-post_{$post->ID}" ), $post->ID, $force_delete );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1592
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1593
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1594
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1595
 * Retrieves the edit comment link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1596
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1597
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1598
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1599
 * @param int|WP_Comment $comment_id Optional. Comment ID or WP_Comment object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1600
 * @return string|void The edit comment link URL for the given comment.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1601
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1602
function get_edit_comment_link( $comment_id = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1603
	$comment = get_comment( $comment_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1604
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1605
	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1606
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1607
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1608
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1609
	$location = admin_url( 'comment.php?action=editcomment&amp;c=' ) . $comment->comment_ID;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1610
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1611
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1612
	 * Filters the comment edit link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1613
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1614
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1615
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1616
	 * @param string $location The edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1617
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1618
	return apply_filters( 'get_edit_comment_link', $location );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1619
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1620
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1621
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1622
 * Displays the edit comment link with formatting.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1623
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1624
 * @since 1.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1625
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1626
 * @param string $text   Optional. Anchor text. If null, default is 'Edit This'. Default null.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1627
 * @param string $before Optional. Display before edit link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1628
 * @param string $after  Optional. Display after edit link. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1629
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1630
function edit_comment_link( $text = null, $before = '', $after = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1631
	$comment = get_comment();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1632
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1633
	if ( ! current_user_can( 'edit_comment', $comment->comment_ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1634
		return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1635
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1636
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1637
	if ( null === $text ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1638
		$text = __( 'Edit This' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1639
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1640
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1641
	$link = '<a class="comment-edit-link" href="' . esc_url( get_edit_comment_link( $comment ) ) . '">' . $text . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1642
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1643
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1644
	 * Filters the comment edit link anchor tag.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1645
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1646
	 * @since 2.3.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1647
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1648
	 * @param string $link       Anchor tag for the edit link.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1649
	 * @param string $comment_id Comment ID as a numeric string.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1650
	 * @param string $text       Anchor text.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1651
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1652
	echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID, $text ) . $after;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1653
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1654
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1655
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1656
 * Displays the edit bookmark link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1657
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1658
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1659
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1660
 * @param int|stdClass $link Optional. Bookmark ID. Default is the ID of the current bookmark.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1661
 * @return string|void The edit bookmark link URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1662
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
function get_edit_bookmark_link( $link = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1664
	$link = get_bookmark( $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1665
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1666
	if ( ! current_user_can( 'manage_links' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1667
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1668
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1669
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1670
	$location = admin_url( 'link.php?action=edit&amp;link_id=' ) . $link->link_id;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1671
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1672
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1673
	 * Filters the bookmark edit link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1674
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1675
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1676
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1677
	 * @param string $location The edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1678
	 * @param int    $link_id  Bookmark ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1679
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1680
	return apply_filters( 'get_edit_bookmark_link', $location, $link->link_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1681
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1682
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1683
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1684
 * Displays the edit bookmark link anchor content.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1685
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1686
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1687
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1688
 * @param string $link     Optional. Anchor text. If empty, default is 'Edit This'. Default empty.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1689
 * @param string $before   Optional. Display before edit link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1690
 * @param string $after    Optional. Display after edit link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1691
 * @param int    $bookmark Optional. Bookmark ID. Default is the current bookmark.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1692
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1693
function edit_bookmark_link( $link = '', $before = '', $after = '', $bookmark = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1694
	$bookmark = get_bookmark( $bookmark );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1695
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1696
	if ( ! current_user_can( 'manage_links' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1697
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1698
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1699
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1700
	if ( empty( $link ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1701
		$link = __( 'Edit This' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1702
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1703
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1704
	$link = '<a href="' . esc_url( get_edit_bookmark_link( $bookmark ) ) . '">' . $link . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1705
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1706
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1707
	 * Filters the bookmark edit link anchor tag.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1708
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1709
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1710
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1711
	 * @param string $link    Anchor tag for the edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1712
	 * @param int    $link_id Bookmark ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1713
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1714
	echo $before . apply_filters( 'edit_bookmark_link', $link, $bookmark->link_id ) . $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1716
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1717
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1718
 * Retrieves the edit user link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1719
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1720
 * @since 3.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1722
 * @param int $user_id Optional. User ID. Defaults to the current user.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1723
 * @return string URL to edit user page or empty string.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1724
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
function get_edit_user_link( $user_id = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1726
	if ( ! $user_id ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1727
		$user_id = get_current_user_id();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1728
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1729
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1730
	if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1731
		return '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1732
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1733
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1734
	$user = get_userdata( $user_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1735
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1736
	if ( ! $user ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1737
		return '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1738
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1739
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1740
	if ( get_current_user_id() === $user->ID ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1741
		$link = get_edit_profile_url( $user->ID );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1742
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1743
		$link = add_query_arg( 'user_id', $user->ID, self_admin_url( 'user-edit.php' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1744
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1745
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1746
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1747
	 * Filters the user edit link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1748
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1749
	 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1750
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1751
	 * @param string $link    The edit link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1752
	 * @param int    $user_id User ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1753
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1754
	return apply_filters( 'get_edit_user_link', $link, $user->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1755
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1756
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1757
//
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1758
// Navigation links.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1759
//
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1760
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1761
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1762
 * Retrieves the previous post that is adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1763
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1764
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1765
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1766
 * @param bool         $in_same_term   Optional. Whether post should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1767
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1768
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1769
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1770
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1771
 * @return WP_Post|null|string Post object if successful. Null if global `$post` is not set.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1772
 *                             Empty string if no corresponding post exists.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1773
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1774
function get_previous_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1775
	return get_adjacent_post( $in_same_term, $excluded_terms, true, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1776
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1777
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1778
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1779
 * Retrieves the next post that is adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1780
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1781
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1782
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1783
 * @param bool         $in_same_term   Optional. Whether post should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1784
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1785
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1786
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1787
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1788
 * @return WP_Post|null|string Post object if successful. Null if global `$post` is not set.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1789
 *                             Empty string if no corresponding post exists.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1790
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1791
function get_next_post( $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1792
	return get_adjacent_post( $in_same_term, $excluded_terms, false, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1793
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1794
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1795
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1796
 * Retrieves the adjacent post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1797
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1798
 * Can either be next or previous post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1799
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1800
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1801
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1802
 * @global wpdb $wpdb WordPress database abstraction object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1803
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1804
 * @param bool         $in_same_term   Optional. Whether post should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1805
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1806
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1807
 *                                     Default empty string.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1808
 * @param bool         $previous       Optional. Whether to retrieve previous post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1809
 *                                     Default true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1810
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1811
 * @return WP_Post|null|string Post object if successful. Null if global `$post` is not set.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1812
 *                             Empty string if no corresponding post exists.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1813
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1814
function get_adjacent_post( $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1815
	global $wpdb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1816
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1817
	$post = get_post();
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1818
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1819
	if ( ! $post || ! taxonomy_exists( $taxonomy ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1820
		return null;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1821
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1822
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1823
	$current_post_date = $post->post_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1824
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1825
	$join     = '';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1826
	$where    = '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1827
	$adjacent = $previous ? 'previous' : 'next';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1828
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1829
	if ( ! empty( $excluded_terms ) && ! is_array( $excluded_terms ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1830
		// Back-compat, $excluded_terms used to be $excluded_categories with IDs separated by " and ".
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1831
		if ( str_contains( $excluded_terms, ' and ' ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1832
			_deprecated_argument(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1833
				__FUNCTION__,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1834
				'3.3.0',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1835
				sprintf(
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1836
					/* translators: %s: The word 'and'. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1837
					__( 'Use commas instead of %s to separate excluded terms.' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1838
					"'and'"
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1839
				)
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1840
			);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1841
			$excluded_terms = explode( ' and ', $excluded_terms );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1842
		} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1843
			$excluded_terms = explode( ',', $excluded_terms );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1844
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1845
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1846
		$excluded_terms = array_map( 'intval', $excluded_terms );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1847
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1848
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1849
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1850
	 * Filters the IDs of terms excluded from adjacent post queries.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1851
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1852
	 * The dynamic portion of the hook name, `$adjacent`, refers to the type
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1853
	 * of adjacency, 'next' or 'previous'.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1854
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1855
	 * Possible hook names include:
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1856
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1857
	 *  - `get_next_post_excluded_terms`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1858
	 *  - `get_previous_post_excluded_terms`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1859
	 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1860
	 * @since 4.4.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1861
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1862
	 * @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1863
	 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1864
	$excluded_terms = apply_filters( "get_{$adjacent}_post_excluded_terms", $excluded_terms );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1865
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1866
	if ( $in_same_term || ! empty( $excluded_terms ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1867
		if ( $in_same_term ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1868
			$join  .= " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1869
			$where .= $wpdb->prepare( 'AND tt.taxonomy = %s', $taxonomy );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1870
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1871
			if ( ! is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1872
				return '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1873
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1874
			$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1875
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1876
			// Remove any exclusions from the term array to include.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1877
			$term_array = array_diff( $term_array, (array) $excluded_terms );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1878
			$term_array = array_map( 'intval', $term_array );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1879
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1880
			if ( ! $term_array || is_wp_error( $term_array ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1881
				return '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1882
			}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1883
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1884
			$where .= ' AND tt.term_id IN (' . implode( ',', $term_array ) . ')';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1885
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1886
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1887
		if ( ! empty( $excluded_terms ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1888
			$where .= " AND p.ID NOT IN ( SELECT tr.object_id FROM $wpdb->term_relationships tr LEFT JOIN $wpdb->term_taxonomy tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id) WHERE tt.term_id IN (" . implode( ',', array_map( 'intval', $excluded_terms ) ) . ') )';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1889
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1890
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1891
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1892
	// 'post_status' clause depends on the current user.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1893
	if ( is_user_logged_in() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1894
		$user_id = get_current_user_id();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1895
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1896
		$post_type_object = get_post_type_object( $post->post_type );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1897
		if ( empty( $post_type_object ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1898
			$post_type_cap    = $post->post_type;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1899
			$read_private_cap = 'read_private_' . $post_type_cap . 's';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1900
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1901
			$read_private_cap = $post_type_object->cap->read_private_posts;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1902
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1903
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1904
		/*
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1905
		 * Results should include private posts belonging to the current user, or private posts where the
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1906
		 * current user has the 'read_private_posts' cap.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1907
		 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1908
		$private_states = get_post_stati( array( 'private' => true ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1909
		$where         .= " AND ( p.post_status = 'publish'";
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1910
		foreach ( $private_states as $state ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1911
			if ( current_user_can( $read_private_cap ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1912
				$where .= $wpdb->prepare( ' OR p.post_status = %s', $state );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1913
			} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1914
				$where .= $wpdb->prepare( ' OR (p.post_author = %d AND p.post_status = %s)', $user_id, $state );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1915
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1916
		}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1917
		$where .= ' )';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1918
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1919
		$where .= " AND p.post_status = 'publish'";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1920
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1921
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1922
	$op    = $previous ? '<' : '>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1923
	$order = $previous ? 'DESC' : 'ASC';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1924
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1925
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1926
	 * Filters the JOIN clause in the SQL for an adjacent post query.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1927
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1928
	 * The dynamic portion of the hook name, `$adjacent`, refers to the type
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1929
	 * of adjacency, 'next' or 'previous'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1930
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1931
	 * Possible hook names include:
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1932
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1933
	 *  - `get_next_post_join`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1934
	 *  - `get_previous_post_join`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1935
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1936
	 * @since 2.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1937
	 * @since 4.4.0 Added the `$taxonomy` and `$post` parameters.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1938
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1939
	 * @param string       $join           The JOIN clause in the SQL.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1940
	 * @param bool         $in_same_term   Whether post should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1941
	 * @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1942
	 * @param string       $taxonomy       Taxonomy. Used to identify the term used when `$in_same_term` is true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1943
	 * @param WP_Post      $post           WP_Post object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1944
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1945
	$join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_term, $excluded_terms, $taxonomy, $post );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1946
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1947
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1948
	 * Filters the WHERE clause in the SQL for an adjacent post query.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1949
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1950
	 * The dynamic portion of the hook name, `$adjacent`, refers to the type
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1951
	 * of adjacency, 'next' or 'previous'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1952
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1953
	 * Possible hook names include:
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1954
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1955
	 *  - `get_next_post_where`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1956
	 *  - `get_previous_post_where`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1957
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1958
	 * @since 2.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1959
	 * @since 4.4.0 Added the `$taxonomy` and `$post` parameters.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1960
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1961
	 * @param string       $where          The `WHERE` clause in the SQL.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1962
	 * @param bool         $in_same_term   Whether post should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1963
	 * @param int[]|string $excluded_terms Array of excluded term IDs. Empty string if none were provided.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1964
	 * @param string       $taxonomy       Taxonomy. Used to identify the term used when `$in_same_term` is true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1965
	 * @param WP_Post      $post           WP_Post object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1966
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1967
	$where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare( "WHERE p.post_date $op %s AND p.post_type = %s $where", $current_post_date, $post->post_type ), $in_same_term, $excluded_terms, $taxonomy, $post );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1968
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1969
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1970
	 * Filters the ORDER BY clause in the SQL for an adjacent post query.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1971
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1972
	 * The dynamic portion of the hook name, `$adjacent`, refers to the type
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1973
	 * of adjacency, 'next' or 'previous'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1974
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1975
	 * Possible hook names include:
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1976
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1977
	 *  - `get_next_post_sort`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1978
	 *  - `get_previous_post_sort`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1979
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1980
	 * @since 2.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1981
	 * @since 4.4.0 Added the `$post` parameter.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1982
	 * @since 4.9.0 Added the `$order` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1983
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1984
	 * @param string $order_by The `ORDER BY` clause in the SQL.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1985
	 * @param WP_Post $post    WP_Post object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1986
	 * @param string  $order   Sort order. 'DESC' for previous post, 'ASC' for next.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1987
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1988
	$sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1", $post, $order );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1989
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1990
	$query        = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort";
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1991
	$key          = md5( $query );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1992
	$last_changed = wp_cache_get_last_changed( 'posts' );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1993
	if ( $in_same_term || ! empty( $excluded_terms ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1994
		$last_changed .= wp_cache_get_last_changed( 'terms' );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1995
	}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1996
	$cache_key = "adjacent_post:$key:$last_changed";
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1997
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1998
	$result = wp_cache_get( $cache_key, 'post-queries' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1999
	if ( false !== $result ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2000
		if ( $result ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2001
			$result = get_post( $result );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2002
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2003
		return $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2004
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2005
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2006
	$result = $wpdb->get_var( $query );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2007
	if ( null === $result ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2008
		$result = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2009
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2010
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2011
	wp_cache_set( $cache_key, $result, 'post-queries' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2012
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2013
	if ( $result ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2014
		$result = get_post( $result );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2015
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2016
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2017
	return $result;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2018
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2019
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2020
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2021
 * Retrieves the adjacent post relational link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2022
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2023
 * Can either be next or previous post relational link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2024
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2025
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2026
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2027
 * @param string       $title          Optional. Link title format. Default '%title'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2028
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2029
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2030
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2031
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2032
 * @param bool         $previous       Optional. Whether to display link to previous or next post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2033
 *                                     Default true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2034
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2035
 * @return string|void The adjacent post relational link URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2036
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2037
function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2038
	$post = get_post();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2039
	if ( $previous && is_attachment() && $post ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2040
		$post = get_post( $post->post_parent );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2041
	} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2042
		$post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2043
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2044
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2045
	if ( empty( $post ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2046
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2047
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2048
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2049
	$post_title = the_title_attribute(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2050
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2051
			'echo' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2052
			'post' => $post,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2053
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2054
	);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2055
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2056
	if ( empty( $post_title ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2057
		$post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2058
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2059
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2060
	$date = mysql2date( get_option( 'date_format' ), $post->post_date );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2061
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2062
	$title = str_replace( '%title', $post_title, $title );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2063
	$title = str_replace( '%date', $date, $title );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2064
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2065
	$link  = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2066
	$link .= esc_attr( $title );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2067
	$link .= "' href='" . get_permalink( $post ) . "' />\n";
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2068
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2069
	$adjacent = $previous ? 'previous' : 'next';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2070
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2071
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2072
	 * Filters the adjacent post relational link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2073
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2074
	 * The dynamic portion of the hook name, `$adjacent`, refers to the type
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2075
	 * of adjacency, 'next' or 'previous'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2076
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2077
	 * Possible hook names include:
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2078
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2079
	 *  - `next_post_rel_link`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2080
	 *  - `previous_post_rel_link`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2081
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2082
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2083
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2084
	 * @param string $link The relational link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2085
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2086
	return apply_filters( "{$adjacent}_post_rel_link", $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2087
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2088
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2089
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2090
 * Displays the relational links for the posts adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2091
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2092
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2093
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2094
 * @param string       $title          Optional. Link title format. Default '%title'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2095
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2096
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2097
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2098
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2099
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2100
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2101
function adjacent_posts_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2102
	echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2103
	echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2104
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2106
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2107
 * Displays relational links for the posts adjacent to the current post for single post pages.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2108
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2109
 * This is meant to be attached to actions like 'wp_head'. Do not call this directly in plugins
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2110
 * or theme templates.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2111
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2112
 * @since 3.0.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2113
 * @since 5.6.0 No longer used in core.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2114
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2115
 * @see adjacent_posts_rel_link()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2116
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2117
function adjacent_posts_rel_link_wp_head() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2118
	if ( ! is_single() || is_attachment() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2119
		return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2120
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2121
	adjacent_posts_rel_link();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2122
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2123
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2124
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2125
 * Displays the relational link for the next post adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2126
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2127
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2128
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2129
 * @see get_adjacent_post_rel_link()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2130
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2131
 * @param string       $title          Optional. Link title format. Default '%title'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2132
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2133
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2134
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2135
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2136
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2137
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2138
function next_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2139
	echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, false, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2140
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2141
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2142
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2143
 * Displays the relational link for the previous post adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2144
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2145
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2146
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2147
 * @see get_adjacent_post_rel_link()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2148
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2149
 * @param string       $title          Optional. Link title format. Default '%title'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2150
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2151
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2152
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2153
 *                                     Default true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2154
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2155
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2156
function prev_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2157
	echo get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, true, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2158
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2159
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2160
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2161
 * Retrieves the boundary post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2162
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2163
 * Boundary being either the first or last post by publish date within the constraints specified
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2164
 * by `$in_same_term` or `$excluded_terms`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2165
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2166
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2167
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2168
 * @param bool         $in_same_term   Optional. Whether returned post should be in the same taxonomy term.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2169
 *                                     Default false.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2170
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2171
 *                                     Default empty.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2172
 * @param bool         $start          Optional. Whether to retrieve first or last post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2173
 *                                     Default true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2174
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2175
 * @return array|null Array containing the boundary post object if successful, null otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2176
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2177
function get_boundary_post( $in_same_term = false, $excluded_terms = '', $start = true, $taxonomy = 'category' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2178
	$post = get_post();
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2179
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2180
	if ( ! $post || ! is_single() || is_attachment() || ! taxonomy_exists( $taxonomy ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2181
		return null;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2182
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2183
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2184
	$query_args = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2185
		'posts_per_page'         => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2186
		'order'                  => $start ? 'ASC' : 'DESC',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2187
		'update_post_term_cache' => false,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2188
		'update_post_meta_cache' => false,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2189
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2190
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2191
	$term_array = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2192
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2193
	if ( ! is_array( $excluded_terms ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2194
		if ( ! empty( $excluded_terms ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2195
			$excluded_terms = explode( ',', $excluded_terms );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2196
		} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2197
			$excluded_terms = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2198
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2199
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2200
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2201
	if ( $in_same_term || ! empty( $excluded_terms ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2202
		if ( $in_same_term ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2203
			$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2204
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2205
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2206
		if ( ! empty( $excluded_terms ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2207
			$excluded_terms = array_map( 'intval', $excluded_terms );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2208
			$excluded_terms = array_diff( $excluded_terms, $term_array );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2209
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2210
			$inverse_terms = array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2211
			foreach ( $excluded_terms as $excluded_term ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2212
				$inverse_terms[] = $excluded_term * -1;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2213
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2214
			$excluded_terms = $inverse_terms;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2215
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2216
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2217
		$query_args['tax_query'] = array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2218
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2219
				'taxonomy' => $taxonomy,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2220
				'terms'    => array_merge( $term_array, $excluded_terms ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2221
			),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2222
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2223
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2224
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2225
	return get_posts( $query_args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2226
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2227
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2228
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2229
 * Retrieves the previous post link that is adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2230
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2231
 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2232
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2233
 * @param string       $format         Optional. Link anchor format. Default '&laquo; %link'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2234
 * @param string       $link           Optional. Link permalink format. Default '%title'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2235
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2236
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2237
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2238
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2239
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2240
 * @return string The link URL of the previous post in relation to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2241
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2242
function get_previous_post_link( $format = '&laquo; %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2243
	return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, true, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2244
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2245
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2246
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2247
 * Displays the previous post link that is adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2248
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2249
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2250
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2251
 * @see get_previous_post_link()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2252
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2253
 * @param string       $format         Optional. Link anchor format. Default '&laquo; %link'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2254
 * @param string       $link           Optional. Link permalink format. Default '%title'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2255
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2256
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2257
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2258
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2259
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2260
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2261
function previous_post_link( $format = '&laquo; %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2262
	echo get_previous_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2263
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2264
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2265
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2266
 * Retrieves the next post link that is adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2267
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2268
 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2269
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2270
 * @param string       $format         Optional. Link anchor format. Default '&laquo; %link'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2271
 * @param string       $link           Optional. Link permalink format. Default '%title'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2272
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2273
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2274
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2275
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2276
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2277
 * @return string The link URL of the next post in relation to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2278
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2279
function get_next_post_link( $format = '%link &raquo;', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2280
	return get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, false, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2281
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2282
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2283
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2284
 * Displays the next post link that is adjacent to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2285
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2286
 * @since 1.5.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2287
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2288
 * @see get_next_post_link()
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2289
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2290
 * @param string       $format         Optional. Link anchor format. Default '&laquo; %link'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2291
 * @param string       $link           Optional. Link permalink format. Default '%title'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2292
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2293
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2294
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2295
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2296
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2297
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2298
function next_post_link( $format = '%link &raquo;', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2299
	echo get_next_post_link( $format, $link, $in_same_term, $excluded_terms, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2300
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2301
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2302
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2303
 * Retrieves the adjacent post link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2304
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2305
 * Can be either next post link or previous.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2306
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2307
 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2308
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2309
 * @param string       $format         Link anchor format.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2310
 * @param string       $link           Link permalink format.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2311
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2312
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2313
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded terms IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2314
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2315
 * @param bool         $previous       Optional. Whether to display link to previous or next post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2316
 *                                     Default true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2317
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2318
 * @return string The link URL of the previous or next post in relation to the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2319
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2320
function get_adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2321
	if ( $previous && is_attachment() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2322
		$post = get_post( get_post()->post_parent );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2323
	} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2324
		$post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2325
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2326
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2327
	if ( ! $post ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2328
		$output = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2329
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2330
		$title = $post->post_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2331
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2332
		if ( empty( $post->post_title ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2333
			$title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2334
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2335
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2336
		/** This filter is documented in wp-includes/post-template.php */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2337
		$title = apply_filters( 'the_title', $title, $post->ID );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2338
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2339
		$date = mysql2date( get_option( 'date_format' ), $post->post_date );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2340
		$rel  = $previous ? 'prev' : 'next';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2341
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2342
		$string = '<a href="' . get_permalink( $post ) . '" rel="' . $rel . '">';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2343
		$inlink = str_replace( '%title', $title, $link );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2344
		$inlink = str_replace( '%date', $date, $inlink );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2345
		$inlink = $string . $inlink . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2346
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2347
		$output = str_replace( '%link', $inlink, $format );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2348
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2349
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2350
	$adjacent = $previous ? 'previous' : 'next';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2351
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2352
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2353
	 * Filters the adjacent post link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2354
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2355
	 * The dynamic portion of the hook name, `$adjacent`, refers to the type
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2356
	 * of adjacency, 'next' or 'previous'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2357
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2358
	 * Possible hook names include:
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2359
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2360
	 *  - `next_post_link`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2361
	 *  - `previous_post_link`
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2362
	 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2363
	 * @since 2.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2364
	 * @since 4.2.0 Added the `$adjacent` parameter.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2365
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2366
	 * @param string         $output   The adjacent post link.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2367
	 * @param string         $format   Link anchor format.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2368
	 * @param string         $link     Link permalink format.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2369
	 * @param WP_Post|string $post     The adjacent post. Empty string if no corresponding post exists.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2370
	 * @param string         $adjacent Whether the post is previous or next.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2371
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2372
	return apply_filters( "{$adjacent}_post_link", $output, $format, $link, $post, $adjacent );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2373
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2374
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2375
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2376
 * Displays the adjacent post link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2377
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2378
 * Can be either next post link or previous.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2379
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2380
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2381
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2382
 * @param string       $format         Link anchor format.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2383
 * @param string       $link           Link permalink format.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2384
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2385
 *                                     Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2386
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded category IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2387
 *                                     Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2388
 * @param bool         $previous       Optional. Whether to display link to previous or next post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2389
 *                                     Default true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2390
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2391
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2392
function adjacent_post_link( $format, $link, $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2393
	echo get_adjacent_post_link( $format, $link, $in_same_term, $excluded_terms, $previous, $taxonomy );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2394
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2395
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2396
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2397
 * Retrieves the link for a page number.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2398
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2399
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2400
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2401
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2402
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2403
 * @param int  $pagenum Optional. Page number. Default 1.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2404
 * @param bool $escape  Optional. Whether to escape the URL for display, with esc_url().
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2405
 *                      If set to false, prepares the URL with sanitize_url(). Default true.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2406
 * @return string The link URL for the given page number.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2407
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2408
function get_pagenum_link( $pagenum = 1, $escape = true ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2409
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2410
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2411
	$pagenum = (int) $pagenum;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2412
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2413
	$request = remove_query_arg( 'paged' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2414
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2415
	$home_root = parse_url( home_url() );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2416
	$home_root = ( isset( $home_root['path'] ) ) ? $home_root['path'] : '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2417
	$home_root = preg_quote( $home_root, '|' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2418
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2419
	$request = preg_replace( '|^' . $home_root . '|i', '', $request );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2420
	$request = preg_replace( '|^/+|', '', $request );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2421
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2422
	if ( ! $wp_rewrite->using_permalinks() || is_admin() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2423
		$base = trailingslashit( get_bloginfo( 'url' ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2424
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2425
		if ( $pagenum > 1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2426
			$result = add_query_arg( 'paged', $pagenum, $base . $request );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2427
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2428
			$result = $base . $request;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2429
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2430
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2431
		$qs_regex = '|\?.*?$|';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2432
		preg_match( $qs_regex, $request, $qs_match );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2433
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2434
		$parts   = array();
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2435
		$parts[] = untrailingslashit( get_bloginfo( 'url' ) );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2436
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2437
		if ( ! empty( $qs_match[0] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2438
			$query_string = $qs_match[0];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2439
			$request      = preg_replace( $qs_regex, '', $request );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2440
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2441
			$query_string = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2442
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2443
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2444
		$request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2445
		$request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2446
		$request = ltrim( $request, '/' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2447
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2448
		if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' !== $request ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2449
			$parts[] = $wp_rewrite->index;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2450
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2451
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2452
		$parts[] = untrailingslashit( $request );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2453
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2454
		if ( $pagenum > 1 ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2455
			$parts[] = $wp_rewrite->pagination_base;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2456
			$parts[] = $pagenum;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2457
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2458
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2459
		$result = user_trailingslashit( implode( '/', array_filter( $parts ) ), 'paged' );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2460
		if ( ! empty( $query_string ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2461
			$result .= $query_string;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2462
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2463
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2464
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2465
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2466
	 * Filters the page number link for the current request.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2467
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2468
	 * @since 2.5.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2469
	 * @since 5.2.0 Added the `$pagenum` argument.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2470
	 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2471
	 * @param string $result  The page number link.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2472
	 * @param int    $pagenum The page number.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2473
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2474
	$result = apply_filters( 'get_pagenum_link', $result, $pagenum );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2475
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2476
	if ( $escape ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2477
		return esc_url( $result );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2478
	} else {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2479
		return sanitize_url( $result );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2480
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2481
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2482
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2483
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2484
 * Retrieves the next posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2485
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2486
 * Backported from 2.1.3 to 2.0.10.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2487
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2488
 * @since 2.0.10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2489
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2490
 * @global int $paged
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2491
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2492
 * @param int $max_page Optional. Max pages. Default 0.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2493
 * @return string|void The link URL for next posts page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2494
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2495
function get_next_posts_page_link( $max_page = 0 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2496
	global $paged;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2497
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2498
	if ( ! is_single() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2499
		if ( ! $paged ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2500
			$paged = 1;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2501
		}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2502
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2503
		$next_page = (int) $paged + 1;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2504
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2505
		if ( ! $max_page || $max_page >= $next_page ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2506
			return get_pagenum_link( $next_page );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2507
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2508
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2509
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2510
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2511
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2512
 * Displays or retrieves the next posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2513
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2514
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2515
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2516
 * @param int  $max_page Optional. Max pages. Default 0.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2517
 * @param bool $display  Optional. Whether to echo the link. Default true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2518
 * @return string|void The link URL for next posts page if `$display = false`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2519
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2520
function next_posts( $max_page = 0, $display = true ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2521
	$link   = get_next_posts_page_link( $max_page );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2522
	$output = $link ? esc_url( $link ) : '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2523
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2524
	if ( $display ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2525
		echo $output;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2526
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2527
		return $output;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2528
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2529
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2530
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2531
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2532
 * Retrieves the next posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2533
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2534
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2535
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2536
 * @global int      $paged
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2537
 * @global WP_Query $wp_query WordPress Query object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2538
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2539
 * @param string $label    Content for link text.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2540
 * @param int    $max_page Optional. Max pages. Default 0.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2541
 * @return string|void HTML-formatted next posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2542
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2543
function get_next_posts_link( $label = null, $max_page = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2544
	global $paged, $wp_query;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2545
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2546
	if ( ! $max_page ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2547
		$max_page = $wp_query->max_num_pages;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2548
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2549
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2550
	if ( ! $paged ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2551
		$paged = 1;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2552
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2553
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2554
	$next_page = (int) $paged + 1;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2555
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2556
	if ( null === $label ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2557
		$label = __( 'Next Page &raquo;' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2558
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2559
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2560
	if ( ! is_single() && ( $next_page <= $max_page ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2561
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2562
		 * Filters the anchor tag attributes for the next posts page link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2563
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2564
		 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2565
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2566
		 * @param string $attributes Attributes for the anchor tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2567
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2568
		$attr = apply_filters( 'next_posts_link_attributes', '' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2569
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2570
		return sprintf(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2571
			'<a href="%1$s" %2$s>%3$s</a>',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2572
			next_posts( $max_page, false ),
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2573
			$attr,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2574
			preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label )
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2575
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2576
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2577
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2578
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2579
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2580
 * Displays the next posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2581
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2582
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2583
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2584
 * @param string $label    Content for link text.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2585
 * @param int    $max_page Optional. Max pages. Default 0.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2586
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2587
function next_posts_link( $label = null, $max_page = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2588
	echo get_next_posts_link( $label, $max_page );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2589
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2590
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2591
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2592
 * Retrieves the previous posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2593
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2594
 * Will only return string, if not on a single page or post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2595
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2596
 * Backported to 2.0.10 from 2.1.3.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2597
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2598
 * @since 2.0.10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2599
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2600
 * @global int $paged
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2601
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2602
 * @return string|void The link for the previous posts page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2603
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2604
function get_previous_posts_page_link() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2605
	global $paged;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2606
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2607
	if ( ! is_single() ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2608
		$previous_page = (int) $paged - 1;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2609
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2610
		if ( $previous_page < 1 ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2611
			$previous_page = 1;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2612
		}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2613
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2614
		return get_pagenum_link( $previous_page );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2615
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2616
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2617
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2618
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2619
 * Displays or retrieves the previous posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2620
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2621
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2622
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2623
 * @param bool $display Optional. Whether to echo the link. Default true.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2624
 * @return string|void The previous posts page link if `$display = false`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2625
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2626
function previous_posts( $display = true ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2627
	$output = esc_url( get_previous_posts_page_link() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2628
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2629
	if ( $display ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2630
		echo $output;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2631
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2632
		return $output;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2633
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2634
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2635
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2636
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2637
 * Retrieves the previous posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2638
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2639
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2640
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2641
 * @global int $paged
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2642
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2643
 * @param string $label Optional. Previous page link text.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2644
 * @return string|void HTML-formatted previous page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2645
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2646
function get_previous_posts_link( $label = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2647
	global $paged;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2648
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2649
	if ( null === $label ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2650
		$label = __( '&laquo; Previous Page' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2651
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2652
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2653
	if ( ! is_single() && $paged > 1 ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2654
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2655
		 * Filters the anchor tag attributes for the previous posts page link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2656
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2657
		 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2658
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2659
		 * @param string $attributes Attributes for the anchor tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2660
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2661
		$attr = apply_filters( 'previous_posts_link_attributes', '' );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2662
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2663
		return sprintf(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2664
			'<a href="%1$s" %2$s>%3$s</a>',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2665
			previous_posts( false ),
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2666
			$attr,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2667
			preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label )
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2668
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2669
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2670
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2671
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2672
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2673
 * Displays the previous posts page link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2674
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2675
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2676
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2677
 * @param string $label Optional. Previous page link text.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2678
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2679
function previous_posts_link( $label = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2680
	echo get_previous_posts_link( $label );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2681
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2682
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2683
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2684
 * Retrieves the post pages link navigation for previous and next pages.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2685
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2686
 * @since 2.8.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2687
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2688
 * @global WP_Query $wp_query WordPress Query object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2689
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2690
 * @param string|array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2691
 *     Optional. Arguments to build the post pages link navigation.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2692
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2693
 *     @type string $sep      Separator character. Default '&#8212;'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2694
 *     @type string $prelabel Link text to display for the previous page link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2695
 *                            Default '&laquo; Previous Page'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2696
 *     @type string $nxtlabel Link text to display for the next page link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2697
 *                            Default 'Next Page &raquo;'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2698
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2699
 * @return string The posts link navigation.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2700
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2701
function get_posts_nav_link( $args = array() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2702
	global $wp_query;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2703
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2704
	$return = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2705
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2706
	if ( ! is_singular() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2707
		$defaults = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2708
			'sep'      => ' &#8212; ',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2709
			'prelabel' => __( '&laquo; Previous Page' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2710
			'nxtlabel' => __( 'Next Page &raquo;' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2711
		);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2712
		$args     = wp_parse_args( $args, $defaults );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2713
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2714
		$max_num_pages = $wp_query->max_num_pages;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2715
		$paged         = get_query_var( 'paged' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2716
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2717
		// Only have sep if there's both prev and next results.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2718
		if ( $paged < 2 || $paged >= $max_num_pages ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2719
			$args['sep'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2720
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2721
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2722
		if ( $max_num_pages > 1 ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2723
			$return  = get_previous_posts_link( $args['prelabel'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2724
			$return .= preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $args['sep'] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2725
			$return .= get_next_posts_link( $args['nxtlabel'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2726
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2727
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2728
	return $return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2729
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2730
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2731
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2732
 * Displays the post pages link navigation for previous and next pages.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2733
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2734
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2735
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2736
 * @param string $sep      Optional. Separator for posts navigation links. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2737
 * @param string $prelabel Optional. Label for previous pages. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2738
 * @param string $nxtlabel Optional Label for next pages. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2739
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2740
function posts_nav_link( $sep = '', $prelabel = '', $nxtlabel = '' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2741
	$args = array_filter( compact( 'sep', 'prelabel', 'nxtlabel' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2742
	echo get_posts_nav_link( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2743
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2744
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2745
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2746
 * Retrieves the navigation to next/previous post, when applicable.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2747
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2748
 * @since 4.1.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2749
 * @since 4.4.0 Introduced the `in_same_term`, `excluded_terms`, and `taxonomy` arguments.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2750
 * @since 5.3.0 Added the `aria_label` parameter.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2751
 * @since 5.5.0 Added the `class` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2752
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2753
 * @param array $args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2754
 *     Optional. Default post navigation arguments. Default empty array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2755
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2756
 *     @type string       $prev_text          Anchor text to display in the previous post link.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2757
 *                                            Default '%title'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2758
 *     @type string       $next_text          Anchor text to display in the next post link.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2759
 *                                            Default '%title'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2760
 *     @type bool         $in_same_term       Whether link should be in the same taxonomy term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2761
 *                                            Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2762
 *     @type int[]|string $excluded_terms     Array or comma-separated list of excluded term IDs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2763
 *                                            Default empty.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2764
 *     @type string       $taxonomy           Taxonomy, if `$in_same_term` is true. Default 'category'.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2765
 *     @type string       $screen_reader_text Screen reader text for the nav element.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2766
 *                                            Default 'Post navigation'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2767
 *     @type string       $aria_label         ARIA label text for the nav element. Default 'Posts'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2768
 *     @type string       $class              Custom class for the nav element. Default 'post-navigation'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2769
 * }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2770
 * @return string Markup for post links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2771
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2772
function get_the_post_navigation( $args = array() ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2773
	// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2774
	if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2775
		$args['aria_label'] = $args['screen_reader_text'];
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2776
	}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2777
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2778
	$args = wp_parse_args(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2779
		$args,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2780
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2781
			'prev_text'          => '%title',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2782
			'next_text'          => '%title',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2783
			'in_same_term'       => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2784
			'excluded_terms'     => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2785
			'taxonomy'           => 'category',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2786
			'screen_reader_text' => __( 'Post navigation' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2787
			'aria_label'         => __( 'Posts' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2788
			'class'              => 'post-navigation',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2789
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2790
	);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2791
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2792
	$navigation = '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2793
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2794
	$previous = get_previous_post_link(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2795
		'<div class="nav-previous">%link</div>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2796
		$args['prev_text'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2797
		$args['in_same_term'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2798
		$args['excluded_terms'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2799
		$args['taxonomy']
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2800
	);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2801
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2802
	$next = get_next_post_link(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2803
		'<div class="nav-next">%link</div>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2804
		$args['next_text'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2805
		$args['in_same_term'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2806
		$args['excluded_terms'],
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2807
		$args['taxonomy']
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2808
	);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2809
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2810
	// Only add markup if there's somewhere to navigate to.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2811
	if ( $previous || $next ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2812
		$navigation = _navigation_markup( $previous . $next, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2813
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2814
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2815
	return $navigation;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2816
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2817
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2818
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2819
 * Displays the navigation to next/previous post, when applicable.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2820
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2821
 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2822
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2823
 * @param array $args Optional. See get_the_post_navigation() for available arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2824
 *                    Default empty array.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2825
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2826
function the_post_navigation( $args = array() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2827
	echo get_the_post_navigation( $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2828
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2829
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2830
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2831
 * Returns the navigation to next/previous set of posts, when applicable.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2832
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2833
 * @since 4.1.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2834
 * @since 5.3.0 Added the `aria_label` parameter.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2835
 * @since 5.5.0 Added the `class` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2836
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2837
 * @global WP_Query $wp_query WordPress Query object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2838
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2839
 * @param array $args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2840
 *     Optional. Default posts navigation arguments. Default empty array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2841
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2842
 *     @type string $prev_text          Anchor text to display in the previous posts link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2843
 *                                      Default 'Older posts'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2844
 *     @type string $next_text          Anchor text to display in the next posts link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2845
 *                                      Default 'Newer posts'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2846
 *     @type string $screen_reader_text Screen reader text for the nav element.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2847
 *                                      Default 'Posts navigation'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2848
 *     @type string $aria_label         ARIA label text for the nav element. Default 'Posts'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2849
 *     @type string $class              Custom class for the nav element. Default 'posts-navigation'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2850
 * }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2851
 * @return string Markup for posts links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2852
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2853
function get_the_posts_navigation( $args = array() ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2854
	global $wp_query;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2855
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2856
	$navigation = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2857
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2858
	// Don't print empty markup if there's only one page.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2859
	if ( $wp_query->max_num_pages > 1 ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2860
		// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2861
		if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2862
			$args['aria_label'] = $args['screen_reader_text'];
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2863
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2864
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2865
		$args = wp_parse_args(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2866
			$args,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2867
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2868
				'prev_text'          => __( 'Older posts' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2869
				'next_text'          => __( 'Newer posts' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2870
				'screen_reader_text' => __( 'Posts navigation' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2871
				'aria_label'         => __( 'Posts' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2872
				'class'              => 'posts-navigation',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2873
			)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2874
		);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2875
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2876
		$next_link = get_previous_posts_link( $args['next_text'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2877
		$prev_link = get_next_posts_link( $args['prev_text'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2878
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2879
		if ( $prev_link ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2880
			$navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2881
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2882
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2883
		if ( $next_link ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2884
			$navigation .= '<div class="nav-next">' . $next_link . '</div>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2885
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2886
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2887
		$navigation = _navigation_markup( $navigation, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2888
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2889
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2890
	return $navigation;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2891
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2892
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2893
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2894
 * Displays the navigation to next/previous set of posts, when applicable.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2895
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2896
 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2897
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2898
 * @param array $args Optional. See get_the_posts_navigation() for available arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2899
 *                    Default empty array.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2900
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2901
function the_posts_navigation( $args = array() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2902
	echo get_the_posts_navigation( $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2903
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2904
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2905
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2906
 * Retrieves a paginated navigation to next/previous set of posts, when applicable.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2907
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2908
 * @since 4.1.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2909
 * @since 5.3.0 Added the `aria_label` parameter.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2910
 * @since 5.5.0 Added the `class` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2911
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2912
 * @global WP_Query $wp_query WordPress Query object.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2913
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2914
 * @param array $args {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2915
 *     Optional. Default pagination arguments, see paginate_links().
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2916
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2917
 *     @type string $screen_reader_text Screen reader text for navigation element.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2918
 *                                      Default 'Posts navigation'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2919
 *     @type string $aria_label         ARIA label text for the nav element. Default 'Posts'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2920
 *     @type string $class              Custom class for the nav element. Default 'pagination'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2921
 * }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2922
 * @return string Markup for pagination links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2923
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2924
function get_the_posts_pagination( $args = array() ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2925
	global $wp_query;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2926
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2927
	$navigation = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2928
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2929
	// Don't print empty markup if there's only one page.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2930
	if ( $wp_query->max_num_pages > 1 ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2931
		// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2932
		if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2933
			$args['aria_label'] = $args['screen_reader_text'];
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2934
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2935
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2936
		$args = wp_parse_args(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2937
			$args,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2938
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2939
				'mid_size'           => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2940
				'prev_text'          => _x( 'Previous', 'previous set of posts' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2941
				'next_text'          => _x( 'Next', 'next set of posts' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2942
				'screen_reader_text' => __( 'Posts navigation' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2943
				'aria_label'         => __( 'Posts' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2944
				'class'              => 'pagination',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2945
			)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2946
		);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2947
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2948
		/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2949
		 * Filters the arguments for posts pagination links.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2950
		 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2951
		 * @since 6.1.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2952
		 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2953
		 * @param array $args {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2954
		 *     Optional. Default pagination arguments, see paginate_links().
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2955
		 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2956
		 *     @type string $screen_reader_text Screen reader text for navigation element.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2957
		 *                                      Default 'Posts navigation'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2958
		 *     @type string $aria_label         ARIA label text for the nav element. Default 'Posts'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2959
		 *     @type string $class              Custom class for the nav element. Default 'pagination'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2960
		 * }
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2961
		 */
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2962
		$args = apply_filters( 'the_posts_pagination_args', $args );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2963
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2964
		// Make sure we get a string back. Plain is the next best thing.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2965
		if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2966
			$args['type'] = 'plain';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2967
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2968
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2969
		// Set up paginated links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2970
		$links = paginate_links( $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2971
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2972
		if ( $links ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2973
			$navigation = _navigation_markup( $links, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2974
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2975
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2976
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2977
	return $navigation;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2978
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2979
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2980
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2981
 * Displays a paginated navigation to next/previous set of posts, when applicable.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2982
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2983
 * @since 4.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2984
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2985
 * @param array $args Optional. See get_the_posts_pagination() for available arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2986
 *                    Default empty array.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2987
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2988
function the_posts_pagination( $args = array() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2989
	echo get_the_posts_pagination( $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2990
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2991
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2992
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2993
 * Wraps passed links in navigational markup.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2994
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2995
 * @since 4.1.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2996
 * @since 5.3.0 Added the `aria_label` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2997
 * @access private
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2998
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  2999
 * @param string $links              Navigational links.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3000
 * @param string $css_class          Optional. Custom class for the nav element.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3001
 *                                   Default 'posts-navigation'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3002
 * @param string $screen_reader_text Optional. Screen reader text for the nav element.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3003
 *                                   Default 'Posts navigation'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3004
 * @param string $aria_label         Optional. ARIA label for the nav element.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3005
 *                                   Defaults to the value of `$screen_reader_text`.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3006
 * @return string Navigation template tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3007
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3008
function _navigation_markup( $links, $css_class = 'posts-navigation', $screen_reader_text = '', $aria_label = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3009
	if ( empty( $screen_reader_text ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3010
		$screen_reader_text = /* translators: Hidden accessibility text. */ __( 'Posts navigation' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3011
	}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3012
	if ( empty( $aria_label ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3013
		$aria_label = $screen_reader_text;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3014
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3015
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3016
	$template = '
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  3017
	<nav class="navigation %1$s" aria-label="%4$s">
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3018
		<h2 class="screen-reader-text">%2$s</h2>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3019
		<div class="nav-links">%3$s</div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3020
	</nav>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3021
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3022
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3023
	 * Filters the navigation markup template.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3024
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3025
	 * Note: The filtered template HTML must contain specifiers for the navigation
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3026
	 * class (%1$s), the screen-reader-text value (%2$s), placement of the navigation
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3027
	 * links (%3$s), and ARIA label text if screen-reader-text does not fit that (%4$s):
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3028
	 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  3029
	 *     <nav class="navigation %1$s" aria-label="%4$s">
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3030
	 *         <h2 class="screen-reader-text">%2$s</h2>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3031
	 *         <div class="nav-links">%3$s</div>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3032
	 *     </nav>
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3033
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3034
	 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3035
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3036
	 * @param string $template  The default template.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3037
	 * @param string $css_class The class passed by the calling function.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3038
	 * @return string Navigation template.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3039
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3040
	$template = apply_filters( 'navigation_markup_template', $template, $css_class );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3041
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3042
	return sprintf( $template, sanitize_html_class( $css_class ), esc_html( $screen_reader_text ), $links, esc_attr( $aria_label ) );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3043
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3044
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3045
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3046
 * Retrieves the comments page number link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3047
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3048
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3049
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3050
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3051
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3052
 * @param int $pagenum  Optional. Page number. Default 1.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3053
 * @param int $max_page Optional. The maximum number of comment pages. Default 0.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3054
 * @return string The comments page number link URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3055
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3056
function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3057
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3058
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3059
	$pagenum  = (int) $pagenum;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3060
	$max_page = (int) $max_page;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3061
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3062
	$result = get_permalink();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3063
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3064
	if ( 'newest' === get_option( 'default_comments_page' ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3065
		if ( $pagenum !== $max_page ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3066
			if ( $wp_rewrite->using_permalinks() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3067
				$result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3068
			} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3069
				$result = add_query_arg( 'cpage', $pagenum, $result );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3070
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3071
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3072
	} elseif ( $pagenum > 1 ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3073
		if ( $wp_rewrite->using_permalinks() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3074
			$result = user_trailingslashit( trailingslashit( $result ) . $wp_rewrite->comments_pagination_base . '-' . $pagenum, 'commentpaged' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3075
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3076
			$result = add_query_arg( 'cpage', $pagenum, $result );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3077
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3078
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3079
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3080
	$result .= '#comments';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3081
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3082
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3083
	 * Filters the comments page number link for the current request.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3084
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3085
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3086
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3087
	 * @param string $result The comments page number link.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3088
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3089
	return apply_filters( 'get_comments_pagenum_link', $result );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3090
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3091
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3092
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3093
 * Retrieves the link to the next comments page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3094
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3095
 * @since 2.7.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3096
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3097
 * @global WP_Query $wp_query WordPress Query object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3098
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3099
 * @param string $label    Optional. Label for link text. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3100
 * @param int    $max_page Optional. Max page. Default 0.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3101
 * @return string|void HTML-formatted link for the next page of comments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3102
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3103
function get_next_comments_link( $label = '', $max_page = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3104
	global $wp_query;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3105
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3106
	if ( ! is_singular() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3107
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3108
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3109
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3110
	$page = get_query_var( 'cpage' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3111
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3112
	if ( ! $page ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3113
		$page = 1;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3114
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3115
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3116
	$next_page = (int) $page + 1;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3117
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3118
	if ( empty( $max_page ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3119
		$max_page = $wp_query->max_num_comment_pages;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3120
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3121
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3122
	if ( empty( $max_page ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3123
		$max_page = get_comment_pages_count();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3124
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3125
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3126
	if ( $next_page > $max_page ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3127
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3128
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3129
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3130
	if ( empty( $label ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3131
		$label = __( 'Newer Comments &raquo;' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3132
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3133
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3134
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3135
	 * Filters the anchor tag attributes for the next comments page link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3136
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3137
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3138
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3139
	 * @param string $attributes Attributes for the anchor tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3140
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3141
	$attr = apply_filters( 'next_comments_link_attributes', '' );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3142
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3143
	return sprintf(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3144
		'<a href="%1$s" %2$s>%3$s</a>',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3145
		esc_url( get_comments_pagenum_link( $next_page, $max_page ) ),
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3146
		$attr,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3147
		preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label )
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3148
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3149
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3150
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3151
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3152
 * Displays the link to the next comments page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3153
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3154
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3155
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3156
 * @param string $label    Optional. Label for link text. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3157
 * @param int    $max_page Optional. Max page. Default 0.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3158
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3159
function next_comments_link( $label = '', $max_page = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3160
	echo get_next_comments_link( $label, $max_page );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3161
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3162
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3163
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3164
 * Retrieves the link to the previous comments page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3165
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3166
 * @since 2.7.1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3167
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3168
 * @param string $label Optional. Label for comments link text. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3169
 * @return string|void HTML-formatted link for the previous page of comments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3170
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3171
function get_previous_comments_link( $label = '' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3172
	if ( ! is_singular() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3173
		return;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3174
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3175
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3176
	$page = get_query_var( 'cpage' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3177
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3178
	if ( (int) $page <= 1 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3179
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3180
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3181
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3182
	$previous_page = (int) $page - 1;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3183
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3184
	if ( empty( $label ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3185
		$label = __( '&laquo; Older Comments' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3186
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3187
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3188
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3189
	 * Filters the anchor tag attributes for the previous comments page link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3190
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3191
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3192
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3193
	 * @param string $attributes Attributes for the anchor tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3194
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3195
	$attr = apply_filters( 'previous_comments_link_attributes', '' );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3196
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3197
	return sprintf(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3198
		'<a href="%1$s" %2$s>%3$s</a>',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3199
		esc_url( get_comments_pagenum_link( $previous_page ) ),
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3200
		$attr,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3201
		preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label )
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3202
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3203
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3204
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3205
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3206
 * Displays the link to the previous comments page.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3207
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3208
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3209
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3210
 * @param string $label Optional. Label for comments link text. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3211
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3212
function previous_comments_link( $label = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3213
	echo get_previous_comments_link( $label );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3214
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3215
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3216
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3217
 * Displays or retrieves pagination links for the comments on the current post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3218
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3219
 * @see paginate_links()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3220
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3221
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3222
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3223
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3224
 * @param string|array $args Optional args. See paginate_links(). Default empty array.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3225
 * @return void|string|array Void if 'echo' argument is true and 'type' is not an array,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3226
 *                           or if the query is not for an existing single post of any post type.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3227
 *                           Otherwise, markup for comment page links or array of comment page links,
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3228
 *                           depending on 'type' argument.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3229
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3230
function paginate_comments_links( $args = array() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3231
	global $wp_rewrite;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3232
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3233
	if ( ! is_singular() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3234
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3235
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3236
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3237
	$page = get_query_var( 'cpage' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3238
	if ( ! $page ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3239
		$page = 1;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3240
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3241
	$max_page = get_comment_pages_count();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3242
	$defaults = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3243
		'base'         => add_query_arg( 'cpage', '%#%' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3244
		'format'       => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3245
		'total'        => $max_page,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3246
		'current'      => $page,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3247
		'echo'         => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3248
		'type'         => 'plain',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3249
		'add_fragment' => '#comments',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3250
	);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3251
	if ( $wp_rewrite->using_permalinks() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3252
		$defaults['base'] = user_trailingslashit( trailingslashit( get_permalink() ) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3253
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3254
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3255
	$args       = wp_parse_args( $args, $defaults );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3256
	$page_links = paginate_links( $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3257
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3258
	if ( $args['echo'] && 'array' !== $args['type'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3259
		echo $page_links;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3260
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3261
		return $page_links;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3262
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3263
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3264
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3265
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3266
 * Retrieves navigation to next/previous set of comments, when applicable.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3267
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3268
 * @since 4.4.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3269
 * @since 5.3.0 Added the `aria_label` parameter.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3270
 * @since 5.5.0 Added the `class` parameter.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3271
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3272
 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3273
 *     Optional. Default comments navigation arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3274
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3275
 *     @type string $prev_text          Anchor text to display in the previous comments link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3276
 *                                      Default 'Older comments'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3277
 *     @type string $next_text          Anchor text to display in the next comments link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3278
 *                                      Default 'Newer comments'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3279
 *     @type string $screen_reader_text Screen reader text for the nav element. Default 'Comments navigation'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3280
 *     @type string $aria_label         ARIA label text for the nav element. Default 'Comments'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3281
 *     @type string $class              Custom class for the nav element. Default 'comment-navigation'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3282
 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3283
 * @return string Markup for comments links.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3284
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3285
function get_the_comments_navigation( $args = array() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3286
	$navigation = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3287
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3288
	// Are there comments to navigate through?
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3289
	if ( get_comment_pages_count() > 1 ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3290
		// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3291
		if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3292
			$args['aria_label'] = $args['screen_reader_text'];
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3293
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3294
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3295
		$args = wp_parse_args(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3296
			$args,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3297
			array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3298
				'prev_text'          => __( 'Older comments' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3299
				'next_text'          => __( 'Newer comments' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3300
				'screen_reader_text' => __( 'Comments navigation' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3301
				'aria_label'         => __( 'Comments' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3302
				'class'              => 'comment-navigation',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3303
			)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3304
		);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3305
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3306
		$prev_link = get_previous_comments_link( $args['prev_text'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3307
		$next_link = get_next_comments_link( $args['next_text'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3308
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3309
		if ( $prev_link ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3310
			$navigation .= '<div class="nav-previous">' . $prev_link . '</div>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3311
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3312
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3313
		if ( $next_link ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3314
			$navigation .= '<div class="nav-next">' . $next_link . '</div>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3315
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3316
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3317
		$navigation = _navigation_markup( $navigation, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3318
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3319
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3320
	return $navigation;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3321
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3322
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3323
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3324
 * Displays navigation to next/previous set of comments, when applicable.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3325
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3326
 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3327
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3328
 * @param array $args See get_the_comments_navigation() for available arguments. Default empty array.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3329
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3330
function the_comments_navigation( $args = array() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3331
	echo get_the_comments_navigation( $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3332
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3333
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3334
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3335
 * Retrieves a paginated navigation to next/previous set of comments, when applicable.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3336
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3337
 * @since 4.4.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3338
 * @since 5.3.0 Added the `aria_label` parameter.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3339
 * @since 5.5.0 Added the `class` parameter.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3340
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3341
 * @see paginate_comments_links()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3342
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3343
 * @param array $args {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3344
 *     Optional. Default pagination arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3345
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3346
 *     @type string $screen_reader_text Screen reader text for the nav element. Default 'Comments navigation'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3347
 *     @type string $aria_label         ARIA label text for the nav element. Default 'Comments'.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3348
 *     @type string $class              Custom class for the nav element. Default 'comments-pagination'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3349
 * }
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3350
 * @return string Markup for pagination links.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3351
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3352
function get_the_comments_pagination( $args = array() ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3353
	$navigation = '';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3354
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3355
	// Make sure the nav element has an aria-label attribute: fallback to the screen reader text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3356
	if ( ! empty( $args['screen_reader_text'] ) && empty( $args['aria_label'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3357
		$args['aria_label'] = $args['screen_reader_text'];
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3358
	}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3359
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3360
	$args         = wp_parse_args(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3361
		$args,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3362
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3363
			'screen_reader_text' => __( 'Comments navigation' ),
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3364
			'aria_label'         => __( 'Comments' ),
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3365
			'class'              => 'comments-pagination',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3366
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3367
	);
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3368
	$args['echo'] = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3369
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3370
	// Make sure we get a string back. Plain is the next best thing.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3371
	if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3372
		$args['type'] = 'plain';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3373
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3374
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3375
	$links = paginate_comments_links( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3376
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3377
	if ( $links ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3378
		$navigation = _navigation_markup( $links, $args['class'], $args['screen_reader_text'], $args['aria_label'] );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3379
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3380
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3381
	return $navigation;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3382
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3383
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3384
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3385
 * Displays a paginated navigation to next/previous set of comments, when applicable.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3386
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3387
 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3388
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3389
 * @param array $args See get_the_comments_pagination() for available arguments. Default empty array.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3390
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3391
function the_comments_pagination( $args = array() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3392
	echo get_the_comments_pagination( $args );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3393
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3394
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3395
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3396
 * Retrieves the URL for the current site where the front end is accessible.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3397
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3398
 * Returns the 'home' option with the appropriate protocol. The protocol will be 'https'
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3399
 * if is_ssl() evaluates to true; otherwise, it will be the same as the 'home' option.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3400
 * If `$scheme` is 'http' or 'https', is_ssl() is overridden.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3401
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3402
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3403
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3404
 * @param string      $path   Optional. Path relative to the home URL. Default empty.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3405
 * @param string|null $scheme Optional. Scheme to give the home URL context. Accepts
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3406
 *                            'http', 'https', 'relative', 'rest', or null. Default null.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3407
 * @return string Home URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3408
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3409
function home_url( $path = '', $scheme = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3410
	return get_home_url( null, $path, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3411
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3412
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3413
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3414
 * Retrieves the URL for a given site where the front end is accessible.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3415
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3416
 * Returns the 'home' option with the appropriate protocol. The protocol will be 'https'
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3417
 * if is_ssl() evaluates to true; otherwise, it will be the same as the 'home' option.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3418
 * If `$scheme` is 'http' or 'https', is_ssl() is overridden.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3419
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3420
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3421
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3422
 * @param int|null    $blog_id Optional. Site ID. Default null (current site).
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3423
 * @param string      $path    Optional. Path relative to the home URL. Default empty.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3424
 * @param string|null $scheme  Optional. Scheme to give the home URL context. Accepts
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3425
 *                             'http', 'https', 'relative', 'rest', or null. Default null.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3426
 * @return string Home URL link with optional path appended.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3427
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3428
function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3429
	$orig_scheme = $scheme;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3430
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3431
	if ( empty( $blog_id ) || ! is_multisite() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3432
		$url = get_option( 'home' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3433
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3434
		switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3435
		$url = get_option( 'home' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3436
		restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3437
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3438
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3439
	if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3440
		if ( is_ssl() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3441
			$scheme = 'https';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3442
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3443
			$scheme = parse_url( $url, PHP_URL_SCHEME );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3444
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3445
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3446
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3447
	$url = set_url_scheme( $url, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3448
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3449
	if ( $path && is_string( $path ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3450
		$url .= '/' . ltrim( $path, '/' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3451
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3452
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3453
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3454
	 * Filters the home URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3455
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3456
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3457
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3458
	 * @param string      $url         The complete home URL including scheme and path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3459
	 * @param string      $path        Path relative to the home URL. Blank string if no path is specified.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3460
	 * @param string|null $orig_scheme Scheme to give the home URL context. Accepts 'http', 'https',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3461
	 *                                 'relative', 'rest', or null.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3462
	 * @param int|null    $blog_id     Site ID, or null for the current site.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3463
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3464
	return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3465
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3466
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3467
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3468
 * Retrieves the URL for the current site where WordPress application files
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3469
 * (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3470
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3471
 * Returns the 'site_url' option with the appropriate protocol, 'https' if
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3472
 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3473
 * overridden.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3474
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3475
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3476
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3477
 * @param string      $path   Optional. Path relative to the site URL. Default empty.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3478
 * @param string|null $scheme Optional. Scheme to give the site URL context. See set_url_scheme().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3479
 * @return string Site URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3480
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3481
function site_url( $path = '', $scheme = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3482
	return get_site_url( null, $path, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3483
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3484
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3485
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3486
 * Retrieves the URL for a given site where WordPress application files
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3487
 * (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3488
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3489
 * Returns the 'site_url' option with the appropriate protocol, 'https' if
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3490
 * is_ssl() and 'http' otherwise. If `$scheme` is 'http' or 'https',
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3491
 * `is_ssl()` is overridden.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3492
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3493
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3494
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3495
 * @param int|null    $blog_id Optional. Site ID. Default null (current site).
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3496
 * @param string      $path    Optional. Path relative to the site URL. Default empty.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3497
 * @param string|null $scheme  Optional. Scheme to give the site URL context. Accepts
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3498
 *                             'http', 'https', 'login', 'login_post', 'admin', or
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3499
 *                             'relative'. Default null.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3500
 * @return string Site URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3501
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3502
function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3503
	if ( empty( $blog_id ) || ! is_multisite() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3504
		$url = get_option( 'siteurl' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3505
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3506
		switch_to_blog( $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3507
		$url = get_option( 'siteurl' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3508
		restore_current_blog();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3509
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3510
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3511
	$url = set_url_scheme( $url, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3512
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3513
	if ( $path && is_string( $path ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3514
		$url .= '/' . ltrim( $path, '/' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3515
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3516
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3517
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3518
	 * Filters the site URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3519
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3520
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3521
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3522
	 * @param string      $url     The complete site URL including scheme and path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3523
	 * @param string      $path    Path relative to the site URL. Blank string if no path is specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3524
	 * @param string|null $scheme  Scheme to give the site URL context. Accepts 'http', 'https', 'login',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3525
	 *                             'login_post', 'admin', 'relative' or null.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3526
	 * @param int|null    $blog_id Site ID, or null for the current site.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3527
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3528
	return apply_filters( 'site_url', $url, $path, $scheme, $blog_id );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3529
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3530
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3531
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3532
 * Retrieves the URL to the admin area for the current site.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3533
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3534
 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3535
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3536
 * @param string $path   Optional. Path relative to the admin URL. Default empty.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3537
 * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3538
 *                       'http' or 'https' can be passed to force those schemes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3539
 * @return string Admin URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3540
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3541
function admin_url( $path = '', $scheme = 'admin' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3542
	return get_admin_url( null, $path, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3543
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3544
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3545
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3546
 * Retrieves the URL to the admin area for a given site.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3547
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3548
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3549
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3550
 * @param int|null $blog_id Optional. Site ID. Default null (current site).
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3551
 * @param string   $path    Optional. Path relative to the admin URL. Default empty.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3552
 * @param string   $scheme  Optional. The scheme to use. Accepts 'http' or 'https',
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3553
 *                          to force those schemes. Default 'admin', which obeys
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3554
 *                          force_ssl_admin() and is_ssl().
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3555
 * @return string Admin URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3556
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3557
function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3558
	$url = get_site_url( $blog_id, 'wp-admin/', $scheme );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3559
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3560
	if ( $path && is_string( $path ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3561
		$url .= ltrim( $path, '/' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3562
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3563
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3564
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3565
	 * Filters the admin area URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3566
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3567
	 * @since 2.8.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3568
	 * @since 5.8.0 The `$scheme` parameter was added.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3569
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3570
	 * @param string      $url     The complete admin area URL including scheme and path.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3571
	 * @param string      $path    Path relative to the admin area URL. Blank string if no path is specified.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3572
	 * @param int|null    $blog_id Site ID, or null for the current site.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3573
	 * @param string|null $scheme  The scheme to use. Accepts 'http', 'https',
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3574
	 *                             'admin', or null. Default 'admin', which obeys force_ssl_admin() and is_ssl().
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3575
	 */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3576
	return apply_filters( 'admin_url', $url, $path, $blog_id, $scheme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3577
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3578
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3579
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3580
 * Retrieves the URL to the includes directory.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3581
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3582
 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3583
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3584
 * @param string      $path   Optional. Path relative to the includes URL. Default empty.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3585
 * @param string|null $scheme Optional. Scheme to give the includes URL context. Accepts
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3586
 *                            'http', 'https', or 'relative'. Default null.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3587
 * @return string Includes URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3588
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3589
function includes_url( $path = '', $scheme = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3590
	$url = site_url( '/' . WPINC . '/', $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3591
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3592
	if ( $path && is_string( $path ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3593
		$url .= ltrim( $path, '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3594
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3595
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3596
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3597
	 * Filters the URL to the includes directory.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3598
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3599
	 * @since 2.8.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3600
	 * @since 5.8.0 The `$scheme` parameter was added.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3601
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3602
	 * @param string      $url    The complete URL to the includes directory including scheme and path.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3603
	 * @param string      $path   Path relative to the URL to the wp-includes directory. Blank string
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3604
	 *                            if no path is specified.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3605
	 * @param string|null $scheme Scheme to give the includes URL context. Accepts
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3606
	 *                            'http', 'https', 'relative', or null. Default null.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3607
	 */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3608
	return apply_filters( 'includes_url', $url, $path, $scheme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3609
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3610
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3611
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3612
 * Retrieves the URL to the content directory.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3613
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3614
 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3615
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3616
 * @param string $path Optional. Path relative to the content URL. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3617
 * @return string Content URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3618
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3619
function content_url( $path = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3620
	$url = set_url_scheme( WP_CONTENT_URL );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3621
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3622
	if ( $path && is_string( $path ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3623
		$url .= '/' . ltrim( $path, '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3624
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3625
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3626
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3627
	 * Filters the URL to the content directory.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3628
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3629
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3630
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3631
	 * @param string $url  The complete URL to the content directory including scheme and path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3632
	 * @param string $path Path relative to the URL to the content directory. Blank string
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3633
	 *                     if no path is specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3634
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3635
	return apply_filters( 'content_url', $url, $path );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3636
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3637
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3638
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3639
 * Retrieves a URL within the plugins or mu-plugins directory.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3640
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3641
 * Defaults to the plugins directory URL if no arguments are supplied.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3642
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3643
 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3644
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3645
 * @param string $path   Optional. Extra path appended to the end of the URL, including
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3646
 *                       the relative directory if $plugin is supplied. Default empty.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3647
 * @param string $plugin Optional. A full path to a file inside a plugin or mu-plugin.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3648
 *                       The URL will be relative to its directory. Default empty.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3649
 *                       Typically this is done by passing `__FILE__` as the argument.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3650
 * @return string Plugins URL link with optional paths appended.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3651
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3652
function plugins_url( $path = '', $plugin = '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3653
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3654
	$path          = wp_normalize_path( $path );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3655
	$plugin        = wp_normalize_path( $plugin );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3656
	$mu_plugin_dir = wp_normalize_path( WPMU_PLUGIN_DIR );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3657
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3658
	if ( ! empty( $plugin ) && str_starts_with( $plugin, $mu_plugin_dir ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3659
		$url = WPMU_PLUGIN_URL;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3660
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3661
		$url = WP_PLUGIN_URL;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3662
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3663
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3664
	$url = set_url_scheme( $url );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3665
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3666
	if ( ! empty( $plugin ) && is_string( $plugin ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3667
		$folder = dirname( plugin_basename( $plugin ) );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3668
		if ( '.' !== $folder ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3669
			$url .= '/' . ltrim( $folder, '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3670
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3671
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3672
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3673
	if ( $path && is_string( $path ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3674
		$url .= '/' . ltrim( $path, '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3675
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3676
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3677
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3678
	 * Filters the URL to the plugins directory.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3679
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3680
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3681
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3682
	 * @param string $url    The complete URL to the plugins directory including scheme and path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3683
	 * @param string $path   Path relative to the URL to the plugins directory. Blank string
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3684
	 *                       if no path is specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3685
	 * @param string $plugin The plugin file path to be relative to. Blank string if no plugin
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3686
	 *                       is specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3687
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3688
	return apply_filters( 'plugins_url', $url, $path, $plugin );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3689
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3690
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3691
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3692
 * Retrieves the site URL for the current network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3693
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3694
 * Returns the site URL with the appropriate protocol, 'https' if
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3695
 * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3696
 * overridden.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3697
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3698
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3699
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3700
 * @see set_url_scheme()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3701
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3702
 * @param string      $path   Optional. Path relative to the site URL. Default empty.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3703
 * @param string|null $scheme Optional. Scheme to give the site URL context. Accepts
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3704
 *                            'http', 'https', or 'relative'. Default null.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3705
 * @return string Site URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3706
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3707
function network_site_url( $path = '', $scheme = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3708
	if ( ! is_multisite() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3709
		return site_url( $path, $scheme );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3710
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3711
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3712
	$current_network = get_network();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3713
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3714
	if ( 'relative' === $scheme ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3715
		$url = $current_network->path;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3716
	} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3717
		$url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3718
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3719
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3720
	if ( $path && is_string( $path ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3721
		$url .= ltrim( $path, '/' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3722
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3723
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3724
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3725
	 * Filters the network site URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3726
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3727
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3728
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3729
	 * @param string      $url    The complete network site URL including scheme and path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3730
	 * @param string      $path   Path relative to the network site URL. Blank string if
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3731
	 *                            no path is specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3732
	 * @param string|null $scheme Scheme to give the URL context. Accepts 'http', 'https',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3733
	 *                            'relative' or null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3734
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3735
	return apply_filters( 'network_site_url', $url, $path, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3736
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3737
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3738
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3739
 * Retrieves the home URL for the current network.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3740
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3741
 * Returns the home URL with the appropriate protocol, 'https' is_ssl()
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3742
 * and 'http' otherwise. If `$scheme` is 'http' or 'https', `is_ssl()` is
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3743
 * overridden.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3744
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3745
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3746
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3747
 * @param string      $path   Optional. Path relative to the home URL. Default empty.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3748
 * @param string|null $scheme Optional. Scheme to give the home URL context. Accepts
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3749
 *                            'http', 'https', or 'relative'. Default null.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3750
 * @return string Home URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3751
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3752
function network_home_url( $path = '', $scheme = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3753
	if ( ! is_multisite() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3754
		return home_url( $path, $scheme );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3755
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3756
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3757
	$current_network = get_network();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3758
	$orig_scheme     = $scheme;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3759
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3760
	if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ), true ) ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3761
		$scheme = is_ssl() ? 'https' : 'http';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3762
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3763
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3764
	if ( 'relative' === $scheme ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3765
		$url = $current_network->path;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3766
	} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3767
		$url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3768
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3769
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3770
	if ( $path && is_string( $path ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3771
		$url .= ltrim( $path, '/' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3772
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3773
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3774
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3775
	 * Filters the network home URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3776
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3777
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3778
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3779
	 * @param string      $url         The complete network home URL including scheme and path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3780
	 * @param string      $path        Path relative to the network home URL. Blank string
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3781
	 *                                 if no path is specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3782
	 * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', 'https',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3783
	 *                                 'relative' or null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3784
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3785
	return apply_filters( 'network_home_url', $url, $path, $orig_scheme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3786
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3787
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3788
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3789
 * Retrieves the URL to the admin area for the network.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3790
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3791
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3792
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3793
 * @param string $path   Optional path relative to the admin URL. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3794
 * @param string $scheme Optional. The scheme to use. Default is 'admin', which obeys force_ssl_admin()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3795
 *                       and is_ssl(). 'http' or 'https' can be passed to force those schemes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3796
 * @return string Admin URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3797
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3798
function network_admin_url( $path = '', $scheme = 'admin' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3799
	if ( ! is_multisite() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3800
		return admin_url( $path, $scheme );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3801
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3802
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3803
	$url = network_site_url( 'wp-admin/network/', $scheme );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3804
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3805
	if ( $path && is_string( $path ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3806
		$url .= ltrim( $path, '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3807
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3808
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3809
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3810
	 * Filters the network admin URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3811
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3812
	 * @since 3.0.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3813
	 * @since 5.8.0 The `$scheme` parameter was added.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3814
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3815
	 * @param string      $url    The complete network admin URL including scheme and path.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3816
	 * @param string      $path   Path relative to the network admin URL. Blank string if
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3817
	 *                            no path is specified.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3818
	 * @param string|null $scheme The scheme to use. Accepts 'http', 'https',
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3819
	 *                            'admin', or null. Default is 'admin', which obeys force_ssl_admin() and is_ssl().
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3820
	 */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3821
	return apply_filters( 'network_admin_url', $url, $path, $scheme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3822
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3823
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3824
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3825
 * Retrieves the URL to the admin area for the current user.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3826
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3827
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3828
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3829
 * @param string $path   Optional. Path relative to the admin URL. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3830
 * @param string $scheme Optional. The scheme to use. Default is 'admin', which obeys force_ssl_admin()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3831
 *                       and is_ssl(). 'http' or 'https' can be passed to force those schemes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3832
 * @return string Admin URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3833
 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3834
function user_admin_url( $path = '', $scheme = 'admin' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3835
	$url = network_site_url( 'wp-admin/user/', $scheme );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3836
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3837
	if ( $path && is_string( $path ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3838
		$url .= ltrim( $path, '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3839
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3840
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3841
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3842
	 * Filters the user admin URL for the current user.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3843
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3844
	 * @since 3.1.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3845
	 * @since 5.8.0 The `$scheme` parameter was added.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3846
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3847
	 * @param string      $url    The complete URL including scheme and path.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3848
	 * @param string      $path   Path relative to the URL. Blank string if
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3849
	 *                            no path is specified.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3850
	 * @param string|null $scheme The scheme to use. Accepts 'http', 'https',
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3851
	 *                            'admin', or null. Default is 'admin', which obeys force_ssl_admin() and is_ssl().
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3852
	 */
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  3853
	return apply_filters( 'user_admin_url', $url, $path, $scheme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3854
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3855
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3856
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3857
 * Retrieves the URL to the admin area for either the current site or the network depending on context.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3858
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3859
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3860
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3861
 * @param string $path   Optional. Path relative to the admin URL. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3862
 * @param string $scheme Optional. The scheme to use. Default is 'admin', which obeys force_ssl_admin()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3863
 *                       and is_ssl(). 'http' or 'https' can be passed to force those schemes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3864
 * @return string Admin URL link with optional path appended.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3865
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3866
function self_admin_url( $path = '', $scheme = 'admin' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3867
	if ( is_network_admin() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3868
		$url = network_admin_url( $path, $scheme );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3869
	} elseif ( is_user_admin() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3870
		$url = user_admin_url( $path, $scheme );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3871
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3872
		$url = admin_url( $path, $scheme );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3873
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3874
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3875
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3876
	 * Filters the admin URL for the current site or network depending on context.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3877
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3878
	 * @since 4.9.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3879
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3880
	 * @param string $url    The complete URL including scheme and path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3881
	 * @param string $path   Path relative to the URL. Blank string if no path is specified.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3882
	 * @param string $scheme The scheme to use.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3883
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3884
	return apply_filters( 'self_admin_url', $url, $path, $scheme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3885
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3886
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3887
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3888
 * Sets the scheme for a URL.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3889
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3890
 * @since 3.4.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3891
 * @since 4.4.0 The 'rest' scheme was added.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3892
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3893
 * @param string      $url    Absolute URL that includes a scheme
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3894
 * @param string|null $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3895
 *                            'login_post', 'admin', 'relative', 'rest', 'rpc', or null. Default null.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3896
 * @return string URL with chosen scheme.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3897
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3898
function set_url_scheme( $url, $scheme = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3899
	$orig_scheme = $scheme;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3900
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3901
	if ( ! $scheme ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3902
		$scheme = is_ssl() ? 'https' : 'http';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3903
	} elseif ( 'admin' === $scheme || 'login' === $scheme || 'login_post' === $scheme || 'rpc' === $scheme ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3904
		$scheme = is_ssl() || force_ssl_admin() ? 'https' : 'http';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3905
	} elseif ( 'http' !== $scheme && 'https' !== $scheme && 'relative' !== $scheme ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3906
		$scheme = is_ssl() ? 'https' : 'http';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3907
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3908
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3909
	$url = trim( $url );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  3910
	if ( str_starts_with( $url, '//' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3911
		$url = 'http:' . $url;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3912
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3913
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3914
	if ( 'relative' === $scheme ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3915
		$url = ltrim( preg_replace( '#^\w+://[^/]*#', '', $url ) );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3916
		if ( '' !== $url && '/' === $url[0] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3917
			$url = '/' . ltrim( $url, "/ \t\n\r\0\x0B" );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3918
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3919
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3920
		$url = preg_replace( '#^\w+://#', $scheme . '://', $url );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3921
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3922
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3923
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3924
	 * Filters the resulting URL after setting the scheme.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3925
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3926
	 * @since 3.4.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3927
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3928
	 * @param string      $url         The complete URL including scheme and path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3929
	 * @param string      $scheme      Scheme applied to the URL. One of 'http', 'https', or 'relative'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3930
	 * @param string|null $orig_scheme Scheme requested for the URL. One of 'http', 'https', 'login',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3931
	 *                                 'login_post', 'admin', 'relative', 'rest', 'rpc', or null.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3932
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3933
	return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3934
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3935
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3936
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3937
 * Retrieves the URL to the user's dashboard.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3938
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3939
 * If a user does not belong to any site, the global user dashboard is used. If the user
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3940
 * belongs to the current site, the dashboard for the current site is returned. If the user
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3941
 * cannot edit the current site, the dashboard to the user's primary site is returned.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3942
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3943
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3944
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3945
 * @param int    $user_id Optional. User ID. Defaults to current user.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3946
 * @param string $path    Optional path relative to the dashboard. Use only paths known to
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3947
 *                        both site and user admins. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3948
 * @param string $scheme  The scheme to use. Default is 'admin', which obeys force_ssl_admin()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3949
 *                        and is_ssl(). 'http' or 'https' can be passed to force those schemes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3950
 * @return string Dashboard URL link with optional path appended.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3951
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3952
function get_dashboard_url( $user_id = 0, $path = '', $scheme = 'admin' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3953
	$user_id = $user_id ? (int) $user_id : get_current_user_id();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3954
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3955
	$blogs = get_blogs_of_user( $user_id );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3956
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3957
	if ( is_multisite() && ! user_can( $user_id, 'manage_network' ) && empty( $blogs ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3958
		$url = user_admin_url( $path, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3959
	} elseif ( ! is_multisite() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3960
		$url = admin_url( $path, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3961
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3962
		$current_blog = get_current_blog_id();
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3963
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  3964
		if ( $current_blog && ( user_can( $user_id, 'manage_network' ) || in_array( $current_blog, array_keys( $blogs ), true ) ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3965
			$url = admin_url( $path, $scheme );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3966
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3967
			$active = get_active_blog_for_user( $user_id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3968
			if ( $active ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3969
				$url = get_admin_url( $active->blog_id, $path, $scheme );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3970
			} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3971
				$url = user_admin_url( $path, $scheme );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3972
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3973
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3974
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3975
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3976
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3977
	 * Filters the dashboard URL for a user.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3978
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3979
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3980
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3981
	 * @param string $url     The complete URL including scheme and path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3982
	 * @param int    $user_id The user ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3983
	 * @param string $path    Path relative to the URL. Blank string if no path is specified.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3984
	 * @param string $scheme  Scheme to give the URL context. Accepts 'http', 'https', 'login',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3985
	 *                        'login_post', 'admin', 'relative' or null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3986
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  3987
	return apply_filters( 'user_dashboard_url', $url, $user_id, $path, $scheme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3988
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3989
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3990
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3991
 * Retrieves the URL to the user's profile editor.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3992
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3993
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3994
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  3995
 * @param int    $user_id Optional. User ID. Defaults to current user.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3996
 * @param string $scheme  Optional. The scheme to use. Default is 'admin', which obeys force_ssl_admin()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3997
 *                        and is_ssl(). 'http' or 'https' can be passed to force those schemes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  3998
 * @return string Dashboard URL link with optional path appended.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  3999
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4000
function get_edit_profile_url( $user_id = 0, $scheme = 'admin' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4001
	$user_id = $user_id ? (int) $user_id : get_current_user_id();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4002
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4003
	if ( is_user_admin() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4004
		$url = user_admin_url( 'profile.php', $scheme );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4005
	} elseif ( is_network_admin() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4006
		$url = network_admin_url( 'profile.php', $scheme );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4007
	} else {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4008
		$url = get_dashboard_url( $user_id, 'profile.php', $scheme );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4009
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4010
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4011
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4012
	 * Filters the URL for a user's profile editor.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4013
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4014
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4015
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4016
	 * @param string $url     The complete URL including scheme and path.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4017
	 * @param int    $user_id The user ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4018
	 * @param string $scheme  Scheme to give the URL context. Accepts 'http', 'https', 'login',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4019
	 *                        'login_post', 'admin', 'relative' or null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4020
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4021
	return apply_filters( 'edit_profile_url', $url, $user_id, $scheme );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4022
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4023
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4024
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4025
 * Returns the canonical URL for a post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4026
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4027
 * When the post is the same as the current requested page the function will handle the
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4028
 * pagination arguments too.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4029
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4030
 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4031
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4032
 * @param int|WP_Post $post Optional. Post ID or object. Default is global `$post`.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4033
 * @return string|false The canonical URL. False if the post does not exist
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4034
 *                      or has not been published yet.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4035
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4036
function wp_get_canonical_url( $post = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4037
	$post = get_post( $post );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4038
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4039
	if ( ! $post ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4040
		return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4041
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4042
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4043
	if ( 'publish' !== $post->post_status ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4044
		return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4045
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4046
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4047
	$canonical_url = get_permalink( $post );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4048
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4049
	// If a canonical is being generated for the current page, make sure it has pagination if needed.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4050
	if ( get_queried_object_id() === $post->ID ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4051
		$page = get_query_var( 'page', 0 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4052
		if ( $page >= 2 ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4053
			if ( ! get_option( 'permalink_structure' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4054
				$canonical_url = add_query_arg( 'page', $page, $canonical_url );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4055
			} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4056
				$canonical_url = trailingslashit( $canonical_url ) . user_trailingslashit( $page, 'single_paged' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4057
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4058
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4059
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4060
		$cpage = get_query_var( 'cpage', 0 );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4061
		if ( $cpage ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4062
			$canonical_url = get_comments_pagenum_link( $cpage );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4063
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4064
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4065
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4066
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4067
	 * Filters the canonical URL for a post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4068
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4069
	 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4070
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4071
	 * @param string  $canonical_url The post's canonical URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4072
	 * @param WP_Post $post          Post object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4073
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4074
	return apply_filters( 'get_canonical_url', $canonical_url, $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4075
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4076
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4077
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4078
 * Outputs rel=canonical for singular queries.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4079
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4080
 * @since 2.9.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4081
 * @since 4.6.0 Adjusted to use `wp_get_canonical_url()`.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4082
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4083
function rel_canonical() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4084
	if ( ! is_singular() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4085
		return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4086
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4087
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4088
	$id = get_queried_object_id();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4089
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4090
	if ( 0 === $id ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4091
		return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4092
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4093
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4094
	$url = wp_get_canonical_url( $id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4095
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4096
	if ( ! empty( $url ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4097
		echo '<link rel="canonical" href="' . esc_url( $url ) . '" />' . "\n";
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4098
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4099
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4100
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4101
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4102
 * Returns a shortlink for a post, page, attachment, or site.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4103
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4104
 * This function exists to provide a shortlink tag that all themes and plugins can target.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4105
 * A plugin must hook in to provide the actual shortlinks. Default shortlink support is
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4106
 * limited to providing ?p= style links for posts. Plugins can short-circuit this function
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4107
 * via the {@see 'pre_get_shortlink'} filter or filter the output via the {@see 'get_shortlink'}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4108
 * filter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4109
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4110
 * @since 3.0.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4111
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4112
 * @param int    $id          Optional. A post or site ID. Default is 0, which means the current post or site.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  4113
 * @param string $context     Optional. Whether the ID is a 'site' ID, 'post' ID, or 'media' ID. If 'post',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4114
 *                            the post_type of the post is consulted. If 'query', the current query is consulted
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4115
 *                            to determine the ID and context. Default 'post'.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4116
 * @param bool   $allow_slugs Optional. Whether to allow post slugs in the shortlink. It is up to the plugin how
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4117
 *                            and whether to honor this. Default true.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4118
 * @return string A shortlink or an empty string if no shortlink exists for the requested resource or if shortlinks
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4119
 *                are not enabled.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4120
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4121
function wp_get_shortlink( $id = 0, $context = 'post', $allow_slugs = true ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4122
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4123
	 * Filters whether to preempt generating a shortlink for the given post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4124
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4125
	 * Returning a value other than false from the filter will short-circuit
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4126
	 * the shortlink generation process, returning that value instead.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4127
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4128
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4129
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4130
	 * @param false|string $return      Short-circuit return value. Either false or a URL string.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4131
	 * @param int          $id          Post ID, or 0 for the current post.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4132
	 * @param string       $context     The context for the link. One of 'post' or 'query',
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4133
	 * @param bool         $allow_slugs Whether to allow post slugs in the shortlink.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4134
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4135
	$shortlink = apply_filters( 'pre_get_shortlink', false, $id, $context, $allow_slugs );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4136
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4137
	if ( false !== $shortlink ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4138
		return $shortlink;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4139
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4140
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4141
	$post_id = 0;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4142
	if ( 'query' === $context && is_singular() ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4143
		$post_id = get_queried_object_id();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4144
		$post    = get_post( $post_id );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4145
	} elseif ( 'post' === $context ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4146
		$post = get_post( $id );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4147
		if ( ! empty( $post->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4148
			$post_id = $post->ID;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4149
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4150
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4151
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4152
	$shortlink = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4153
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4154
	// Return `?p=` link for all public post types.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4155
	if ( ! empty( $post_id ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4156
		$post_type = get_post_type_object( $post->post_type );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4157
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4158
		if ( 'page' === $post->post_type
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4159
			&& 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4160
		) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4161
			$shortlink = home_url( '/' );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  4162
		} elseif ( $post_type && $post_type->public ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4163
			$shortlink = home_url( '?p=' . $post_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4164
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4165
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4166
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4167
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4168
	 * Filters the shortlink for a post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4169
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4170
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4171
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4172
	 * @param string $shortlink   Shortlink URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4173
	 * @param int    $id          Post ID, or 0 for the current post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4174
	 * @param string $context     The context for the link. One of 'post' or 'query',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4175
	 * @param bool   $allow_slugs Whether to allow post slugs in the shortlink. Not used by default.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4176
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4177
	return apply_filters( 'get_shortlink', $shortlink, $id, $context, $allow_slugs );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4178
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4179
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4180
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4181
 * Injects rel=shortlink into the head if a shortlink is defined for the current page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4182
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4183
 * Attached to the {@see 'wp_head'} action.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4184
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4185
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4186
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4187
function wp_shortlink_wp_head() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4188
	$shortlink = wp_get_shortlink( 0, 'query' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4189
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4190
	if ( empty( $shortlink ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4191
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4192
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4193
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4194
	echo "<link rel='shortlink' href='" . esc_url( $shortlink ) . "' />\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4195
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4196
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4197
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4198
 * Sends a Link: rel=shortlink header if a shortlink is defined for the current page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4199
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4200
 * Attached to the {@see 'wp'} action.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4201
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4202
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4203
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4204
function wp_shortlink_header() {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4205
	if ( headers_sent() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4206
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4207
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4208
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4209
	$shortlink = wp_get_shortlink( 0, 'query' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4210
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4211
	if ( empty( $shortlink ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4212
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4213
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4214
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4215
	header( 'Link: <' . $shortlink . '>; rel=shortlink', false );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4216
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4217
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4218
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4219
 * Displays the shortlink for a post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4220
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4221
 * Must be called from inside "The Loop"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4222
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4223
 * Call like the_shortlink( __( 'Shortlinkage FTW' ) )
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4224
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4225
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4226
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4227
 * @param string $text   Optional The link text or HTML to be displayed. Defaults to 'This is the short link.'
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4228
 * @param string $title  Optional The tooltip for the link. Must be sanitized. Defaults to the sanitized post title.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4229
 * @param string $before Optional HTML to display before the link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4230
 * @param string $after  Optional HTML to display after the link. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4231
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4232
function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4233
	$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4234
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4235
	if ( empty( $text ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4236
		$text = __( 'This is the short link.' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4237
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4238
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4239
	if ( empty( $title ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4240
		$title = the_title_attribute( array( 'echo' => false ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4241
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4242
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4243
	$shortlink = wp_get_shortlink( $post->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4244
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4245
	if ( ! empty( $shortlink ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4246
		$link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4247
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4248
		/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4249
		 * Filters the short link anchor tag for a post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4250
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4251
		 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4252
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4253
		 * @param string $link      Shortlink anchor tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4254
		 * @param string $shortlink Shortlink URL.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4255
		 * @param string $text      Shortlink's text.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4256
		 * @param string $title     Shortlink's title attribute.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4257
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4258
		$link = apply_filters( 'the_shortlink', $link, $shortlink, $text, $title );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4259
		echo $before, $link, $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4260
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  4261
}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4262
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4263
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4264
 * Retrieves the avatar URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4265
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4266
 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4267
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4268
 * @param mixed $id_or_email The avatar to retrieve a URL for. Accepts a user ID, Gravatar MD5 hash,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4269
 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4270
 * @param array $args {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4271
 *     Optional. Arguments to use instead of the default arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4272
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4273
 *     @type int    $size           Height and width of the avatar in pixels. Default 96.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4274
 *     @type string $default        URL for the default image or a default type. Accepts:
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4275
 *                                  - '404' (return a 404 instead of a default image)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4276
 *                                  - 'retro' (a 8-bit arcade-style pixelated face)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4277
 *                                  - 'robohash' (a robot)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4278
 *                                  - 'monsterid' (a monster)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4279
 *                                  - 'wavatar' (a cartoon face)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4280
 *                                  - 'identicon' (the "quilt", a geometric pattern)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4281
 *                                  - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4282
 *                                  - 'blank' (transparent GIF)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4283
 *                                  - 'gravatar_default' (the Gravatar logo)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4284
 *                                  Default is the value of the 'avatar_default' option,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4285
 *                                  with a fallback of 'mystery'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4286
 *     @type bool   $force_default  Whether to always show the default image, never the Gravatar.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4287
 *                                  Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4288
 *     @type string $rating         What rating to display avatars up to. Accepts:
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4289
 *                                  - 'G' (suitable for all audiences)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4290
 *                                  - 'PG' (possibly offensive, usually for audiences 13 and above)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4291
 *                                  - 'R' (intended for adult audiences above 17)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4292
 *                                  - 'X' (even more mature than above)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4293
 *                                  Default is the value of the 'avatar_rating' option.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4294
 *     @type string $scheme         URL scheme to use. See set_url_scheme() for accepted values.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4295
 *                                  Default null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4296
 *     @type array  $processed_args When the function returns, the value will be the processed/sanitized $args
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4297
 *                                  plus a "found_avatar" guess. Pass as a reference. Default null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4298
 * }
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4299
 * @return string|false The URL of the avatar on success, false on failure.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4300
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4301
function get_avatar_url( $id_or_email, $args = null ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4302
	$args = get_avatar_data( $id_or_email, $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4303
	return $args['url'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4304
}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4305
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4306
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4307
 * Check if this comment type allows avatars to be retrieved.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4308
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4309
 * @since 5.1.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4310
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4311
 * @param string $comment_type Comment type to check.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4312
 * @return bool Whether the comment type is allowed for retrieving avatars.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4313
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4314
function is_avatar_comment_type( $comment_type ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4315
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4316
	 * Filters the list of allowed comment types for retrieving avatars.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4317
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4318
	 * @since 3.0.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4319
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4320
	 * @param array $types An array of content types. Default only contains 'comment'.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4321
	 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4322
	$allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4323
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4324
	return in_array( $comment_type, (array) $allowed_comment_types, true );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4325
}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4326
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4327
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4328
 * Retrieves default data about the avatar.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4329
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4330
 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4331
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4332
 * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4333
 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4334
 * @param array $args {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4335
 *     Optional. Arguments to use instead of the default arguments.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4336
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4337
 *     @type int    $size           Height and width of the avatar in pixels. Default 96.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4338
 *     @type int    $height         Display height of the avatar in pixels. Defaults to $size.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4339
 *     @type int    $width          Display width of the avatar in pixels. Defaults to $size.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4340
 *     @type string $default        URL for the default image or a default type. Accepts:
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4341
 *                                  - '404' (return a 404 instead of a default image)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4342
 *                                  - 'retro' (a 8-bit arcade-style pixelated face)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4343
 *                                  - 'robohash' (a robot)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4344
 *                                  - 'monsterid' (a monster)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4345
 *                                  - 'wavatar' (a cartoon face)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4346
 *                                  - 'identicon' (the "quilt", a geometric pattern)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4347
 *                                  - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4348
 *                                  - 'blank' (transparent GIF)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4349
 *                                  - 'gravatar_default' (the Gravatar logo)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4350
 *                                  Default is the value of the 'avatar_default' option,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4351
 *                                  with a fallback of 'mystery'.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4352
 *     @type bool   $force_default  Whether to always show the default image, never the Gravatar.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4353
 *                                  Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4354
 *     @type string $rating         What rating to display avatars up to. Accepts:
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4355
 *                                  - 'G' (suitable for all audiences)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4356
 *                                  - 'PG' (possibly offensive, usually for audiences 13 and above)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4357
 *                                  - 'R' (intended for adult audiences above 17)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4358
 *                                  - 'X' (even more mature than above)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4359
 *                                  Default is the value of the 'avatar_rating' option.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4360
 *     @type string $scheme         URL scheme to use. See set_url_scheme() for accepted values.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4361
 *                                  Default null.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4362
 *     @type array  $processed_args When the function returns, the value will be the processed/sanitized $args
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4363
 *                                  plus a "found_avatar" guess. Pass as a reference. Default null.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4364
 *     @type string $extra_attr     HTML attributes to insert in the IMG element. Is not sanitized.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4365
 *                                  Default empty.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4366
 * }
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4367
 * @return array {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4368
 *     Along with the arguments passed in `$args`, this will contain a couple of extra arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4369
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4370
 *     @type bool         $found_avatar True if an avatar was found for this user,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4371
 *                                      false or not set if none was found.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4372
 *     @type string|false $url          The URL of the avatar that was found, or false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4373
 * }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4374
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4375
function get_avatar_data( $id_or_email, $args = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4376
	$args = wp_parse_args(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4377
		$args,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4378
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4379
			'size'           => 96,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4380
			'height'         => null,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4381
			'width'          => null,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4382
			'default'        => get_option( 'avatar_default', 'mystery' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4383
			'force_default'  => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4384
			'rating'         => get_option( 'avatar_rating' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4385
			'scheme'         => null,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4386
			'processed_args' => null, // If used, should be a reference.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4387
			'extra_attr'     => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4388
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4389
	);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4390
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4391
	if ( is_numeric( $args['size'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4392
		$args['size'] = absint( $args['size'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4393
		if ( ! $args['size'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4394
			$args['size'] = 96;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4395
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4396
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4397
		$args['size'] = 96;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4398
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4399
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4400
	if ( is_numeric( $args['height'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4401
		$args['height'] = absint( $args['height'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4402
		if ( ! $args['height'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4403
			$args['height'] = $args['size'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4404
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4405
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4406
		$args['height'] = $args['size'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4407
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4408
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4409
	if ( is_numeric( $args['width'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4410
		$args['width'] = absint( $args['width'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4411
		if ( ! $args['width'] ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4412
			$args['width'] = $args['size'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4413
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4414
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4415
		$args['width'] = $args['size'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4416
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4417
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4418
	if ( empty( $args['default'] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4419
		$args['default'] = get_option( 'avatar_default', 'mystery' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4420
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4421
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4422
	switch ( $args['default'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4423
		case 'mm':
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4424
		case 'mystery':
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4425
		case 'mysteryman':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4426
			$args['default'] = 'mm';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4427
			break;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4428
		case 'gravatar_default':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4429
			$args['default'] = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4430
			break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4431
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4432
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4433
	$args['force_default'] = (bool) $args['force_default'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4434
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4435
	$args['rating'] = strtolower( $args['rating'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4436
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4437
	$args['found_avatar'] = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4438
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4439
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4440
	 * Filters whether to retrieve the avatar URL early.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4441
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4442
	 * Passing a non-null value in the 'url' member of the return array will
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4443
	 * effectively short circuit get_avatar_data(), passing the value through
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4444
	 * the {@see 'get_avatar_data'} filter and returning early.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4445
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4446
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4447
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4448
	 * @param array $args        Arguments passed to get_avatar_data(), after processing.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4449
	 * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4450
	 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4451
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4452
	$args = apply_filters( 'pre_get_avatar_data', $args, $id_or_email );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4453
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4454
	if ( isset( $args['url'] ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4455
		/** This filter is documented in wp-includes/link-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4456
		return apply_filters( 'get_avatar_data', $args, $id_or_email );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4457
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4458
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4459
	$email_hash = '';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4460
	$user       = false;
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4461
	$email      = false;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4462
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4463
	if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4464
		$id_or_email = get_comment( $id_or_email );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4465
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4466
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4467
	// Process the user identifier.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4468
	if ( is_numeric( $id_or_email ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4469
		$user = get_user_by( 'id', absint( $id_or_email ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4470
	} elseif ( is_string( $id_or_email ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4471
		if ( str_contains( $id_or_email, '@md5.gravatar.com' ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4472
			// MD5 hash.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4473
			list( $email_hash ) = explode( '@', $id_or_email );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4474
		} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4475
			// Email address.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4476
			$email = $id_or_email;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4477
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4478
	} elseif ( $id_or_email instanceof WP_User ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4479
		// User object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4480
		$user = $id_or_email;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4481
	} elseif ( $id_or_email instanceof WP_Post ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4482
		// Post object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4483
		$user = get_user_by( 'id', (int) $id_or_email->post_author );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4484
	} elseif ( $id_or_email instanceof WP_Comment ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4485
		if ( ! is_avatar_comment_type( get_comment_type( $id_or_email ) ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4486
			$args['url'] = false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4487
			/** This filter is documented in wp-includes/link-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4488
			return apply_filters( 'get_avatar_data', $args, $id_or_email );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4489
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4490
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4491
		if ( ! empty( $id_or_email->user_id ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4492
			$user = get_user_by( 'id', (int) $id_or_email->user_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4493
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4494
		if ( ( ! $user || is_wp_error( $user ) ) && ! empty( $id_or_email->comment_author_email ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4495
			$email = $id_or_email->comment_author_email;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4496
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4497
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4498
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4499
	if ( ! $email_hash ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4500
		if ( $user ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4501
			$email = $user->user_email;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4502
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4503
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4504
		if ( $email ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4505
			$email_hash = md5( strtolower( trim( $email ) ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4506
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4507
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4508
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4509
	if ( $email_hash ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4510
		$args['found_avatar'] = true;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  4511
		$gravatar_server      = hexdec( $email_hash[0] ) % 3;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4512
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4513
		$gravatar_server = rand( 0, 2 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4514
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4515
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4516
	$url_args = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4517
		's' => $args['size'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4518
		'd' => $args['default'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4519
		'f' => $args['force_default'] ? 'y' : false,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4520
		'r' => $args['rating'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4521
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4522
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4523
	if ( is_ssl() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4524
		$url = 'https://secure.gravatar.com/avatar/' . $email_hash;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4525
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4526
		$url = sprintf( 'http://%d.gravatar.com/avatar/%s', $gravatar_server, $email_hash );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4527
	}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4528
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4529
	$url = add_query_arg(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4530
		rawurlencode_deep( array_filter( $url_args ) ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4531
		set_url_scheme( $url, $args['scheme'] )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4532
	);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4533
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4534
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4535
	 * Filters the avatar URL.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4536
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4537
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4538
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4539
	 * @param string $url         The URL of the avatar.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4540
	 * @param mixed  $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4541
	 *                            user email, WP_User object, WP_Post object, or WP_Comment object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4542
	 * @param array  $args        Arguments passed to get_avatar_data(), after processing.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4543
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4544
	$args['url'] = apply_filters( 'get_avatar_url', $url, $id_or_email, $args );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4545
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4546
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4547
	 * Filters the avatar data.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4548
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4549
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4550
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4551
	 * @param array $args        Arguments passed to get_avatar_data(), after processing.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4552
	 * @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  4553
	 *                           user email, WP_User object, WP_Post object, or WP_Comment object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4554
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4555
	return apply_filters( 'get_avatar_data', $args, $id_or_email );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  4556
}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4557
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4558
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4559
 * Retrieves the URL of a file in the theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4560
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4561
 * Searches in the stylesheet directory before the template directory so themes
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4562
 * which inherit from a parent theme can just override one file.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4563
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4564
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4565
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4566
 * @param string $file Optional. File to search for in the stylesheet directory.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4567
 * @return string The URL of the file.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4568
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4569
function get_theme_file_uri( $file = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4570
	$file = ltrim( $file, '/' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4571
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4572
	$stylesheet_directory = get_stylesheet_directory();
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4573
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4574
	if ( empty( $file ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4575
		$url = get_stylesheet_directory_uri();
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4576
	} elseif ( get_template_directory() !== $stylesheet_directory && file_exists( $stylesheet_directory . '/' . $file ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4577
		$url = get_stylesheet_directory_uri() . '/' . $file;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4578
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4579
		$url = get_template_directory_uri() . '/' . $file;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4580
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4581
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4582
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4583
	 * Filters the URL to a file in the theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4584
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4585
	 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4586
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4587
	 * @param string $url  The file URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4588
	 * @param string $file The requested file to search for.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4589
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4590
	return apply_filters( 'theme_file_uri', $url, $file );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4591
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4592
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4593
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4594
 * Retrieves the URL of a file in the parent theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4595
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4596
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4597
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4598
 * @param string $file Optional. File to return the URL for in the template directory.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4599
 * @return string The URL of the file.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4600
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4601
function get_parent_theme_file_uri( $file = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4602
	$file = ltrim( $file, '/' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4603
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4604
	if ( empty( $file ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4605
		$url = get_template_directory_uri();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4606
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4607
		$url = get_template_directory_uri() . '/' . $file;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4608
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4609
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4610
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4611
	 * Filters the URL to a file in the parent theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4612
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4613
	 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4614
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4615
	 * @param string $url  The file URL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4616
	 * @param string $file The requested file to search for.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4617
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4618
	return apply_filters( 'parent_theme_file_uri', $url, $file );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4619
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4620
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4621
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4622
 * Retrieves the path of a file in the theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4623
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4624
 * Searches in the stylesheet directory before the template directory so themes
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4625
 * which inherit from a parent theme can just override one file.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4626
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4627
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4628
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4629
 * @param string $file Optional. File to search for in the stylesheet directory.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4630
 * @return string The path of the file.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4631
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4632
function get_theme_file_path( $file = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4633
	$file = ltrim( $file, '/' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4634
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4635
	$stylesheet_directory = get_stylesheet_directory();
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4636
	$template_directory   = get_template_directory();
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4637
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4638
	if ( empty( $file ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4639
		$path = $stylesheet_directory;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4640
	} elseif ( $stylesheet_directory !== $template_directory && file_exists( $stylesheet_directory . '/' . $file ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4641
		$path = $stylesheet_directory . '/' . $file;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4642
	} else {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4643
		$path = $template_directory . '/' . $file;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4644
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4645
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4646
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4647
	 * Filters the path to a file in the theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4648
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4649
	 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4650
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4651
	 * @param string $path The file path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4652
	 * @param string $file The requested file to search for.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4653
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4654
	return apply_filters( 'theme_file_path', $path, $file );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4655
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4656
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4657
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4658
 * Retrieves the path of a file in the parent theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4659
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4660
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4661
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4662
 * @param string $file Optional. File to return the path for in the template directory.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4663
 * @return string The path of the file.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4664
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4665
function get_parent_theme_file_path( $file = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4666
	$file = ltrim( $file, '/' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4667
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4668
	if ( empty( $file ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4669
		$path = get_template_directory();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4670
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4671
		$path = get_template_directory() . '/' . $file;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4672
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4673
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4674
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4675
	 * Filters the path to a file in the parent theme.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4676
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4677
	 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4678
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4679
	 * @param string $path The file path.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4680
	 * @param string $file The requested file to search for.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4681
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4682
	return apply_filters( 'parent_theme_file_path', $path, $file );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4683
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4684
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4685
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4686
 * Retrieves the URL to the privacy policy page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4687
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4688
 * @since 4.9.6
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4689
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4690
 * @return string The URL to the privacy policy page. Empty string if it doesn't exist.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4691
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4692
function get_privacy_policy_url() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4693
	$url            = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4694
	$policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4695
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4696
	if ( ! empty( $policy_page_id ) && get_post_status( $policy_page_id ) === 'publish' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4697
		$url = (string) get_permalink( $policy_page_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4698
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4699
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4700
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4701
	 * Filters the URL of the privacy policy page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4702
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4703
	 * @since 4.9.6
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4704
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4705
	 * @param string $url            The URL to the privacy policy page. Empty string
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4706
	 *                               if it doesn't exist.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4707
	 * @param int    $policy_page_id The ID of privacy policy page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4708
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4709
	return apply_filters( 'privacy_policy_url', $url, $policy_page_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4710
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4711
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4712
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4713
 * Displays the privacy policy link with formatting, when applicable.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4714
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4715
 * @since 4.9.6
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4716
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4717
 * @param string $before Optional. Display before privacy policy link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4718
 * @param string $after  Optional. Display after privacy policy link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4719
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4720
function the_privacy_policy_link( $before = '', $after = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4721
	echo get_the_privacy_policy_link( $before, $after );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4722
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4723
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4724
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4725
 * Returns the privacy policy link with formatting, when applicable.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4726
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4727
 * @since 4.9.6
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4728
 * @since 6.2.0 Added 'privacy-policy' rel attribute.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4729
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4730
 * @param string $before Optional. Display before privacy policy link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4731
 * @param string $after  Optional. Display after privacy policy link. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4732
 * @return string Markup for the link and surrounding elements. Empty string if it
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4733
 *                doesn't exist.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4734
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4735
function get_the_privacy_policy_link( $before = '', $after = '' ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4736
	$link               = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4737
	$privacy_policy_url = get_privacy_policy_url();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4738
	$policy_page_id     = (int) get_option( 'wp_page_for_privacy_policy' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4739
	$page_title         = ( $policy_page_id ) ? get_the_title( $policy_page_id ) : '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4740
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4741
	if ( $privacy_policy_url && $page_title ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4742
		$link = sprintf(
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4743
			'<a class="privacy-policy-link" href="%s" rel="privacy-policy">%s</a>',
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4744
			esc_url( $privacy_policy_url ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4745
			esc_html( $page_title )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4746
		);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4747
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4748
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4749
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4750
	 * Filters the privacy policy link.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4751
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4752
	 * @since 4.9.6
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4753
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4754
	 * @param string $link               The privacy policy link. Empty string if it
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4755
	 *                                   doesn't exist.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4756
	 * @param string $privacy_policy_url The URL of the privacy policy. Empty string
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4757
	 *                                   if it doesn't exist.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4758
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4759
	$link = apply_filters( 'the_privacy_policy_link', $link, $privacy_policy_url );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4760
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4761
	if ( $link ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4762
		return $before . $link . $after;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4763
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4764
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4765
	return '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  4766
}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4767
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4768
/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4769
 * Returns an array of URL hosts which are considered to be internal hosts.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4770
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4771
 * By default the list of internal hosts is comprised of the host name of
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4772
 * the site's home_url() (as parsed by wp_parse_url()).
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4773
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4774
 * This list is used when determining if a specified URL is a link to a page on
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4775
 * the site itself or a link offsite (to an external host). This is used, for
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4776
 * example, when determining if the "nofollow" attribute should be applied to a
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4777
 * link.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4778
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4779
 * @see wp_is_internal_link
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4780
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4781
 * @since 6.2.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4782
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4783
 * @return string[] An array of URL hosts.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4784
 */
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4785
function wp_internal_hosts() {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4786
	static $internal_hosts;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4787
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4788
	if ( empty( $internal_hosts ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4789
		/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4790
		 * Filters the array of URL hosts which are considered internal.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4791
		 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4792
		 * @since 6.2.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4793
		 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4794
		 * @param string[] $internal_hosts An array of internal URL hostnames.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4795
		 */
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4796
		$internal_hosts = apply_filters(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4797
			'wp_internal_hosts',
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4798
			array(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4799
				wp_parse_url( home_url(), PHP_URL_HOST ),
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4800
			)
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4801
		);
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4802
		$internal_hosts = array_unique(
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4803
			array_map( 'strtolower', (array) $internal_hosts )
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4804
		);
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4805
	}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4806
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4807
	return $internal_hosts;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4808
}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4809
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4810
/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4811
 * Determines whether or not the specified URL is of a host included in the internal hosts list.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4812
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4813
 * @see wp_internal_hosts()
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4814
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4815
 * @since 6.2.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4816
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4817
 * @param string $link The URL to test.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4818
 * @return bool Returns true for internal URLs and false for all other URLs.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4819
 */
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4820
function wp_is_internal_link( $link ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4821
	$link = strtolower( $link );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4822
	if ( in_array( wp_parse_url( $link, PHP_URL_SCHEME ), wp_allowed_protocols(), true ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4823
		return in_array( wp_parse_url( $link, PHP_URL_HOST ), wp_internal_hosts(), true );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4824
	}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4825
	return false;
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  4826
}