Ticket #21309: 21309.10.diff
File 21309.10.diff, 32.3 KB (added by , 13 years ago) |
---|
-
wp-includes/admin-bar.php
419 419 * @since 3.1.0 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 428 429 && 'add' != $current_screen->action … … 619 620 return; 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( 625 626 'id' => 'updates', -
wp-includes/class-wp-atom-server.php
846 846 * @param int $postID Post ID. 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 855 854 $url = $this->app_base . $this->ENTRY_PATH . "/$postID"; … … 878 877 */ 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 885 883 $url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID"; -
wp-includes/post-template.php
26 26 * @return int 27 27 */ 28 28 function get_the_ID() { 29 global $post; 30 return $post->ID; 29 return get_post()->ID; 31 30 } 32 31 33 32 /** … … 97 96 * 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);102 function get_the_title( $post = 0 ) { 103 $post = get_post( $post ); 105 104 106 105 $title = isset($post->post_title) ? $post->post_title : ''; 107 106 $id = isset($post->ID) ? $post->ID : (int) $id; … … 178 177 * @return string 179 178 */ 180 179 function get_the_content($more_link_text = null, $stripteaser = false) { 181 global $ post, $more, $page, $pages, $multipage, $preview;180 global $more, $page, $pages, $multipage, $preview; 182 181 182 $post = get_post(); 183 183 184 if ( null === $more_link_text ) 184 185 $more_link_text = __( '(more...)' ); 185 186 … … 187 188 $hasTeaser = false; 188 189 189 190 // If post password required and it doesn't match the cookie. 190 if ( post_password_required( $post) )191 if ( post_password_required() ) 191 192 return get_the_password_form(); 192 193 193 194 if ( $page > count($pages) ) // if the requested page doesn't exist … … 259 260 if ( !empty( $deprecated ) ) 260 261 _deprecated_argument( __FUNCTION__, '2.3' ); 261 262 262 global $post; 263 if ( post_password_required($post) ) { 263 if ( post_password_required() ) { 264 264 return __( 'There is no excerpt because this is a protected post.' ); 265 265 } 266 266 … … 676 676 * @return string Link. 677 677 */ 678 678 function _wp_link_page( $i ) { 679 global $post, $wp_rewrite; 679 global $wp_rewrite; 680 $post = get_post(); 680 681 681 682 if ( 1 == $i ) { 682 683 $url = get_permalink(); … … 1171 1172 * @return string 1172 1173 */ 1173 1174 function prepend_attachment($content) { 1174 global $post;1175 $post = get_post(); 1175 1176 1176 1177 if ( empty($post->post_type) || $post->post_type != 'attachment' ) 1177 1178 return $content; … … 1198 1199 * @return string HTML content for password form for password protected post. 1199 1200 */ 1200 1201 function get_the_password_form() { 1201 global $post;1202 $post = get_post(); 1202 1203 $label = 'pwbox-' . ( empty($post->ID) ? rand() : $post->ID ); 1203 1204 $output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" method="post"> 1204 1205 <p>' . __("This post is password protected. To view it please enter your password below:") . '</p> -
wp-includes/post.php
372 372 * @uses $wpdb 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']; 383 383 … … 914 914 * 915 915 * @uses $post The Loop current post global 916 916 * 917 * @param mixed $ the_post Optional. Post object or post ID.917 * @param mixed $post Optional. Post object or post ID. 918 918 * @return bool|string post type or false on failure. 919 919 */ 920 function get_post_type( $the_post = false ) { 921 global $post; 920 function get_post_type( $post = null ) { 921 if ( $post = get_post( $post ) ) 922 return $post->post_type; 922 923 923 if ( false === $the_post )924 $the_post = $post;925 elseif ( is_numeric($the_post) )926 $the_post = get_post($the_post);927 928 if ( is_object($the_post) )929 return $the_post->post_type;930 931 924 return false; 932 925 } 933 926 … … 1152 1145 $args->rewrite['with_front'] = true; 1153 1146 if ( ! isset( $args->rewrite['pages'] ) ) 1154 1147 $args->rewrite['pages'] = true; 1155 if ( ! isset( $args->rewrite['feeds'] ) || ! $args->has_archive)1148 if ( ! isset( $args->rewrite['feeds'] ) && isset( $args->has_archive ) ) 1156 1149 $args->rewrite['feeds'] = (bool) $args->has_archive; 1157 1150 if ( ! isset( $args->rewrite['ep_mask'] ) ) { 1158 1151 if ( isset( $args->permalink_epmask ) ) … … 1166 1159 else 1167 1160 add_rewrite_tag("%$post_type%", '([^/]+)', $args->query_var ? "{$args->query_var}=" : "post_type=$post_type&name="); 1168 1161 1169 if ( $args->has_archive ) { 1170 $archive_slug = $args->has_archive === true ? $args->rewrite['slug'] : $args->has_archive; 1171 if ( $args->rewrite['with_front'] ) 1172 $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug; 1173 else 1174 $archive_slug = $wp_rewrite->root . $archive_slug; 1162 $archive_slug = is_string( $args->has_archive ) && $args->has_archive ? $args->has_archive : $args->rewrite['slug']; 1163 if ( $args->rewrite['with_front'] ) 1164 $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug; 1165 else 1166 $archive_slug = $wp_rewrite->root . $archive_slug; 1175 1167 1168 // Feed support can be added even without an archive. 1169 if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) { 1170 $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; 1171 add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); 1172 add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' ); 1173 } 1174 1175 if ( $args->has_archive ) { 1176 1176 add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$post_type", 'top' ); 1177 if ( $args->rewrite['feeds'] && $wp_rewrite->feeds ) {1178 $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';1179 add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );1180 add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$post_type" . '&feed=$matches[1]', 'top' );1181 }1182 1177 if ( $args->rewrite['pages'] ) 1183 1178 add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$post_type" . '&paged=$matches[1]', 'top' ); 1184 1179 } -
wp-includes/comment-template.php
810 810 * @uses $post Gets the ID of the current post for the token 811 811 */ 812 812 function wp_comment_form_unfiltered_html_nonce() { 813 global $post; 813 $post = get_post(); 814 $post_id = $post ? $post->ID : 0; 814 815 815 $post_id = 0;816 if ( !empty($post) )817 $post_id = $post->ID;818 819 816 if ( current_user_can( 'unfiltered_html' ) ) { 820 817 wp_nonce_field( 'unfiltered-html-comment_' . $post_id, '_wp_unfiltered_html_comment_disabled', false ); 821 818 echo "<script>(function(){if(window===window.parent){document.getElementById('_wp_unfiltered_html_comment_disabled').name='_wp_unfiltered_html_comment';}})();</script>\n"; -
wp-includes/media.php
775 775 * @return string HTML content to display gallery. 776 776 */ 777 777 function gallery_shortcode($attr) { 778 global $post;778 $post = get_post(); 779 779 780 780 static $instance = 0; 781 781 $instance++; … … 928 928 * @param bool $prev Optional. Default is true to display previous link, false for next. 929 929 */ 930 930 function adjacent_image_link($prev = true, $size = 'thumbnail', $text = false) { 931 global $post; 932 $post = get_post($post); 931 $post = get_post(); 933 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 ) … … 1102 1101 * an AJAX request that will call WP_Embed::cache_oembed(). 1103 1102 */ 1104 1103 function maybe_run_ajax_cache() { 1105 global $post_ID;1104 $post = get_post(); 1106 1105 1107 if ( empty($post_ID)|| empty($_GET['message']) || 1 != $_GET['message'] )1106 if ( ! $post || empty($_GET['message']) || 1 != $_GET['message'] ) 1108 1107 return; 1109 1108 1110 1109 ?> 1111 1110 <script type="text/javascript"> 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 /* ]]> */ 1117 1116 </script> … … 1167 1166 * @return string The embed HTML on success, otherwise the original URL. 1168 1167 */ 1169 1168 function shortcode( $attr, $url = '' ) { 1170 global $post;1169 $post = get_post(); 1171 1170 1172 1171 if ( empty($url) ) 1173 1172 return ''; -
wp-includes/link-template.php
55 55 * @param string $mode Permalink mode can be either 'title', 'id', or default, which is 'id'. 56 56 */ 57 57 function permalink_anchor($mode = 'id') { 58 global $post;58 $post = get_post(); 59 59 switch ( strtolower($mode) ) { 60 60 case 'title': 61 61 $title = sanitize_title($post->post_title) . '-' . $post->ID; … … 232 232 * 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;240 function get_page_link( $post = false, $leavename = false, $sample = false ) { 241 $post = get_post( $post ); 242 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') ) 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 );246 $link = _get_page_link( $post, $leavename, $sample ); 251 247 252 return apply_filters( 'page_link', $link, $id, $sample);248 return apply_filters( 'page_link', $link, $post->ID, $sample ); 253 249 } 254 250 255 251 /** … … 260 256 * @since 2.1.0 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' ) ); 274 270 … … 276 272 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 282 278 $link = home_url($link); 283 279 $link = user_trailingslashit($link, 'page'); 284 280 } else { 285 $link = home_url( "?page_id=$id");281 $link = home_url( '?page_id=' . $post->ID ); 286 282 } 287 283 288 return apply_filters( '_get_page_link', $link, $ id);284 return apply_filters( '_get_page_link', $link, $post->ID ); 289 285 } 290 286 291 287 /** … … 295 291 * 296 292 * @since 2.0.0 297 293 * 298 * @param int $id Optional. Post ID.294 * @param mixed $post Optional. Post ID or object. 299 295 * @return string 300 296 */ 301 function get_attachment_link( $id = false) {302 global $ post, $wp_rewrite;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; 302 $post = get_post( $post ); 308 303 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); 304 if ( $wp_rewrite->using_permalinks() && ($post->post_parent > 0) && ($post->post_parent != $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 );309 $parentlink = get_permalink( $post->post_parent ); 316 310 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 marker311 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 ) 323 317 $link = user_trailingslashit( trailingslashit($parentlink) . $name ); … … 1122 1116 * @return mixed Post object if successful. Null if global $post is not set. Empty string if no corresponding post exists. 1123 1117 */ 1124 1118 function get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $previous = true ) { 1125 global $ post, $wpdb;1119 global $wpdb; 1126 1120 1127 if ( empty( $post) )1121 if ( ! $post = get_post() ) 1128 1122 return null; 1129 1123 1130 1124 $current_post_date = $post->post_date; … … 1200 1194 * @return string 1201 1195 */ 1202 1196 function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) { 1203 if ( $previous && is_attachment() && is_object( $GLOBALS['post']) )1204 $post = get_post( $GLOBALS['post']->post_parent);1197 if ( $previous && is_attachment() && $post = get_post() ) 1198 $post = get_post( $post->post_parent ); 1205 1199 else 1206 $post = get_adjacent_post( $in_same_cat,$excluded_categories,$previous);1200 $post = get_adjacent_post( $in_same_cat, $excluded_categories, $previous ); 1207 1201 1208 1202 if ( empty($post) ) 1209 1203 return; … … 1292 1286 * @return object 1293 1287 */ 1294 1288 function get_boundary_post( $in_same_cat = false, $excluded_categories = '', $start = true ) { 1295 global $post; 1296 1297 if ( empty($post) || ! is_single() || is_attachment() ) 1289 $post = get_post(); 1290 if ( ! $post || ! is_single() || is_attachment() ) 1298 1291 return null; 1299 1292 1300 1293 $cat_array = array(); … … 1366 1359 */ 1367 1360 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { 1368 1361 if ( $previous && is_attachment() ) 1369 $post = get_post( $GLOBALS['post']->post_parent);1362 $post = get_post( get_post()->post_parent ); 1370 1363 else 1371 1364 $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); 1372 1365 … … 1673 1666 * @return string 1674 1667 */ 1675 1668 function get_comments_pagenum_link( $pagenum = 1, $max_page = 0 ) { 1676 global $ post, $wp_rewrite;1669 global $wp_rewrite; 1677 1670 1678 1671 $pagenum = (int) $pagenum; 1679 1672 1680 $result = get_permalink( $post->ID);1673 $result = get_permalink(); 1681 1674 1682 1675 if ( 'newest' == get_option('default_comments_page') ) { 1683 1676 if ( $pagenum != $max_page ) { … … 2438 2431 * @param string $after Optional HTML to display after the link. 2439 2432 */ 2440 2433 function the_shortlink( $text = '', $title = '', $before = '', $after = '' ) { 2441 global $post;2442 2443 2434 if ( empty( $text ) ) 2444 2435 $text = __('This is the short link.'); 2445 2436 2446 2437 if ( empty( $title ) ) 2447 2438 $title = the_title_attribute( array( 'echo' => false ) ); 2448 2439 2449 $shortlink = wp_get_shortlink( $post->ID);2440 $shortlink = wp_get_shortlink(); 2450 2441 2451 2442 if ( !empty( $shortlink ) ) { 2452 2443 $link = '<a rel="shortlink" href="' . esc_url( $shortlink ) . '" title="' . $title . '">' . $text . '</a>'; -
wp-includes/author-template.php
69 69 * @return string The author's display name. 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); 76 75 } … … 164 163 * @return int The number of posts by the author. 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 171 169 /** -
wp-includes/general-template.php
1311 1311 * @since 1.0.0 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 1318 1317 /** … … 1367 1366 * @return string|null Null if displaying, string if retrieving. 1368 1367 */ 1369 1368 function get_the_date( $d = '' ) { 1370 global $post;1369 $post = get_post(); 1371 1370 $the_date = ''; 1372 1371 1373 1372 if ( '' == $d ) … … 1528 1527 * @uses $post 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; 1535 1534 } … … 1546 1545 * @param string $after Optional Output after the date. 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; 1556 1555 } -
wp-includes/deprecated.php
57 57 * @deprecated Use The Loop - {@link http://codex.wordpress.org/The_Loop Use new WordPress Loop} 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') ); 63 63 64 64 // Since the old style loop is being used, advance the query iterator here. 65 65 $wp_query->next_post(); 66 66 67 setup_postdata( $post);67 setup_postdata( get_post() ); 68 68 } 69 69 70 70 /** -
wp-includes/class-wp-editor.php
126 126 } 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 132 132 if ( empty(self::$first_init) ) { … … 370 370 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']) ) { 377 377 $body_class .= ' ' . $set['tinymce']['body_class']; … … 612 612 } 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; 618 619 $width = $width + 22; // compensate for the padding and border -
wp-includes/category-template.php
1054 1054 * 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; 1061 function get_the_terms( $post, $taxonomy ) { 1062 if ( ! $post = get_post( $post ) ) 1063 return false; 1063 1064 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 ); 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');1067 $terms = wp_get_object_terms( $post->ID, $taxonomy ); 1068 wp_cache_add($post->ID, $terms, $taxonomy . '_relationships'); 1077 1069 } 1078 1070 1079 $terms = apply_filters( 'get_the_terms', $terms, $ id, $taxonomy );1071 $terms = apply_filters( 'get_the_terms', $terms, $post->ID, $taxonomy ); 1080 1072 1081 1073 if ( empty( $terms ) ) 1082 1074 return false; -
wp-admin/includes/class-wp-posts-list-table.php
316 316 } 317 317 318 318 function _display_rows( $posts, $level = 0 ) { 319 global $post, $mode; 319 global $mode; 320 $post = get_post(); 320 321 321 322 // Create array of post IDs. 322 323 $post_ids = array(); … … 458 459 unset( $children_pages[$parent] ); //required in order to keep track of orphans 459 460 } 460 461 461 function single_row( $ a_post, $level = 0 ) {462 global $ post, $mode;462 function single_row( $post, $level = 0 ) { 463 global $mode; 463 464 static $alternate; 464 465 465 $global_post = $post;466 $ post = $a_post;466 $global_post = get_post(); 467 $GLOBALS['post'] = $post; 467 468 setup_postdata( $post ); 468 469 469 470 $edit_link = get_edit_post_link( $post->ID ); … … 529 530 } 530 531 else { 531 532 $attributes = 'class="post-title page-title column-title"' . $style; 532 533 533 534 $pad = str_repeat( '— ', $level ); 534 535 ?> 535 536 <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong> … … 684 685 ?> 685 686 </tr> 686 687 <?php 687 $ post= $global_post;688 $GLOBALS['post'] = $global_post; 688 689 } 689 690 690 691 /** -
wp-admin/includes/class-wp-media-list-table.php
156 156 } 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' ); 162 163 $alt = ''; -
wp-admin/includes/post.php
928 928 /** 929 929 * Executes a query for attachments. An array of WP_Query arguments 930 930 * can be passed in, which will override the arguments set by this function. 931 * 931 * 932 932 * @since 2.5.0 933 933 * @uses apply_filters() Calls 'upload_per_page' on posts_per_page argument 934 934 * … … 1139 1139 * @since 2.9.0 1140 1140 * 1141 1141 * @param int $thumbnail_id ID of the attachment used for thumbnail 1142 * @param int $post_id ID of the post associated with the thumbnail, defaults to global $post_ID1142 * @param mixed $post The post ID or object associated with the thumbnail, defaults to global $post. 1143 1143 * @return string html 1144 1144 */ 1145 function _wp_post_thumbnail_html( $thumbnail_id = null, $post _id= null ) {1146 global $content_width, $_wp_additional_image_sizes , $post_ID;1145 function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) { 1146 global $content_width, $_wp_additional_image_sizes; 1147 1147 1148 if ( empty( $post_id ) ) 1149 $post_id = $post_ID; 1148 $post = get_post( $post ); 1150 1149 1151 $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post _id) );1150 $upload_iframe_src = esc_url( get_upload_iframe_src('image', $post->ID ) ); 1152 1151 $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>'; 1153 1152 $content = sprintf( $set_thumbnail_link, $upload_iframe_src, esc_html__( 'Set featured image' ) ); 1154 1153 … … 1160 1159 else 1161 1160 $thumbnail_html = wp_get_attachment_image( $thumbnail_id, 'post-thumbnail' ); 1162 1161 if ( !empty( $thumbnail_html ) ) { 1163 $ajax_nonce = wp_create_nonce( "set_post_thumbnail-$post_id");1162 $ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID ); 1164 1163 $content = sprintf( $set_thumbnail_link, $upload_iframe_src, $thumbnail_html ); 1165 1164 $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>'; 1166 1165 } 1167 1166 $content_width = $old_content_width; 1168 1167 } 1169 1168 1170 return apply_filters( 'admin_post_thumbnail_html', $content, $post _id);1169 return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID ); 1171 1170 } 1172 1171 1173 1172 /** … … 1225 1224 * @return none 1226 1225 */ 1227 1226 function _admin_notice_post_locked() { 1228 global $post; 1229 1227 $post = get_post(); 1230 1228 $lock = explode( ':', get_post_meta( $post->ID, '_edit_lock', true ) ); 1231 1229 $user = isset( $lock[1] ) ? $lock[1] : get_post_meta( $post->ID, '_edit_last', true ); 1232 1230 $last_user = get_userdata( $user ); -
wp-admin/includes/meta-boxes.php
469 469 * @param object $post 470 470 */ 471 471 function post_comment_meta_box($post) { 472 global $wpdb , $post_ID;472 global $wpdb; 473 473 474 474 wp_nonce_field( 'get-comments', 'add_comment_nonce', false ); 475 475 ?> 476 476 <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> 477 477 <?php 478 478 479 $total = get_comments( array( 'post_id' => $post _ID, 'number' => 1, 'count' => true ) );479 $total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) ); 480 480 $wp_list_table = _get_list_table('WP_Post_Comments_List_Table'); 481 481 $wp_list_table->display( true ); 482 482 … … 912 912 * 913 913 * @since 2.9.0 914 914 */ 915 function post_thumbnail_meta_box() { 916 global $post; 915 function post_thumbnail_meta_box( $post ) { 917 916 $thumbnail_id = get_post_meta( $post->ID, '_thumbnail_id', true ); 918 917 echo _wp_post_thumbnail_html( $thumbnail_id ); 919 918 } -
wp-admin/includes/class-wp-comments-list-table.php
302 302 } 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; 308 309 $the_comment_class = join( ' ', get_comment_class( wp_get_comment_status( $comment->comment_ID ) ) ); … … 325 326 } 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; 331 333 … … 479 481 } 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] ) ) { 485 487 $pending_comments = $this->pending_count[$post->ID]; -
wp-admin/includes/template.php
166 166 * @return array List of popular term IDs. 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(); 175 174 … … 575 574 * @param unknown_type $multi 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 ) 581 581 $edit = ! ( in_array($post->post_status, array('draft', 'pending') ) && (!$post->post_date_gmt || '0000-00-00 00:00:00' == $post->post_date_gmt ) ); … … 670 670 * @return unknown 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 676 677 if ( $items ) { 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) 686 685 $current = ' selected="selected"'; … … 1345 1344 * @since 2.7.0 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 1352 1352 /** … … 1356 1356 * returned. 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);1362 function _draft_or_post_title( $post = 0 ) { 1363 $title = get_the_title( $post ); 1364 1364 if ( empty($title) ) 1365 1365 $title = __('(no title)'); 1366 1366 return $title; -
wp-admin/includes/export.php
279 279 * @since 2.3.0 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 ); 285 285 if ( empty( $taxonomies ) )