Changeset 7491
- Timestamp:
- 03/23/2008 05:02:11 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r7485 r7491 1226 1226 add_action('admin_head_media_upload_library_form', 'media_admin_css'); 1227 1227 1228 1229 register_taxonomy(1230 'image_tags',1231 'attachment:image',1232 array(1233 'label' => __('Tags'),1234 'template' => __('Tags: %l'),1235 'sort' => false,1236 )1237 );1238 1239 // Any 'attachment' taxonomy will be included in the description input form for the multi uploader1240 // Example:1241 /*1242 register_taxonomy(1243 'image_people',1244 'attachment:image',1245 array(1246 'label' => __('People'),1247 'template' => __('People: %l'),1248 'helps' => __('Left to right, top to bottom.'),1249 'sort' => true,1250 'args' => array(1251 'orderby' => 'term_order'1252 )1253 )1254 );1255 */1256 /*1257 register_taxonomy('movie_director', 'attachment:video', array('label'=>__('Directors'), 'template'=>__('Directed by %l.')));1258 register_taxonomy('movie_producer', 'attachment:video', array('label'=>__('Producers'), 'template'=>__('Produced by %l.')));1259 register_taxonomy('movie_screenwriter', 'attachment:video', array('label'=>__('Screenwriter'), 'template'=>__('Screenplay by %l.')));1260 register_taxonomy('movie_actor', 'attachment:video', array('label'=>__('Cast'), 'template'=>array(__('Cast: %l.')));1261 register_taxonomy('movie_crew', 'attachment:video', array('label'=>__('Crew'), 'template'=>array(__('Crew: %l.')));1262 */1263 1264 1228 ?> -
trunk/wp-includes/classes.php
r7454 r7491 2 2 3 3 class WP { 4 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots' );4 var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term'); 5 5 6 6 var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type', 'post_status', 'category__in', 'category__not_in', 'category__and', 'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and', 'tag_id', 'post_mime_type', 'perm'); -
trunk/wp-includes/default-filters.php
r6985 r7491 107 107 add_filter('the_content', 'convert_chars'); 108 108 add_filter('the_content', 'wpautop'); 109 add_filter('the_content', 'prepend_attachment'); 109 110 110 111 add_filter('the_excerpt', 'wptexturize'); -
trunk/wp-includes/post-template.php
r7404 r7491 502 502 503 503 function prepend_attachment($content) { 504 global $post; 505 506 if ( empty($post->post_type) || $post->post_type != 'attachment' ) 507 return; 508 504 509 $p = '<p class="attachment">'; 505 510 // show the medium sized image representation of the attachment if available, and link to the raw file -
trunk/wp-includes/query.php
r7109 r7491 115 115 116 116 if ( in_array( $tag_obj->slug, $slug ) ) 117 return true; 118 119 return false; 120 } 121 122 function is_tax( $slug = '' ) { 123 global $wp_query; 124 125 if ( !$wp_query->is_tax ) 126 return false; 127 128 if ( empty($slug) ) 129 return true; 130 131 $term = $wp_query->get_queried_object(); 132 133 $slug = (array) $slug; 134 135 if ( in_array( $term->slug, $slug ) ) 117 136 return true; 118 137 … … 371 390 var $is_category = false; 372 391 var $is_tag = false; 392 var $is_tax = false; 373 393 var $is_search = false; 374 394 var $is_feed = false; … … 396 416 $this->is_category = false; 397 417 $this->is_tag = false; 418 $this->is_tax = false; 398 419 $this->is_search = false; 399 420 $this->is_feed = false; … … 658 679 } 659 680 681 if ( empty($qv['taxonomy']) || empty($qv['term']) ) { 682 $this->is_tax = false; 683 } else { 684 $this->is_tax = true; 685 } 686 660 687 if ( empty($qv['author']) || ($qv['author'] == '0') ) { 661 688 $this->is_author = false; … … 841 868 if ( $q['m'] ) { 842 869 $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']); 843 $where .= ' AND YEAR(post_date)='. substr($q['m'], 0, 4);870 $where .= " AND YEAR($wpdb->posts.post_date)=" . substr($q['m'], 0, 4); 844 871 if (strlen($q['m'])>5) 845 $where .= ' AND MONTH(post_date)='. substr($q['m'], 4, 2);872 $where .= " AND MONTH($wpdb->posts.post_date)=" . substr($q['m'], 4, 2); 846 873 if (strlen($q['m'])>7) 847 $where .= ' AND DAYOFMONTH(post_date)='. substr($q['m'], 6, 2);874 $where .= " AND DAYOFMONTH($wpdb->posts.post_date)=" . substr($q['m'], 6, 2); 848 875 if (strlen($q['m'])>9) 849 $where .= ' AND HOUR(post_date)='. substr($q['m'], 8, 2);876 $where .= " AND HOUR($wpdb->posts.post_date)=" . substr($q['m'], 8, 2); 850 877 if (strlen($q['m'])>11) 851 $where .= ' AND MINUTE(post_date)='. substr($q['m'], 10, 2);878 $where .= " AND MINUTE($wpdb->posts.post_date)=" . substr($q['m'], 10, 2); 852 879 if (strlen($q['m'])>13) 853 $where .= ' AND SECOND(post_date)='. substr($q['m'], 12, 2);880 $where .= " AND SECOND($wpdb->posts.post_date)=" . substr($q['m'], 12, 2); 854 881 } 855 882 856 883 if ( '' !== $q['hour'] ) 857 $where .= " AND HOUR( post_date)='" . $q['hour'] . "'";884 $where .= " AND HOUR($wpdb->posts.post_date)='" . $q['hour'] . "'"; 858 885 859 886 if ( '' !== $q['minute'] ) 860 $where .= " AND MINUTE( post_date)='" . $q['minute'] . "'";887 $where .= " AND MINUTE($wpdb->posts.post_date)='" . $q['minute'] . "'"; 861 888 862 889 if ( '' !== $q['second'] ) 863 $where .= " AND SECOND( post_date)='" . $q['second'] . "'";890 $where .= " AND SECOND($wpdb->posts.post_date)='" . $q['second'] . "'"; 864 891 865 892 if ( $q['year'] ) 866 $where .= " AND YEAR( post_date)='" . $q['year'] . "'";893 $where .= " AND YEAR($wpdb->posts.post_date)='" . $q['year'] . "'"; 867 894 868 895 if ( $q['monthnum'] ) 869 $where .= " AND MONTH( post_date)='" . $q['monthnum'] . "'";896 $where .= " AND MONTH($wpdb->posts.post_date)='" . $q['monthnum'] . "'"; 870 897 871 898 if ( $q['day'] ) 872 $where .= " AND DAYOFMONTH( post_date)='" . $q['day'] . "'";899 $where .= " AND DAYOFMONTH($wpdb->posts.post_date)='" . $q['day'] . "'"; 873 900 874 901 if ('' != $q['name']) { 875 902 $q['name'] = sanitize_title($q['name']); 876 $where .= " AND post_name = '" . $q['name'] . "'";903 $where .= " AND $wpdb->posts.post_name = '" . $q['name'] . "'"; 877 904 } else if ('' != $q['pagename']) { 878 905 if ( isset($this->queried_object_id) ) … … 904 931 $q['attachment'] = sanitize_title(basename($attach_paths)); 905 932 $q['name'] = $q['attachment']; 906 $where .= " AND post_name = '" . $q['attachment'] . "'";933 $where .= " AND $wpdb->posts.post_name = '" . $q['attachment'] . "'"; 907 934 } 908 935 909 936 if ( $q['w'] ) 910 $where .= " AND WEEK( post_date, 1)='" . $q['w'] . "'";937 $where .= " AND WEEK($wpdb->posts.post_date, 1)='" . $q['w'] . "'"; 911 938 912 939 if ( intval($q['comments_popup']) ) … … 942 969 foreach((array)$q['search_terms'] as $term) { 943 970 $term = addslashes_gpc($term); 944 $search .= "{$searchand}(( post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}'))";971 $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))"; 945 972 $searchand = ' AND '; 946 973 } 947 974 $term = $wpdb->escape($q['s']); 948 975 if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) 949 $search .= " OR ( post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')";976 $search .= " OR ($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')"; 950 977 951 978 if ( !empty($search) ) … … 1113 1140 } 1114 1141 1142 // Taxonomies 1143 if ( $this->is_tax ) { 1144 $terms = get_terms($q['taxonomy'], array('slug'=>$q['term'])); 1145 foreach ( $terms as $term ) 1146 $term_ids[] = $term->term_id; 1147 $post_ids = get_objects_in_term($term_ids, $q['taxonomy']); 1148 1149 if ( count($post_ids) ) { 1150 $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") "; 1151 $post_type = 'any'; 1152 $q['post_status'] = 'publish'; 1153 $post_status_join = true; 1154 } else { 1155 $whichcat = " AND 0 = 1"; 1156 } 1157 } 1158 1115 1159 // Author/user stuff 1116 1160 … … 1130 1174 } 1131 1175 $author_array = preg_split('/[,\s]+/', $q['author']); 1132 $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);1176 $whichauthor .= " AND ($wpdb->posts.post_author ".$eq.' '.intval($author_array[0]); 1133 1177 for ($i = 1; $i < (count($author_array)); $i = $i + 1) { 1134 $whichauthor .= ' '.$andor. ' post_author '.$eq.' '.intval($author_array[$i]);1178 $whichauthor .= ' '.$andor." $wpdb->posts.post_author ".$eq.' '.intval($author_array[$i]); 1135 1179 } 1136 1180 $whichauthor .= ')'; … … 1150 1194 $q['author_name'] = sanitize_title($q['author_name']); 1151 1195 $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'"); 1152 $whichauthor .= ' AND (post_author = '.intval($q['author']).')';1196 $whichauthor .= " AND ($wpdb->posts.post_author = ".intval($q['author']).')'; 1153 1197 } 1154 1198 … … 1165 1209 // Order by 1166 1210 if ( empty($q['orderby']) ) { 1167 $q['orderby'] = 'post_date '.$q['order'];1211 $q['orderby'] = "$wpdb->posts.post_date ".$q['order']; 1168 1212 } else { 1169 1213 // Used to filter values … … 1181 1225 case 'menu_order': 1182 1226 case 'ID': 1227 $orderby = "$wpdb->posts.ID"; 1183 1228 break; 1184 1229 case 'rand': … … 1186 1231 break; 1187 1232 default: 1188 $orderby = 'post_'. $orderby;1233 $orderby = "$wpdb->posts.post_" . $orderby; 1189 1234 } 1190 1235 if ( in_array($orderby_array[$i], $allowed_keys) ) … … 1196 1241 1197 1242 if ( empty($q['orderby']) ) 1198 $q['orderby'] = 'post_date '.$q['order'];1243 $q['orderby'] = "$wpdb->posts.post_date ".$q['order']; 1199 1244 } 1200 1245 1201 1246 if ( $this->is_attachment ) { 1202 $where .= " AND post_type = 'attachment'";1247 $where .= " AND $wpdb->posts.post_type = 'attachment'"; 1203 1248 } elseif ($this->is_page) { 1204 $where .= " AND post_type = 'page'";1249 $where .= " AND $wpdb->posts.post_type = 'page'"; 1205 1250 } elseif ($this->is_single) { 1206 $where .= " AND post_type = 'post'";1251 $where .= " AND $wpdb->posts.post_type = 'post'"; 1207 1252 } elseif ( 'any' == $post_type ) { 1208 1253 $where .= ''; 1209 1254 } else { 1210 $where .= " AND post_type = '$post_type'";1255 $where .= " AND $wpdb->posts.post_type = '$post_type'"; 1211 1256 } 1212 1257 1213 1258 if ( isset($q['post_status']) && '' != $q['post_status'] ) { 1259 $statuswheres = array(); 1214 1260 $q_status = explode(',', $q['post_status']); 1215 1261 $r_status = array(); 1216 1262 $p_status = array(); 1217 1263 if ( in_array( 'draft' , $q_status ) ) 1218 $r_status[] = " post_status = 'draft'";1264 $r_status[] = "$wpdb->posts.post_status = 'draft'"; 1219 1265 if ( in_array( 'pending', $q_status ) ) 1220 $r_status[] = " post_status = 'pending'";1266 $r_status[] = "$wpdb->posts.post_status = 'pending'"; 1221 1267 if ( in_array( 'future' , $q_status ) ) 1222 $r_status[] = " post_status = 'future'";1268 $r_status[] = "$wpdb->posts.post_status = 'future'"; 1223 1269 if ( in_array( 'inherit' , $q_status ) ) 1224 $r_status[] = " post_status = 'inherit'";1270 $r_status[] = "$wpdb->posts.post_status = 'inherit'"; 1225 1271 if ( in_array( 'private', $q_status ) ) 1226 $p_status[] = " post_status = 'private'";1272 $p_status[] = "$wpdb->posts.post_status = 'private'"; 1227 1273 if ( in_array( 'publish', $q_status ) ) 1228 $r_status[] = " post_status = 'publish'";1274 $r_status[] = "$wpdb->posts.post_status = 'publish'"; 1229 1275 1230 1276 if ( empty($q['perm'] ) || 'readable' != $q['perm'] ) { … … 1235 1281 if ( !empty($r_status) ) { 1236 1282 if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can("edit_others_{$post_type}s") ) 1237 $ where .= " AND (post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))";1283 $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))"; 1238 1284 else 1239 $ where .= " AND(" . join( ' OR ', $r_status ) . ")";1285 $statuswheres[] = "(" . join( ' OR ', $r_status ) . ")"; 1240 1286 } 1241 1287 if ( !empty($p_status) ) { 1242 1288 if ( !empty($q['perm'] ) && 'readable' == $q['perm'] && !current_user_can("read_private_{$post_type}s") ) 1243 $ where .= " AND (post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))";1289 $statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $p_status ) . "))"; 1244 1290 else 1245 $where .= " AND (" . join( ' OR ', $p_status ) . ")"; 1246 } 1291 $statuswheres[] = "(" . join( ' OR ', $p_status ) . ")"; 1292 } 1293 if ( $post_status_join ) { 1294 $join .= " INNER JOIN $wpdb->posts AS p2 ON ($wpdb->posts.post_parent = p2.ID) "; 1295 foreach ( $statuswheres as $index => $statuswhere ) 1296 $statuswheres[$index] = "($statuswhere OR ($wpdb->posts.post_status = 'inherit' AND " . str_replace($wpdb->posts, 'p2', $statuswhere) . "))"; 1297 } 1298 foreach ( $statuswheres as $statuswhere ) 1299 $where .= " AND $statuswhere"; 1247 1300 } elseif ( !$this->is_singular ) { 1248 $where .= " AND ( post_status = 'publish'";1301 $where .= " AND ($wpdb->posts.post_status = 'publish'"; 1249 1302 1250 1303 if ( is_admin() ) 1251 $where .= " OR post_status = 'future' OR post_status = 'draft' ORpost_status = 'pending'";1304 $where .= " OR $wpdb->posts.post_status = 'future' OR $wpdb->posts.post_status = 'draft' OR $wpdb->posts.post_status = 'pending'"; 1252 1305 1253 1306 if ( is_user_logged_in() ) { 1254 $where .= current_user_can( "read_private_{$post_type}s" ) ? " OR post_status = 'private'" : " OR post_author = $user_ID ANDpost_status = 'private'";1307 $where .= current_user_can( "read_private_{$post_type}s" ) ? " OR $wpdb->posts.post_status = 'private'" : " OR $wpdb->posts.post_author = $user_ID AND $wpdb->posts.post_status = 'private'"; 1255 1308 } 1256 1309 … … 1505 1558 $this->queried_object = &$tag; 1506 1559 $this->queried_object_id = (int) $tag_id; 1560 } else if ($this->is_tax) { 1561 $tax = $this->get('taxonomy'); 1562 $slug = $this->get('term'); 1563 $term = &get_terms($tax, array('slug'=>$slug)); 1564 if ( is_wp_error($term) ) 1565 return $term; 1566 $this->queried_object = $term; 1567 $this->queried_object_id = $term->term_id; 1507 1568 } else if ($this->is_posts_page) { 1508 1569 $this->queried_object = & get_page(get_option('page_for_posts')); -
trunk/wp-includes/rewrite.php
r6964 r7491 831 831 $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite); 832 832 833 // Extra permastructs 834 $extra_rewrite = array(); 835 foreach ( $this->extra_permastructs as $permastruct ) 836 $extra_rewrite = array_merge($extra_rewrite, $this->generate_rewrite_rules($permastruct, EP_NONE)); 837 833 838 // Put them together. 834 839 if ( $this->use_verbose_page_rules ) 835 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $ this->extra_rules);840 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $extra_rewrite, $this->extra_rules); 836 841 else 837 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $ page_rewrite, $this->extra_rules);842 $this->rules = array_merge($this->extra_rules_top, $robots_rewrite, $default_feeds, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $tag_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $extra_rewrite, $page_rewrite, $this->extra_rules); 838 843 839 844 do_action_ref_array('generate_rewrite_rules', array(&$this)); … … 949 954 } 950 955 956 function add_permastruct($struct, $with_front = true) { 957 if ( $with_front ) 958 $struct = $this->front . $struct; 959 $this->extra_permastructs[] = $struct; 960 } 961 951 962 function flush_rules() { 952 963 delete_option('rewrite_rules'); -
trunk/wp-includes/taxonomy.php
r7481 r7491 146 146 */ 147 147 function register_taxonomy( $taxonomy, $object_type, $args = array() ) { 148 global $wp_taxonomies ;148 global $wp_taxonomies, $wp_rewrite; 149 149 150 150 $defaults = array('hierarchical' => false, 'update_count_callback' => ''); 151 151 $args = wp_parse_args($args, $defaults); 152 153 if ( !empty( $args['rewrite'] ) ) { 154 if ( !is_array($args['rewrite']) ) 155 $args['rewrite'] = array(); 156 if ( !isset($args['rewrite']['slug']) ) 157 $args['rewrite']['slug'] = sanitize_title_with_dashes($taxonomy); 158 $wp_rewrite->add_rewrite_tag("%$taxonomy%", '([^/]+)', "taxonomy=$taxonomy&term="); 159 $wp_rewrite->add_permastruct("{$args['rewrite']['slug']}/%$taxonomy%"); 160 } 152 161 153 162 $args['name'] = $taxonomy; -
trunk/wp-includes/template-loader.php
r6483 r7491 25 25 return; 26 26 } else if ( is_attachment() && $template = get_attachment_template() ) { 27 remove_filter('the_content', 'prepend_attachment'); 27 28 include($template); 28 29 return; 29 30 } else if ( is_single() && $template = get_single_template() ) { 30 if ( is_attachment() )31 add_filter('the_content', 'prepend_attachment');32 31 include($template); 33 32 return; 34 33 } else if ( is_page() && $template = get_page_template() ) { 35 if ( is_attachment() )36 add_filter('the_content', 'prepend_attachment');37 34 include($template); 38 35 return; … … 41 38 return; 42 39 } else if ( is_tag() && $template = get_tag_template()) { 40 include($template); 41 return; 42 } else if ( is_tax() && $template = get_taxonomy_template()) { 43 43 include($template); 44 44 return; … … 59 59 return; 60 60 } else if ( file_exists(TEMPLATEPATH . "/index.php") ) { 61 if ( is_attachment() )62 add_filter('the_content', 'prepend_attachment');63 61 include(TEMPLATEPATH . "/index.php"); 64 62 return; -
trunk/wp-includes/theme.php
r7224 r7491 382 382 } 383 383 384 function get_taxonomy_template() { 385 $template = ''; 386 $taxonomy = get_query_var('taxonomy'); 387 $term = get_query_var('term'); 388 if ( $taxonomy && $term && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php") ) 389 $template = TEMPLATEPATH . "/taxonomy-$taxonomy-$term.php"; 390 elseif ( $taxonomy && file_exists(TEMPLATEPATH . "/taxonomy-$taxonomy.php") ) 391 $template = TEMPLATEPATH . "/taxonomy-$taxonomy.php"; 392 elseif ( file_exists(TEMPLATEPATH . "/taxonomy.php") ) 393 $template = TEMPLATEPATH . "/taxonomy.php"; 394 395 return apply_filters('taxonomy_template', $template); 396 } 384 397 385 398 function get_date_template() {
Note: See TracChangeset
for help on using the changeset viewer.