mirror of
git://develop.git.wordpress.org/
synced 2025-02-24 16:43:06 +01:00
Popular tags' edit links should respect the current post type. Adds unit test.
Props mordauk, fahmiadib. Fixes #25566. git-svn-id: https://develop.svn.wordpress.org/trunk@27720 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fbb2e1dc89
commit
815adc833a
@ -370,7 +370,7 @@ do_action( "after-{$taxonomy}-table", $taxonomy );
|
||||
|
||||
if ( !is_null( $tax->labels->popular_items ) ) {
|
||||
if ( current_user_can( $tax->cap->edit_terms ) )
|
||||
$tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) );
|
||||
$tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'post_type' => $post_type, 'echo' => false, 'link' => 'edit' ) );
|
||||
else
|
||||
$tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false ) );
|
||||
|
||||
|
@ -571,6 +571,9 @@ function wp_list_categories( $args = '' ) {
|
||||
* The 'topic_count_text_callback' argument is a function, which given the count
|
||||
* of the posts with that tag returns a text for the tooltip of the tag link.
|
||||
*
|
||||
* The 'post_type' argument is used only when 'link' is set to 'edit'. It determines the post_type
|
||||
* passed to edit.php for the popular tags edit links.
|
||||
*
|
||||
* The 'exclude' and 'include' arguments are used for the {@link get_tags()}
|
||||
* function. Only one should be used, because only one will be used and the
|
||||
* other ignored, if they are both set.
|
||||
@ -584,7 +587,7 @@ function wp_tag_cloud( $args = '' ) {
|
||||
$defaults = array(
|
||||
'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
|
||||
'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC',
|
||||
'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'echo' => true
|
||||
'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => 'post_tag', 'post_type' => '', 'echo' => true
|
||||
);
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
@ -595,7 +598,7 @@ function wp_tag_cloud( $args = '' ) {
|
||||
|
||||
foreach ( $tags as $key => $tag ) {
|
||||
if ( 'edit' == $args['link'] )
|
||||
$link = get_edit_tag_link( $tag->term_id, $tag->taxonomy );
|
||||
$link = get_edit_term_link( $tag->term_id, $tag->taxonomy, $args['post_type'] );
|
||||
else
|
||||
$link = get_term_link( intval($tag->term_id), $tag->taxonomy );
|
||||
if ( is_wp_error( $link ) )
|
||||
|
@ -873,4 +873,43 @@ class Tests_Post extends WP_UnitTestCase {
|
||||
$post_id = $this->factory->post->create( array( 'post_date' => '2014-03-01 16:35:00' ) );
|
||||
$this->assertEquals( 'March 1, 2014', get_the_date( 'F j, Y', $post_id ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 25566
|
||||
*/
|
||||
function test_wp_tag_cloud_link_with_post_type() {
|
||||
$post_type = 'new_post_type';
|
||||
$tax = 'new_tag';
|
||||
register_post_type( $post_type, array( 'taxonomies' => array( 'post_tag', $tax ) ) );
|
||||
register_taxonomy( $tax, $post_type );
|
||||
|
||||
$post = $this->factory->post->create( array( 'post_type' => $post_type ) );
|
||||
wp_set_object_terms( $post, rand_str(), $tax );
|
||||
|
||||
$wp_tag_cloud = wp_tag_cloud( array(
|
||||
'post_type' => $post_type,
|
||||
'taxonomy' => $tax,
|
||||
'echo' => false,
|
||||
'link' => 'edit'
|
||||
) );
|
||||
|
||||
$terms = get_terms( $tax );
|
||||
$term = reset( $terms );
|
||||
$url = sprintf( '%s?action=edit&taxonomy=%s&tag_ID=%d&post_type=%s',
|
||||
admin_url( 'edit-tags.php' ),
|
||||
$tax,
|
||||
$term->term_id,
|
||||
$post_type
|
||||
);
|
||||
$expected_wp_tag_cloud = sprintf( "<a href='%s' class='tag-link-%d' title='1 topic' style='font-size: 8pt;'>%s</a>",
|
||||
$url,
|
||||
$term->term_id,
|
||||
$term->name
|
||||
);
|
||||
$this->assertEquals( $expected_wp_tag_cloud, $wp_tag_cloud );
|
||||
|
||||
_unregister_post_type( $post_type );
|
||||
_unregister_taxonomy( $tax );
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user