wp/wp-includes/post-template.php
author ymh <ymh.work@gmail.com>
Mon, 08 Sep 2025 19:44:41 +0200
changeset 23 417f20492bf7
parent 22 8c2e4d02f4ef
permissions -rw-r--r--
Update Docker configuration and plugin versions - Upgrade MariaDB from 10.6 to 11 with auto-upgrade support - Add WordPress debug environment variable to FPM container - Update PHP-FPM Dockerfile base image - Update Include Mastodon Feed plugin with bug fixes and improvements - Update Portfolio plugin (v2.58) with latest translations and demo data enhancements - Remove old README.md from Mastodon Feed plugin 🤖 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 Post 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
 * Gets content for the current post in the loop.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @subpackage Template
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    12
 * Displays the ID of the current item in the WordPress Loop.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    16
function the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
	echo get_the_ID();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    21
 * Retrieves the ID of the current item in the WordPress Loop.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    25
 * @return int|false The ID of the current item in the WordPress Loop. False if $post is not set.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    27
function get_the_ID() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
	$post = get_post();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
	return ! empty( $post ) ? $post->ID : false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    33
 * Displays or retrieves the current post title with optional markup.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    37
 * @param string $before  Optional. Markup to prepend to the title. Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    38
 * @param string $after   Optional. Markup to append to the title. Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    39
 * @param bool   $display Optional. Whether to echo or return the title. Default true for echo.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    40
 * @return void|string Void if `$display` argument is true or the title is empty,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    41
 *                     current post title if `$display` is false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    43
function the_title( $before = '', $after = '', $display = true ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
	$title = get_the_title();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    46
	if ( strlen( $title ) === 0 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    48
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
	$title = $before . $title . $after;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    52
	if ( $display ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
		echo $title;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    54
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
		return $title;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    56
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
    60
 * Sanitizes the current title when retrieving or displaying.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    62
 * Works like the_title(), except the parameters can be in a string or
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
 * an array. See the function for what can be override in the $args parameter.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    65
 * The title before it is displayed will have the tags stripped and esc_attr()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    66
 * before it is passed to the user or displayed. The default as with the_title(),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    67
 * is to display the title.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
 * @param string|array $args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    72
 *     Title attribute arguments. Optional.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    73
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    74
 *     @type string  $before Markup to prepend to the title. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    75
 *     @type string  $after  Markup to append to the title. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    76
 *     @type bool    $echo   Whether to echo or return the title. Default true for echo.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    77
 *     @type WP_Post $post   Current post object to retrieve the title for.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    78
 * }
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    79
 * @return void|string Void if 'echo' argument is true, the title attribute if 'echo' is false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
function the_title_attribute( $args = '' ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    82
	$defaults    = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    83
		'before' => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    84
		'after'  => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    85
		'echo'   => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    86
		'post'   => get_post(),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
    87
	);
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    88
	$parsed_args = wp_parse_args( $args, $defaults );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    90
	$title = get_the_title( $parsed_args['post'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
    92
	if ( strlen( $title ) === 0 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
		return;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    94
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    96
	$title = $parsed_args['before'] . $title . $parsed_args['after'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    97
	$title = esc_attr( strip_tags( $title ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    99
	if ( $parsed_args['echo'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   100
		echo $title;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   101
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
		return $title;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   103
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   104
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   107
 * Retrieves the post title.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
 * If the post is protected and the visitor is not an admin, then "Protected"
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   110
 * will be inserted before the post title. If the post is private, then
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   111
 * "Private" will be inserted before the post title.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   112
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   115
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
function get_the_title( $post = 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
	$post = get_post( $post );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   121
	$post_title = isset( $post->post_title ) ? $post->post_title : '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   122
	$post_id    = isset( $post->ID ) ? $post->ID : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
	if ( ! is_admin() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
		if ( ! empty( $post->post_password ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   126
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   127
			/* translators: %s: Protected post title. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   128
			$prepend = __( 'Protected: %s' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   129
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   130
			/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   131
			 * Filters the text prepended to the post title for protected posts.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   132
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   133
			 * The filter is only applied on the front end.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   134
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   135
			 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   137
			 * @param string  $prepend Text displayed before the post title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   138
			 *                         Default 'Protected: %s'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   139
			 * @param WP_Post $post    Current post object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   140
			 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   141
			$protected_title_format = apply_filters( 'protected_title_format', $prepend, $post );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   142
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   143
			$post_title = sprintf( $protected_title_format, $post_title );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   144
		} elseif ( isset( $post->post_status ) && 'private' === $post->post_status ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   145
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   146
			/* translators: %s: Private post title. */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   147
			$prepend = __( 'Private: %s' );
5
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
			/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   150
			 * Filters the text prepended to the post title of private posts.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   152
			 * The filter is only applied on the front end.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   153
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
			 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   155
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   156
			 * @param string  $prepend Text displayed before the post title.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   157
			 *                         Default 'Private: %s'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   158
			 * @param WP_Post $post    Current post object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   159
			 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   160
			$private_title_format = apply_filters( 'private_title_format', $prepend, $post );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   161
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   162
			$post_title = sprintf( $private_title_format, $post_title );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   163
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   166
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   167
	 * Filters the post title.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   168
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   169
	 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   170
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   171
	 * @param string $post_title The post title.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   172
	 * @param int    $post_id    The post ID.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   173
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   174
	return apply_filters( 'the_title', $post_title, $post_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   177
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   178
 * Displays the Post Global Unique Identifier (guid).
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   180
 * The guid will appear to be a link, but should not be used as a link to the
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
 * post. The reason you should not use it as a link, is because of moving the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
 * blog across domains.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   184
 * URL is escaped to make it XML-safe.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   188
 * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   190
function the_guid( $post = 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   191
	$post = get_post( $post );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   192
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   193
	$post_guid = isset( $post->guid ) ? get_the_guid( $post ) : '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   194
	$post_id   = isset( $post->ID ) ? $post->ID : 0;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   195
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   196
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   197
	 * Filters the escaped Global Unique Identifier (guid) of the post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   198
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   199
	 * @since 4.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   200
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   201
	 * @see get_the_guid()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   203
	 * @param string $post_guid Escaped Global Unique Identifier (guid) of the post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   204
	 * @param int    $post_id   The post ID.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   205
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   206
	echo apply_filters( 'the_guid', $post_guid, $post_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   210
 * Retrieves the Post Global Unique Identifier (guid).
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
 * The guid will appear to be a link, but should not be used as an link to the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
 * post. The reason you should not use it as a link, is because of moving the
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
 * blog across domains.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   218
 * @param int|WP_Post $post Optional. Post ID or post object. Default is global $post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   221
function get_the_guid( $post = 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   222
	$post = get_post( $post );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   223
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   224
	$post_guid = isset( $post->guid ) ? $post->guid : '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   225
	$post_id   = isset( $post->ID ) ? $post->ID : 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   227
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   228
	 * Filters the Global Unique Identifier (guid) of the post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   229
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   230
	 * @since 1.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   231
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   232
	 * @param string $post_guid Global Unique Identifier (guid) of the post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   233
	 * @param int    $post_id   The post ID.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   234
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   235
	return apply_filters( 'get_the_guid', $post_guid, $post_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   239
 * Displays the post content.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
 * @param string $more_link_text Optional. Content for when there is more text.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   244
 * @param bool   $strip_teaser   Optional. Strip teaser content before the more text. Default false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   246
function the_content( $more_link_text = null, $strip_teaser = false ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
	$content = get_the_content( $more_link_text, $strip_teaser );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   248
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   249
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   250
	 * Filters the post content.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   251
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
	 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   253
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
	 * @param string $content Content of the current post.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   255
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
	$content = apply_filters( 'the_content', $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
	$content = str_replace( ']]>', ']]&gt;', $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
	echo $content;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   262
 * Retrieves the post content.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
 * @since 0.71
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   265
 * @since 5.2.0 Added the `$post` parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   267
 * @global int   $page      Page number of a single post/page.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   268
 * @global int   $more      Boolean indicator for whether single post/page is being viewed.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   269
 * @global bool  $preview   Whether post/page is in preview mode.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   270
 * @global array $pages     Array of all pages in post/page. Each array element contains
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   271
 *                          part of the content separated by the `<!--nextpage-->` tag.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   272
 * @global int   $multipage Boolean indicator for whether multiple pages are in play.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   273
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   274
 * @param string             $more_link_text Optional. Content for when there is more text.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   275
 * @param bool               $strip_teaser   Optional. Strip teaser content before the more text. Default false.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   276
 * @param WP_Post|object|int $post           Optional. WP_Post instance or Post ID/object. Default null.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   279
function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
	global $page, $more, $preview, $pages, $multipage;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   282
	$_post = get_post( $post );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   283
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   284
	if ( ! ( $_post instanceof WP_Post ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   285
		return '';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   286
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   287
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   288
	/*
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   289
	 * Use the globals if the $post parameter was not specified,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   290
	 * but only after they have been set up in setup_postdata().
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   291
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   292
	if ( null === $post && did_action( 'the_post' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   293
		$elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   294
	} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   295
		$elements = generate_postdata( $_post );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   296
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   298
	if ( null === $more_link_text ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   299
		$more_link_text = sprintf(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   300
			'<span aria-label="%1$s">%2$s</span>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   301
			sprintf(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   302
				/* translators: %s: Post title. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   303
				__( 'Continue reading %s' ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   304
				the_title_attribute(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   305
					array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   306
						'echo' => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   307
						'post' => $_post,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   308
					)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   309
				)
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   310
			),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   311
			__( '(more&hellip;)' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   312
		);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   313
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   315
	$output     = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
	$has_teaser = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
	// If post password required and it doesn't match the cookie.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   319
	if ( post_password_required( $_post ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   320
		return get_the_password_form( $_post );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   321
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   323
	// If the requested page doesn't exist.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   324
	if ( $elements['page'] > count( $elements['pages'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   325
		// Give them the highest numbered page that DOES exist.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   326
		$elements['page'] = count( $elements['pages'] );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   327
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   329
	$page_no = $elements['page'];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   330
	$content = $elements['pages'][ $page_no - 1 ];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
	if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   332
		if ( has_block( 'more', $content ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   333
			// Remove the core/more block delimiters. They will be left over after $content is split up.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   334
			$content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   335
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   336
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
		$content = explode( $matches[0], $content, 2 );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   338
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   339
		if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
			$more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   341
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
		$has_teaser = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
		$content = array( $content );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   348
	if ( str_contains( $_post->post_content, '<!--noteaser-->' )
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   349
		&& ( ! $elements['multipage'] || 1 === $elements['page'] )
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   350
	) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
		$strip_teaser = true;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   352
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
	$teaser = $content[0];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   356
	if ( $elements['more'] && $strip_teaser && $has_teaser ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
		$teaser = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   358
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
	$output .= $teaser;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
	if ( count( $content ) > 1 ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   363
		if ( $elements['more'] ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   364
			$output .= '<span id="more-' . $_post->ID . '"></span>' . $content[1];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
		} else {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   366
			if ( ! empty( $more_link_text ) ) {
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
				/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   369
				 * Filters the Read More link text.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   370
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   371
				 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   372
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   373
				 * @param string $more_link_element Read More link element.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   374
				 * @param string $more_link_text    Read More text.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   375
				 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   376
				$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   377
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
			$output = force_balance_tags( $output );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
	return $output;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   386
 * Displays the post excerpt.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
 * @since 0.71
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
function the_excerpt() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   391
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   392
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   393
	 * Filters the displayed post excerpt.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   394
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   395
	 * @since 0.71
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   396
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   397
	 * @see get_the_excerpt()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   398
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   399
	 * @param string $post_excerpt The post excerpt.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   400
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   401
	echo apply_filters( 'the_excerpt', get_the_excerpt() );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   405
 * Retrieves the post excerpt.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
 * @since 0.71
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   408
 * @since 4.5.0 Introduced the `$post` parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   410
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   411
 * @return string Post excerpt.
0
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
function get_the_excerpt( $post = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   414
	if ( is_bool( $post ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   415
		_deprecated_argument( __FUNCTION__, '2.3.0' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   416
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   418
	$post = get_post( $post );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   419
	if ( empty( $post ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   420
		return '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   421
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   423
	if ( post_password_required( $post ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
		return __( 'There is no excerpt because this is a protected post.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   427
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   428
	 * Filters the retrieved post excerpt.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   429
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   430
	 * @since 1.2.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   431
	 * @since 4.5.0 Introduced the `$post` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   432
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   433
	 * @param string  $post_excerpt The post excerpt.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   434
	 * @param WP_Post $post         Post object.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   435
	 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   436
	return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   440
 * Determines whether the post has a custom excerpt.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   441
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   442
 * For more information on this and similar theme functions, check out
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   443
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   444
 * Conditional Tags} article in the Theme Developer Handbook.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
 * @since 2.3.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   448
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   449
 * @return bool True if the post has a custom excerpt, false otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   451
function has_excerpt( $post = 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   452
	$post = get_post( $post );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   453
	return ( ! empty( $post->post_excerpt ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   457
 * Displays the classes for the post container element.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   461
 * @param string|string[] $css_class Optional. One or more classes to add to the class list.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   462
 *                                   Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   463
 * @param int|WP_Post     $post      Optional. Post ID or post object. Defaults to the global `$post`.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   465
function post_class( $css_class = '', $post = null ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   466
	// Separates classes with a single space, collates classes for post DIV.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   467
	echo 'class="' . esc_attr( implode( ' ', get_post_class( $css_class, $post ) ) ) . '"';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   471
 * Retrieves an array of the class names for the post container element.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   473
 * The class names are many:
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   474
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   475
 *  - If the post has a post thumbnail, `has-post-thumbnail` is added as a class.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   476
 *  - If the post is sticky, then the `sticky` class name is added.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   477
 *  - The class `hentry` is always added to each post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   478
 *  - For each taxonomy that the post belongs to, a class will be added of the format
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   479
 *    `{$taxonomy}-{$slug}`, e.g. `category-foo` or `my_custom_taxonomy-bar`.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   480
 *    The `post_tag` taxonomy is a special case; the class has the `tag-` prefix
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   481
 *    instead of `post_tag-`.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   482
 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   483
 * All class names are passed through the filter, {@see 'post_class'}, followed by
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   484
 * `$css_class` parameter value, with the post ID as the last parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
 * @since 2.7.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   487
 * @since 4.2.0 Custom taxonomy class names were added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   489
 * @param string|string[] $css_class Optional. Space-separated string or array of class names
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   490
 *                                   to add to the class list. Default empty.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   491
 * @param int|WP_Post     $post      Optional. Post ID or post object.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   492
 * @return string[] Array of class names.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   494
function get_post_class( $css_class = '', $post = null ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   495
	$post = get_post( $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
	$classes = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   499
	if ( $css_class ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   500
		if ( ! is_array( $css_class ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   501
			$css_class = preg_split( '#\s+#', $css_class );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   502
		}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   503
		$classes = array_map( 'esc_attr', $css_class );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   504
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   505
		// Ensure that we always coerce class to being an array.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   506
		$css_class = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   507
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   508
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   509
	if ( ! $post ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
		return $classes;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   511
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
	$classes[] = 'post-' . $post->ID;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   514
	if ( ! is_admin() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
		$classes[] = $post->post_type;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   516
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
	$classes[] = 'type-' . $post->post_type;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
	$classes[] = 'status-' . $post->post_status;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   520
	// Post Format.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
	if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
		$post_format = get_post_format( $post->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   524
		if ( $post_format && ! is_wp_error( $post_format ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
			$classes[] = 'format-' . sanitize_html_class( $post_format );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   526
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
			$classes[] = 'format-standard';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   528
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   531
	$post_password_required = post_password_required( $post->ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   532
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   533
	// Post requires password.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   534
	if ( $post_password_required ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
		$classes[] = 'post-password-required';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   536
	} elseif ( ! empty( $post->post_password ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   537
		$classes[] = 'post-password-protected';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   538
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   539
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   540
	// Post thumbnails.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   541
	if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   542
		$classes[] = 'has-post-thumbnail';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   543
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   544
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   545
	// Sticky for Sticky Posts.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   546
	if ( is_sticky( $post->ID ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   547
		if ( is_home() && ! is_paged() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   548
			$classes[] = 'sticky';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   549
		} elseif ( is_admin() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   550
			$classes[] = 'status-sticky';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   551
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   552
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   554
	// hentry for hAtom compliance.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
	$classes[] = 'hentry';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   557
	// All public taxonomies.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   558
	$taxonomies = get_taxonomies( array( 'public' => true ) );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   559
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   560
	/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   561
	 * Filters the taxonomies to generate classes for each individual term.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   562
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   563
	 * Default is all public taxonomies registered to the post type.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   564
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   565
	 * @since 6.1.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   566
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   567
	 * @param string[] $taxonomies List of all taxonomy names to generate classes for.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   568
	 * @param int      $post_id    The post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   569
	 * @param string[] $classes    An array of post class names.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   570
	 * @param string[] $css_class  An array of additional class names added to the post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   571
	*/
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   572
	$taxonomies = apply_filters( 'post_class_taxonomies', $taxonomies, $post->ID, $classes, $css_class );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   573
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   574
	foreach ( (array) $taxonomies as $taxonomy ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   575
		if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   576
			foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   577
				if ( empty( $term->slug ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   578
					continue;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   579
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   580
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   581
				$term_class = sanitize_html_class( $term->slug, $term->term_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   582
				if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   583
					$term_class = $term->term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   584
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   585
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   586
				// 'post_tag' uses the 'tag' prefix for backward compatibility.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   587
				if ( 'post_tag' === $taxonomy ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   588
					$classes[] = 'tag-' . $term_class;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   589
				} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   590
					$classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   591
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   592
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   594
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   595
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
	$classes = array_map( 'esc_attr', $classes );
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
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   599
	 * Filters the list of CSS class names for the current post.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   602
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   603
	 * @param string[] $classes   An array of post class names.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   604
	 * @param string[] $css_class An array of additional class names added to the post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   605
	 * @param int      $post_id   The post ID.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   606
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   607
	$classes = apply_filters( 'post_class', $classes, $css_class, $post->ID );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   609
	return array_unique( $classes );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   610
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   611
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   612
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   613
 * Displays the class names for the body element.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   614
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   615
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   616
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   617
 * @param string|string[] $css_class Optional. Space-separated string or array of class names
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   618
 *                                   to add to the class list. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   619
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   620
function body_class( $css_class = '' ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   621
	// Separates class names with a single space, collates class names for body element.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   622
	echo 'class="' . esc_attr( implode( ' ', get_body_class( $css_class ) ) ) . '"';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   623
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   626
 * Retrieves an array of the class names for the body element.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   627
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   628
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   629
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   630
 * @global WP_Query $wp_query WordPress Query object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   631
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   632
 * @param string|string[] $css_class Optional. Space-separated string or array of class names
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   633
 *                                   to add to the class list. Default empty.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   634
 * @return string[] Array of class names.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   635
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   636
function get_body_class( $css_class = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   637
	global $wp_query;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   638
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   639
	$classes = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   640
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   641
	if ( is_rtl() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   642
		$classes[] = 'rtl';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   643
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   645
	if ( is_front_page() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   646
		$classes[] = 'home';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   647
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   648
	if ( is_home() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   649
		$classes[] = 'blog';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   650
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   651
	if ( is_privacy_policy() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   652
		$classes[] = 'privacy-policy';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   653
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   654
	if ( is_archive() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
		$classes[] = 'archive';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   656
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   657
	if ( is_date() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
		$classes[] = 'date';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   659
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   660
	if ( is_search() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   661
		$classes[] = 'search';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   662
		$classes[] = $wp_query->posts ? 'search-results' : 'search-no-results';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   663
	}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   664
	if ( is_paged() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
		$classes[] = 'paged';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   666
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   667
	if ( is_attachment() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
		$classes[] = 'attachment';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   669
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   670
	if ( is_404() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   671
		$classes[] = 'error404';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   672
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   673
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   674
	if ( is_singular() ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   675
		$post      = $wp_query->get_queried_object();
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   676
		$post_id   = $post->ID;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   677
		$post_type = $post->post_type;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   679
		$classes[] = 'wp-singular';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   680
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   681
		if ( is_page_template() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   682
			$classes[] = "{$post_type}-template";
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   683
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   684
			$template_slug  = get_page_template_slug( $post_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   685
			$template_parts = explode( '/', $template_slug );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   686
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   687
			foreach ( $template_parts as $part ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   688
				$classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( array( '.', '/' ), '-', basename( $part, '.php' ) ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   689
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   690
			$classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( '.', '-', $template_slug ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   691
		} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   692
			$classes[] = "{$post_type}-template-default";
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   693
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   695
		if ( is_single() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   696
			$classes[] = 'single';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   697
			if ( isset( $post->post_type ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   698
				$classes[] = 'single-' . sanitize_html_class( $post->post_type, $post_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   699
				$classes[] = 'postid-' . $post_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   701
				// Post Format.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   702
				if ( post_type_supports( $post->post_type, 'post-formats' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   703
					$post_format = get_post_format( $post->ID );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   704
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   705
					if ( $post_format && ! is_wp_error( $post_format ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   706
						$classes[] = 'single-format-' . sanitize_html_class( $post_format );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   707
					} else {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   708
						$classes[] = 'single-format-standard';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   709
					}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   710
				}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
		if ( is_attachment() ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   715
			$mime_type   = get_post_mime_type( $post_id );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
			$mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   717
			$classes[]   = 'attachmentid-' . $post_id;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   718
			$classes[]   = 'attachment-' . str_replace( $mime_prefix, '', $mime_type );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   719
		} elseif ( is_page() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   720
			$classes[] = 'page';
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   721
			$classes[] = 'page-id-' . $post_id;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   722
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   723
			if ( get_pages(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   724
				array(
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   725
					'parent' => $post_id,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   726
					'number' => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   727
				)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   728
			) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   729
				$classes[] = 'page-parent';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   730
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   731
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   732
			if ( $post->post_parent ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   733
				$classes[] = 'page-child';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   734
				$classes[] = 'parent-pageid-' . $post->post_parent;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   735
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
	} elseif ( is_archive() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
		if ( is_post_type_archive() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   739
			$classes[] = 'post-type-archive';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
			$post_type = get_query_var( 'post_type' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   741
			if ( is_array( $post_type ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
				$post_type = reset( $post_type );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   743
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
			$classes[] = 'post-type-archive-' . sanitize_html_class( $post_type );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   745
		} elseif ( is_author() ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   746
			$author    = $wp_query->get_queried_object();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
			$classes[] = 'author';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   748
			if ( isset( $author->user_nicename ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   749
				$classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   750
				$classes[] = 'author-' . $author->ID;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   752
		} elseif ( is_category() ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   753
			$cat       = $wp_query->get_queried_object();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   754
			$classes[] = 'category';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   755
			if ( isset( $cat->term_id ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   756
				$cat_class = sanitize_html_class( $cat->slug, $cat->term_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   757
				if ( is_numeric( $cat_class ) || ! trim( $cat_class, '-' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   758
					$cat_class = $cat->term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   759
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   760
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   761
				$classes[] = 'category-' . $cat_class;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
				$classes[] = 'category-' . $cat->term_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   763
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
		} elseif ( is_tag() ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   765
			$tag       = $wp_query->get_queried_object();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
			$classes[] = 'tag';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   767
			if ( isset( $tag->term_id ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   768
				$tag_class = sanitize_html_class( $tag->slug, $tag->term_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   769
				if ( is_numeric( $tag_class ) || ! trim( $tag_class, '-' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   770
					$tag_class = $tag->term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   771
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   772
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   773
				$classes[] = 'tag-' . $tag_class;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   774
				$classes[] = 'tag-' . $tag->term_id;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
		} elseif ( is_tax() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
			$term = $wp_query->get_queried_object();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
			if ( isset( $term->term_id ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   779
				$term_class = sanitize_html_class( $term->slug, $term->term_id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   780
				if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   781
					$term_class = $term->term_id;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   782
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   783
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
				$classes[] = 'tax-' . sanitize_html_class( $term->taxonomy );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   785
				$classes[] = 'term-' . $term_class;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
				$classes[] = 'term-' . $term->term_id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   789
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   790
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   791
	if ( is_user_logged_in() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
		$classes[] = 'logged-in';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   793
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   794
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   795
	if ( is_admin_bar_showing() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   796
		$classes[] = 'admin-bar';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
		$classes[] = 'no-customize-support';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   798
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   800
	if ( current_theme_supports( 'custom-background' )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   801
		&& ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
		$classes[] = 'custom-background';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   803
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   805
	if ( has_custom_logo() ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   806
		$classes[] = 'wp-custom-logo';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   807
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   808
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   809
	if ( current_theme_supports( 'responsive-embeds' ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   810
		$classes[] = 'wp-embed-responsive';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   811
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   812
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   813
	$page = $wp_query->get( 'page' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   815
	if ( ! $page || $page < 2 ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
		$page = $wp_query->get( 'paged' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   817
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   819
	if ( $page && $page > 1 && ! is_404() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
		$classes[] = 'paged-' . $page;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   822
		if ( is_single() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
			$classes[] = 'single-paged-' . $page;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   824
		} elseif ( is_page() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
			$classes[] = 'page-paged-' . $page;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   826
		} elseif ( is_category() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
			$classes[] = 'category-paged-' . $page;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   828
		} elseif ( is_tag() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   829
			$classes[] = 'tag-paged-' . $page;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   830
		} elseif ( is_date() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   831
			$classes[] = 'date-paged-' . $page;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   832
		} elseif ( is_author() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   833
			$classes[] = 'author-paged-' . $page;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   834
		} elseif ( is_search() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   835
			$classes[] = 'search-paged-' . $page;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   836
		} elseif ( is_post_type_archive() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   837
			$classes[] = 'post-type-paged-' . $page;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   838
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   839
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   840
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   841
	$classes[] = 'wp-theme-' . sanitize_html_class( get_template() );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   842
	if ( is_child_theme() ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   843
		$classes[] = 'wp-child-theme-' . sanitize_html_class( get_stylesheet() );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   844
	}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
   845
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   846
	if ( ! empty( $css_class ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   847
		if ( ! is_array( $css_class ) ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   848
			$css_class = preg_split( '#\s+#', $css_class );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   849
		}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   850
		$classes = array_merge( $classes, $css_class );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   852
		// Ensure that we always coerce class to being an array.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   853
		$css_class = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   854
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   856
	$classes = array_map( 'esc_attr', $classes );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   858
	/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   859
	 * Filters the list of CSS body class names for the current post or page.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   860
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   861
	 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   862
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   863
	 * @param string[] $classes   An array of body class names.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   864
	 * @param string[] $css_class An array of additional class names added to the body.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   865
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   866
	$classes = apply_filters( 'body_class', $classes, $css_class );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   867
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   868
	return array_unique( $classes );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   869
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   870
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   871
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   872
 * Determines whether the post requires password and whether a correct password has been provided.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   873
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   874
 * @since 2.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   875
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   876
 * @param int|WP_Post|null $post An optional post. Global $post used if not provided.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
 * @return bool false if a password is not required or the correct password cookie is present, true otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   878
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
function post_password_required( $post = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   880
	$post = get_post( $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   882
	if ( empty( $post->post_password ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   883
		/** This filter is documented in wp-includes/post-template.php */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   884
		return apply_filters( 'post_password_required', false, $post );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   885
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   886
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   887
	if ( ! isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   888
		/** This filter is documented in wp-includes/post-template.php */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   889
		return apply_filters( 'post_password_required', true, $post );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   890
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   891
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   892
	require_once ABSPATH . WPINC . '/class-phpass.php';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   893
	$hasher = new PasswordHash( 8, true );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   894
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   895
	$hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   896
	if ( ! str_starts_with( $hash, '$P$B' ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   897
		$required = true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   898
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   899
		$required = ! $hasher->CheckPassword( $post->post_password, $hash );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   900
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   901
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   902
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   903
	 * Filters whether a post requires the user to supply a password.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   904
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   905
	 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   906
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   907
	 * @param bool    $required Whether the user needs to supply a password. True if password has not been
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   908
	 *                          provided or is incorrect, false if password has been supplied or is not required.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   909
	 * @param WP_Post $post     Post object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   910
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   911
	return apply_filters( 'post_password_required', $required, $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   912
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   913
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   914
//
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   915
// Page Template Functions for usage in Themes.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   916
//
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   918
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   919
 * The formatted output of a list of pages.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   921
 * Displays page links for paginated posts (i.e. including the `<!--nextpage-->`
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
 * Quicktag one or more times). This tag must be within The Loop.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   923
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   924
 * @since 1.2.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   925
 * @since 5.1.0 Added the `aria_current` argument.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   926
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   927
 * @global int $page
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   928
 * @global int $numpages
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   929
 * @global int $multipage
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   930
 * @global int $more
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   931
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   932
 * @param string|array $args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   933
 *     Optional. Array or string of default arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   934
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   935
 *     @type string       $before           HTML or text to prepend to each link. Default is `<p> Pages:`.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   936
 *     @type string       $after            HTML or text to append to each link. Default is `</p>`.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   937
 *     @type string       $link_before      HTML or text to prepend to each link, inside the `<a>` tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   938
 *                                          Also prepended to the current item, which is not linked. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   939
 *     @type string       $link_after       HTML or text to append to each Pages link inside the `<a>` tag.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   940
 *                                          Also appended to the current item, which is not linked. Default empty.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   941
 *     @type string       $aria_current     The value for the aria-current attribute. Possible values are 'page',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   942
 *                                          'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   943
 *     @type string       $next_or_number   Indicates whether page numbers should be used. Valid values are number
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   944
 *                                          and next. Default is 'number'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   945
 *     @type string       $separator        Text between pagination links. Default is ' '.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   946
 *     @type string       $nextpagelink     Link text for the next page link, if available. Default is 'Next Page'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   947
 *     @type string       $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   948
 *     @type string       $pagelink         Format string for page numbers. The % in the parameter string will be
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   949
 *                                          replaced with the page number, so 'Page %' generates "Page 1", "Page 2", etc.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   950
 *                                          Defaults to '%', just the page number.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   951
 *     @type int|bool     $echo             Whether to echo or not. Accepts 1|true or 0|false. Default 1|true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   952
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
 * @return string Formatted output in HTML.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
function wp_link_pages( $args = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   956
	global $page, $numpages, $multipage, $more;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   957
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   958
	$defaults = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   959
		'before'           => '<p class="post-nav-links">' . __( 'Pages:' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   960
		'after'            => '</p>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
		'link_before'      => '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   962
		'link_after'       => '',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   963
		'aria_current'     => 'page',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   964
		'next_or_number'   => 'number',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   965
		'separator'        => ' ',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
		'nextpagelink'     => __( 'Next page' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   967
		'previouspagelink' => __( 'Previous page' ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   968
		'pagelink'         => '%',
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   969
		'echo'             => 1,
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
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   972
	$parsed_args = wp_parse_args( $args, $defaults );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   973
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   974
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   975
	 * Filters the arguments used in retrieving page links for paginated posts.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   976
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   977
	 * @since 3.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   978
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   979
	 * @param array $parsed_args An array of page link arguments. See wp_link_pages()
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   980
	 *                           for information on accepted arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   981
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   982
	$parsed_args = apply_filters( 'wp_link_pages_args', $parsed_args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   984
	$output = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   985
	if ( $multipage ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   986
		if ( 'number' === $parsed_args['next_or_number'] ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   987
			$output .= $parsed_args['before'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
			for ( $i = 1; $i <= $numpages; $i++ ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   989
				$link = $parsed_args['link_before'] . str_replace( '%', $i, $parsed_args['pagelink'] ) . $parsed_args['link_after'];
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   990
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   991
				if ( $i !== $page || ! $more && 1 === $page ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   992
					$link = _wp_link_page( $i ) . $link . '</a>';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   993
				} elseif ( $i === $page ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   994
					$link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $parsed_args['aria_current'] ) . '">' . $link . '</span>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   995
				}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
   996
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   997
				/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   998
				 * Filters the HTML output of individual page number links.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   999
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1000
				 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1001
				 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1002
				 * @param string $link The page number HTML output.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1003
				 * @param int    $i    Page number for paginated posts' page links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1004
				 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1005
				$link = apply_filters( 'wp_link_pages_link', $link, $i );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1006
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1007
				// Use the custom links separator beginning with the second link.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1008
				$output .= ( 1 === $i ) ? ' ' : $parsed_args['separator'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1009
				$output .= $link;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1010
			}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1011
			$output .= $parsed_args['after'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1012
		} elseif ( $more ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1013
			$output .= $parsed_args['before'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1014
			$prev    = $page - 1;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1015
			if ( $prev > 0 ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1016
				$link = _wp_link_page( $prev ) . $parsed_args['link_before'] . $parsed_args['previouspagelink'] . $parsed_args['link_after'] . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1017
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1018
				/** This filter is documented in wp-includes/post-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1019
				$output .= apply_filters( 'wp_link_pages_link', $link, $prev );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1020
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1021
			$next = $page + 1;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1022
			if ( $next <= $numpages ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1023
				if ( $prev ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1024
					$output .= $parsed_args['separator'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1025
				}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1026
				$link = _wp_link_page( $next ) . $parsed_args['link_before'] . $parsed_args['nextpagelink'] . $parsed_args['link_after'] . '</a>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1027
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1028
				/** This filter is documented in wp-includes/post-template.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1029
				$output .= apply_filters( 'wp_link_pages_link', $link, $next );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1030
			}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1031
			$output .= $parsed_args['after'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1032
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1033
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1034
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1035
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1036
	 * Filters the HTML output of page links for paginated posts.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1037
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1038
	 * @since 3.6.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1039
	 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1040
	 * @param string       $output HTML output of paginated posts' page links.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1041
	 * @param array|string $args   An array or query string of arguments. See wp_link_pages()
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1042
	 *                             for information on accepted arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1043
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1044
	$html = apply_filters( 'wp_link_pages', $output, $args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1045
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1046
	if ( $parsed_args['echo'] ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1047
		echo $html;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1048
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1049
	return $html;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1050
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1051
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1052
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1053
 * Helper function for wp_link_pages().
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1054
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1055
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1056
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1057
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1058
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1059
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1060
 * @param int $i Page number.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1061
 * @return string Link.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1062
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1063
function _wp_link_page( $i ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1064
	global $wp_rewrite;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1065
	$post       = get_post();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1066
	$query_args = array();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1067
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1068
	if ( 1 === $i ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1069
		$url = get_permalink();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1070
	} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1071
		if ( ! get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ), true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1072
			$url = add_query_arg( 'page', $i, get_permalink() );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1073
		} elseif ( '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
  1074
			$url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1075
		} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1076
			$url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1077
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1078
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1079
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1080
	if ( is_preview() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1081
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1082
		if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1083
			$query_args['preview_id']    = wp_unslash( $_GET['preview_id'] );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1084
			$query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1085
		}
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
		$url = get_preview_post_link( $post, $query_args, $url );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1088
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1089
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1090
	return '<a href="' . esc_url( $url ) . '" class="post-page-numbers">';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1091
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1092
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1093
//
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1094
// Post-meta: Custom per-post fields.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1095
//
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1096
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1097
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1098
 * Retrieves post custom meta data field.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1099
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1100
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1101
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1102
 * @param string $key Meta data key name.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1103
 * @return array|string|false Array of values, or single value if only one element exists.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1104
 *                            False if the key does not exist.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1105
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1106
function post_custom( $key = '' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1107
	$custom = get_post_custom();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1108
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1109
	if ( ! isset( $custom[ $key ] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1110
		return false;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1111
	} elseif ( 1 === count( $custom[ $key ] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1112
		return $custom[ $key ][0];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1113
	} else {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1114
		return $custom[ $key ];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1115
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1116
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1117
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1118
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1119
 * Displays a list of post custom fields.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1120
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1121
 * @since 1.2.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1122
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1123
 * @deprecated 6.0.2 Use get_post_meta() to retrieve post meta and render manually.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1124
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1125
function the_meta() {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1126
	_deprecated_function( __FUNCTION__, '6.0.2', 'get_post_meta()' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1127
	$keys = get_post_custom_keys();
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1128
	if ( $keys ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1129
		$li_html = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1130
		foreach ( (array) $keys as $key ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1131
			$keyt = trim( $key );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1132
			if ( is_protected_meta( $keyt, 'post' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1133
				continue;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1134
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1135
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1136
			$values = array_map( 'trim', get_post_custom_values( $key ) );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1137
			$value  = implode( ', ', $values );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1138
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1139
			$html = sprintf(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1140
				"<li><span class='post-meta-key'>%s</span> %s</li>\n",
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1141
				/* translators: %s: Post custom field name. */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1142
				esc_html( sprintf( _x( '%s:', 'Post custom field name' ), $key ) ),
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1143
				esc_html( $value )
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1144
			);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1145
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1146
			/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1147
			 * Filters the HTML output of the li element in the post custom fields list.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1148
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1149
			 * @since 2.2.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1150
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1151
			 * @param string $html  The HTML output for the li element.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1152
			 * @param string $key   Meta key.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1153
			 * @param string $value Meta value.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1154
			 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1155
			$li_html .= apply_filters( 'the_meta_key', $html, $key, $value );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1156
		}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1157
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1158
		if ( $li_html ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1159
			echo "<ul class='post-meta'>\n{$li_html}</ul>\n";
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1160
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1161
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1162
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1163
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1164
//
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1165
// Pages.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1166
//
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1167
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1168
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1169
 * Retrieves or displays a list of pages as a dropdown (select list).
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1170
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1171
 * @since 2.1.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1172
 * @since 4.2.0 The `$value_field` argument was added.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1173
 * @since 4.3.0 The `$class` argument was added.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1174
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1175
 * @see get_pages()
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1176
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1177
 * @param array|string $args {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1178
 *     Optional. Array or string of arguments to generate a page dropdown. See get_pages() for additional arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1179
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1180
 *     @type int          $depth                 Maximum depth. Default 0.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1181
 *     @type int          $child_of              Page ID to retrieve child pages of. Default 0.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1182
 *     @type int|string   $selected              Value of the option that should be selected. Default 0.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1183
 *     @type bool|int     $echo                  Whether to echo or return the generated markup. Accepts 0, 1,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1184
 *                                               or their bool equivalents. Default 1.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1185
 *     @type string       $name                  Value for the 'name' attribute of the select element.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1186
 *                                               Default 'page_id'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1187
 *     @type string       $id                    Value for the 'id' attribute of the select element.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1188
 *     @type string       $class                 Value for the 'class' attribute of the select element. Default: none.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1189
 *                                               Defaults to the value of `$name`.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1190
 *     @type string       $show_option_none      Text to display for showing no pages. Default empty (does not display).
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1191
 *     @type string       $show_option_no_change Text to display for "no change" option. Default empty (does not display).
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1192
 *     @type string       $option_none_value     Value to use when no page is selected. Default empty.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1193
 *     @type string       $value_field           Post field used to populate the 'value' attribute of the option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1194
 *                                               elements. Accepts any valid post field. Default 'ID'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1195
 * }
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1196
 * @return string HTML dropdown list of pages.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1197
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1198
function wp_dropdown_pages( $args = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1199
	$defaults = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1200
		'depth'                 => 0,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1201
		'child_of'              => 0,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1202
		'selected'              => 0,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1203
		'echo'                  => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1204
		'name'                  => 'page_id',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1205
		'id'                    => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1206
		'class'                 => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1207
		'show_option_none'      => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1208
		'show_option_no_change' => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1209
		'option_none_value'     => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1210
		'value_field'           => 'ID',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1211
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1212
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1213
	$parsed_args = wp_parse_args( $args, $defaults );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1214
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1215
	$pages  = get_pages( $parsed_args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1216
	$output = '';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1217
	// Back-compat with old system where both id and name were based on $name argument.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1218
	if ( empty( $parsed_args['id'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1219
		$parsed_args['id'] = $parsed_args['name'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1220
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1221
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1222
	if ( ! empty( $pages ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1223
		$class = '';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1224
		if ( ! empty( $parsed_args['class'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1225
			$class = " class='" . esc_attr( $parsed_args['class'] ) . "'";
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1226
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1227
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1228
		$output = "<select name='" . esc_attr( $parsed_args['name'] ) . "'" . $class . " id='" . esc_attr( $parsed_args['id'] ) . "'>\n";
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1229
		if ( $parsed_args['show_option_no_change'] ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1230
			$output .= "\t<option value=\"-1\">" . $parsed_args['show_option_no_change'] . "</option>\n";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1231
		}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1232
		if ( $parsed_args['show_option_none'] ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1233
			$output .= "\t<option value=\"" . esc_attr( $parsed_args['option_none_value'] ) . '">' . $parsed_args['show_option_none'] . "</option>\n";
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1234
		}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1235
		$output .= walk_page_dropdown_tree( $pages, $parsed_args['depth'], $parsed_args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1236
		$output .= "</select>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1237
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1238
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1239
	/**
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1240
	 * Filters the HTML output of a list of pages as a dropdown.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1241
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1242
	 * @since 2.1.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1243
	 * @since 4.4.0 `$parsed_args` and `$pages` added as arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1244
	 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1245
	 * @param string    $output      HTML output for dropdown list of pages.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1246
	 * @param array     $parsed_args The parsed arguments array. See wp_dropdown_pages()
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1247
	 *                               for information on accepted arguments.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1248
	 * @param WP_Post[] $pages       Array of the page objects.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1249
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1250
	$html = apply_filters( 'wp_dropdown_pages', $output, $parsed_args, $pages );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1251
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1252
	if ( $parsed_args['echo'] ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1253
		echo $html;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1254
	}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1255
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1256
	return $html;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1257
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1258
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1259
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1260
 * Retrieves or displays a list of pages (or hierarchical post type items) in list (li) format.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1261
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1262
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1263
 * @since 4.7.0 Added the `item_spacing` argument.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1264
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1265
 * @see get_pages()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1266
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1267
 * @global WP_Query $wp_query WordPress Query object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1268
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1269
 * @param array|string $args {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1270
 *     Optional. Array or string of arguments to generate a list of pages. See get_pages() for additional arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1271
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1272
 *     @type int          $child_of     Display only the sub-pages of a single page by ID. Default 0 (all pages).
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1273
 *     @type string       $authors      Comma-separated list of author IDs. Default empty (all authors).
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1274
 *     @type string       $date_format  PHP date format to use for the listed pages. Relies on the 'show_date' parameter.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1275
 *                                      Default is the value of 'date_format' option.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1276
 *     @type int          $depth        Number of levels in the hierarchy of pages to include in the generated list.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1277
 *                                      Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1278
 *                                      the given n depth). Default 0.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1279
 *     @type bool         $echo         Whether or not to echo the list of pages. Default true.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1280
 *     @type string       $exclude      Comma-separated list of page IDs to exclude. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1281
 *     @type array        $include      Comma-separated list of page IDs to include. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1282
 *     @type string       $link_after   Text or HTML to follow the page link label. Default null.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1283
 *     @type string       $link_before  Text or HTML to precede the page link label. Default null.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1284
 *     @type string       $post_type    Post type to query for. Default 'page'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1285
 *     @type string|array $post_status  Comma-separated list or array of post statuses to include. Default 'publish'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1286
 *     @type string       $show_date    Whether to display the page publish or modified date for each page. Accepts
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1287
 *                                      'modified' or any other value. An empty value hides the date. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1288
 *     @type string       $sort_column  Comma-separated list of column names to sort the pages by. Accepts 'post_author',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1289
 *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1290
 *                                      'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1291
 *     @type string       $title_li     List heading. Passing a null or empty value will result in no heading, and the list
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1292
 *                                      will not be wrapped with unordered list `<ul>` tags. Default 'Pages'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1293
 *     @type string       $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1294
 *                                      Default 'preserve'.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1295
 *     @type Walker       $walker       Walker instance to use for listing pages. Default empty which results in a
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1296
 *                                      Walker_Page instance being used.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1297
 * }
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1298
 * @return void|string Void if 'echo' argument is true, HTML list of pages if 'echo' is false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1299
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1300
function wp_list_pages( $args = '' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1301
	$defaults = array(
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1302
		'depth'        => 0,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1303
		'show_date'    => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1304
		'date_format'  => get_option( 'date_format' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1305
		'child_of'     => 0,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1306
		'exclude'      => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1307
		'title_li'     => __( 'Pages' ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1308
		'echo'         => 1,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1309
		'authors'      => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1310
		'sort_column'  => 'menu_order, post_title',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1311
		'link_before'  => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1312
		'link_after'   => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1313
		'item_spacing' => 'preserve',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1314
		'walker'       => '',
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1315
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1316
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1317
	$parsed_args = wp_parse_args( $args, $defaults );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1318
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1319
	if ( ! in_array( $parsed_args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1320
		// Invalid value, fall back to default.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1321
		$parsed_args['item_spacing'] = $defaults['item_spacing'];
7
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
	$output       = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1325
	$current_page = 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1327
	// Sanitize, mostly to keep spaces out.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1328
	$parsed_args['exclude'] = preg_replace( '/[^0-9,]/', '', $parsed_args['exclude'] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1330
	// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array).
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1331
	$exclude_array = ( $parsed_args['exclude'] ) ? explode( ',', $parsed_args['exclude'] ) : array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1332
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1333
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1334
	 * Filters the array of pages to exclude from the pages list.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1335
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1336
	 * @since 2.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1337
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1338
	 * @param string[] $exclude_array An array of page IDs to exclude.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1339
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1340
	$parsed_args['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1341
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1342
	$parsed_args['hierarchical'] = 0;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1343
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1344
	// Query pages.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1345
	$pages = get_pages( $parsed_args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1346
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1347
	if ( ! empty( $pages ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1348
		if ( $parsed_args['title_li'] ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1349
			$output .= '<li class="pagenav">' . $parsed_args['title_li'] . '<ul>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1350
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1351
		global $wp_query;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1352
		if ( is_page() || is_attachment() || $wp_query->is_posts_page ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1353
			$current_page = get_queried_object_id();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1354
		} elseif ( is_singular() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1355
			$queried_object = get_queried_object();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1356
			if ( is_post_type_hierarchical( $queried_object->post_type ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1357
				$current_page = $queried_object->ID;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1358
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1359
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1361
		$output .= walk_page_tree( $pages, $parsed_args['depth'], $current_page, $parsed_args );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1362
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1363
		if ( $parsed_args['title_li'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1364
			$output .= '</ul></li>';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1365
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1366
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1367
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1368
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1369
	 * Filters the HTML output of the pages to list.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1370
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1371
	 * @since 1.5.1
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1372
	 * @since 4.4.0 `$pages` added as arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1373
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1374
	 * @see wp_list_pages()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1375
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1376
	 * @param string    $output      HTML output of the pages list.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1377
	 * @param array     $parsed_args An array of page-listing arguments. See wp_list_pages()
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1378
	 *                               for information on accepted arguments.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1379
	 * @param WP_Post[] $pages       Array of the page objects.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1380
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1381
	$html = apply_filters( 'wp_list_pages', $output, $parsed_args, $pages );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1382
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1383
	if ( $parsed_args['echo'] ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1384
		echo $html;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1385
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1386
		return $html;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1387
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1388
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1389
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1390
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1391
 * Displays or retrieves a list of pages with an optional home link.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1392
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1393
 * The arguments are listed below and part of the arguments are for wp_list_pages() function.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1394
 * Check that function for more info on those arguments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1395
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1396
 * @since 2.7.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1397
 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1398
 * @since 4.7.0 Added the `item_spacing` argument.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1399
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1400
 * @param array|string $args {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1401
 *     Optional. Array or string of arguments to generate a page menu. See wp_list_pages() for additional arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1402
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1403
 *     @type string          $sort_column  How to sort the list of pages. Accepts post column names.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1404
 *                                         Default 'menu_order, post_title'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1405
 *     @type string          $menu_id      ID for the div containing the page list. Default is empty string.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1406
 *     @type string          $menu_class   Class to use for the element containing the page list. Default 'menu'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1407
 *     @type string          $container    Element to use for the element containing the page list. Default 'div'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1408
 *     @type bool            $echo         Whether to echo the list or return it. Accepts true (echo) or false (return).
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1409
 *                                         Default true.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1410
 *     @type int|bool|string $show_home    Whether to display the link to the home page. Can just enter the text
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1411
 *                                         you'd like shown for the home link. 1|true defaults to 'Home'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1412
 *     @type string          $link_before  The HTML or text to prepend to $show_home text. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1413
 *     @type string          $link_after   The HTML or text to append to $show_home text. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1414
 *     @type string          $before       The HTML or text to prepend to the menu. Default is '<ul>'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1415
 *     @type string          $after        The HTML or text to append to the menu. Default is '</ul>'.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1416
 *     @type string          $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve'
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1417
 *                                         or 'discard'. Default 'discard'.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1418
 *     @type Walker          $walker       Walker instance to use for listing pages. Default empty which results in a
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1419
 *                                         Walker_Page instance being used.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1420
 * }
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1421
 * @return void|string Void if 'echo' argument is true, HTML menu if 'echo' is false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1422
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1423
function wp_page_menu( $args = array() ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1424
	$defaults = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1425
		'sort_column'  => 'menu_order, post_title',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1426
		'menu_id'      => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1427
		'menu_class'   => 'menu',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1428
		'container'    => 'div',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1429
		'echo'         => true,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1430
		'link_before'  => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1431
		'link_after'   => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1432
		'before'       => '<ul>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1433
		'after'        => '</ul>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1434
		'item_spacing' => 'discard',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1435
		'walker'       => '',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1436
	);
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1437
	$args     = wp_parse_args( $args, $defaults );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1438
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1439
	if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ), true ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1440
		// Invalid value, fall back to default.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1441
		$args['item_spacing'] = $defaults['item_spacing'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1442
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1443
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1444
	if ( 'preserve' === $args['item_spacing'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1445
		$t = "\t";
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1446
		$n = "\n";
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1447
	} else {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1448
		$t = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1449
		$n = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1450
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1451
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1452
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1453
	 * Filters the arguments used to generate a page-based menu.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1454
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1455
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1456
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1457
	 * @see wp_page_menu()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1458
	 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1459
	 * @param array $args An array of page menu arguments. See wp_page_menu()
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1460
	 *                    for information on accepted arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1461
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
	$args = apply_filters( 'wp_page_menu_args', $args );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1464
	$menu = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1465
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1466
	$list_args = $args;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1468
	// Show Home in the menu.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1469
	if ( ! empty( $args['show_home'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1470
		if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1471
			$text = __( 'Home' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1472
		} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1473
			$text = $args['show_home'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1474
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1475
		$class = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1476
		if ( is_front_page() && ! is_paged() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
			$class = 'class="current_page_item"';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1478
		}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1479
		$menu .= '<li ' . $class . '><a href="' . esc_url( home_url( '/' ) ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1480
		// If the front page is a page, add it to the exclude list.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1481
		if ( 'page' === get_option( 'show_on_front' ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1482
			if ( ! empty( $list_args['exclude'] ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1483
				$list_args['exclude'] .= ',';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1484
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1485
				$list_args['exclude'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1486
			}
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1487
			$list_args['exclude'] .= get_option( 'page_on_front' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1488
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1489
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1490
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1491
	$list_args['echo']     = false;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1492
	$list_args['title_li'] = '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1493
	$menu                 .= wp_list_pages( $list_args );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1494
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1495
	$container = sanitize_text_field( $args['container'] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1496
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1497
	// Fallback in case `wp_nav_menu()` was called without a container.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1498
	if ( empty( $container ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1499
		$container = 'div';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1500
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1501
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1502
	if ( $menu ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1503
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1504
		// wp_nav_menu() doesn't set before and after.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1505
		if ( isset( $args['fallback_cb'] ) &&
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1506
			'wp_page_menu' === $args['fallback_cb'] &&
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1507
			'ul' !== $container ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1508
			$args['before'] = "<ul>{$n}";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1509
			$args['after']  = '</ul>';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1510
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1511
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1512
		$menu = $args['before'] . $menu . $args['after'];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1513
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1514
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1515
	$attrs = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1516
	if ( ! empty( $args['menu_id'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1517
		$attrs .= ' id="' . esc_attr( $args['menu_id'] ) . '"';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1518
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1519
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1520
	if ( ! empty( $args['menu_class'] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1521
		$attrs .= ' class="' . esc_attr( $args['menu_class'] ) . '"';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1522
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1523
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1524
	$menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}";
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
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1527
	 * Filters the HTML output of a page-based menu.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1528
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1529
	 * @since 2.7.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1530
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1531
	 * @see wp_page_menu()
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
	 * @param string $menu The HTML output.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1534
	 * @param array  $args An array of arguments. See wp_page_menu()
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1535
	 *                     for information on accepted arguments.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1536
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1537
	$menu = apply_filters( 'wp_page_menu', $menu, $args );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1538
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1539
	if ( $args['echo'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1540
		echo $menu;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1541
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1542
		return $menu;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1543
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1544
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1545
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1546
//
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1547
// Page helpers.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1548
//
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1549
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1550
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1551
 * Retrieves HTML list content for page list.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1552
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1553
 * @uses Walker_Page to create HTML list content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1554
 * @since 2.1.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1555
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1556
 * @param array $pages
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1557
 * @param int   $depth
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1558
 * @param int   $current_page
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1559
 * @param array $args
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1560
 * @return string
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1561
 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1562
function walk_page_tree( $pages, $depth, $current_page, $args ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1563
	if ( empty( $args['walker'] ) ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1564
		$walker = new Walker_Page();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1565
	} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1566
		/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1567
		 * @var Walker $walker
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1568
		 */
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1569
		$walker = $args['walker'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1570
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1571
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1572
	foreach ( (array) $pages as $page ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1573
		if ( $page->post_parent ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1574
			$args['pages_with_children'][ $page->post_parent ] = true;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1575
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1576
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1577
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1578
	return $walker->walk( $pages, $depth, $args, $current_page );
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
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1581
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1582
 * Retrieves HTML dropdown (select) content for page list.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1583
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1584
 * @since 2.1.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1585
 * @since 5.3.0 Formalized the existing `...$args` parameter by adding it
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1586
 *              to the function signature.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1587
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1588
 * @uses Walker_PageDropdown to create HTML dropdown content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1589
 * @see Walker_PageDropdown::walk() for parameters and return description.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1590
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1591
 * @param mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1592
 * @return string
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1593
 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1594
function walk_page_dropdown_tree( ...$args ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1595
	if ( empty( $args[2]['walker'] ) ) { // The user's options are the third parameter.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1596
		$walker = new Walker_PageDropdown();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1597
	} else {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1598
		/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1599
		 * @var Walker $walker
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1600
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1601
		$walker = $args[2]['walker'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1602
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1603
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1604
	return $walker->walk( ...$args );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1605
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1606
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1607
//
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1608
// Attachments.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1609
//
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1610
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1611
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1612
 * Displays an attachment page link using an image or icon.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1613
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1614
 * @since 2.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1615
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1616
 * @param int|WP_Post $post       Optional. Post ID or post object.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1617
 * @param bool        $fullsize   Optional. Whether to use full size. Default false.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1618
 * @param bool        $deprecated Deprecated. Not used.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1619
 * @param bool        $permalink Optional. Whether to include permalink. Default false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1620
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1621
function the_attachment_link( $post = 0, $fullsize = false, $deprecated = false, $permalink = false ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1622
	if ( ! empty( $deprecated ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1623
		_deprecated_argument( __FUNCTION__, '2.5.0' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1624
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1625
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1626
	if ( $fullsize ) {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1627
		echo wp_get_attachment_link( $post, 'full', $permalink );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1628
	} else {
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1629
		echo wp_get_attachment_link( $post, 'thumbnail', $permalink );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1630
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1631
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1632
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1633
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1634
 * Retrieves an attachment page link using an image or icon, if possible.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1635
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1636
 * @since 2.5.0
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1637
 * @since 4.4.0 The `$post` parameter can now accept either a post ID or `WP_Post` object.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1638
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1639
 * @param int|WP_Post  $post      Optional. Post ID or post object.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1640
 * @param string|int[] $size      Optional. Image size. Accepts any registered image size name, or an array
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1641
 *                                of width and height values in pixels (in that order). Default 'thumbnail'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1642
 * @param bool         $permalink Optional. Whether to add permalink to image. Default false.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1643
 * @param bool         $icon      Optional. Whether the attachment is an icon. Default false.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1644
 * @param string|false $text      Optional. Link text to use. Activated by passing a string, false otherwise.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1645
 *                                Default false.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1646
 * @param array|string $attr      Optional. Array or string of attributes. Default empty.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1647
 * @return string HTML content.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1648
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1649
function wp_get_attachment_link( $post = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1650
	$_post = get_post( $post );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1651
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1652
	if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! wp_get_attachment_url( $_post->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1653
		return __( 'Missing Attachment' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1654
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1655
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1656
	$url = wp_get_attachment_url( $_post->ID );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1657
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1658
	if ( $permalink ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1659
		$url = get_attachment_link( $_post->ID );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1660
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1661
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1662
	if ( $text ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1663
		$link_text = $text;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1664
	} elseif ( $size && 'none' !== $size ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1665
		$link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1666
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1667
		$link_text = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1668
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1669
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1670
	if ( '' === trim( $link_text ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1671
		$link_text = $_post->post_title;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1672
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1673
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1674
	if ( '' === trim( $link_text ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1675
		$link_text = esc_html( pathinfo( get_attached_file( $_post->ID ), PATHINFO_FILENAME ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1676
	}
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1677
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1678
	/**
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1679
	 * Filters the list of attachment link attributes.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1680
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1681
	 * @since 6.2.0
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1682
	 *
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1683
	 * @param array $attributes An array of attributes for the link markup,
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1684
	 *                          keyed on the attribute name.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1685
	 * @param int   $id         Post ID.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1686
	 */
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1687
	$attributes = apply_filters( 'wp_get_attachment_link_attributes', array( 'href' => $url ), $_post->ID );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1688
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1689
	$link_attributes = '';
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1690
	foreach ( $attributes as $name => $value ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1691
		$value            = 'href' === $name ? esc_url( $value ) : esc_attr( $value );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1692
		$link_attributes .= ' ' . esc_attr( $name ) . "='" . $value . "'";
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1693
	}
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1694
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1695
	$link_html = "<a$link_attributes>$link_text</a>";
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1696
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1697
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1698
	 * Filters a retrieved attachment page link.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1699
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1700
	 * @since 2.7.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1701
	 * @since 5.1.0 Added the `$attr` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1702
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1703
	 * @param string       $link_html The page link HTML output.
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1704
	 * @param int|WP_Post  $post      Post ID or object. Can be 0 for the current global post.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1705
	 * @param string|int[] $size      Requested image size. Can be any registered image size name, or
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1706
	 *                                an array of width and height values in pixels (in that order).
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1707
	 * @param bool         $permalink Whether to add permalink to image. Default false.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1708
	 * @param bool         $icon      Whether to include an icon.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1709
	 * @param string|false $text      If string, will be link text.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1710
	 * @param array|string $attr      Array or string of attributes.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1711
	 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1712
	return apply_filters( 'wp_get_attachment_link', $link_html, $post, $size, $permalink, $icon, $text, $attr );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1713
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1714
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1715
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1716
 * Wraps attachment in paragraph tag before content.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1717
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1718
 * @since 2.0.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
 * @param string $content
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1721
 * @return string
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1722
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1723
function prepend_attachment( $content ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1724
	$post = get_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1725
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1726
	if ( empty( $post->post_type ) || 'attachment' !== $post->post_type ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1727
		return $content;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1728
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1729
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1730
	if ( wp_attachment_is( 'video', $post ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1731
		$meta = wp_get_attachment_metadata( get_the_ID() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1732
		$atts = array( 'src' => wp_get_attachment_url() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1733
		if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1734
			$atts['width']  = (int) $meta['width'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1735
			$atts['height'] = (int) $meta['height'];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1736
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1737
		if ( has_post_thumbnail() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1738
			$atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1739
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1740
		$p = wp_video_shortcode( $atts );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1741
	} elseif ( wp_attachment_is( 'audio', $post ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1742
		$p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1743
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1744
		$p = '<p class="attachment">';
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1745
		// Show the medium sized image representation of the attachment if available, and link to the raw file.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1746
		$p .= wp_get_attachment_link( 0, 'medium', false );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1747
		$p .= '</p>';
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
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1750
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1751
	 * Filters the attachment markup to be prepended to the post content.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1752
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1753
	 * @since 2.0.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1754
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1755
	 * @see prepend_attachment()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1756
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1757
	 * @param string $p The attachment HTML output.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1758
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1759
	$p = apply_filters( 'prepend_attachment', $p );
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
	return "$p\n$content";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1762
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1763
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1764
//
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1765
// Misc.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1766
//
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1767
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1768
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1769
 * Retrieves protected post password form content.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1770
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1771
 * @since 1.0.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1772
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1773
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1774
 * @return string HTML content for password form for password protected post.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1775
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1776
function get_the_password_form( $post = 0 ) {
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1777
	$post                  = get_post( $post );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1778
	$field_id              = 'pwbox-' . ( empty( $post->ID ) ? wp_rand() : $post->ID );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1779
	$invalid_password      = '';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1780
	$invalid_password_html = '';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1781
	$aria                  = '';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1782
	$class                 = '';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1783
	$redirect_field        = '';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1784
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1785
	// If the referrer is the same as the current request, the user has entered an invalid password.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1786
	if ( ! empty( $post->ID ) && wp_get_raw_referer() === get_permalink( $post->ID ) && isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1787
		/**
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1788
		 * Filters the invalid password message shown on password-protected posts.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1789
		 * The filter is only applied if the post is password protected.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1790
		 *
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1791
		 * @since 6.8.0
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1792
		 *
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1793
		 * @param string  $text The message shown to users when entering an invalid password.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1794
		 * @param WP_Post $post Post object.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1795
		 */
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1796
		$invalid_password      = apply_filters( 'the_password_form_incorrect_password', __( 'Invalid password.' ), $post );
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1797
		$invalid_password_html = '<div class="post-password-form-invalid-password" role="alert"><p id="error-' . $field_id . '">' . $invalid_password . '</p></div>';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1798
		$aria                  = ' aria-describedby="error-' . $field_id . '"';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1799
		$class                 = ' password-form-error';
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1800
	}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1801
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1802
	if ( ! empty( $post->ID ) ) {
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1803
		$redirect_field = sprintf(
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1804
			'<input type="hidden" name="redirect_to" value="%s" />',
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1805
			esc_attr( get_permalink( $post->ID ) )
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1806
		);
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1807
	}
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1808
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1809
	$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form' . $class . '" method="post">' . $redirect_field . $invalid_password_html . '
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1810
	<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p>
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1811
	<p><label for="' . $field_id . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $field_id . '" type="password" spellcheck="false" required size="20"' . $aria . ' /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1812
	';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1813
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1814
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1815
	 * Filters the HTML output for the protected post password form.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1816
	 *
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1817
	 * If modifying the password field, please note that the WordPress database schema
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1818
	 * limits the password field to 255 characters regardless of the value of the
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1819
	 * `minlength` or `maxlength` attributes or other validation that may be added to
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1820
	 * the input.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1821
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1822
	 * @since 2.7.0
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1823
	 * @since 5.8.0 Added the `$post` parameter.
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1824
	 * @since 6.8.0 Added the `$invalid_password` parameter.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1825
	 *
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1826
	 * @param string  $output           The password form HTML output.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1827
	 * @param WP_Post $post             Post object.
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1828
	 * @param string  $invalid_password The invalid password message.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1829
	 */
22
8c2e4d02f4ef Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
  1830
	return apply_filters( 'the_password_form', $output, $post, $invalid_password );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1831
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1832
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1833
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1834
 * Determines whether the current post uses a page template.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1835
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1836
 * This template tag allows you to determine if you are in a page template.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1837
 * You can optionally provide a template filename or array of template filenames
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1838
 * and then the check will be specific to that template.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1839
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1840
 * For more information on this and similar theme functions, check out
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1841
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1842
 * Conditional Tags} article in the Theme Developer Handbook.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1843
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1844
 * @since 2.5.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1845
 * @since 4.2.0 The `$template` parameter was changed to also accept an array of page templates.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1846
 * @since 4.7.0 Now works with any post type, not just pages.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1847
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1848
 * @param string|string[] $template The specific template filename or array of templates to match.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1849
 * @return bool True on success, false on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1850
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1851
function is_page_template( $template = '' ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1852
	if ( ! is_singular() ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1853
		return false;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1854
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1855
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1856
	$page_template = get_page_template_slug( get_queried_object_id() );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1857
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1858
	if ( empty( $template ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1859
		return (bool) $page_template;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1860
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1861
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1862
	if ( $template === $page_template ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1863
		return true;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1864
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1865
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1866
	if ( is_array( $template ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1867
		if ( ( in_array( 'default', $template, true ) && ! $page_template )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1868
			|| in_array( $page_template, $template, true )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1869
		) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1870
			return true;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1871
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1872
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1873
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1874
	return ( 'default' === $template && ! $page_template );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1875
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1876
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1877
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1878
 * Gets the specific template filename for a given post.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1879
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1880
 * @since 3.4.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1881
 * @since 4.7.0 Now works with any post type, not just pages.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1882
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1883
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1884
 * @return string|false Page template filename. Returns an empty string when the default page template
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1885
 *                      is in use. Returns false if the post does not exist.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1886
 */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1887
function get_page_template_slug( $post = null ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1888
	$post = get_post( $post );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1889
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1890
	if ( ! $post ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1891
		return false;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1892
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1893
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1894
	$template = get_post_meta( $post->ID, '_wp_page_template', true );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1895
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1896
	if ( ! $template || 'default' === $template ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1897
		return '';
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1898
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1899
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1900
	return $template;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1901
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1902
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1903
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1904
 * Retrieves formatted date timestamp of a revision (linked to that revisions's page).
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1905
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1906
 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1907
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1908
 * @param int|WP_Post $revision Revision ID or revision object.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1909
 * @param bool        $link     Optional. Whether to link to revision's page. Default true.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1910
 * @return string|false i18n formatted datetimestamp or localized 'Current Revision'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1911
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1912
function wp_post_revision_title( $revision, $link = true ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1913
	$revision = get_post( $revision );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1914
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1915
	if ( ! $revision ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1916
		return $revision;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1917
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1918
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1919
	if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1920
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1921
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1922
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1923
	/* translators: Revision date format, see https://www.php.net/manual/datetime.format.php */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1924
	$datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1925
	/* translators: %s: Revision date. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1926
	$autosavef = __( '%s [Autosave]' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1927
	/* translators: %s: Revision date. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1928
	$currentf = __( '%s [Current Revision]' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1929
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1930
	$date      = date_i18n( $datef, strtotime( $revision->post_modified ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1931
	$edit_link = get_edit_post_link( $revision->ID );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1932
	if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1933
		$date = "<a href='$edit_link'>$date</a>";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1934
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1935
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1936
	if ( ! wp_is_post_revision( $revision ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1937
		$date = sprintf( $currentf, $date );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1938
	} elseif ( wp_is_post_autosave( $revision ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1939
		$date = sprintf( $autosavef, $date );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1940
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1941
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1942
	return $date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1943
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1944
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1945
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1946
 * Retrieves formatted date timestamp of a revision (linked to that revisions's page).
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1947
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1948
 * @since 3.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1949
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1950
 * @param int|WP_Post $revision Revision ID or revision object.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1951
 * @param bool        $link     Optional. Whether to link to revision's page. Default true.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1952
 * @return string|false gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1953
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1954
function wp_post_revision_title_expanded( $revision, $link = true ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1955
	$revision = get_post( $revision );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  1956
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1957
	if ( ! $revision ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1958
		return $revision;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1959
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1960
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1961
	if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ), true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1962
		return false;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1963
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1964
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1965
	$author = get_the_author_meta( 'display_name', $revision->post_author );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1966
	/* translators: Revision date format, see https://www.php.net/manual/datetime.format.php */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1967
	$datef = _x( 'F j, Y @ H:i:s', 'revision date format' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1968
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1969
	$gravatar = get_avatar( $revision->post_author, 24 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1970
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1971
	$date      = date_i18n( $datef, strtotime( $revision->post_modified ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1972
	$edit_link = get_edit_post_link( $revision->ID );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1973
	if ( $link && current_user_can( 'edit_post', $revision->ID ) && $edit_link ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1974
		$date = "<a href='$edit_link'>$date</a>";
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1975
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1976
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1977
	$revision_date_author = sprintf(
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1978
		/* translators: Post revision title. 1: Author avatar, 2: Author name, 3: Time ago, 4: Date. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1979
		__( '%1$s %2$s, %3$s ago (%4$s)' ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1980
		$gravatar,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1981
		$author,
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1982
		human_time_diff( strtotime( $revision->post_modified_gmt ) ),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1983
		$date
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1984
	);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1985
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1986
	/* translators: %s: Revision date with author avatar. */
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1987
	$autosavef = __( '%s [Autosave]' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1988
	/* translators: %s: Revision date with author avatar. */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1989
	$currentf = __( '%s [Current Revision]' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1990
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1991
	if ( ! wp_is_post_revision( $revision ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1992
		$revision_date_author = sprintf( $currentf, $revision_date_author );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1993
	} elseif ( wp_is_post_autosave( $revision ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1994
		$revision_date_author = sprintf( $autosavef, $revision_date_author );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1995
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1996
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1997
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1998
	 * Filters the formatted author and date for a revision.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1999
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2000
	 * @since 4.4.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2001
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2002
	 * @param string  $revision_date_author The formatted string.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2003
	 * @param WP_Post $revision             The revision object.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2004
	 * @param bool    $link                 Whether to link to the revisions page, as passed into
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2005
	 *                                      wp_post_revision_title_expanded().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2006
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2007
	return apply_filters( 'wp_post_revision_title_expanded', $revision_date_author, $revision, $link );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2008
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2009
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2010
/**
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  2011
 * Displays a list of a post's revisions.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2012
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2013
 * Can output either a UL with edit links or a TABLE with diff interface, and
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2014
 * restore action links.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2015
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2016
 * @since 2.6.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2017
 *
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2018
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2019
 * @param string      $type 'all' (default), 'revision' or 'autosave'
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2020
 */
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2021
function wp_list_post_revisions( $post = 0, $type = 'all' ) {
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2022
	$post = get_post( $post );
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2023
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2024
	if ( ! $post ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2025
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2026
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2027
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2028
	// $args array with (parent, format, right, left, type) deprecated since 3.6.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2029
	if ( is_array( $type ) ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2030
		$type = ! empty( $type['type'] ) ? $type['type'] : $type;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  2031
		_deprecated_argument( __FUNCTION__, '3.6.0' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2032
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2033
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2034
	$revisions = wp_get_post_revisions( $post->ID );
21
48c4eec2b7e6 Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents: 19
diff changeset
  2035
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  2036
	if ( ! $revisions ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2037
		return;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2038
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2039
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2040
	$rows = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2041
	foreach ( $revisions as $revision ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2042
		if ( ! current_user_can( 'read_post', $revision->ID ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2043
			continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2044
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2045
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2046
		$is_autosave = wp_is_post_autosave( $revision );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2047
		if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2048
			continue;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2049
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2050
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2051
		$rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2052
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2053
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2054
	echo "<div class='hide-if-js'><p>" . __( 'JavaScript must be enabled to use this feature.' ) . "</p></div>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2055
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2056
	echo "<ul class='post-revisions hide-if-no-js'>\n";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2057
	echo $rows;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  2058
	echo '</ul>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  2059
}
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2060
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2061
/**
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2062
 * Retrieves the parent post object for the given post.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2063
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2064
 * @since 5.7.0
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2065
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2066
 * @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2067
 * @return WP_Post|null Parent post object, or null if there isn't one.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2068
 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2069
function get_post_parent( $post = null ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2070
	$wp_post = get_post( $post );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2071
	return ! empty( $wp_post->post_parent ) ? get_post( $wp_post->post_parent ) : null;
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2072
}
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2073
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2074
/**
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2075
 * Returns whether the given post has a parent post.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2076
 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2077
 * @since 5.7.0
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
 * @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2080
 * @return bool Whether the post has a parent post.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2081
 */
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2082
function has_post_parent( $post = null ) {
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2083
	return (bool) get_post_parent( $post );
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  2084
}