220 else |
220 else |
221 $post = &get_post($id); |
221 $post = &get_post($id); |
222 |
222 |
223 $pagestruct = $wp_rewrite->get_page_permastruct(); |
223 $pagestruct = $wp_rewrite->get_page_permastruct(); |
224 |
224 |
225 if ( '' != $pagestruct && ( ( isset($post->post_status) && 'draft' != $post->post_status ) || $sample ) ) { |
225 if ( '' != $pagestruct && ( ( isset($post->post_status) && 'draft' != $post->post_status && 'pending' != $post->post_status ) || $sample ) ) { |
226 $link = get_page_uri($id); |
226 $link = get_page_uri($id); |
227 $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct); |
227 $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct); |
228 $link = trailingslashit(get_option('home')) . "$link"; |
228 $link = trailingslashit(get_option('home')) . "$link"; |
229 $link = user_trailingslashit($link, 'page'); |
229 $link = user_trailingslashit($link, 'page'); |
230 } else { |
230 } else { |
617 * @param string $feed Optional. Feed type. |
617 * @param string $feed Optional. Feed type. |
618 * @return string |
618 * @return string |
619 */ |
619 */ |
620 function get_search_feed_link($search_query = '', $feed = '') { |
620 function get_search_feed_link($search_query = '', $feed = '') { |
621 if ( empty($search_query) ) |
621 if ( empty($search_query) ) |
622 $search = esc_attr(get_search_query()); |
622 $search = esc_attr( urlencode(get_search_query()) ); |
623 else |
623 else |
624 $search = esc_attr(stripslashes($search_query)); |
624 $search = esc_attr( urlencode(stripslashes($search_query)) ); |
625 |
625 |
626 if ( empty($feed) ) |
626 if ( empty($feed) ) |
627 $feed = get_default_feed(); |
627 $feed = get_default_feed(); |
628 |
628 |
629 $link = trailingslashit(get_option('home')) . "?s=$search&feed=$feed"; |
629 $link = trailingslashit(get_option('home')) . "?s=$search&feed=$feed"; |
642 * @param string $feed Optional. Feed type. |
642 * @param string $feed Optional. Feed type. |
643 * @return string |
643 * @return string |
644 */ |
644 */ |
645 function get_search_comments_feed_link($search_query = '', $feed = '') { |
645 function get_search_comments_feed_link($search_query = '', $feed = '') { |
646 if ( empty($search_query) ) |
646 if ( empty($search_query) ) |
647 $search = esc_attr(get_search_query()); |
647 $search = esc_attr( urlencode(get_search_query()) ); |
648 else |
648 else |
649 $search = esc_attr(stripslashes($search_query)); |
649 $search = esc_attr( urlencode(stripslashes($search_query)) ); |
650 |
650 |
651 if ( empty($feed) ) |
651 if ( empty($feed) ) |
652 $feed = get_default_feed(); |
652 $feed = get_default_feed(); |
653 |
653 |
654 $link = trailingslashit(get_option('home')) . "?s=$search&feed=comments-$feed"; |
654 $link = trailingslashit(get_option('home')) . "?s=$search&feed=comments-$feed"; |
718 * @param string $link Optional. Anchor text. |
718 * @param string $link Optional. Anchor text. |
719 * @param string $before Optional. Display before edit link. |
719 * @param string $before Optional. Display before edit link. |
720 * @param string $after Optional. Display after edit link. |
720 * @param string $after Optional. Display after edit link. |
721 * @param int $id Optional. Post ID. |
721 * @param int $id Optional. Post ID. |
722 */ |
722 */ |
723 function edit_post_link( $link = 'Edit This', $before = '', $after = '', $id = 0 ) { |
723 function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) { |
724 if ( !$post = &get_post( $id ) ) |
724 if ( !$post = &get_post( $id ) ) |
725 return; |
725 return; |
726 |
726 |
727 if ( !$url = get_edit_post_link( $post->ID ) ) |
727 if ( !$url = get_edit_post_link( $post->ID ) ) |
728 return; |
728 return; |
729 |
729 |
|
730 if ( null === $link ) |
|
731 $link = __('Edit This'); |
|
732 |
730 $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( __( 'Edit post' ) ) . '">' . $link . '</a>'; |
733 $link = '<a class="post-edit-link" href="' . $url . '" title="' . esc_attr( __( 'Edit post' ) ) . '">' . $link . '</a>'; |
731 echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; |
734 echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; |
|
735 } |
|
736 |
|
737 /** |
|
738 * Retrieve delete posts link for post. |
|
739 * |
|
740 * Can be used within the WordPress loop or outside of it. Can be used with |
|
741 * pages, posts, attachments, and revisions. |
|
742 * |
|
743 * @since 2.9.0 |
|
744 * |
|
745 * @param int $id Optional. Post ID. |
|
746 * @param string $context Optional, default to display. How to write the '&', defaults to '&'. |
|
747 * @return string |
|
748 */ |
|
749 function get_delete_post_link($id = 0, $context = 'display') { |
|
750 if ( !$post = &get_post( $id ) ) |
|
751 return; |
|
752 |
|
753 if ( 'display' == $context ) |
|
754 $action = 'action=trash&'; |
|
755 else |
|
756 $action = 'action=trash&'; |
|
757 |
|
758 switch ( $post->post_type ) : |
|
759 case 'page' : |
|
760 if ( !current_user_can( 'delete_page', $post->ID ) ) |
|
761 return; |
|
762 $file = 'page'; |
|
763 $var = 'post'; |
|
764 break; |
|
765 case 'attachment' : |
|
766 if ( !current_user_can( 'delete_post', $post->ID ) ) |
|
767 return; |
|
768 $file = 'media'; |
|
769 $var = 'attachment_id'; |
|
770 break; |
|
771 case 'revision' : |
|
772 if ( !current_user_can( 'delete_post', $post->ID ) ) |
|
773 return; |
|
774 $file = 'revision'; |
|
775 $var = 'revision'; |
|
776 $action = ''; |
|
777 break; |
|
778 default : |
|
779 if ( !current_user_can( 'edit_post', $post->ID ) ) |
|
780 return apply_filters( 'get_delete_post_link', '', $post->ID, $context );; |
|
781 $file = 'post'; |
|
782 $var = 'post'; |
|
783 break; |
|
784 endswitch; |
|
785 |
|
786 return apply_filters( 'get_delete_post_link', wp_nonce_url( admin_url("$file.php?{$action}$var=$post->ID"), "trash-{$file}_" . $post->ID ), $context ); |
732 } |
787 } |
733 |
788 |
734 /** |
789 /** |
735 * Retrieve edit comment link. |
790 * Retrieve edit comment link. |
736 * |
791 * |
763 * @param string $link Optional. Anchor text. |
818 * @param string $link Optional. Anchor text. |
764 * @param string $before Optional. Display before edit link. |
819 * @param string $before Optional. Display before edit link. |
765 * @param string $after Optional. Display after edit link. |
820 * @param string $after Optional. Display after edit link. |
766 * @return string|null HTML content, if $echo is set to false. |
821 * @return string|null HTML content, if $echo is set to false. |
767 */ |
822 */ |
768 function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) { |
823 function edit_comment_link( $link = null, $before = '', $after = '' ) { |
769 global $comment, $post; |
824 global $comment, $post; |
770 |
825 |
771 if ( $post->post_type == 'page' ) { |
826 if ( $post->post_type == 'page' ) { |
772 if ( !current_user_can( 'edit_page', $post->ID ) ) |
827 if ( !current_user_can( 'edit_page', $post->ID ) ) |
773 return; |
828 return; |
774 } else { |
829 } else { |
775 if ( !current_user_can( 'edit_post', $post->ID ) ) |
830 if ( !current_user_can( 'edit_post', $post->ID ) ) |
776 return; |
831 return; |
777 } |
832 } |
|
833 |
|
834 if ( null === $link ) |
|
835 $link = __('Edit This'); |
778 |
836 |
779 $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>'; |
837 $link = '<a class="comment-edit-link" href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>'; |
780 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; |
838 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after; |
781 } |
839 } |
782 |
840 |
896 $adjacent = $previous ? 'previous' : 'next'; |
954 $adjacent = $previous ? 'previous' : 'next'; |
897 $op = $previous ? '<' : '>'; |
955 $op = $previous ? '<' : '>'; |
898 $order = $previous ? 'DESC' : 'ASC'; |
956 $order = $previous ? 'DESC' : 'ASC'; |
899 |
957 |
900 $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories ); |
958 $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories ); |
901 $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = 'post' AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date), $in_same_cat, $excluded_categories ); |
959 $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories ); |
902 $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); |
960 $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" ); |
903 |
961 |
904 $query = "SELECT p.* FROM $wpdb->posts AS p $join $where $sort"; |
962 $query = "SELECT p.* FROM $wpdb->posts AS p $join $where $sort"; |
905 $query_key = 'adjacent_post_' . md5($query); |
963 $query_key = 'adjacent_post_' . md5($query); |
906 $result = wp_cache_get($query_key, 'counts'); |
964 $result = wp_cache_get($query_key, 'counts'); |
1204 if ( empty($post->post_title) ) |
1262 if ( empty($post->post_title) ) |
1205 $title = $previous ? __('Previous Post') : __('Next Post'); |
1263 $title = $previous ? __('Previous Post') : __('Next Post'); |
1206 |
1264 |
1207 $title = apply_filters('the_title', $title, $post); |
1265 $title = apply_filters('the_title', $title, $post); |
1208 $date = mysql2date(get_option('date_format'), $post->post_date); |
1266 $date = mysql2date(get_option('date_format'), $post->post_date); |
1209 |
1267 $rel = $previous ? 'prev' : 'next'; |
1210 $string = '<a href="'.get_permalink($post).'">'; |
1268 |
|
1269 $string = '<a href="'.get_permalink($post).'" rel="'.$rel.'">'; |
1211 $link = str_replace('%title', $title, $link); |
1270 $link = str_replace('%title', $title, $link); |
1212 $link = str_replace('%date', $date, $link); |
1271 $link = str_replace('%date', $date, $link); |
1213 $link = $string . $link . '</a>'; |
1272 $link = $string . $link . '</a>'; |
1214 |
1273 |
1215 $format = str_replace('%link', $link, $format); |
1274 $format = str_replace('%link', $link, $format); |
1654 x=d.selection, |
1713 x=d.selection, |
1655 s=(e?e():(k)?k():(x?x.createRange().text:0)), |
1714 s=(e?e():(k)?k():(x?x.createRange().text:0)), |
1656 f='" . admin_url('press-this.php') . "', |
1715 f='" . admin_url('press-this.php') . "', |
1657 l=d.location, |
1716 l=d.location, |
1658 e=encodeURIComponent, |
1717 e=encodeURIComponent, |
1659 g=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=2'; |
1718 u=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=4'; |
1660 function a(){ |
1719 a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570'))l.href=u;}; |
1661 if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=720,height=570')){ |
1720 if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a(); |
1662 l.href=g; |
1721 void(0)"; |
1663 } |
|
1664 }"; |
|
1665 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) |
|
1666 $link .= 'setTimeout(a,0);'; |
|
1667 else |
|
1668 $link .= 'a();'; |
|
1669 |
|
1670 $link .= "void(0);"; |
|
1671 |
1722 |
1672 $link = str_replace(array("\r", "\n", "\t"), '', $link); |
1723 $link = str_replace(array("\r", "\n", "\t"), '', $link); |
1673 |
1724 |
1674 return apply_filters('shortcut_link', $link); |
1725 return apply_filters('shortcut_link', $link); |
1675 } |
1726 } |
1804 $url .= '/' . ltrim($path, '/'); |
1855 $url .= '/' . ltrim($path, '/'); |
1805 |
1856 |
1806 return apply_filters('plugins_url', $url, $path, $plugin); |
1857 return apply_filters('plugins_url', $url, $path, $plugin); |
1807 } |
1858 } |
1808 |
1859 |
|
1860 /** |
|
1861 * Output rel=canonical for singular queries |
|
1862 * |
|
1863 * @package WordPress |
|
1864 * @since 2.9.0 |
|
1865 */ |
|
1866 function rel_canonical() { |
|
1867 if ( !is_singular() ) |
|
1868 return; |
|
1869 |
|
1870 global $wp_the_query; |
|
1871 if ( !$id = $wp_the_query->get_queried_object_id() ) |
|
1872 return; |
|
1873 |
|
1874 $link = get_permalink( $id ); |
|
1875 echo "<link rel='canonical' href='$link' />\n"; |
|
1876 } |
|
1877 |
1809 ?> |
1878 ?> |