/** * Filters the request to allow for the format prefix. * * @access private * @since 3.1.0 * * @param array $qvs * @return array */ function _post_format_request( $qvs ) { if ( ! isset( $qvs['post_format'] ) ) { return $qvs; } $slugs = get_post_format_slugs(); if ( isset( $slugs[ $qvs['post_format'] ] ) ) { $qvs['post_format'] = 'post-format-' . $slugs[ $qvs['post_format'] ]; } $tax = get_taxonomy( 'post_format' ); if ( ! is_admin() ) { $qvs['post_type'] = $tax->object_type; } return $qvs; } /** * Filters the post format term link to remove the format prefix. * * @access private * @since 3.1.0 * * @global WP_Rewrite $wp_rewrite WordPress rewrite component. * * @param string $link * @param WP_Term $term * @param string $taxonomy * @return string */ function _post_format_link( $link, $term, $taxonomy ) { global $wp_rewrite; if ( 'post_format' !== $taxonomy ) { return $link; } if ( $wp_rewrite->get_extra_permastruct( $taxonomy ) ) { return str_replace( "/{$term->slug}", '/' . str_replace( 'post-format-', '', $term->slug ), $link ); } else { $link = remove_query_arg( 'post_format', $link ); return add_query_arg( 'post_format', str_replace( 'post-format-', '', $term->slug ), $link ); } } /** * Remove the post format prefix from the name property of the term object created by get_term(). * * @access private * @since 3.1.0 * * @param object $term * @return object */ function _post_format_get_term( $term ) { if ( isset( $term->slug ) ) { $term->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } return $term; } /** * Remove the post format prefix from the name property of the term objects created by get_terms(). * * @access private * @since 3.1.0 * * @param array $terms * @param string|array $taxonomies * @param array $args * @return array */ function _post_format_get_terms( $terms, $taxonomies, $args ) { 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 ) { $terms[ $order ]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } } } } return $terms; } /** * Remove the post format prefix from the name property of the term objects created by wp_get_object_terms(). * * @access private * @since 3.1.0 * * @param array $terms * @return array */ function _post_format_wp_get_object_terms( $terms ) { foreach ( (array) $terms as $order => $term ) { if ( isset( $term->taxonomy ) && 'post_format' === $term->taxonomy ) { $terms[ $order ]->name = get_post_format_string( str_replace( 'post-format-', '', $term->slug ) ); } } return $terms; }