diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-includes/post-formats.php --- a/wp/wp-includes/post-formats.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-includes/post-formats.php Tue Dec 15 13:49:49 2020 +0100 @@ -11,7 +11,7 @@ * * @since 3.1.0 * - * @param int|object|null $post Post ID or post object. Optional, default is the current post from the loop. + * @param int|object|null $post Optional. Post ID or post object. Defaults to the current post in the loop. * @return string|false The format if successful. False otherwise. */ function get_post_format( $post = null ) { @@ -41,9 +41,10 @@ * * @since 3.1.0 * - * @param string|array $format Optional. The format or formats to check. - * @param object|int|null $post Optional. The post to check. If not supplied, defaults to the current post if used in the loop. - * @return bool True if the post has any of the given formats (or any format, if no format specified), false otherwise. + * @param string|array $format Optional. The format or formats to check. + * @param WP_Post|int|null $post Optional. The post to check. Defaults to the current post in the loop. + * @return bool True if the post has any of the given formats (or any format, if no format specified), + * false otherwise. */ function has_post_format( $format = array(), $post = null ) { $prefixed = array(); @@ -64,7 +65,7 @@ * * @param int|object $post The post for which to assign a format. * @param string $format A format to assign. Use an empty string or array to remove all formats from the post. - * @return array|WP_Error|false WP_Error on error. Array of affected term IDs on success. + * @return array|WP_Error|false Array of affected term IDs on success. WP_Error on error. */ function set_post_format( $post, $format ) { $post = get_post( $post ); @@ -75,7 +76,7 @@ if ( ! empty( $format ) ) { $format = sanitize_key( $format ); - if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs() ) ) { + if ( 'standard' === $format || ! in_array( $format, get_post_format_slugs(), true ) ) { $format = ''; } else { $format = 'post-format-' . $format; @@ -90,11 +91,11 @@ * * @since 3.1.0 * - * @return array The array of translated post format names. + * @return string[] Array of post format labels keyed by format slug. */ function get_post_format_strings() { $strings = array( - 'standard' => _x( 'Standard', 'Post format' ), // Special case. any value that evals to false will be considered standard + 'standard' => _x( 'Standard', 'Post format' ), // Special case. Any value that evals to false will be considered standard. 'aside' => _x( 'Aside', 'Post format' ), 'chat' => _x( 'Chat', 'Post format' ), 'gallery' => _x( 'Gallery', 'Post format' ), @@ -113,7 +114,7 @@ * * @since 3.1.0 * - * @return array The array of post format slugs as both keys and values. + * @return string[] The array of post format slugs as both keys and values. */ function get_post_format_slugs() { $slugs = array_keys( get_post_format_strings() ); @@ -183,7 +184,7 @@ * @access private * @since 3.1.0 * - * @global WP_Rewrite $wp_rewrite + * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * * @param string $link * @param object $term @@ -192,7 +193,7 @@ */ function _post_format_link( $link, $term, $taxonomy ) { global $wp_rewrite; - if ( 'post_format' != $taxonomy ) { + if ( 'post_format' !== $taxonomy ) { return $link; } if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) { @@ -231,14 +232,14 @@ * @return array */ function _post_format_get_terms( $terms, $taxonomies, $args ) { - if ( in_array( 'post_format', (array) $taxonomies ) ) { - if ( isset( $args['fields'] ) && 'names' == $args['fields'] ) { + if ( in_array( 'post_format', (array) $taxonomies, true ) ) { + if ( isset( $args['fields'] ) && 'names' === $args['fields'] ) { foreach ( $terms as $order => $name ) { $terms[ $order ] = get_post_format_string( str_replace( 'post-format-', '', $name ) ); } } else { foreach ( (array) $terms as $order => $term ) { - if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) { + if ( isset( $term->taxonomy ) && 'post_format' === $term->taxonomy ) { $terms[ $order ]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } } @@ -258,7 +259,7 @@ */ function _post_format_wp_get_object_terms( $terms ) { foreach ( (array) $terms as $order => $term ) { - if ( isset( $term->taxonomy ) && 'post_format' == $term->taxonomy ) { + if ( isset( $term->taxonomy ) && 'post_format' === $term->taxonomy ) { $terms[ $order ]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } }