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