Ticket #1914: attachment-permalinks.diff
| File attachment-permalinks.diff, 3.2 KB (added by , 12 years ago) |
|---|
-
wp-includes/link-template.php
321 321 $link = str_replace( '%postname%', $name, $link ); 322 322 } 323 323 324 if ( ! $link ) 325 $link = home_url( '/?attachment_id=' . $post->ID ); 324 if ( ! $link ) { 325 if($wp_rewrite->using_permalinks()) { 326 $link = home_url( '/attachment/' . $post->ID ); 327 } else { 328 $link = home_url( '/?attachment_id=' . $post->ID ); 329 } 330 } 326 331 327 332 return apply_filters( 'attachment_link', $link, $post->ID ); 328 333 } … … 1468 1473 * 1469 1474 * @param int $pagenum Optional. Page ID. 1470 1475 * @param bool $escape Optional. Whether to escape the URL for display, with esc_url(). Defaults to true. 1471 *Otherwise, prepares the URL with esc_url_raw().1476 * Otherwise, prepares the URL with esc_url_raw(). 1472 1477 * @return string 1473 1478 */ 1474 1479 function get_pagenum_link($pagenum = 1, $escape = true ) { -
wp-includes/rewrite.php
679 679 '%post_id%', 680 680 '%author%', 681 681 '%pagename%', 682 '%search%' 682 '%search%', 683 '%attachment_id%' 683 684 ); 684 685 685 686 /** … … 722 723 'p=', 723 724 'author_name=', 724 725 'pagename=', 725 's=' 726 's=', 727 'attachment_id=' 726 728 ); 727 729 728 730 /** … … 1551 1553 $post_rewrite = $this->generate_rewrite_rules( $this->permalink_structure, EP_PERMALINK ); 1552 1554 $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite); 1553 1555 1556 // Attachment 1557 $attachment_rewrite = $this->generate_rewrite_rules( "/attachment/%attachment_id%", EP_NONE, false, false, false, false, false ); 1558 $attachment_rewrite = apply_filters('attachment_rewrite_rules', $attachment_rewrite); 1559 1554 1560 // Date 1555 1561 $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct(), EP_DATE); 1556 1562 $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite); … … 1596 1602 1597 1603 // Put them together. 1598 1604 if ( $this->use_verbose_page_rules ) 1599 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $ page_rewrite, $post_rewrite, $this->extra_rules);1605 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $attachment_rewrite, $page_rewrite, $post_rewrite, $this->extra_rules); 1600 1606 else 1601 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $ post_rewrite, $page_rewrite, $this->extra_rules);1607 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $deprecated_files, $registration_pages, $root_rewrite, $comments_rewrite, $search_rewrite, $author_rewrite, $date_rewrite, $attachment_rewrite, $post_rewrite, $page_rewrite, $this->extra_rules); 1602 1608 1603 1609 do_action_ref_array('generate_rewrite_rules', array(&$this)); 1604 1610 $this->rules = apply_filters('rewrite_rules_array', $this->rules);