Ticket #1214: functions.php.diff
| File functions.php.diff, 1.5 KB (added by , 21 years ago) |
|---|
-
functions.php
177 177 if ($uri == $siteurl) 178 178 return 0; 179 179 180 // First, check to see if there is a 'p=N' to match against:181 preg_match('#[?&] p=(\d+)#', $uri, $values);182 $p = intval($values[ 1]);180 // First, check to see if there is a 'p=N' or 'page_id=N' to match against: 181 preg_match('#[?&](p|page_id)=(\d+)#', $uri, $values); 182 $p = intval($values[2]); 183 183 if ($p) return $p; 184 184 185 185 // Match $uri against our permalink structure … … 227 227 228 228 // If using %post_id%, we're done: 229 229 if (intval($post_id)) return intval($post_id); 230 230 231 231 // Otherwise, build a WHERE clause, making the values safe along the way: 232 232 if ($year) $where .= " AND YEAR(post_date) = '" . intval($year) . "'"; 233 233 if ($monthnum) $where .= " AND MONTH(post_date) = '" . intval($monthnum) . "'"; … … 242 242 return false; 243 243 } 244 244 245 // if all we got was a postname, it's probably a page, so we'll want to check for a possible subpage 246 if ($postname && !$year && !$monthnum && !$day && !$hour && !$minute && !$second) { 247 $postname = rtrim(strstr($uri, $postname), '/'); 248 $uri_array = explode('/', $postname); 249 $postname = $uri_array[count($uri_array) - 1]; 250 $where = " AND post_name = '" . $wpdb->escape($postname) . "' "; 251 } 252 245 253 // Run the query to get the post ID: 246 254 $id = intval($wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE 1 = 1 " . $where)); 247 255