4 function the_permalink() {
5 echo apply_filters('the_permalink', get_permalink());
10 * Conditionally adds a trailing slash if the permalink structure
11 * has a trailing slash, strips the trailing slash if not
12 * @global object Uses $wp_rewrite
13 * @param $string string a URL with or without a trailing slash
14 * @param $type_of_url string the type of URL being considered (e.g. single, category, etc) for use in the filter
17 function user_trailingslashit($string, $type_of_url = '') {
19 if ( $wp_rewrite->use_trailing_slashes )
20 $string = trailingslashit($string);
22 $string = untrailingslashit($string);
24 // Note that $type_of_url can be one of following:
25 // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged
26 $string = apply_filters('user_trailingslashit', $string, $type_of_url);
31 function permalink_anchor($mode = 'id') {
33 switch ( strtolower($mode) ) {
35 $title = sanitize_title($post->post_title) . '-' . $post->ID;
36 echo '<a id="'.$title.'"></a>';
40 echo '<a id="post-' . $post->ID . '"></a>';
46 function get_permalink($id = 0, $leavename=false) {
54 $leavename? '' : '%postname%',
58 $leavename? '' : '%pagename%',
61 $post = &get_post($id);
63 if ( empty($post->ID) ) return FALSE;
65 if ( $post->post_type == 'page' )
66 return get_page_link($post->ID, $leavename);
67 elseif ($post->post_type == 'attachment')
68 return get_attachment_link($post->ID);
70 $permalink = get_option('permalink_structure');
72 if ( '' != $permalink && !in_array($post->post_status, array('draft', 'pending')) ) {
73 $unixtime = strtotime($post->post_date);
76 if ( strpos($permalink, '%category%') !== false ) {
77 $cats = get_the_category($post->ID);
79 usort($cats, '_usort_terms_by_ID'); // order by ID
80 $category = $cats[0]->slug;
81 if ( $parent=$cats[0]->parent )
82 $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
84 // show default category in permalinks, without
85 // having to assign it explicitly
86 if ( empty($category) ) {
87 $default_category = get_category( get_option( 'default_category' ) );
88 $category = is_wp_error( $default_category ) ? '' : $default_category->slug;
93 if ( strpos($permalink, '%author%') !== false ) {
94 $authordata = get_userdata($post->post_author);
95 $author = $authordata->user_nicename;
98 $date = explode(" ",date('Y m d H i s', $unixtime));
113 $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink);
114 $permalink = user_trailingslashit($permalink, 'single');
115 return apply_filters('post_link', $permalink, $post);
116 } else { // if they're not using the fancy permalink option
117 $permalink = get_option('home') . '/?p=' . $post->ID;
118 return apply_filters('post_link', $permalink, $post);
122 // get permalink from post ID
123 function post_permalink($post_id = 0, $deprecated = '') {
124 return get_permalink($post_id);
127 // Respects page_on_front. Use this one.
128 function get_page_link($id = false, $leavename = false) {
133 $id = (int) $post->ID;
135 if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
136 $link = get_option('home');
138 $link = _get_page_link( $id , $leavename );
140 return apply_filters('page_link', $link, $id);
143 // Ignores page_on_front. Internal use only.
144 function _get_page_link( $id = false, $leavename = false ) {
145 global $post, $wp_rewrite;
148 $id = (int) $post->ID;
150 $post = &get_post($id);
152 $pagestruct = $wp_rewrite->get_page_permastruct();
154 if ( '' != $pagestruct && isset($post->post_status) && 'draft' != $post->post_status ) {
155 $link = get_page_uri($id);
156 $link = ( $leavename ) ? $pagestruct : str_replace('%pagename%', $link, $pagestruct);
157 $link = get_option('home') . "/$link";
158 $link = user_trailingslashit($link, 'page');
160 $link = get_option('home') . "/?page_id=$id";
163 return apply_filters( '_get_page_link', $link, $id );
166 function get_attachment_link($id = false) {
167 global $post, $wp_rewrite;
172 $id = (int) $post->ID;
175 $object = get_post($id);
176 if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) && ($object->post_parent != $id) ) {
177 $parent = get_post($object->post_parent);
178 if ( 'page' == $parent->post_type )
179 $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front
181 $parentlink = get_permalink( $object->post_parent );
182 if ( is_numeric($object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
183 $name = 'attachment/' . $object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
185 $name = $object->post_name;
186 if (strpos($parentlink, '?') === false)
187 $link = user_trailingslashit( trailingslashit($parentlink) . $name );
191 $link = get_bloginfo('url') . "/?attachment_id=$id";
194 return apply_filters('attachment_link', $link, $id);
197 function get_year_link($year) {
200 $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600));
201 $yearlink = $wp_rewrite->get_year_permastruct();
202 if ( !empty($yearlink) ) {
203 $yearlink = str_replace('%year%', $year, $yearlink);
204 return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink, 'year'), $year);
206 return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year);
210 function get_month_link($year, $month) {
213 $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600));
215 $month = gmdate('m', time()+(get_option('gmt_offset') * 3600));
216 $monthlink = $wp_rewrite->get_month_permastruct();
217 if ( !empty($monthlink) ) {
218 $monthlink = str_replace('%year%', $year, $monthlink);
219 $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink);
220 return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $year, $month);
222 return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month);
226 function get_day_link($year, $month, $day) {
229 $year = gmdate('Y', time()+(get_option('gmt_offset') * 3600));
231 $month = gmdate('m', time()+(get_option('gmt_offset') * 3600));
233 $day = gmdate('j', time()+(get_option('gmt_offset') * 3600));
235 $daylink = $wp_rewrite->get_day_permastruct();
236 if ( !empty($daylink) ) {
237 $daylink = str_replace('%year%', $year, $daylink);
238 $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink);
239 $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink);
240 return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink, 'day'), $year, $month, $day);
242 return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day);
246 function get_feed_link($feed = '') {
249 $permalink = $wp_rewrite->get_feed_permastruct();
250 if ( '' != $permalink ) {
251 if ( false !== strpos($feed, 'comments_') ) {
252 $feed = str_replace('comments_', '', $feed);
253 $permalink = $wp_rewrite->get_comment_feed_permastruct();
256 if ( get_default_feed() == $feed )
259 $permalink = str_replace('%feed%', $feed, $permalink);
260 $permalink = preg_replace('#/+#', '/', "/$permalink");
261 $output = get_option('home') . user_trailingslashit($permalink, 'feed');
264 $feed = get_default_feed();
266 if ( false !== strpos($feed, 'comments_') )
267 $feed = str_replace('comments_', 'comments-', $feed);
269 $output = get_option('home') . "/?feed={$feed}";
272 return apply_filters('feed_link', $output, $feed);
275 function get_post_comments_feed_link($post_id = '', $feed = '') {
278 if ( empty($post_id) )
279 $post_id = (int) $id;
282 $feed = get_default_feed();
284 if ( '' != get_option('permalink_structure') ) {
285 $url = trailingslashit( get_permalink($post_id) ) . 'feed';
286 if ( $feed != get_default_feed() )
288 $url = user_trailingslashit($url, 'single_feed');
290 $type = get_post_field('post_type', $post_id);
291 if ( 'page' == $type )
292 $url = get_option('home') . "/?feed=$feed&page_id=$post_id";
294 $url = get_option('home') . "/?feed=$feed&p=$post_id";
297 return apply_filters('post_comments_feed_link', $url);
300 /** post_comments_feed_link() - Output the comment feed link for a post.
302 * Prints out the comment feed link for a post. Link text is placed in the
303 * anchor. If no link text is specified, default text is used. If no post ID
304 * is specified, the current post is used.
310 * @param string Descriptive text
311 * @param int Optional post ID. Default to current post.
312 * @return string Link to the comment feed for the current post
314 function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {
315 $url = get_post_comments_feed_link($post_id, $feed);
316 if ( empty($link_text) )
317 $link_text = __('Comments Feed');
319 echo "<a href='$url'>$link_text</a>";
322 function get_author_feed_link( $author_id, $feed = '' ) {
323 $author_id = (int) $author_id;
324 $permalink_structure = get_option('permalink_structure');
327 $feed = get_default_feed();
329 if ( '' == $permalink_structure ) {
330 $link = get_option('home') . '?feed=rss2&author=' . $author_id;
332 $link = get_author_posts_url($author_id);
333 $link = trailingslashit($link) . user_trailingslashit('feed', 'feed');
336 $link = apply_filters('author_feed_link', $link);
341 /** get_category_feed_link() - Get the feed link for a given category
343 * Returns a link to the feed for all post in a given category. A specific feed can be requested
344 * or left blank to get the default feed.
350 * @param int $cat_id ID of a category
351 * @param string $feed Feed type
352 * @return string Link to the feed for the category specified by $cat_id
354 function get_category_feed_link($cat_id, $feed = '') {
355 $cat_id = (int) $cat_id;
357 $category = get_category($cat_id);
359 if ( empty($category) || is_wp_error($category) )
363 $feed = get_default_feed();
365 $permalink_structure = get_option('permalink_structure');
367 if ( '' == $permalink_structure ) {
368 $link = get_option('home') . "?feed=$feed&cat=" . $cat_id;
370 $link = get_category_link($cat_id);
371 if( $feed == get_default_feed() )
374 $feed_link = "feed/$feed";
376 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
379 $link = apply_filters('category_feed_link', $link, $feed);
384 function get_tag_feed_link($tag_id, $feed = '') {
385 $tag_id = (int) $tag_id;
387 $tag = get_tag($tag_id);
389 if ( empty($tag) || is_wp_error($tag) )
392 $permalink_structure = get_option('permalink_structure');
395 $feed = get_default_feed();
397 if ( '' == $permalink_structure ) {
398 $link = get_option('home') . "?feed=$feed&tag=" . $tag->slug;
400 $link = get_tag_link($tag->term_id);
401 if ( $feed == get_default_feed() )
404 $feed_link = "feed/$feed";
405 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
408 $link = apply_filters('tag_feed_link', $link, $feed);
413 function get_search_feed_link($search_query = '', $feed = '') {
414 if ( empty($search_query) )
415 $search = attribute_escape(get_search_query());
417 $search = attribute_escape(stripslashes($search_query));
420 $feed = get_default_feed();
422 $link = get_option('home') . "?s=$search&feed=$feed";
424 $link = apply_filters('search_feed_link', $link);
429 function get_search_comments_feed_link($search_query = '', $feed = '') {
430 if ( empty($search_query) )
431 $search = attribute_escape(get_search_query());
433 $search = attribute_escape(stripslashes($search_query));
436 $feed = get_default_feed();
438 $link = get_option('home') . "?s=$search&feed=comments-$feed";
440 $link = apply_filters('search_feed_link', $link);
445 function get_edit_post_link( $id = 0, $context = 'display' ) {
446 if ( !$post = &get_post( $id ) )
449 if ( 'display' == $context )
450 $action = 'action=edit&';
452 $action = 'action=edit&';
454 switch ( $post->post_type ) :
456 if ( !current_user_can( 'edit_page', $post->ID ) )
462 if ( !current_user_can( 'edit_post', $post->ID ) )
465 $var = 'attachment_id';
468 if ( !current_user_can( 'edit_post', $post->ID ) )
475 if ( !current_user_can( 'edit_post', $post->ID ) )
482 return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context );
485 function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
488 if ( $post->post_type == 'page' ) {
489 if ( !current_user_can( 'edit_page', $post->ID ) )
492 if ( !current_user_can( 'edit_post', $post->ID ) )
496 $link = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . __( 'Edit post' ) . '">' . $link . '</a>';
497 echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
500 function get_edit_comment_link( $comment_id = 0 ) {
501 $comment = &get_comment( $comment_id );
502 $post = &get_post( $comment->comment_post_ID );
504 if ( $post->post_type == 'page' ) {
505 if ( !current_user_can( 'edit_page', $post->ID ) )
508 if ( !current_user_can( 'edit_post', $post->ID ) )
512 $location = admin_url('comment.php?action=editcomment&c=') . $comment->comment_ID;
513 return apply_filters( 'get_edit_comment_link', $location );
516 function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
517 global $comment, $post;
519 if ( $post->post_type == 'attachment' ) {
520 } elseif ( $post->post_type == 'page' ) {
521 if ( !current_user_can( 'edit_page', $post->ID ) )
524 if ( !current_user_can( 'edit_post', $post->ID ) )
528 $link = '<a href="' . get_edit_comment_link( $comment->comment_ID ) . '" title="' . __( 'Edit comment' ) . '">' . $link . '</a>';
529 echo $before . apply_filters( 'edit_comment_link', $link, $comment->comment_ID ) . $after;
534 function get_previous_post($in_same_cat = false, $excluded_categories = '') {
535 return get_adjacent_post($in_same_cat, $excluded_categories);
538 function get_next_post($in_same_cat = false, $excluded_categories = '') {
539 return get_adjacent_post($in_same_cat, $excluded_categories, false);
542 function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true) {
545 if( empty($post) || !is_single() || is_attachment() )
548 $current_post_date = $post->post_date;
551 $posts_in_ex_cats_sql = '';
552 if ( $in_same_cat || !empty($excluded_categories) ) {
553 $join = " INNER JOIN $wpdb->term_relationships AS tr ON p.ID = tr.object_id INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id";
555 if ( $in_same_cat ) {
556 $cat_array = wp_get_object_terms($post->ID, 'category', 'fields=ids');
557 $join .= " AND tt.taxonomy = 'category' AND tt.term_id IN (" . implode($cat_array, ',') . ')';
560 $posts_in_ex_cats_sql = "AND tt.taxonomy = 'category'";
561 if ( !empty($excluded_categories) ) {
562 $excluded_categories = array_map('intval', explode(' and ', $excluded_categories));
563 if ( !empty($cat_array) ) {
564 $excluded_categories = array_diff($excluded_categories, $cat_array);
565 $posts_in_ex_cats_sql = '';
568 if ( !empty($excluded_categories) ) {
569 $posts_in_ex_cats_sql = " AND tt.taxonomy = 'category' AND tt.term_id NOT IN (" . implode($excluded_categories, ',') . ')';
574 $adjacent = $previous ? 'previous' : 'next';
575 $op = $previous ? '<' : '>';
576 $order = $previous ? 'DESC' : 'ASC';
578 $join = apply_filters( "get_{$adjacent}_post_join", $join, $in_same_cat, $excluded_categories );
579 $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 );
580 $sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" );
582 return $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort");
585 function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
586 adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
589 function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') {
590 adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
593 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
594 if ( $previous && is_attachment() )
595 $post = & get_post($GLOBALS['post']->post_parent);
597 $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous);
602 $title = $post->post_title;
604 if ( empty($post->post_title) )
605 $title = $previous ? __('Previous Post') : __('Next Post');
607 $title = apply_filters('the_title', $title, $post);
608 $string = '<a href="'.get_permalink($post).'">';
609 $link = str_replace('%title', $title, $link);
610 $link = $string . $link . '</a>';
612 $format = str_replace('%link', $link, $format);
614 $adjacent = $previous ? 'previous' : 'next';
615 echo apply_filters( "{$adjacent}_post_link", $format, $link );
618 function get_pagenum_link($pagenum = 1) {
621 $pagenum = (int) $pagenum;
623 $request = remove_query_arg( 'paged' );
625 $home_root = parse_url(get_option('home'));
626 $home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
627 $home_root = preg_quote( trailingslashit( $home_root ), '|' );
629 $request = preg_replace('|^'. $home_root . '|', '', $request);
630 $request = preg_replace('|^/+|', '', $request);
632 if ( !$wp_rewrite->using_permalinks() || is_admin() ) {
633 $base = trailingslashit( get_bloginfo( 'home' ) );
635 if ( $pagenum > 1 ) {
636 $result = add_query_arg( 'paged', $pagenum, $base . $request );
638 $result = $base . $request;
641 $qs_regex = '|\?.*?$|';
642 preg_match( $qs_regex, $request, $qs_match );
644 if ( !empty( $qs_match[0] ) ) {
645 $query_string = $qs_match[0];
646 $request = preg_replace( $qs_regex, '', $request );
651 $request = preg_replace( '|page/\d+/?$|', '', $request);
652 $request = preg_replace( '|^index\.php|', '', $request);
653 $request = ltrim($request, '/');
655 $base = trailingslashit( get_bloginfo( 'url' ) );
657 if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
658 $base .= 'index.php/';
660 if ( $pagenum > 1 ) {
661 $request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( 'page/' . $pagenum, 'paged' );
664 $result = $base . $request . $query_string;
667 $result = apply_filters('get_pagenum_link', $result);
672 function get_next_posts_page_link($max_page = 0) {
675 if ( !is_single() ) {
678 $nextpage = intval($paged) + 1;
679 if ( !$max_page || $max_page >= $nextpage )
680 return get_pagenum_link($nextpage);
684 function next_posts($max_page = 0) {
685 echo clean_url(get_next_posts_page_link($max_page));
688 function next_posts_link($label='Next Page »', $max_page=0) {
689 global $paged, $wp_query;
691 $max_page = $wp_query->max_num_pages;
695 $nextpage = intval($paged) + 1;
696 if ( (! is_single()) && (empty($paged) || $nextpage <= $max_page) ) {
698 next_posts($max_page);
699 echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
703 function get_previous_posts_page_link() {
706 if ( !is_single() ) {
707 $nextpage = intval($paged) - 1;
710 return get_pagenum_link($nextpage);
714 function previous_posts() {
715 echo clean_url(get_previous_posts_page_link());
718 function previous_posts_link($label='« Previous Page') {
720 if ( (!is_single()) && ($paged > 1) ) {
723 echo '">'. preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $label) .'</a>';
727 function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') {
729 if ( !is_singular() ) {
730 $max_num_pages = $wp_query->max_num_pages;
731 $paged = get_query_var('paged');
733 //only have sep if there's both prev and next results
734 if ($paged < 2 || $paged >= $max_num_pages) {
738 if ( $max_num_pages > 1 ) {
739 previous_posts_link($prelabel);
740 echo preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', $sep);
741 next_posts_link($nxtlabel);
746 function get_shortcut_link() {
753 s=(e?e():(k)?k():(x?x.createRange().text:0)),
754 f='" . admin_url('press-this.php') . "',
756 e=encodeURIComponent,
757 g=f+'?u='+e(l.href)+'&t='+e(d.title)+'&s='+e(s)+'&v=2';
759 if(!w.open(g,'t','toolbar=0,resizable=0,scrollbars=1,status=1,width=700,height=500')){
763 if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false)
764 $link .= 'setTimeout(a,0);';
770 $link = str_replace(array("\r", "\n", "\t"), '', $link);
772 return apply_filters('shortcut_link', $link);
775 /** Return the site url
781 * Returns the 'site_url' option with the appropriate protocol, 'https' if is_ssl() and 'http' otherwise.
782 * If $scheme is 'http' or 'https', is_ssl() is overridden.
784 * @param string $path Optional path relative to the site url
785 * @param string $scheme Optional scheme to give the site url context. Currently 'http','https', 'login', 'login_post', or 'admin'
786 * @return string Site url link with optional path appended
788 function site_url($path = '', $scheme = null) {
789 // should the list of allowed schemes be maintained elsewhere?
790 if ( !in_array($scheme, array('http', 'https')) ) {
791 if ( ('login_post' == $scheme) && ( force_ssl_login() || force_ssl_admin() ) )
793 elseif ( ('login' == $scheme) && ( force_ssl_admin() ) )
795 elseif ( ('admin' == $scheme) && force_ssl_admin() )
798 $scheme = ( is_ssl() ? 'https' : 'http' );
801 $url = str_replace( 'http://', "{$scheme}://", get_option('siteurl') );
803 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
804 $url .= '/' . ltrim($path, '/');
809 /** Return the admin url
815 * Returns the url to the admin area
817 * @param string $path Optional path relative to the admin url
818 * @return string Admin url link with optional path appended
820 function admin_url($path = '') {
821 $url = site_url('wp-admin/', 'admin');
823 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
824 $url .= ltrim($path, '/');
829 /** Return the includes url
835 * Returns the url to the includes directory
837 * @param string $path Optional path relative to the includes url
838 * @return string Includes url link with optional path appended
840 function includes_url($path = '') {
841 $url = site_url() . '/' . WPINC . '/';
843 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
844 $url .= ltrim($path, '/');
849 /** Return the content url
855 * Returns the url to the content directory
857 * @param string $path Optional path relative to the content url
858 * @return string Content url link with optional path appended
860 function content_url($path = '') {
861 $scheme = ( is_ssl() ? 'https' : 'http' );
862 $url = WP_CONTENT_URL;
863 if ( 0 === strpos($url, 'http') ) {
865 $url = str_replace( 'http://', "{$scheme}://", $url );
868 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
869 $url .= '/' . ltrim($path, '/');
874 /** Return the plugins url
880 * Returns the url to the plugins directory
882 * @param string $path Optional path relative to the plugins url
883 * @return string Plugins url link with optional path appended
885 function plugins_url($path = '') {
886 $scheme = ( is_ssl() ? 'https' : 'http' );
887 $url = WP_PLUGIN_URL;
888 if ( 0 === strpos($url, 'http') ) {
890 $url = str_replace( 'http://', "{$scheme}://", $url );
893 if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
894 $url .= '/' . ltrim($path, '/');