Changeset 21735
- Timestamp:
- 09/04/2012 04:29:28 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-comments-list-table.php
r21323 r21735 303 303 304 304 function single_row( $a_comment ) { 305 global $post, $comment; 305 global $comment; 306 $post = get_post(); 306 307 307 308 $comment = $a_comment; … … 326 327 327 328 function column_comment( $comment ) { 328 global $post, $comment_status; 329 global $comment_status; 330 $post = get_post(); 329 331 330 332 $user_can = $this->user_can; … … 480 482 481 483 function column_response( $comment ) { 482 global $post;484 $post = get_post(); 483 485 484 486 if ( isset( $this->pending_count[$post->ID] ) ) { -
trunk/wp-admin/includes/class-wp-media-list-table.php
r21504 r21735 157 157 158 158 function display_rows() { 159 global $post, $id; 159 $post = get_post(); 160 $id = $post->ID; 160 161 161 162 add_filter( 'the_title','esc_html' ); -
trunk/wp-admin/includes/class-wp-posts-list-table.php
r21597 r21735 317 317 318 318 function _display_rows( $posts, $level = 0 ) { 319 global $ post, $mode;319 global $mode; 320 320 321 321 // Create array of post IDs. … … 459 459 } 460 460 461 function single_row( $ a_post, $level = 0 ) {462 global $ post, $mode;461 function single_row( $post, $level = 0 ) { 462 global $mode; 463 463 static $alternate; 464 464 465 $global_post = $post;466 $ post = $a_post;465 $global_post = get_post(); 466 $GLOBALS['post'] = $post; 467 467 setup_postdata( $post ); 468 468 … … 530 530 else { 531 531 $attributes = 'class="post-title page-title column-title"' . $style; 532 532 533 533 $pad = str_repeat( '— ', $level ); 534 534 ?> … … 685 685 </tr> 686 686 <?php 687 $ post= $global_post;687 $GLOBALS['post'] = $global_post; 688 688 } 689 689 -
trunk/wp-admin/includes/export.php
r19859 r21735 280 280 */ 281 281 function wxr_post_taxonomy() { 282 global $post;282 $post = get_post(); 283 283 284 284 $taxonomies = get_object_taxonomies( $post->post_type ); -
trunk/wp-admin/includes/meta-boxes.php
r21688 r21735 467 467 * @param object $post 468 468 */ 469 function post_comment_meta_box( $post) {470 global $wpdb , $post_ID;469 function post_comment_meta_box( $post ) { 470 global $wpdb; 471 471 472 472 wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); 473 473 ?> 474 <p class="hide-if-no-js" id="add-new-comment"><a href="#commentstatusdiv" onclick="commentReply.addcomment(<?php echo $post _ID; ?>);return false;"><?php _e('Add comment'); ?></a></p>474 <p class="hide-if-no-js" id="add-new-comment"><a href="#commentstatusdiv" onclick="commentReply.addcomment(<?php echo $post->ID; ?>);return false;"><?php _e('Add comment'); ?></a></p> 475 475 <?php 476 476 477 $total = get_comments( array( 'post_id' => $post _ID, 'number' => 1, 'count' => true ) );477 $total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) ); 478 478 $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); 479 479 $wp_list_table->display( true ); … … 911 911 * @since 2.9.0 912 912 */ 913 function post_thumbnail_meta_box() { 914 global $post; 913 function post_thumbnail_meta_box( $post ) { 915 914 $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 916 915 echo _wp_post_thumbnail_html( $thumbnail_id ); -
trunk/wp-admin/includes/post.php
r21651 r21735 1122 1122 * 1123 1123 * @param int $thumbnail_id ID of the attachment used for thumbnail 1124 * @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID1124 * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. 1125 1125 * @return string html 1126 1126 */ 1127 function _wp_post_thumbnail_html( $thumbnail_id = null, $post_id = null ) { 1128 global $content_width, $_wp_additional_image_sizes, $post_ID; 1129 1130 if ( empty( $post_id ) ) 1131 $post_id = $post_ID; 1132 1133 $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post_id) ); 1127 function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { 1128 global $content_width, $_wp_additional_image_sizes; 1129 1130 $post = get_post( $post ); 1131 1132 $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->ID ) ); 1134 1133 $set_thumbnail_link = '<p class="hide-if-no-js"><a title="' . esc_attr__( 'Set featured image' ) . '" href="%s" id="set-post-thumbnail" class="thickbox">%s</a></p>'; 1135 1134 $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) ); … … 1143 1142 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' ); 1144 1143 if ( !empty( $thumbnail_html ) ) { 1145 $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id");1144 $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID ); 1146 1145 $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html ); 1147 1146 $content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html__( 'Remove featured image' ) . '</a></p>'; … … 1150 1149 } 1151 1150 1152 return apply_filters( 'admin_post_thumbnail_html', $content, $post _id);1151 return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID ); 1153 1152 } 1154 1153 … … 1208 1207 */ 1209 1208 function _admin_notice_post_locked() { 1210 global $post; 1211 1209 $post = get_post(); 1212 1210 $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); 1213 1211 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); -
trunk/wp-admin/includes/template.php
r21659 r21735 167 167 */ 168 168 function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) { 169 global $post_ID; 170 171 if ( $post_ID ) 172 $checked_terms = wp_get_object_terms($post_ID, $taxonomy, array('fields'=>'ids')); 169 $post = get_post(); 170 if ( $post->ID ) 171 $checked_terms = wp_get_object_terms($post->ID, $taxonomy, array('fields'=>'ids')); 173 172 else 174 173 $checked_terms = array(); … … 576 575 */ 577 576 function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { 578 global $wp_locale, $post, $comment; 577 global $wp_locale, $comment; 578 $post = get_post(); 579 579 580 580 if ( $for_post ) … … 671 671 */ 672 672 function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { 673 global $wpdb, $post_ID; 673 global $wpdb; 674 $post = get_post(); 674 675 $items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' ORDER BY menu_order", $parent) ); 675 676 … … 677 678 foreach ( $items as $item ) { 678 679 // A page cannot be its own parent. 679 if (!empty ( $post_ID ) ) { 680 if ( $item->ID == $post_ID ) { 681 continue; 682 } 683 } 680 if ( $post->ID && $item->ID == $post->ID ) 681 continue; 682 684 683 $pad = str_repeat( ' ', $level * 3 ); 685 684 if ( $item->ID == $default) … … 1346 1345 */ 1347 1346 function the_post_password() { 1348 global $post; 1349 if ( isset( $post->post_password ) ) echo esc_attr( $post->post_password ); 1347 $post = get_post(); 1348 if ( isset( $post->post_password ) ) 1349 echo esc_attr( $post->post_password ); 1350 1350 } 1351 1351 … … 1357 1357 * 1358 1358 * @since 2.7.0 1359 * @param int $post_id The post id. If not supplied the global $post is used.1359 * @param mixed $post Post id or object. If not supplied the global $post is used. 1360 1360 * @return string The post title if set 1361 1361 */ 1362 function _draft_or_post_title( $post _id= 0 ) {1363 $title = get_the_title( $post_id);1364 if ( empty( $title) )1365 $title = __( '(no title)');1362 function _draft_or_post_title( $post = 0 ) { 1363 $title = get_the_title( $post ); 1364 if ( empty( $title ) ) 1365 $title = __( '(no title)' ); 1366 1366 return $title; 1367 1367 } -
trunk/wp-includes/admin-bar.php
r21549 r21735 420 420 */ 421 421 function wp_admin_bar_edit_menu( $wp_admin_bar ) { 422 global $ post, $tag, $wp_the_query;422 global $tag, $wp_the_query; 423 423 424 424 if ( is_admin() ) { 425 425 $current_screen = get_current_screen(); 426 $post = get_post(); 426 427 427 428 if ( 'post' == $current_screen->base … … 620 621 621 622 $title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; 622 $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; 623 $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; 623 624 624 625 $wp_admin_bar->add_menu( array( -
trunk/wp-includes/author-template.php
r20615 r21735 70 70 */ 71 71 function get_the_modified_author() { 72 global $post; 73 if ( $last_id = get_post_meta($post->ID, '_edit_last', true) ) { 72 if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true) ) { 74 73 $last_user = get_userdata($last_id); 75 74 return apply_filters('the_modified_author', $last_user->display_name); … … 165 164 */ 166 165 function get_the_author_posts() { 167 global $post; 168 return count_user_posts($post->post_author); 166 return count_user_posts( get_post()->post_author ); 169 167 } 170 168 -
trunk/wp-includes/category-template.php
r20675 r21735 1055 1055 * @since 2.5.0 1056 1056 * 1057 * @param int $id Post ID.1057 * @param mixed $post Post ID or object. 1058 1058 * @param string $taxonomy Taxonomy name. 1059 1059 * @return array|bool False on failure. Array of term objects on success. 1060 1060 */ 1061 function get_the_terms( $id, $taxonomy ) { 1062 global $post; 1063 1064 $id = (int) $id; 1065 1066 if ( !$id ) { 1067 if ( empty( $post->ID ) ) 1068 return false; 1069 else 1070 $id = (int) $post->ID; 1071 } 1072 1073 $terms = get_object_term_cache( $id, $taxonomy ); 1061 function get_the_terms( $post, $taxonomy ) { 1062 if ( ! $post = get_post( $post ) ) 1063 return false; 1064 1065 $terms = get_object_term_cache( $post->ID, $taxonomy ); 1074 1066 if ( false === $terms ) { 1075 $terms = wp_get_object_terms( $ id, $taxonomy );1076 wp_cache_add($ id, $terms, $taxonomy . '_relationships');1077 } 1078 1079 $terms = apply_filters( 'get_the_terms', $terms, $ id, $taxonomy );1067 $terms = wp_get_object_terms( $post->ID, $taxonomy ); 1068 wp_cache_add($post->ID, $terms, $taxonomy . '_relationships'); 1069 } 1070 1071 $terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy ); 1080 1072 1081 1073 if ( empty( $terms ) ) -
trunk/wp-includes/class-wp-atom-server.php
r21651 r21735 847 847 * @return string 848 848 */ 849 function get_entry_url( $postID = null) {849 function get_entry_url( $postID = null ) { 850 850 if (!isset($postID)) { 851 global $post; 852 $postID = (int) $post->ID; 851 $postID = (int) get_post()->ID; 853 852 } 854 853 … … 879 878 function get_media_url($postID = null) { 880 879 if (!isset($postID)) { 881 global $post; 882 $postID = (int) $post->ID; 880 $postID = (int) get_post()->ID; 883 881 } 884 882 -
trunk/wp-includes/class-wp-editor.php
r21664 r21735 127 127 128 128 public static function editor_settings($editor_id, $set) { 129 global $editor_styles , $post;129 global $editor_styles; 130 130 $first_run = false; 131 131 … … 371 371 $body_class = $editor_id; 372 372 373 if ( isset($post) )374 $body_class .= " post-type-$post->post_type";373 if ( $post = get_post() ) 374 $body_class .= ' post-type-' . $post->post_type; 375 375 376 376 if ( !empty($set['tinymce']['body_class']) ) { … … 613 613 614 614 public static function wp_fullscreen_html() { 615 global $content_width, $post; 615 global $content_width; 616 $post = get_post(); 616 617 617 618 $width = isset($content_width) && 800 > $content_width ? $content_width : 800; -
trunk/wp-includes/comment-template.php
r21364 r21735 811 811 */ 812 812 function wp_comment_form_unfiltered_html_nonce() { 813 global $post; 814 815 $post_id = 0; 816 if ( !empty($post) ) 817 $post_id = $post->ID; 813 $post = get_post(); 814 $post_id = $post ? $post->ID : 0; 818 815 819 816 if ( current_user_can( 'unfiltered_html' ) ) { -
trunk/wp-includes/deprecated.php
r21651 r21735 58 58 */ 59 59 function start_wp() { 60 global $wp_query , $post;60 global $wp_query; 61 61 62 62 _deprecated_function( __FUNCTION__, '1.5', __('new WordPress Loop') ); … … 65 65 $wp_query->next_post(); 66 66 67 setup_postdata( $post);67 setup_postdata( get_post() ); 68 68 } 69 69 -
trunk/wp-includes/general-template.php
r21610 r21735 1312 1312 */ 1313 1313 function the_date_xml() { 1314 global $post; 1315 echo mysql2date('Y-m-d', $post->post_date, false); 1314 echo mysql2date( 'Y-m-d', get_post()->post_date, false ); 1316 1315 } 1317 1316 … … 1368 1367 */ 1369 1368 function get_the_date( $d = '' ) { 1370 global $post;1369 $post = get_post(); 1371 1370 $the_date = ''; 1372 1371 … … 1529 1528 */ 1530 1529 function the_weekday() { 1531 global $wp_locale , $post;1532 $the_weekday = $wp_locale->get_weekday( mysql2date('w', $post->post_date, false));1530 global $wp_locale; 1531 $the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) ); 1533 1532 $the_weekday = apply_filters('the_weekday', $the_weekday); 1534 1533 echo $the_weekday; … … 1547 1546 */ 1548 1547 function the_weekday_date($before='',$after='') { 1549 global $wp_locale, $ post, $day, $previousweekday;1548 global $wp_locale, $day, $previousweekday; 1550 1549 $the_weekday_date = ''; 1551 1550 if ( $currentday != $previousweekday ) { 1552 1551 $the_weekday_date .= $before; 1553 $the_weekday_date .= $wp_locale->get_weekday( mysql2date('w', $post->post_date, false));1552 $the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) ); 1554 1553 $the_weekday_date .= $after; 1555 1554 $previousweekday = $currentday; -
trunk/wp-includes/link-template.php
r21734 r21735 55 55 * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'. 56 56 */ 57 function permalink_anchor( $mode = 'id') {58 global $post;59 switch ( strtolower( $mode) ) {57 function permalink_anchor( $mode = 'id' ) { 58 $post = get_post(); 59 switch ( strtolower( $mode ) ) { 60 60 case 'title': 61 $title = sanitize_title( $post->post_title) . '-' . $post->ID;61 $title = sanitize_title( $post->post_title ) . '-' . $post->ID; 62 62 echo '<a id="'.$title.'"></a>'; 63 63 break; … … 78 78 * @return string 79 79 */ 80 function get_permalink( $id = 0, $leavename = false) {80 function get_permalink( $id = 0, $leavename = false ) { 81 81 $rewritecode = array( 82 82 '%year%', … … 233 233 * @since 1.5.0 234 234 * 235 * @param int $id Optional. Post ID.235 * @param mixed $post Optional. Post ID or object. 236 236 * @param bool $leavename Optional, defaults to false. Whether to keep page name. 237 237 * @param bool $sample Optional, defaults to false. Is it a sample permalink. 238 238 * @return string 239 239 */ 240 function get_page_link( $id = false, $leavename = false, $sample = false ) { 241 global $post; 242 243 $id = (int) $id; 244 if ( !$id ) 245 $id = (int) $post->ID; 246 247 if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') ) 240 function get_page_link( $post = false, $leavename = false, $sample = false ) { 241 $post = get_post( $post ); 242 243 if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) ) 248 244 $link = home_url('/'); 249 245 else 250 $link = _get_page_link( $ id, $leavename, $sample );251 252 return apply_filters( 'page_link', $link, $id, $sample);246 $link = _get_page_link( $post, $leavename, $sample ); 247 248 return apply_filters( 'page_link', $link, $post->ID, $sample ); 253 249 } 254 250 … … 261 257 * @access private 262 258 * 263 * @param int $id Optional. Post ID.259 * @param mixed $post Optional. Post ID or object. 264 260 * @param bool $leavename Optional. Leave name. 265 261 * @param bool $sample Optional. Sample permalink. 266 262 * @return string 267 263 */ 268 function _get_page_link( $ id= false, $leavename = false, $sample = false ) {264 function _get_page_link( $post = false, $leavename = false, $sample = false ) { 269 265 global $wp_rewrite; 270 266 271 $post = get_post( $ id);267 $post = get_post( $post ); 272 268 273 269 $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ); … … 277 273 if ( !empty($link) && ( ( isset($post->post_status) && !$draft_or_pending ) || $sample ) ) { 278 274 if ( ! $leavename ) { 279 $link = str_replace('%pagename%', get_page_uri( $id), $link);275 $link = str_replace('%pagename%', get_page_uri( $post ), $link); 280 276 } 281 277 … … 283 279 $link = user_trailingslashit($link, 'page'); 284 280 } else { 285 $link = home_url( "?page_id=$id");286 } 287 288 return apply_filters( '_get_page_link', $link, $ id);281 $link = home_url( '?page_id=' . $post->ID ); 282 } 283 284 return apply_filters( '_get_page_link', $link, $post->ID ); 289 285 } 290 286 … … 296 292 * @since 2.0.0 297 293 * 298 * @param int $id Optional. Post ID.299 * @return string 300 */ 301 function get_attachment_link( $id = false) {302 global $ post, $wp_rewrite;294 * @param mixed $post Optional. Post ID or object. 295 * @return string 296 */ 297 function get_attachment_link( $post = null ) { 298 global $wp_rewrite; 303 299 304 300 $link = false; 305 301 306 if ( ! $id) 307 $id = (int) $post->ID; 308 309 $object = get_post($id); 310 if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) && ($object->post_parent != $id) ) { 311 $parent = get_post($object->post_parent); 302 $post = get_post( $post ); 303 304 if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) { 305 $parent = get_post($post->post_parent); 312 306 if ( 'page' == $parent->post_type ) 313 $parentlink = _get_page_link( $ object->post_parent ); // Ignores page_on_front307 $parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front 314 308 else 315 $parentlink = get_permalink( $ object->post_parent );316 317 if ( is_numeric($ object->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )318 $name = 'attachment/' . $ object->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker309 $parentlink = get_permalink( $post->post_parent ); 310 311 if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') ) 312 $name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker 319 313 else 320 $name = $ object->post_name;314 $name = $post->post_name; 321 315 322 316 if ( strpos($parentlink, '?') === false ) … … 325 319 326 320 if ( ! $link ) 327 $link = home_url( "/?attachment_id=$id");328 329 return apply_filters( 'attachment_link', $link, $id);321 $link = home_url( '/?attachment_id=' . $post->ID ); 322 323 return apply_filters( 'attachment_link', $link, $post->ID ); 330 324 } 331 325 … … 896 890 */ 897 891 function get_edit_post_link( $id = 0, $context = 'display' ) { 898 if ( ! $post = get_post( $id ) )892 if ( ! $post = get_post( $id ) ) 899 893 return; 900 894 … … 1123 1117 */ 1124 1118 function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $previous = true ) { 1125 global $ post, $wpdb;1126 1127 if ( empty( $post) )1119 global $wpdb; 1120 1121 if ( ! $post = get_post() ) 1128 1122 return null; 1129 1123 … … 1208 1202 */ 1209 1203 function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) { 1210 if ( $previous && is_attachment() && is_object( $GLOBALS['post']) )1211 $post = get_post( $GLOBALS['post']->post_parent);1204 if ( $previous && is_attachment() && $post = get_post() ) 1205 $post = get_post( $post->post_parent ); 1212 1206 else 1213 $post = get_adjacent_post( $in_same_cat,$excluded_categories,$previous);1207 $post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous ); 1214 1208 1215 1209 if ( empty($post) ) … … 1300 1294 */ 1301 1295 function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $start = true ) { 1302 global $post; 1303 1304 if ( empty($post) || ! is_single() || is_attachment() ) 1296 $post = get_post(); 1297 if ( ! $post || ! is_single() || is_attachment() ) 1305 1298 return null; 1306 1299 … … 1374 1367 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { 1375 1368 if ( $previous && is_attachment() ) 1376 $post = get_post( $GLOBALS['post']->post_parent);1369 $post = get_post( get_post()->post_parent ); 1377 1370 else 1378 1371 $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); … … 1681 1674 */ 1682 1675 function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { 1683 global $ post, $wp_rewrite;1676 global $wp_rewrite; 1684 1677 1685 1678 $pagenum = (int) $pagenum; 1686 1679 1687 $result = get_permalink( $post->ID);1680 $result = get_permalink(); 1688 1681 1689 1682 if ( 'newest' == get_option('default_comments_page') ) { … … 2413 2406 */ 2414 2407 function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { 2415 global $post;2416 2417 2408 if ( empty( $text ) ) 2418 2409 $text = __('This is the short link.'); … … 2421 2412 $title = the_title_attribute( array( 'echo' => false ) ); 2422 2413 2423 $shortlink = wp_get_shortlink( $post->ID);2414 $shortlink = wp_get_shortlink(); 2424 2415 2425 2416 if ( !empty( $shortlink ) ) { -
trunk/wp-includes/media.php
r21691 r21735 776 776 */ 777 777 function gallery_shortcode($attr) { 778 global $post;778 $post = get_post(); 779 779 780 780 static $instance = 0; … … 929 929 */ 930 930 function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) { 931 global $post; 932 $post = get_post($post); 933 $attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') )); 931 $post = get_post(); 932 $attachments = array_values( get_children( array( 'post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID' ) ) ); 934 933 935 934 foreach ( $attachments as $k => $attachment ) … … 1103 1102 */ 1104 1103 function maybe_run_ajax_cache() { 1105 global $post_ID;1106 1107 if ( empty($post_ID)|| empty($_GET['message']) || 1 != $_GET['message'] )1104 $post = get_post(); 1105 1106 if ( ! $post || empty($_GET['message']) || 1 != $_GET['message'] ) 1108 1107 return; 1109 1108 … … 1112 1111 /* <![CDATA[ */ 1113 1112 jQuery(document).ready(function($){ 1114 $.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post _ID, 'relative' ); ?>");1113 $.get("<?php echo admin_url( 'admin-ajax.php?action=oembed-cache&post=' . $post->ID, 'relative' ); ?>"); 1115 1114 }); 1116 1115 /* ]]> */ … … 1168 1167 */ 1169 1168 function shortcode( $attr, $url = '' ) { 1170 global $post;1171 1172 if ( empty( $url) )1169 $post = get_post(); 1170 1171 if ( empty( $url ) ) 1173 1172 return ''; 1174 1173 … … 1191 1190 } 1192 1191 1193 $post_ID = ( ! empty($post->ID) ) ? $post->ID : null;1194 if ( ! empty($this->post_ID) ) // Potentially set by WP_Embed::cache_oembed()1192 $post_ID = ( ! empty( $post->ID ) ) ? $post->ID : null; 1193 if ( ! empty( $this->post_ID ) ) // Potentially set by WP_Embed::cache_oembed() 1195 1194 $post_ID = $this->post_ID; 1196 1195 … … 1207 1206 return $this->maybe_make_link( $url ); 1208 1207 1209 if ( ! empty($cache) )1208 if ( ! empty( $cache ) ) 1210 1209 return apply_filters( 'embed_oembed_html', $cache, $url, $attr, $post_ID ); 1211 1210 } -
trunk/wp-includes/post-template.php
r21597 r21735 27 27 */ 28 28 function get_the_ID() { 29 global $post; 30 return $post->ID; 29 return get_post()->ID; 31 30 } 32 31 … … 98 97 * @since 0.71 99 98 * 100 * @param int $id Optional. Post ID.99 * @param mixed $post Optional. Post ID or object. 101 100 * @return string 102 101 */ 103 function get_the_title( $ id= 0 ) {104 $post = get_post( $id);105 106 $title = isset( $post->post_title) ? $post->post_title : '';107 $id = isset( $post->ID) ? $post->ID : (int) $id;108 109 if ( ! is_admin() ) {110 if ( ! empty($post->post_password) ) {111 $protected_title_format = apply_filters( 'protected_title_format', __('Protected: %s'));112 $title = sprintf( $protected_title_format, $title);113 } else if ( isset( $post->post_status) && 'private' == $post->post_status ) {114 $private_title_format = apply_filters( 'private_title_format', __('Private: %s'));115 $title = sprintf( $private_title_format, $title);102 function get_the_title( $post = 0 ) { 103 $post = get_post( $post ); 104 105 $title = isset( $post->post_title ) ? $post->post_title : ''; 106 $id = isset( $post->ID ) ? $post->ID : 0; 107 108 if ( ! is_admin() ) { 109 if ( ! empty( $post->post_password ) ) { 110 $protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ) ); 111 $title = sprintf( $protected_title_format, $title ); 112 } else if ( isset( $post->post_status ) && 'private' == $post->post_status ) { 113 $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ) ); 114 $title = sprintf( $private_title_format, $title ); 116 115 } 117 116 } 117 118 118 return apply_filters( 'the_title', $title, $id ); 119 119 } … … 178 178 * @return string 179 179 */ 180 function get_the_content($more_link_text = null, $stripteaser = false) { 181 global $post, $more, $page, $pages, $multipage, $preview; 180 function get_the_content( $more_link_text = null, $stripteaser = false ) { 181 global $more, $page, $pages, $multipage, $preview; 182 183 $post = get_post(); 182 184 183 185 if ( null === $more_link_text ) … … 188 190 189 191 // If post password required and it doesn't match the cookie. 190 if ( post_password_required( $post) )192 if ( post_password_required() ) 191 193 return get_the_password_form(); 192 194 … … 260 262 _deprecated_argument( __FUNCTION__, '2.3' ); 261 263 262 global $post; 263 if ( post_password_required($post) ) { 264 if ( post_password_required() ) { 264 265 return __( 'There is no excerpt because this is a protected post.' ); 265 266 } … … 677 678 */ 678 679 function _wp_link_page( $i ) { 679 global $post, $wp_rewrite; 680 global $wp_rewrite; 681 $post = get_post(); 680 682 681 683 if ( 1 == $i ) { … … 1172 1174 */ 1173 1175 function prepend_attachment($content) { 1174 global $post;1176 $post = get_post(); 1175 1177 1176 1178 if ( empty($post->post_type) || $post->post_type != 'attachment' ) … … 1199 1201 */ 1200 1202 function get_the_password_form() { 1201 global $post;1203 $post = get_post(); 1202 1204 $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID ); 1203 1205 $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post"> -
trunk/wp-includes/post.php
r21655 r21735 373 373 * @link http://codex.wordpress.org/Function_Reference/get_post 374 374 * 375 * @param int|object $post Post ID or post object. 375 * @param int|object $post Post ID or post object. Optional, default is the current post from the loop. 376 376 * @param string $output Optional, default is Object. Either OBJECT, ARRAY_A, or ARRAY_N. 377 377 * @param string $filter Optional, default is raw. 378 378 * @return WP_Post|null WP_Post on success or null on failure 379 379 */ 380 function get_post( $post , $output = OBJECT, $filter = 'raw' ) {380 function get_post( $post = null, $output = OBJECT, $filter = 'raw' ) { 381 381 if ( empty( $post ) && isset( $GLOBALS['post'] ) ) 382 382 $post = $GLOBALS['post']; … … 946 946 * @uses $post The Loop current post global 947 947 * 948 * @param mixed $ the_post Optional. Post object or post ID.948 * @param mixed $post Optional. Post object or post ID. 949 949 * @return bool|string post type or false on failure. 950 950 */ 951 function get_post_type( $the_post = false ) { 952 global $post; 953 954 if ( false === $the_post ) 955 $the_post = $post; 956 elseif ( is_numeric($the_post) ) 957 $the_post = get_post($the_post); 958 959 if ( is_object($the_post) ) 960 return $the_post->post_type; 951 function get_post_type( $post = null ) { 952 if ( $post = get_post( $post ) ) 953 return $post->post_type; 961 954 962 955 return false;
Note: See TracChangeset
for help on using the changeset viewer.