diff options
Diffstat (limited to 'wp-includes')
-rw-r--r-- | wp-includes/bookmark-template.php | 9 | ||||
-rw-r--r-- | wp-includes/category-template.php | 2 | ||||
-rw-r--r-- | wp-includes/classes.php | 3 | ||||
-rw-r--r-- | wp-includes/comment-template.php | 2 | ||||
-rw-r--r-- | wp-includes/feed.php | 4 | ||||
-rw-r--r-- | wp-includes/formatting.php | 9 | ||||
-rw-r--r-- | wp-includes/functions.php | 26 | ||||
-rw-r--r-- | wp-includes/general-template.php | 10 | ||||
-rw-r--r-- | wp-includes/link-template.php | 31 | ||||
-rw-r--r-- | wp-includes/post-template.php | 36 | ||||
-rw-r--r-- | wp-includes/post.php | 2 | ||||
-rw-r--r-- | wp-includes/theme.php | 4 | ||||
-rw-r--r-- | wp-includes/vars.php | 32 |
13 files changed, 92 insertions, 78 deletions
diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php index 54b6d15..65e38aa 100644 --- a/wp-includes/bookmark-template.php +++ b/wp-includes/bookmark-template.php @@ -266,9 +266,9 @@ function _walk_bookmarks($bookmarks, $args = '' ) { if ( '' != $rel ) $rel = ' rel="' . $rel . '"'; - $desc = attribute_escape($bookmark->link_description); - $name = attribute_escape($bookmark->link_name); - $title = $desc; + $desc = attribute_escape(apply_filters('link_description', $bookmark->link_description)); + $name = attribute_escape(apply_filters('link_title', $bookmark->link_name)); + $title = $desc; if ( $show_updated ) if ( '00' != substr($bookmark->link_updated_f, 0, 2) ) { @@ -336,7 +336,8 @@ function wp_list_bookmarks($args = '') { if ( empty($bookmarks) ) continue; $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->cat_ID", $class), $category_before); - $output .= "$title_before$cat->cat_name$title_after\n\t<ul>\n"; + $catname = apply_filters( "link_category", $cat->cat_name ); + $output .= "$title_before$catname$title_after\n\t<ul>\n"; $output .= _walk_bookmarks($bookmarks, $r); $output .= "\n\t</ul>\n$category_after\n"; } diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 0d85c01..32ace67 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -38,7 +38,7 @@ function get_category_link($category_id) { $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename; $catlink = str_replace('%category%', $category_nicename, $catlink); - $catlink = get_option('home') . user_trailingslashit($catlink); + $catlink = get_option('home') . user_trailingslashit($catlink, 'category'); } return apply_filters('category_link', $catlink, $category_id); } diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 8c8dcd0..5bdeebe 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -580,13 +580,14 @@ class Walker_Category extends Walker { extract($args); $cat_name = attribute_escape( $category->cat_name); + $cat_name = apply_filters( 'list_cats', $cat_name, $category ); $link = '<a href="' . get_category_link( $category->cat_ID ) . '" '; if ( $use_desc_for_title == 0 || empty($category->category_description) ) $link .= 'title="' . sprintf(__( 'View all posts filed under %s' ), $cat_name) . '"'; else $link .= 'title="' . attribute_escape( apply_filters( 'category_description', $category->category_description, $category )) . '"'; $link .= '>'; - $link .= apply_filters( 'list_cats', $category->cat_name, $category ).'</a>'; + $link .= $cat_name . '</a>'; if ( (! empty($feed_image)) || (! empty($feed)) ) { $link .= ' '; diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php index ea3ce15..ba7c0cb 100644 --- a/wp-includes/comment-template.php +++ b/wp-includes/comment-template.php @@ -226,7 +226,7 @@ function get_trackback_url() { $tb_url = get_option('siteurl') . '/wp-trackback.php?p=' . $id; if ( '' != get_option('permalink_structure') ) - $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback'); + $tb_url = trailingslashit(get_permalink()) . user_trailingslashit('trackback', 'single_trackback'); return $tb_url; } diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 687a304..741bf7b 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -113,7 +113,7 @@ function get_author_rss_link($echo = false, $author_id, $author_nicename) { $link = get_option('home') . '?feed=rss2&author=' . $author_id; } else { $link = get_author_posts_url($author_id, $author_nicename); - $link = $link . user_trailingslashit('feed'); + $link = $link . user_trailingslashit('feed', 'feed'); } $link = apply_filters('author_feed_link', $link); @@ -131,7 +131,7 @@ function get_category_rss_link($echo = false, $cat_ID, $category_nicename) { $link = get_option('home') . '?feed=rss2&cat=' . $cat_ID; } else { $link = get_category_link($cat_ID); - $link = $link . user_trailingslashit('feed/'); + $link = $link . user_trailingslashit('feed', 'feed'); } $link = apply_filters('category_feed_link', $link); diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index 718a217..b10d53c 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -563,10 +563,11 @@ function backslashit($string) { } function trailingslashit($string) { - if ( '/' != substr($string, -1)) { - $string .= '/'; - } - return $string; + return untrailingslashit($string) . '/'; +} + +function untrailingslashit($string) { + return rtrim($string, '/'); } function addslashes_gpc($gpc) { diff --git a/wp-includes/functions.php b/wp-includes/functions.php index d843b39..29437a5 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1113,7 +1113,7 @@ function wp_upload_dir() { return apply_filters('upload_dir', $uploads); } -function wp_upload_bits($name, $type, $bits, $overwrite = false) { +function wp_upload_bits($name, $type, $bits) { if ( empty($name) ) return array('error' => __("Empty filename")); @@ -1141,21 +1141,10 @@ function wp_upload_bits($name, $type, $bits, $overwrite = false) { $filename = str_replace("$number$ext", ++$number . $ext, $filename); } - // If we are asked to over write the file then make sure - // the $name has the complete path and is writable. - if($overwrite) { - if(!is_writable($name)) { - return(array("error" => __("Can not over write file."))); - } - $new_file = $name; - $filename = basename($name); - } - else { - $new_file = $upload['path'] . "/$filename"; - if ( ! wp_mkdir_p( dirname($new_file) ) ) { - $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); - return array('error' => $message); - } + $new_file = $upload['path'] . "/$filename"; + if ( ! wp_mkdir_p( dirname($new_file) ) ) { + $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file)); + return array('error' => $message); } $ifp = @ fopen($new_file, 'wb'); @@ -1170,11 +1159,8 @@ function wp_upload_bits($name, $type, $bits, $overwrite = false) { $perms = $perms & 0000666; @ chmod($new_file, $perms); - // Compute the URL if this is a new file. + // Compute the URL $url = $upload['url'] . "/$filename"; - if($overwrite) { - $url = $name; - } return array('file' => $new_file, 'url' => $url, 'error' => false); } diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index 81d696c..d320d67 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -215,8 +215,8 @@ function wp_title($sep = '»', $display = true) { // If there is a post if ( is_single() || is_page() ) { $post = $wp_query->get_queried_object(); - $title = strip_tags($post->post_title); $title = apply_filters('single_post_title', $title); + $title = strip_tags($post->post_title); } $prefix = ''; @@ -582,12 +582,16 @@ function get_calendar($initial = true) { ); if ( $ak_post_titles ) { foreach ( $ak_post_titles as $ak_post_title ) { + + $post_title = apply_filters( "the_title", $ak_post_title->post_title ); + $post_title = str_replace('"', '"', wptexturize( $post_title )); + if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) $ak_titles_for_day['day_'.$ak_post_title->dom] = ''; if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one - $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '"', wptexturize($ak_post_title->post_title)); + $ak_titles_for_day["$ak_post_title->dom"] = $post_title; else - $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '"', wptexturize($ak_post_title->post_title)); + $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title; } } diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 65a502a..10de62a 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -16,14 +16,19 @@ function permalink_link() { // For backwards compatibility * has a trailing slash, strips the trailing slash if not * @global object Uses $wp_rewrite * @param $string string a URL with or without a trailing slash + * @param $type_of_url string the type of URL being considered (e.g. single, category, etc) for use in the filter * @return string */ -function user_trailingslashit($string) { +function user_trailingslashit($string, $type_of_url = '') { global $wp_rewrite; if ( $wp_rewrite->use_trailing_slashes ) $string = trailingslashit($string); else - $string = preg_replace('|/$|', '', $string); // untrailing slash + $string = untrailingslashit($string); + + // Note that $type_of_url can be one of following: + // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged + $string = apply_filters('user_trailingslashit', $string, $type_of_url); return $string; } @@ -94,7 +99,9 @@ function get_permalink($id = 0) { $author, $post->post_name, ); - return apply_filters('post_link', get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink), $post); + $permalink = get_option('home') . str_replace($rewritecode, $rewritereplace, $permalink); + $permalink = user_trailingslashit($permalink, 'single'); + return apply_filters('post_link', $permalink, $post); } else { // if they're not using the fancy permalink option $permalink = get_option('home') . '/?p=' . $post->ID; return apply_filters('post_link', $permalink, $post); @@ -134,7 +141,7 @@ function _get_page_link( $id = false ) { $link = get_page_uri($id); $link = str_replace('%pagename%', $link, $pagestruct); $link = get_option('home') . "/$link"; - $link = user_trailingslashit($link); + $link = user_trailingslashit($link, 'page'); } else { $link = get_option('home') . "/?page_id=$id"; } @@ -176,7 +183,7 @@ function get_year_link($year) { $yearlink = $wp_rewrite->get_year_permastruct(); if ( !empty($yearlink) ) { $yearlink = str_replace('%year%', $year, $yearlink); - return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink), $year); + return apply_filters('year_link', get_option('home') . user_trailingslashit($yearlink, 'year'), $year); } else { return apply_filters('year_link', get_option('home') . '/?m=' . $year, $year); } @@ -192,7 +199,7 @@ function get_month_link($year, $month) { if ( !empty($monthlink) ) { $monthlink = str_replace('%year%', $year, $monthlink); $monthlink = str_replace('%monthnum%', zeroise(intval($month), 2), $monthlink); - return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink), $year, $month); + return apply_filters('month_link', get_option('home') . user_trailingslashit($monthlink, 'month'), $year, $month); } else { return apply_filters('month_link', get_option('home') . '/?m=' . $year . zeroise($month, 2), $year, $month); } @@ -212,7 +219,7 @@ function get_day_link($year, $month, $day) { $daylink = str_replace('%year%', $year, $daylink); $daylink = str_replace('%monthnum%', zeroise(intval($month), 2), $daylink); $daylink = str_replace('%day%', zeroise(intval($day), 2), $daylink); - return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink), $year, $month, $day); + return apply_filters('day_link', get_option('home') . user_trailingslashit($daylink, 'day'), $year, $month, $day); } else { return apply_filters('day_link', get_option('home') . '/?m=' . $year . zeroise($month, 2) . zeroise($day, 2), $year, $month, $day); } @@ -236,7 +243,7 @@ function get_feed_link($feed='rss2') { $permalink = str_replace('%feed%', $feed, $permalink); $permalink = preg_replace('#/+#', '/', "/$permalink"); - $output = get_option('home') . user_trailingslashit($permalink); + $output = get_option('home') . user_trailingslashit($permalink, 'feed'); } else { if ( false !== strpos($feed, 'comments_') ) $feed = str_replace('comments_', 'comments-', $feed); @@ -257,7 +264,7 @@ function get_post_comments_feed_link($post_id = '', $feed = 'rss2') { $url = trailingslashit( get_permalink() ) . 'feed'; if ( 'rss2' != $feed ) $url .= "/$feed"; - $url = user_trailingslashit($url); + $url = user_trailingslashit($url, 'single_feed'); } else { $url = get_option('home') . "/?feed=$feed&p=$id"; } @@ -471,13 +478,13 @@ function get_pagenum_link($pagenum = 1) { $qstr = preg_replace('|^/+|', '', $qstr); if ( $permalink ) - $qstr = user_trailingslashit($qstr); + $qstr = user_trailingslashit($qstr, 'paged'); $qstr = preg_replace('/&([^#])(?![a-z]{1,8};)/', '&$1', trailingslashit( get_option('home') ) . $qstr ); // showing /page/1/ or ?paged=1 is redundant if ( 1 === $pagenum ) { - $qstr = str_replace(user_trailingslashit('index.php/page/1'), '', $qstr); // for PATHINFO style - $qstr = str_replace(user_trailingslashit('page/1'), '', $qstr); // for mod_rewrite style + $qstr = str_replace(user_trailingslashit('index.php/page/1', 'paged'), '', $qstr); // for PATHINFO style + $qstr = str_replace(user_trailingslashit('page/1', 'paged'), '', $qstr); // for mod_rewrite style $qstr = remove_query_arg('paged', $qstr); // for query style } return $qstr; diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index cfa56f8..3b1ca35 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -155,10 +155,14 @@ function wp_link_pages($args = '') { $j = str_replace('%',"$i",$pagelink); $output .= ' '; if ( ($i != $page) || ((!$more) && ($page==1)) ) { - if ( '' == get_option('permalink_structure') ) - $output .= '<a href="' . get_permalink() . '&page=' . $i . '">'; - else - $output .= '<a href="' . trailingslashit(get_permalink()) . $i . '/">'; + if ( 1 == $i ) { + $output .= '<a href="' . get_permalink() . '">'; + } else { + if ( '' == get_option('permalink_structure') ) + $output .= '<a href="' . get_permalink() . '&page=' . $i . '">'; + else + $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">'; + } } $output .= $j; if ( ($i != $page) || ((!$more) && ($page==1)) ) @@ -170,17 +174,25 @@ function wp_link_pages($args = '') { $output .= $before; $i = $page - 1; if ( $i && $more ) { - if ( '' == get_option('permalink_structure') ) - $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $previouspagelink . '</a>'; - else - $output .= '<a href="' . get_permalink() . $i . '/">'.$previouspagelink.'</a>'; + if ( 1 == $i ) { + $output .= '<a href="' . get_permalink() . '">' . $previouspagelink . '</a>'; + } else { + if ( '' == get_option('permalink_structure') ) + $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $previouspagelink . '</a>'; + else + $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $previouspagelink . '</a>'; + } } $i = $page + 1; if ( $i <= $numpages && $more ) { - if ( '' == get_option('permalink_structure') ) - $output .= '<a href="' . get_permalink() . '&page=' . $i . '">'.$nextpagelink.'</a>'; - else - $output .= '<a href="' . trailingslashit(get_permalink()) . $i . '/">' . $nextpagelink . '</a>'; + if ( 1 == $i ) { + $output .= '<a href="' . get_permalink() . '">' . $nextpagelink . '</a>'; + } else { + if ( '' == get_option('permalink_structure') ) + $output .= '<a href="' . get_permalink() . '&page=' . $i . '">' . $nextpagelink . '</a>'; + else + $output .= '<a href="' . trailingslashit(get_permalink()) . user_trailingslashit($i, 'single_paged') . '">' . $nextpagelink . '</a>'; + } } $output .= $after; } diff --git a/wp-includes/post.php b/wp-includes/post.php index 33a0a3c..810ad31 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -105,6 +105,7 @@ function &get_post(&$post, $output = OBJECT) { $post_cache[$blog_id][$post->ID] = &$post; $_post = & $post_cache[$blog_id][$post->ID]; } else { + $post = (int) $post; if ( isset($post_cache[$blog_id][$post]) ) $_post = & $post_cache[$blog_id][$post]; elseif ( $_post = wp_cache_get($post, 'pages') ) @@ -932,6 +933,7 @@ function &get_page(&$page, $output = OBJECT) { wp_cache_add($page->ID, $page, 'pages'); $_page = $page; } else { + $page = (int) $page; // first, check the cache if ( ! ( $_page = wp_cache_get($page, 'pages') ) ) { // not in the page cache? diff --git a/wp-includes/theme.php b/wp-includes/theme.php index 2f2c1fb..7e45c54 100644 --- a/wp-includes/theme.php +++ b/wp-includes/theme.php @@ -441,9 +441,9 @@ function get_theme_mod($name, $default = false) { $mods = get_option("mods_$theme"); if ( isset($mods[$name]) ) - return $mods[$name]; + return apply_filters( "theme_mod_$name", $mods[$name] ); - return sprintf($default, get_template_directory_uri()); + return apply_filters( "theme_mod_$name", sprintf($default, get_template_directory_uri()) ); } function set_theme_mod($name, $value) { diff --git a/wp-includes/vars.php b/wp-includes/vars.php index 1675ca4..26f0fa0 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -13,27 +13,27 @@ if ( preg_match('#([^/]+\.php)$#', $PHP_SELF, $self_matches) ) { } // Simple browser detection -// We should probably be doing true/false instead of 1/0 here ~ Mark -$is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0; +$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = false; -if ( preg_match('/Lynx/', $_SERVER['HTTP_USER_AGENT']) ) - $is_lynx = 1; -elseif ( preg_match('/Gecko/', $_SERVER['HTTP_USER_AGENT']) ) - $is_gecko = 1; -elseif ( preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Win/', $_SERVER['HTTP_USER_AGENT']) ) - $is_winIE = 1; -elseif ( preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT']) && preg_match('/Mac/', $_SERVER['HTTP_USER_AGENT']) ) - $is_macIE = 1; -elseif ( preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']) ) - $is_opera = 1; -elseif ( preg_match('/Nav/', $_SERVER['HTTP_USER_AGENT']) || preg_match('/Mozilla\/4\./', $_SERVER['HTTP_USER_AGENT']) ) - $is_NS4 = 1; +if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) { + $is_lynx = true; +} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) { + $is_gecko = true; +} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Win')) { + $is_winIE = true; +} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) { + $is_macIE = true; +} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { + $is_opera = true; +} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Nav') !== false && strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla/4.') !== false) { + $is_NS4 = true; +} $is_IE = ( $is_macIE || $is_winIE ); // Server detection -$is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? 1 : 0; -$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? 1 : 0; +$is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false; +$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false; // if the config file does not provide the smilies array, let's define it here if (!isset($wpsmiliestrans)) { |