Ticket #5418: 5418.wp-includes.root.diff
| File 5418.wp-includes.root.diff, 61.2 KB (added by DD32, 4 years ago) |
|---|
-
wp-app.php
215 215 * Create Post (No arguments) 216 216 */ 217 217 function create_post() { 218 global $blog_id, $ wpdb;218 global $blog_id, $user_ID; 219 219 $this->get_accepted_content_type($this->atom_content_types); 220 220 221 221 $parser = new AtomParser(); … … 249 249 250 250 $blog_ID = (int ) $blog_id; 251 251 $post_status = ($publish) ? 'publish' : 'draft'; 252 $post_author = (int) $user ->ID;252 $post_author = (int) $user_ID; 253 253 $post_title = $entry->title[1]; 254 254 $post_content = $entry->content[1]; 255 255 $post_excerpt = $entry->summary[1]; … … 269 269 if ( is_wp_error( $postID ) ) 270 270 $this->internal_error($postID->get_error_message()); 271 271 272 if (!$postID) {272 if (!$postID) 273 273 $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); 274 }275 274 276 275 // getting warning here about unable to set headers 277 276 // because something in the cache is printing to the buffer … … 296 295 } 297 296 298 297 function put_post($postID) { 299 global $wpdb;300 301 298 // checked for valid content-types (atom+xml) 302 299 // quick check and exit 303 300 $this->get_accepted_content_type($this->atom_content_types); … … 313 310 314 311 // check for not found 315 312 global $entry; 316 $entry = $GLOBALS['entry'];317 313 $this->set_current_entry($postID); 318 314 319 315 if(!current_user_can('edit_post', $entry['ID'])) … … 376 372 } 377 373 378 374 function get_attachment($postID = NULL) { 379 380 global $entry;381 375 if (!isset($postID)) { 382 376 $this->get_attachments(); 383 377 } else { … … 389 383 } 390 384 391 385 function create_attachment() { 392 global $wp, $wpdb, $wp_query, $blog_id;393 386 394 387 $type = $this->get_accepted_content_type(); 395 388 … … 418 411 419 412 $url = $file['url']; 420 413 $file = $file['file']; 421 $filename = basename($file);422 414 423 $header =apply_filters('wp_create_file_in_uploads', $file); // replicate415 apply_filters('wp_create_file_in_uploads', $file); // replicate 424 416 425 417 // Construct the attachment array 426 418 $attachment = array( … … 433 425 ); 434 426 435 427 // Save the data 436 $postID = wp_insert_attachment($attachment, $file , $post);428 $postID = wp_insert_attachment($attachment, $file); 437 429 438 if (!$postID) {430 if (!$postID) 439 431 $this->internal_error(__('Sorry, your entry could not be posted. Something wrong happened.')); 440 }441 432 442 433 $output = $this->get_entry($postID, 'attachment'); 443 434 … … 446 437 } 447 438 448 439 function put_attachment($postID) { 449 global $wpdb;450 451 440 // checked for valid content-types (atom+xml) 452 441 // quick check and exit 453 442 $this->get_accepted_content_type($this->atom_content_types); … … 466 455 if(!current_user_can('edit_post', $entry['ID'])) 467 456 $this->auth_required(__('Sorry, you do not have the right to edit this post.')); 468 457 469 $publish = (isset($parsed->draft) && trim($parsed->draft) == 'yes') ? false : true;470 471 458 extract($entry); 472 459 473 460 $post_title = $parsed->title[1]; … … 546 533 547 534 function put_file($postID) { 548 535 549 $type = $this->get_accepted_content_type();550 551 536 // first check if user can upload 552 537 if(!current_user_can('upload_files')) 553 538 $this->auth_required(__('You do not have permission to upload files.')); … … 605 590 } 606 591 607 592 function the_entries_url($page = NULL) { 608 $url = $this->get_entries_url($page); 609 echo $url; 593 echo $this->get_entries_url($page); 610 594 } 611 595 612 function get_categories_url($ page = NULL) {596 function get_categories_url($deprecated = '') { 613 597 return $this->app_base . $this->CATEGORIES_PATH; 614 598 } 615 599 616 600 function the_categories_url() { 617 $url = $this->get_categories_url(); 618 echo $url; 601 echo $this->get_categories_url(); 619 602 } 620 603 621 604 function get_attachments_url($page = NULL) { … … 627 610 } 628 611 629 612 function the_attachments_url($page = NULL) { 630 $url = $this->get_attachments_url($page); 631 echo $url; 613 echo $this->get_attachments_url($page); 632 614 } 633 615 634 616 function get_service_url() { … … 638 620 function get_entry_url($postID = NULL) { 639 621 if(!isset($postID)) { 640 622 global $post; 641 $postID = (int) $ GLOBALS['post']->ID;623 $postID = (int) $post->ID; 642 624 } 643 625 644 626 $url = $this->app_base . $this->ENTRY_PATH . "/$postID"; … … 648 630 } 649 631 650 632 function the_entry_url($postID = NULL) { 651 $url = $this->get_entry_url($postID); 652 echo $url; 633 echo $this->get_entry_url($postID); 653 634 } 654 635 655 636 function get_media_url($postID = NULL) { 656 637 if(!isset($postID)) { 657 638 global $post; 658 $postID = (int) $ GLOBALS['post']->ID;639 $postID = (int) $post->ID; 659 640 } 660 641 661 642 $url = $this->app_base . $this->MEDIA_SINGLE_PATH ."/file/$postID"; … … 665 646 } 666 647 667 648 function the_media_url($postID = NULL) { 668 $url = $this->get_media_url($postID); 669 echo $url; 649 echo $this->get_media_url($postID); 670 650 } 671 651 672 652 function set_current_entry($postID) { … … 759 739 function get_entry($postID, $post_type = 'post') { 760 740 log_app('function',"get_entry($postID, '$post_type')"); 761 741 ob_start(); 762 global $posts, $post, $wp_query, $wp, $wpdb, $blog_id;763 742 switch($post_type) { 764 743 case 'post': 765 744 $varname = 'p'; -
wp-includes/author-template.php
316 316 * @return string The URL to the author's page. 317 317 */ 318 318 function get_author_posts_url($author_id, $author_nicename = '') { 319 global $wp db, $wp_rewrite, $post;319 global $wp_rewrite; 320 320 $auth_ID = (int) $author_id; 321 321 $link = $wp_rewrite->get_author_permastruct(); 322 322 -
wp-includes/canonical.php
2 2 // Based on "Permalink Redirect" from Scott Yang and "Enforce www. Preference" by Mark Jaquith 3 3 4 4 function redirect_canonical($requested_url=NULL, $do_redirect=true) { 5 global $wp_rewrite, $ posts, $is_IIS;5 global $wp_rewrite, $is_IIS; 6 6 7 7 if ( is_feed() || is_trackback() || is_search() || is_comments_popup() || is_admin() || $is_IIS || ( isset($_POST) && count($_POST) ) || is_preview() ) 8 8 return; … … 176 176 } 177 177 178 178 function redirect_guess_404_permalink() { 179 global $wp _query, $wpdb;179 global $wpdb; 180 180 if ( !get_query_var('name') ) 181 181 return false; 182 182 -
wp-includes/capabilities.php
138 138 var $allcaps = array(); 139 139 140 140 function WP_User($id, $name = '') { 141 global $wpdb;142 141 143 142 if ( empty($id) && empty($name) ) 144 143 return; -
wp-includes/category-template.php
66 66 } 67 67 68 68 function get_the_category($id = false) { 69 global $post, $term_cache , $blog_id;69 global $post, $term_cache; 70 70 71 71 $id = (int) $id; 72 72 if ( !$id ) … … 168 168 } 169 169 170 170 function in_category( $category ) { // Check if the current post is in the given category 171 global $post , $blog_id;171 global $post; 172 172 173 173 $categories = get_object_term_cache($post->ID, 'category'); 174 174 if ( false === $categories ) -
wp-includes/category.php
1 1 <?php 2 2 3 3 function get_all_category_ids() { 4 global $wpdb;5 6 4 if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) { 7 5 $cat_ids = get_terms('category', 'fields=ids&get=all'); 8 6 wp_cache_add('all_category_ids', $cat_ids, 'category'); … … 39 37 } 40 38 41 39 function get_category_by_path($category_path, $full_match = true, $output = OBJECT) { 42 global $wpdb;43 40 $category_path = rawurlencode(urldecode($category_path)); 44 41 $category_path = str_replace('%2F', '/', $category_path); 45 42 $category_path = str_replace('%20', ' ', $category_path); … … 86 83 87 84 // Get the ID of a category from its name 88 85 function get_cat_ID($cat_name='General') { 89 global $wpdb;90 91 86 $cat = get_term_by('name', $cat_name, 'category'); 92 87 if ($cat) 93 88 return $cat->term_id; … … 132 127 // Tags 133 128 134 129 function &get_tags($args = '') { 135 global $wpdb, $category_links;136 137 130 $key = md5( serialize( $args ) ); 138 131 if ( $cache = wp_cache_get( 'get_tags', 'category' ) ) 139 132 if ( isset( $cache[ $key ] ) ) -
wp-includes/comment-template.php
38 38 } 39 39 40 40 function get_comment_author_link() { 41 global $comment;42 41 $url = get_comment_author_url(); 43 42 $author = get_comment_author(); 44 43 … … 72 71 } 73 72 74 73 function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) { 75 global $comment;76 74 $url = get_comment_author_url(); 77 75 $display = ($linktext != '') ? $linktext : $url; 78 76 $display = str_replace( 'http://www.', '', $display ); … … 146 144 } 147 145 148 146 function get_comments_number( $post_id = 0 ) { 149 global $wpdb, $id;150 147 $post_id = (int) $post_id; 151 148 152 149 if ( !$post_id ) … … 237 234 } 238 235 239 236 function trackback_rdf($timezone = 0) { 240 global $id;241 237 if (stripos($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator') === false) { 242 238 echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 243 239 xmlns:dc="http://purl.org/dc/elements/1.1/" … … 309 305 } 310 306 311 307 function comments_popup_script($width=400, $height=400, $file='') { 312 global $wpcommentspopupfile, $wp trackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;308 global $wpcommentspopupfile, $wpcommentsjavascript; 313 309 314 310 if (empty ($file)) { 315 311 $wpcommentspopupfile = ''; // Use the index. … … 323 319 } 324 320 325 321 function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') { 326 global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post , $wpdb;322 global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post; 327 323 328 324 if ( is_single() || is_page() ) 329 325 return; -
wp-includes/comment.php
105 105 106 106 // Deprecate in favor of get_comment()? 107 107 function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { // less flexible, but saves DB queries 108 global $postc, $id, $ commentdata, $wpdb;108 global $postc, $id, $wpdb; 109 109 if ( $no_cache ) { 110 110 $query = $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_ID = %d", $comment_ID); 111 111 if ( false == $include_unapproved ) … … 129 129 130 130 131 131 function get_lastcommentmodified($timezone = 'server') { 132 global $cache_lastcommentmodified, $ pagenow, $wpdb;132 global $cache_lastcommentmodified, $wpdb; 133 133 $add_seconds_blog = get_option('gmt_offset') * 3600; 134 134 $add_seconds_server = date('Z'); 135 135 $now = current_time('mysql', 1); … … 228 228 } 229 229 230 230 function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_agent) { 231 global $wpdb;232 233 231 do_action('wp_blacklist_check', $author, $email, $url, $comment, $user_ip, $user_agent); 234 232 235 233 if ( preg_match_all('/&#(\d+);/', $comment . $author . $url, $chars) ) { … … 293 291 294 292 295 293 function wp_get_comment_status($comment_id) { 296 global $wpdb;297 298 294 $comment = get_comment($comment_id); 299 295 if ( !$comment ) 300 296 return false; … … 686 682 687 683 688 684 function pingback($content, $post_ID) { 689 global $wp_version , $wpdb;685 global $wp_version; 690 686 include_once(ABSPATH . WPINC . '/class-IXR.php'); 691 687 692 688 // original code by Mort (http://mort.mine.nu:8080) -
wp-includes/feed.php
98 98 } 99 99 100 100 101 function comments_rss_link($link_text = 'Comments RSS', $ commentsrssfilename = 'nolongerused') {101 function comments_rss_link($link_text = 'Comments RSS', $deprecated = '') { 102 102 $url = get_post_comments_feed_link(); 103 103 echo "<a href='$url'>$link_text</a>"; 104 104 } 105 105 106 106 107 function comments_rss($ commentsrssfilename = 'nolongerused') {107 function comments_rss($deprecated = '') { 108 108 return get_post_comments_feed_link(); 109 109 } 110 110 111 111 112 112 function get_author_rss_link($echo = false, $author_id, $author_nicename) { 113 $auth _ID= (int) $author_id;113 $author_id = (int) $author_id; 114 114 $permalink_structure = get_option('permalink_structure'); 115 115 116 116 if ( '' == $permalink_structure ) { … … 168 168 } 169 169 170 170 171 function get_category_rss_link($echo = false, $cat_ID, $ category_nicename) {172 $link = get_category_feed_link($cat_ID, $feed ='rss2');171 function get_category_rss_link($echo = false, $cat_ID, $deprecated = '') { 172 $link = get_category_feed_link($cat_ID, 'rss2'); 173 173 174 174 if ( $echo ) 175 175 echo $link; … … 180 180 function get_the_category_rss($type = 'rss') { 181 181 $categories = get_the_category(); 182 182 $tags = get_the_tags(); 183 $home = get_bloginfo_rss('home');184 183 $the_list = ''; 185 184 $cat_names = array(); 186 185 … … 252 251 253 252 254 253 function rss_enclosure() { 255 global $ id, $post;254 global $post; 256 255 if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) 257 256 return; 258 257 … … 267 266 } 268 267 269 268 function atom_enclosure() { 270 global $ id, $post;269 global $post; 271 270 if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) ) 272 271 return; 273 272 -
wp-includes/formatting.php
363 363 return $title; 364 364 } 365 365 366 function convert_chars($content, $ flag = 'obsolete') {366 function convert_chars($content, $deprecated = '') { 367 367 // Translation of invalid Unicode references range to valid range 368 368 $wp_htmltranswinuni = array( 369 369 '€' => '€', // the Euro sign … … 560 560 } 561 561 562 562 function format_to_post($content) { 563 global $wpdb;564 563 $content = apply_filters('format_to_post', $content); 565 564 return $content; 566 565 } … … 783 782 } else if (($diff <= 86400) && ($diff > 3600)) { 784 783 $hours = round($diff / 3600); 785 784 if ($hours <= 1) { 786 $hour = 1;785 $hours = 1; 787 786 } 788 787 $since = sprintf(__ngettext('%s hour', '%s hours', $hours), $hours); 789 788 } elseif ($diff >= 86400) { … … 797 796 } 798 797 799 798 function wp_trim_excerpt($text) { // Fakes an excerpt if needed 800 global $post;801 799 if ( '' == $text ) { 802 800 $text = get_the_content(''); 803 801 $text = apply_filters('the_content', $text); -
wp-includes/functions.php
108 108 } 109 109 110 110 111 function get_weekstartend( $mysqlstring, $start_of_week ) {111 function get_weekstartend( $mysqlstring, $start_of_week = '' ) { 112 112 $my = substr( $mysqlstring, 0, 4 ); 113 113 $mm = substr( $mysqlstring, 8, 2 ); 114 114 $md = substr( $mysqlstring, 5, 2 ); 115 115 $day = mktime( 0, 0, 0, $md, $mm, $my ); 116 116 $weekday = date( 'w', $day ); 117 117 $i = 86400; 118 if( !is_numeric($a) ) 119 $start_of_week = get_option( 'start_of_week' ); 118 120 119 if ( $weekday < get_option( 'start_of_week' ))120 $weekday = 7 - ( get_option( 'start_of_week' ) - $weekday );121 if ( $weekday < $start_of_week ) 122 $weekday = 7 - $start_of_week - $weekday; 121 123 122 while ( $weekday > get_option( 'start_of_week' )) {124 while ( $weekday > $start_of_week ) { 123 125 $weekday = date( 'w', $day ); 124 if ( $weekday < get_option( 'start_of_week' ))125 $weekday = 7 - ( get_option( 'start_of_week' ) - $weekday );126 if ( $weekday < $start_of_week ) 127 $weekday = 7 - $start_of_week - $weekday; 126 128 127 $day = $day -86400;129 $day -= 86400; 128 130 $i = 0; 129 131 } 130 132 $week['start'] = $day + 86400 - $i; … … 488 490 } 489 491 490 492 function do_enclose( $content, $post_ID ) { 491 global $wp _version, $wpdb;493 global $wpdb; 492 494 include_once( ABSPATH . WPINC . '/class-IXR.php' ); 493 495 494 496 $log = debug_fopen( ABSPATH . 'enclosures.log', 'a' ); … … 1028 1030 return apply_filters( 'upload_dir', $uploads ); 1029 1031 } 1030 1032 1031 function wp_upload_bits( $name, $ type, $bits ) {1033 function wp_upload_bits( $name, $deprecated, $bits ) { 1032 1034 if ( empty( $name ) ) 1033 1035 return array( 'error' => __( "Empty filename" ) ); 1034 1036 … … 1066 1068 if ( ! $ifp ) 1067 1069 return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ); 1068 1070 1069 $success =@fwrite( $ifp, $bits );1071 @fwrite( $ifp, $bits ); 1070 1072 fclose( $ifp ); 1071 1073 // Set correct file permissions 1072 1074 $stat = @ stat( dirname( $new_file ) ); … … 1211 1213 1212 1214 1213 1215 function wp_nonce_ays( $action ) { 1214 global $pagenow , $menu, $submenu, $parent_file, $submenu_file;1216 global $pagenow; 1215 1217 1216 1218 $adminurl = get_option( 'siteurl' ) . '/wp-admin'; 1217 1219 if ( wp_get_referer() ) … … 1499 1501 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 1500 1502 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 1501 1503 1502 $data = curl_exec($ch);1504 curl_exec($ch); 1503 1505 1504 1506 $status = curl_getinfo($ch, CURLINFO_HTTP_CODE); 1505 1507 curl_close ($ch); -
wp-includes/general-template.php
164 164 165 165 $cat = get_query_var('cat'); 166 166 $tag = get_query_var('tag_id'); 167 $p = get_query_var('p');168 $name = get_query_var('name');169 167 $category_name = get_query_var('category_name'); 170 168 $author = get_query_var('author'); 171 169 $author_name = get_query_var('author_name'); … … 386 384 $archive_week_end_date_format = get_option('date_format'); 387 385 } 388 386 389 $add_hours = intval(get_option('gmt_offset'));390 $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));391 392 387 //filters 393 388 $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r ); 394 389 $join = apply_filters('getarchives_join', "", $r); … … 524 519 525 520 526 521 function get_calendar($initial = true) { 527 global $wpdb, $m, $monthnum, $year, $ timedifference, $wp_locale, $posts;522 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; 528 523 529 524 $key = md5( $m . $monthnum . $year ); 530 525 if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) { … … 547 542 548 543 // week_begins = 0 stands for Sunday 549 544 $week_begins = intval(get_option('start_of_week')); 550 $add_hours = intval(get_option('gmt_offset'));551 $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));552 545 553 546 // Let's figure out when we are 554 547 if ( !empty($monthnum) && !empty($year) ) { … … 560 553 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's 561 554 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('${thisyear}0101', INTERVAL $d DAY) ), '%m')"); 562 555 } elseif ( !empty($m) ) { 563 $calendar = substr($m, 0, 6);564 556 $thisyear = ''.intval(substr($m, 0, 4)); 565 557 if ( strlen($m) < 6 ) 566 558 $thismonth = '01'; … … 755 747 756 748 757 749 function the_date($d='', $before='', $after='', $echo = true) { 758 global $ id, $post, $day, $previousday;750 global $post, $day, $previousday; 759 751 $the_date = ''; 760 752 if ( $day != $previousday ) { 761 753 $the_date .= $before; … … 842 834 843 835 844 836 function the_weekday() { 845 global $wp_locale, $ id, $post;837 global $wp_locale, $post; 846 838 $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date)); 847 839 $the_weekday = apply_filters('the_weekday', $the_weekday); 848 840 echo $the_weekday; … … 850 842 851 843 852 844 function the_weekday_date($before='',$after='') { 853 global $wp_locale, $ id, $post, $day, $previousweekday;845 global $wp_locale, $post, $day, $previousweekday; 854 846 $the_weekday_date = ''; 855 847 if ( $day != $previousweekday ) { 856 848 $the_weekday_date .= $before; -
wp-includes/l10n.php
75 75 } 76 76 77 77 function load_default_textdomain() { 78 global $l10n;79 80 78 $locale = get_locale(); 81 79 if ( empty($locale) ) 82 80 $locale = 'en_US'; -
wp-includes/link-template.php
232 232 233 233 function get_feed_link($feed='rss2') { 234 234 global $wp_rewrite; 235 $do_perma = 0;236 $feed_url = get_option('siteurl');237 $comment_feed_url = $feed_url;238 235 239 236 $permalink = $wp_rewrite->get_feed_permastruct(); 240 237 if ( '' != $permalink ) { … … 494 491 } 495 492 496 493 function get_next_posts_page_link($max_page = 0) { 497 global $paged , $pagenow;494 global $paged; 498 495 499 496 if ( !is_single() ) { 500 497 if ( !$paged ) … … 510 507 } 511 508 512 509 function next_posts_link($label='Next Page »', $max_page=0) { 513 global $paged, $wp db, $wp_query;510 global $paged, $wp_query; 514 511 if ( !$max_page ) { 515 512 $max_page = $wp_query->max_num_pages; 516 513 } … … 525 522 } 526 523 527 524 function get_previous_posts_page_link() { 528 global $paged , $pagenow;525 global $paged; 529 526 530 527 if ( !is_single() ) { 531 528 $nextpage = intval($paged) - 1; -
wp-includes/pluggable.php
528 528 529 529 if ( ! function_exists('wp_notify_postauthor') ) : 530 530 function wp_notify_postauthor($comment_id, $comment_type='') { 531 global $wpdb;532 533 531 $comment = get_comment($comment_id); 534 532 $post = get_post($comment->comment_post_ID); 535 533 $user = get_userdata( $post->post_author ); -
wp-includes/post-template.php
81 81 82 82 83 83 function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') { 84 global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages; 85 global $preview; 86 global $pagenow; 84 global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow; 85 87 86 $output = ''; 88 87 89 88 if ( !empty($post->post_password) ) { // if there's a password … … 137 136 } 138 137 139 138 140 function get_the_excerpt($deprecated = true) {141 global $ id, $post;139 function get_the_excerpt($deprecated = '') { 140 global $post; 142 141 $output = ''; 143 142 $output = $post->post_excerpt; 144 143 if ( !empty($post->post_password) ) { // if there's a password … … 167 166 $r = wp_parse_args( $args, $defaults ); 168 167 extract( $r, EXTR_SKIP ); 169 168 170 global $post, $ id, $page, $numpages, $multipage, $more, $pagenow;169 global $post, $page, $numpages, $multipage, $more, $pagenow; 171 170 if ( $more_file != '' ) 172 171 $file = $more_file; 173 172 else … … 249 248 250 249 // this will probably change at some point... 251 250 function the_meta() { 252 global $id;253 254 251 if ( $keys = get_post_custom_keys() ) { 255 252 echo "<ul class='post-meta'>\n"; 256 253 foreach ( $keys as $key ) { … … 386 383 if ( !$post = & get_post($id) ) 387 384 return false; 388 385 389 $imagedata = wp_get_attachment_metadata( $post->ID );390 391 386 $file = get_attached_file( $post->ID ); 392 387 393 388 if ( !$fullsize && $thumbfile = wp_get_attachment_thumb_file( $post->ID ) ) { -
wp-includes/post.php
26 26 } 27 27 28 28 function &get_children($args = '', $output = OBJECT) { 29 global $wpdb;30 31 29 if ( empty( $args ) ) { 32 30 if ( isset( $GLOBALS['post'] ) ) { 33 31 $args = 'post_parent=' . (int) $GLOBALS['post']->post_parent; … … 163 161 } 164 162 165 163 function get_post_type($post = false) { 166 global $ wpdb, $posts;164 global $posts; 167 165 168 166 if ( false === $post ) 169 167 $post = $posts[0]; … … 310 308 } 311 309 312 310 function get_post_meta($post_id, $key, $single = false) { 313 global $wpdb;314 315 311 $post_id = (int) $post_id; 316 312 317 313 $meta_cache = wp_cache_get($post_id, 'post_meta'); … … 342 338 function update_post_meta($post_id, $meta_key, $meta_value, $prev_value = '') { 343 339 global $wpdb; 344 340 345 $original_value = $meta_value;346 341 $meta_value = maybe_serialize($meta_value); 347 348 $original_prev = $prev_value;349 342 $prev_value = maybe_serialize($prev_value); 350 343 351 344 // expected_slashed ($meta_key) … … 378 371 379 372 380 373 function get_post_custom($post_id = 0) { 381 global $id , $wpdb;374 global $id; 382 375 383 376 if ( !$post_id ) 384 377 $post_id = (int) $id; … … 577 570 } 578 571 579 572 function wp_get_single_post($postid = 0, $mode = OBJECT) { 580 global $wpdb;581 582 573 $postid = (int) $postid; 583 574 584 575 $post = get_post($postid, $mode); … … 597 588 } 598 589 599 590 function wp_insert_post($postarr = array()) { 600 global $wpdb, $wp_rewrite, $ allowedtags, $user_ID;591 global $wpdb, $wp_rewrite, $user_ID; 601 592 602 593 $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, 603 594 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, … … 768 759 } 769 760 770 761 function wp_update_post($postarr = array()) { 771 global $wpdb;772 773 762 if ( is_object($postarr) ) 774 763 $postarr = get_object_vars($postarr); 775 764 … … 835 824 836 825 function wp_set_post_tags( $post_id = 0, $tags = '', $append = false ) { 837 826 /* $append - true = don't delete existing tags, just add on, false = replace the tags with the new tags */ 838 global $wpdb;839 827 840 828 $post_id = (int) $post_id; 841 829 … … 849 837 } 850 838 851 839 function wp_set_post_categories($post_ID = 0, $post_categories = array()) { 852 global $wpdb;853 854 840 $post_ID = (int) $post_ID; 855 841 // If $post_categories isn't already an array, make it one: 856 842 if (!is_array($post_categories) || 0 == count($post_categories) || empty($post_categories)) … … 890 876 } 891 877 892 878 function get_enclosed($post_id) { // Get enclosures already enclosed for a post 893 global $wpdb;894 879 $custom_fields = get_post_custom( $post_id ); 895 880 $pung = array(); 896 881 if ( !is_array( $custom_fields ) ) … … 1226 1211 $post_name = sanitize_title($post_name); 1227 1212 1228 1213 // expected_slashed ($post_name) 1229 $post_name_check = 1230 $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_ID)); 1214 $post_name_check = $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM $wpdb->posts WHERE post_name = '$post_name' AND post_status = 'inherit' AND ID != %d LIMIT 1", $post_ID)); 1231 1215 1232 1216 if ($post_name_check) { 1233 1217 $suffix = 2; … … 1547 1531 } 1548 1532 1549 1533 function get_lastpostdate($timezone = 'server') { 1550 global $cache_lastpostdate, $pagenow, $wpdb, $blog_id; 1551 $add_seconds_blog = get_option('gmt_offset') * 3600; 1534 global $cache_lastpostdate, $wpdb, $blog_id; 1552 1535 $add_seconds_server = date('Z'); 1553 1536 if ( !isset($cache_lastpostdate[$blog_id][$timezone]) ) { 1554 1537 switch(strtolower($timezone)) { … … 1570 1553 } 1571 1554 1572 1555 function get_lastpostmodified($timezone = 'server') { 1573 global $cache_lastpostmodified, $pagenow, $wpdb, $blog_id; 1574 $add_seconds_blog = get_option('gmt_offset') * 3600; 1556 global $cache_lastpostmodified, $wpdb, $blog_id; 1575 1557 $add_seconds_server = date('Z'); 1576 1558 if ( !isset($cache_lastpostmodified[$blog_id][$timezone]) ) { 1577 1559 switch(strtolower($timezone)) { … … 1633 1615 } 1634 1616 1635 1617 function update_post_caches(&$posts) { 1636 global $wpdb;1637 1638 1618 // No point in doing all this work if we didn't match any posts. 1639 1619 if ( !$posts ) 1640 1620 return; … … 1738 1718 if ( defined('WP_IMPORTING') ) 1739 1719 return; 1740 1720 1741 $post = get_post($post_id);1742 1743 1721 $data = array( 'post_id' => $post_id, 'meta_value' => '1' ); 1744 1722 if ( get_option('default_pingback_flag') ) 1745 1723 $wpdb->insert( $wpdb->postmeta, $data + array( 'meta_key' => '_pingme' ) ); -
wp-includes/query.php
728 728 } 729 729 730 730 function &get_posts() { 731 global $wpdb, $ pagenow, $user_ID;731 global $wpdb, $user_ID; 732 732 733 733 do_action_ref_array('pre_get_posts', array(&$this)); 734 734 … … 741 741 $distinct = ''; 742 742 $whichcat = ''; 743 743 $whichauthor = ''; 744 $whichpage = '';745 $result = '';746 744 $where = ''; 747 745 $limits = ''; 748 746 $join = ''; … … 789 787 $q['page'] = abs($q['page']); 790 788 } 791 789 792 $add_hours = intval(get_option('gmt_offset'));793 $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));794 $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";795 796 790 // If a month is specified in the querystring, load that month 797 791 if ( $q['m'] ) { 798 792 $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']); … … 1495 1489 1496 1490 // Setup global post data. 1497 1491 function setup_postdata($post) { 1498 global $id, $postdata, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages, $wp_query; 1499 global $pagenow; 1492 global $id, $authordata, $day, $currentmonth, $page, $pages, $multipage, $more, $numpages; 1500 1493 1501 1494 $id = (int) $post->ID; 1502 1495 -
wp-includes/rewrite.php
311 311 } 312 312 313 313 function page_rewrite_rules() { 314 global $wpdb;315 316 314 $rewrite_rules = array(); 317 315 $page_structure = $this->get_page_permastruct(); 318 316 -
wp-includes/taxonomy.php
773 773 * @return mixed sanitized field 774 774 */ 775 775 function sanitize_term_field($field, $value, $term_id, $taxonomy, $context) { 776 if ( 'parent' == $field || 'term_id' == $field || 'count' == $field 777 || 'term_group' == $field ) 776 if ( 'parent' == $field || 'term_id' == $field || 'count' == $field || 'term_group' == $field ) 778 777 $value = (int) $value; 779 778 780 779 if ( 'raw' == $context ) … … 1209 1208 if ( !empty($args['term_id']) ) 1210 1209 $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s AND term_id != %d", $slug, $args['term_id'] ); 1211 1210 else 1212 $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s $where", $slug );1211 $query = $wpdb->prepare( "SELECT slug FROM $wpdb->terms WHERE slug = %s", $slug ); 1213 1212 1214 1213 if ( $wpdb->get_var( $query ) ) { 1215 1214 $num = 2; … … 1471 1470 * @return null|array Null value is given with empty $object_ids. 1472 1471 */ 1473 1472 function update_object_term_cache($object_ids, $object_type) { 1474 global $wpdb;1475 1476 1473 if ( empty($object_ids) ) 1477 1474 return; 1478 1475 -
wp-includes/theme.php
436 436 } 437 437 438 438 function load_template($_template_file) { 439 global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, 440 $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; 439 global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query, $wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment, $user_ID; 441 440 442 441 if ( is_array($wp_query->query_vars) ) 443 442 extract($wp_query->query_vars, EXTR_SKIP); -
wp-includes/user.php
75 75 else 76 76 $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'"); 77 77 78 $user = get_userdata($user_id);79 78 wp_cache_delete($user_id, 'users'); 80 79 81 80 return true; … … 138 137 return false; 139 138 } 140 139 141 $user = get_userdata($user_id);142 140 wp_cache_delete($user_id, 'users'); 143 141 144 142 return true; -
wp-includes/widgets.php
227 227 228 228 $sidebars_widgets = wp_get_sidebars_widgets(false); 229 229 230 if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $ sidebar => $widgets )230 if ( is_array($sidebars_widgets) ) foreach ( $sidebars_widgets as $widgets ) 231 231 if ( is_array($widgets) ) foreach ( $widgets as $widget ) 232 232 if ( $wp_registered_widgets[$widget]['callback'] == $callback ) 233 233 return true; … … 572 572 } 573 573 574 574 function wp_widget_text_page() { 575 $options = $newoptions =get_option('widget_text');575 $options = get_option('widget_text'); 576 576 ?> 577 577 <div class="wrap"> 578 578 <form method="POST"> … … 1005 1005 } else { 1006 1006 $newoptions[$number]['error'] = true; 1007 1007 $newoptions[$number]['url'] = wp_specialchars(__('Error: could not find an RSS or ATOM feed at that URL.'), 1); 1008 $error = sprintf(__('Error in RSS %1$d: %2$s'), $number, $newoptions[$number]['error']);1009 1008 } 1010 1009 } 1011 1010 } … … 1023 1022 <p style="text-align:center;"><?php _e('Give the feed a title (optional):'); ?></p> 1024 1023 <input style="width: 400px;" id="rss-title-<?php echo "$number"; ?>" name="rss-title-<?php echo "$number"; ?>" type="text" value="<?php echo $title; ?>" /> 1025 1024 <p style="text-align:center; line-height: 30px;"><?php _e('How many items would you like to display?'); ?> <select id="rss-items-<?php echo $number; ?>" name="rss-items-<?php echo $number; ?>"><?php for ( $i = 1; $i <= 10; ++$i ) echo "<option value='$i' ".($items==$i ? "selected='selected'" : '').">$i</option>"; ?></select></p> 1026 <input type="hidden" id="rss-submit-<?php echo "$number"; ?>" name="rss-submit-<?php echo "$number"; ?>" value="1" />1025 <input type="hidden" id="rss-submit-<?php echo "$number"; ?>" name="rss-submit-<?php echo $number; ?>" value="1" /> 1027 1026 <?php 1028 1027 } 1029 1028 … … 1043 1042 } 1044 1043 1045 1044 function wp_widget_rss_page() { 1046 $options = $newoptions =get_option('widget_rss');1045 $options = get_option('widget_rss'); 1047 1046 ?> 1048 1047 <div class="wrap"> 1049 1048 <form method="POST"> -
wp-login.php
27 27 28 28 // Rather than duplicating this HTML all over the place, we'll stick it in function 29 29 function login_header($title = 'Login', $message = '') { 30 global $errors, $error , $wp_locale;30 global $errors, $error; 31 31 32 32 ?> 33 33 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -
xmlrpc.php
459 459 * wp_getAuthors 460 460 */ 461 461 function wp_getAuthors($args) { 462 global $wpdb;463 462 464 463 $this->escape($args); 465 464 … … 533 532 * wp_suggestCategories 534 533 */ 535 534 function wp_suggestCategories($args) { 536 global $wpdb;537 538 535 $this->escape($args); 539 536 540 537 $blog_id = (int) $args[0]; … … 625 622 return $this->error; 626 623 } 627 624 628 $user_data = get_userdatabylogin($user_login);629 625 $post_data = wp_get_single_post($post_ID, ARRAY_A); 630 626 631 627 $categories = implode(',', wp_get_post_categories($post_ID)); … … 648 644 /* blogger.getRecentPosts ...gets recent posts */ 649 645 function blogger_getRecentPosts($args) { 650 646 651 global $wpdb;652 653 647 $this->escape($args); 654 648 655 649 $blog_ID = (int) $args[1]; /* though we don't use it yet */ … … 767 761 /* blogger.newPost ...creates a new post */ 768 762 function blogger_newPost($args) { 769 763 770 global $wpdb;771 772 764 $this->escape($args); 773 765 774 $blog_ID = (int) $args[1]; /* though we don't use it yet */ 775 $user_login = $args[2]; 776 $user_pass = $args[3]; 777 $content = $args[4]; 778 $publish = $args[5]; 766 $blog_ID = (int) $args[1]; /* though we don't use it yet */ 767 $user_login = $args[2]; 768 $user_pass = $args[3]; 769 $content = $args[4]; 770 $publish = $args[5]; 771 772 if (!$this->login_pass_ok($user_login, $user_pass)) { 773 return $this->error; 774 } 775 776 $cap = ($publish) ? 'publish_posts' : 'edit_posts'; 777 $user = set_current_user(0, $user_login); 778 if ( !current_user_can($cap) ) 779 return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); 780 781 $post_status = ($publish) ? 'publish' : 'draft'; 782 783 $post_author = $user->ID; 784 785 $post_title = xmlrpc_getposttitle($content); 786 $post_category = xmlrpc_getpostcategory($content); 787 $post_content = xmlrpc_removepostdata($content); 788 789 $post_date = current_time('mysql'); 790 $post_date_gmt = current_time('mysql', 1); 791 792 $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status'); 793 794 $post_ID = wp_insert_post($post_data); 795 if ( is_wp_error( $post_ID ) ) 796 return new IXR_Error(500, $post_ID->get_error_message()); 779 797 780 if (!$this->login_pass_ok($user_login, $user_pass)) { 781 return $this->error; 782 } 798 if (!$post_ID) 799 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); 783 800 784 $cap = ($publish) ? 'publish_posts' : 'edit_posts'; 785 $user = set_current_user(0, $user_login); 786 if ( !current_user_can($cap) ) 787 return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); 801 $this->attach_uploads( $post_ID, $post_content ); 788 802 789 $post_status = ($publish) ? 'publish' : 'draft';803 logIO('O', "Posted ! ID: $post_ID"); 790 804 791 $post_author = $user->ID; 792 793 $post_title = xmlrpc_getposttitle($content); 794 $post_category = xmlrpc_getpostcategory($content); 795 $post_content = xmlrpc_removepostdata($content); 796 797 $post_date = current_time('mysql'); 798 $post_date_gmt = current_time('mysql', 1); 799 800 $post_data = compact('blog_ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status'); 801 802 $post_ID = wp_insert_post($post_data); 803 if ( is_wp_error( $post_ID ) ) 804 return new IXR_Error(500, $post_ID->get_error_message()); 805 806 if (!$post_ID) { 807 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); 808 } 809 $this->attach_uploads( $post_ID, $post_content ); 810 811 logIO('O', "Posted ! ID: $post_ID"); 812 813 return $post_ID; 805 return $post_ID; 814 806 } 815 807 816 817 808 /* blogger.editPost ...edits a post */ 818 809 function blogger_editPost($args) { 819 810 820 global $wpdb;821 822 811 $this->escape($args); 823 824 $post_ID = (int) $args[1];825 $user_login = $args[2];826 $user_pass = $args[3];827 $content = $args[4];828 $publish = $args[5];829 830 if (!$this->login_pass_ok($user_login, $user_pass)) {831 return $this->error;832 }833 834 $actual_post = wp_get_single_post($post_ID,ARRAY_A);835 836 if (!$actual_post) {837 return new IXR_Error(404, __('Sorry, no such post.'));838 }839 812 813 $post_ID = (int) $args[1]; 814 $user_login = $args[2]; 815 $user_pass = $args[3]; 816 $content = $args[4]; 817 $publish = $args[5]; 818 819 if (!$this->login_pass_ok($user_login, $user_pass)) { 820 return $this->error; 821 } 822 823 $actual_post = wp_get_single_post($post_ID,ARRAY_A); 824 825 if (!$actual_post) { 826 return new IXR_Error(404, __('Sorry, no such post.')); 827 } 828 840 829 $this->escape($actual_post); 841 842 set_current_user(0, $user_login);843 if ( !current_user_can('edit_post', $post_ID) )844 return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.'));845 846 extract($actual_post, EXTR_SKIP);847 848 if ( ('publish' == $post_status) && !current_user_can('publish_posts') )849 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.'));850 851 $post_title = xmlrpc_getposttitle($content);852 $post_category = xmlrpc_getpostcategory($content);853 $post_content = xmlrpc_removepostdata($content);854 855 $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt');856 857 $result = wp_update_post($postdata);858 859 if (!$result) {860 return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.'));861 }862 $this->attach_uploads( $ID, $post_content );863 864 return true;830 831 set_current_user(0, $user_login); 832 if ( !current_user_can('edit_post', $post_ID) ) 833 return new IXR_Error(401, __('Sorry, you do not have the right to edit this post.')); 834 835 extract($actual_post, EXTR_SKIP); 836 837 if ( ('publish' == $post_status) && !current_user_can('publish_posts') ) 838 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); 839 840 $post_title = xmlrpc_getposttitle($content); 841 $post_category = xmlrpc_getpostcategory($content); 842 $post_content = xmlrpc_removepostdata($content); 843 844 $postdata = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt'); 845 846 $result = wp_update_post($postdata); 847 848 if (!$result) { 849 return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be edited.')); 850 } 851 $this->attach_uploads( $ID, $post_content ); 852 853 return true; 865 854 } 866 855 867 856 868 857 /* blogger.deletePost ...deletes a post */ 869 858 function blogger_deletePost($args) { 870 871 global $wpdb;872 873 859 $this->escape($args); 874 875 $post_ID = (int) $args[1];876 $user_login = $args[2];877 $user_pass = $args[3];878 $publish = $args[4];879 880 if (!$this->login_pass_ok($user_login, $user_pass)) {881 return $this->error;882 }883 884 $actual_post = wp_get_single_post($post_ID,ARRAY_A);885 886 if (!$actual_post) {887 return new IXR_Error(404, __('Sorry, no such post.'));888 }889 890 set_current_user(0, $user_login);891 if ( !current_user_can('edit_post', $post_ID) )892 return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.'));893 894 $result = wp_delete_post($post_ID);895 896 if (!$result) {897 return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.'));898 }899 900 return true;860 861 $post_ID = (int) $args[1]; 862 $user_login = $args[2]; 863 $user_pass = $args[3]; 864 $publish = $args[4]; 865 866 if (!$this->login_pass_ok($user_login, $user_pass)) { 867 return $this->error; 868 } 869 870 $actual_post = wp_get_single_post($post_ID,ARRAY_A); 871 872 if (!$actual_post) { 873 return new IXR_Error(404, __('Sorry, no such post.')); 874 } 875 876 set_current_user(0, $user_login); 877 if ( !current_user_can('edit_post', $post_ID) ) 878 return new IXR_Error(401, __('Sorry, you do not have the right to delete this post.')); 879 880 $result = wp_delete_post($post_ID); 881 882 if (!$result) { 883 return new IXR_Error(500, __('For some strange yet very annoying reason, this post could not be deleted.')); 884 } 885 886 return true; 901 887 } 902 888 903 889 … … 908 894 909 895 /* metaweblog.newPost creates a post */ 910 896 function mw_newPost($args) { 911 912 global $wpdb, $post_default_category;913 914 897 $this->escape($args); 915 898 916 $blog_ID = (int) $args[0]; // we will support this in the near future 917 $user_login = $args[1]; 918 $user_pass = $args[2]; 919 $content_struct = $args[3]; 920 $publish = $args[4]; 899 $blog_ID = (int) $args[0]; // we will support this in the near future 900 $user_login = $args[1]; 901 $user_pass = $args[2]; 902 $content_struct = $args[3]; 903 $publish = $args[4]; 904 905 if (!$this->login_pass_ok($user_login, $user_pass)) { 906 return $this->error; 907 } 908 909 $cap = ($publish) ? 'publish_posts' : 'edit_posts'; 910 $user = set_current_user(0, $user_login); 911 if ( !current_user_can($cap) ) 912 return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.')); 921 913 922 if (!$this->login_pass_ok($user_login, $user_pass)) {923 return $this->error;924 }925 926 $cap = ($publish) ? 'publish_posts' : 'edit_posts';927 $user = set_current_user(0, $user_login);928 if ( !current_user_can($cap) )929 return new IXR_Error(401, __('Sorry, you are not allowed to post on this blog.'));930 931 914 // The post_type defaults to post, but could also be page. 932 915 $post_type = "post"; 933 916 if( … … 959 942 $menu_order = $content_struct["wp_page_order"]; 960 943 } 961 944 962 $post_author = $user->ID;945 $post_author = $user->ID; 963 946 964 947 // If an author id was provided then use it instead. 965 948 if( … … 984 967 $post_author = $content_struct["wp_author_id"]; 985 968 } 986 969 987 $post_title = $content_struct['title']; 988 $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); 989 $post_status = $publish ? 'publish' : 'draft'; 970 $post_title = $content_struct['title']; 971 $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); 972 $post_status = $publish ? 'publish' : 'draft'; 973 974 $post_excerpt = $content_struct['mt_excerpt']; 975 $post_more = $content_struct['mt_text_more']; 990 976 991 $post_excerpt = $content_struct['mt_excerpt'];992 $post_more = $content_struct['mt_text_more'];993 994 977 $tags_input = $content_struct['mt_keywords']; 995 978 996 979 if(isset($content_struct["mt_allow_comments"])) { … … 1058 1041 $ping_status = get_option("default_ping_status"); 1059 1042 } 1060 1043 1061 if ($post_more) { 1062 $post_content = $post_content . "\n<!--more-->\n" . $post_more; 1063 } 1044 if ($post_more) { 1045 $post_content = $post_content . "\n<!--more-->\n" . $post_more; 1046 } 1047 1048 $to_ping = $content_struct['mt_tb_ping_urls']; 1049 if ( is_array($to_ping) ) 1050 $to_ping = implode(' ', $to_ping); 1064 1051 1065 $to_ping = $content_struct['mt_tb_ping_urls'];1066 if ( is_array($to_ping) )1067 $to_ping = implode(' ', $to_ping);1068 1069 1052 // Do some timestamp voodoo 1070 1053 $dateCreatedd = $content_struct['dateCreated']; 1071 1054 if (!empty($dateCreatedd)) { … … 1077 1060 $post_date_gmt = current_time('mysql', 1); 1078 1061 } 1079 1062 1080 $catnames = $content_struct['categories']; 1081 logIO('O', 'Post cats: ' . printr($catnames,true)); 1082 $post_category = array(); 1063 $catnames = $content_struct['categories']; 1064 logIO('O', 'Post cats: ' . printr($catnames,true)); 1065 $post_category = array(); 1066 1067 if (is_array($catnames)) { 1068 foreach ($catnames as $cat) { 1069 $post_category[] = get_cat_ID($cat); 1070 } 1071 } 1083 1072 1084 if (is_array($catnames)) { 1085 foreach ($catnames as $cat) { 1086 $post_category[] = get_cat_ID($cat); 1087 } 1088 } 1089 1090 // We've got all the data -- post it: 1091 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input'); 1092 1093 $post_ID = wp_insert_post($postdata); 1094 if ( is_wp_error( $post_ID ) ) 1095 return new IXR_Error(500, $post_ID->get_error_message()); 1096 1097 if (!$post_ID) { 1098 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); 1099 } 1100 1101 $this->attach_uploads( $post_ID, $post_content ); 1102 1103 logIO('O', "Posted ! ID: $post_ID"); 1104 1105 return strval($post_ID); 1073 // We've got all the data -- post it: 1074 $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'to_ping', 'post_type', 'post_name', 'post_password', 'post_parent', 'menu_order', 'tags_input'); 1075 1076 $post_ID = wp_insert_post($postdata); 1077 if ( is_wp_error( $post_ID ) ) 1078 return new IXR_Error(500, $post_ID->get_error_message()); 1079 1080 if (!$post_ID) { 1081 return new IXR_Error(500, __('Sorry, your entry could not be posted. Something wrong happened.')); 1082 } 1083 1084 $this->attach_uploads( $post_ID, $post_content ); 1085 1086 logIO('O', "Posted ! ID: $post_ID"); 1087 1088 return strval($post_ID); 1106 1089 } 1107 1090 1108 1091 function attach_uploads( $post_ID, $post_content ) { … … 1122 1105 /* metaweblog.editPost ...edits a post */ 1123 1106 function mw_editPost($args) { 1124 1107 1125 global $wpdb, $post_default_category;1126 1127 1108 $this->escape($args); 1128 1109 1129 $post_ID = (int) $args[0]; 1130 $user_login = $args[1]; 1131 $user_pass = $args[2]; 1132 $content_struct = $args[3]; 1133 $publish = $args[4]; 1110 $post_ID = (int) $args[0]; 1111 $user_login = $args[1]; 1112 $user_pass = $args[2]; 1113 $content_struct = $args[3]; 1114 $publish = $args[4]; 1115 1116 if (!$this->login_pass_ok($user_login, $user_pass)) { 1117 return $this->error; 1118 } 1134 1119 1135 if (!$this->login_pass_ok($user_login, $user_pass)) {1136 return $this->error;1137 }1138 1139 1120 $user = set_current_user(0, $user_login); 1140 1121 1141 1122 // The post_type defaults to post, but could also be page. … … 1147 1128 $post_type = "page"; 1148 1129 } 1149 1130 1150 // Edit page caps are checked in editPage. Just check post here.1151 if ( ( 'post' == $post_type ) && !current_user_can('edit_post', $post_ID) )1152 return new IXR_Error(401, __('Sorry, you can not edit this post.'));1131 // Edit page caps are checked in editPage. Just check post here. 1132 if ( ( 'post' == $post_type ) && !current_user_can('edit_post', $post_ID) ) 1133 return new IXR_Error(401, __('Sorry, you can not edit this post.')); 1153 1134 1154 $postdata = wp_get_single_post($post_ID, ARRAY_A);1135 $postdata = wp_get_single_post($post_ID, ARRAY_A); 1155 1136 1156 1137 // If there is no post data for the give post id, stop 1157 1138 // now and return an error. Other wise a new post will be … … 1268 1249 } 1269 1250 } 1270 1251 1271 $post_title = $content_struct['title']; 1272 $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); 1273 $catnames = $content_struct['categories']; 1252 $post_title = $content_struct['title']; 1253 $post_content = apply_filters( 'content_save_pre', $content_struct['description'] ); 1254 $catnames = $content_struct['categories']; 1255 1256 $post_category = array(); 1257 1258 if (is_array($catnames)) { 1259 foreach ($catnames as $cat) { 1260 $post_category[] = get_cat_ID($cat); 1261 } 1262 } 1263 1264 $post_excerpt = $content_struct['mt_excerpt']; 1265 $post_more = $content_struct['mt_text_more']; 1266 $post_status = $publish ? 'publish' : 'draft'; 1267 1268 $tags_input = $content_struct['mt_keywords']; 1274 1269 1275 $post_category = array(); 1270 if ( ('publish' == $post_status) ) { 1271 if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') ) 1272 return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); 1273 else if ( !current_user_can('publish_posts') ) 1274 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); 1275 } 1276 1277 if ($post_more) { 1278 $post_content = $post_content . "\n<!--more-->\n" . $post_more; 1279 } 1276 1280 1277 if (is_array($catnames)) { 1278 foreach ($catnames as $cat) { 1279 $post_category[] = get_cat_ID($cat); 1280 } 1281 } 1281 $to_ping = $content_struct['mt_tb_ping_urls']; 1282 if ( is_array($to_ping) ) 1283 $to_ping = implode(' ', $to_ping); 1284 1285 // Do some timestamp voodoo 1286 $dateCreatedd = $content_struct['dateCreated']; 1287 if (!empty($dateCreatedd)) { 1288 $dateCreated = $dateCreatedd->getIso(); 1289 $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); 1290 $post_date_gmt = iso8601_to_datetime($dateCreated . "Z", GMT); 1291 } else { 1292 $post_date = $postdata['post_date']; 1293 $post_date_gmt = $postdata['post_date_gmt']; 1294 } 1282 1295 1283 $post_excerpt = $content_struct['mt_excerpt']; 1284 $post_more = $content_struct['mt_text_more']; 1285 $post_status = $publish ? 'publish' : 'draft'; 1286 1287 $tags_input = $content_struct['mt_keywords']; 1288 1289 if ( ('publish' == $post_status) ) { 1290 if ( ( 'page' == $post_type ) && !current_user_can('publish_pages') ) 1291 return new IXR_Error(401, __('Sorry, you do not have the right to publish this page.')); 1292 else if ( !current_user_can('publish_posts') ) 1293 return new IXR_Error(401, __('Sorry, you do not have the right to publish this post.')); 1294 } 1295 1296 if ($post_more) { 1297 $post_content = $post_content . "\n<!--more-->\n" . $post_more; 1298 } 1299 1300 $to_ping = $content_struct['mt_tb_ping_urls']; 1301 if ( is_array($to_ping) ) 1302 $to_ping = implode(' ', $to_ping); 1303 1304 // Do some timestamp voodoo 1305 $dateCreatedd = $content_struct['dateCreated']; 1306 if (!empty($dateCreatedd)) { 1307 $dateCreated = $dateCreatedd->getIso(); 1308 $post_date = get_date_from_gmt(iso8601_to_datetime($dateCreated)); 1309 $post_date_gmt = iso8601_to_datetime($dateCreated . "Z", GMT); 1310 } else { 1311 $post_date = $postdata['post_date']; 1312 $post_date_gmt = $postdata['post_date_gmt']; 1313 } 1314 1315 // We've got all the data -- post it: 1316 $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input'); 1317 1318 $result = wp_update_post($newpost); 1319 if (!$result) { 1320 return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); 1321 } 1322 $this->attach_uploads( $ID, $post_content ); 1323 1324 logIO('O',"(MW) Edited ! ID: $post_ID"); 1325 1326 return true; 1296 // We've got all the data -- post it: 1297 $newpost = compact('ID', 'post_content', 'post_title', 'post_category', 'post_status', 'post_excerpt', 'comment_status', 'ping_status', 'post_date', 'post_date_gmt', 'to_ping', 'post_name', 'post_password', 'post_parent', 'menu_order', 'post_author', 'tags_input'); 1298 1299 $result = wp_update_post($newpost); 1300 if (!$result) { 1301 return new IXR_Error(500, __('Sorry, your entry could not be edited. Something wrong happened.')); 1302 } 1303 $this->attach_uploads( $ID, $post_content ); 1304 1305 logIO('O',"(MW) Edited ! ID: $post_ID"); 1306 1307 return true; 1327 1308 } 1328 1309 1329 1310 1330 1311 /* metaweblog.getPost ...returns a post */ 1331 1312 function mw_getPost($args) { 1332 1313 1333 global $wpdb;1334 1335 1314 $this->escape($args); 1336 1337 $post_ID = (int) $args[0]; 1338 $user_login = $args[1]; 1339 $user_pass = $args[2]; 1340 1341 if (!$this->login_pass_ok($user_login, $user_pass)) { 1342 return $this->error; 1343 } 1344 1345 $postdata = wp_get_single_post($post_ID, ARRAY_A); 1346 1347 if ($postdata['post_date'] != '') { 1348 1349 $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']); 1350 $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']); 1351 1352 $categories = array(); 1353 $catids = wp_get_post_categories($post_ID); 1354 foreach($catids as $catid) { 1355 $categories[] = get_cat_name($catid); 1356 } 1357 1358 $tagnames = array(); 1359 $tags = wp_get_post_tags( $post_ID ); 1360 if ( !empty( $tags ) ) { 1361 foreach ( $tags as $tag ) { 1362 $tagnames[] = $tag->name; 1315 1316 $post_ID = (int) $args[0]; 1317 $user_login = $args[1]; 1318 $user_pass = $args[2]; 1319 1320 if (!$this->login_pass_ok($user_login, $user_pass)) { 1321 return $this->error; 1322 } 1323 1324 $postdata = wp_get_single_post($post_ID, ARRAY_A); 1325 1326 if ($postdata['post_date'] != '') { 1327 $post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']); 1328 $post_date_gmt = mysql2date('Ymd\TH:i:s', $postdata['post_date_gmt']); 1329 1330 $categories = array(); 1331 $catids = wp_get_post_categories($post_ID); 1332 foreach($catids as $catid) 1333 $categories[] = get_cat_name($catid); 1334 1335 $tagnames = array(); 1336 $tags = wp_get_post_tags( $post_ID ); 1337 if ( !empty( $tags ) ) { 1338 foreach ( $tags as $tag ) 1339 $tagnames[] = $tag->name; 1340 $tagnames = implode( ', ', $tagnames ); 1341 } else { 1342 $tagnames = ''; 1363 1343 } 1364 $tagnames = implode( ', ', $tagnames ); 1344 1345 $post = get_extended($postdata['post_content']); 1346 $link = post_permalink($postdata['ID']); 1347 1348 // Get the author info. 1349 $author = get_userdata($postdata['post_author']); 1350 1351 $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0; 1352 $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0; 1353 1354 $resp = array( 1355 'dateCreated' => new IXR_Date($post_date), 1356 'userid' => $postdata['post_author'], 1357 'postid' => $postdata['ID'], 1358 'description' => $post['main'], 1359 'title' => $postdata['post_title'], 1360 'link' => $link, 1361 'permaLink' => $link, 1362 // commented out because no other tool seems to use this 1363 // 'content' => $entry['post_content'], 1364 'categories' => $categories, 1365 'mt_excerpt' => $postdata['post_excerpt'], 1366 'mt_text_more' => $post['extended'], 1367 'mt_allow_comments' => $allow_comments, 1368 'mt_allow_pings' => $allow_pings, 1369 'mt_keywords' => $tagnames, 1370 'wp_slug' => $postdata['post_name'], 1371 'wp_password' => $postdata['post_password'], 1372 'wp_author_id' => $author->ID, 1373 'wp_author_display_name' => $author->display_name, 1374 'date_created_gmt' => new IXR_Date($post_date_gmt), 1375 'post_status' => $postdata['post_status'] 1376 ); 1377 1378 return $resp; 1365 1379 } else { 1366 $tagnames = '';1380 return new IXR_Error(404, __('Sorry, no such post.')); 1367 1381 } 1368 1369 $post = get_extended($postdata['post_content']);1370 $link = post_permalink($postdata['ID']);1371 1372 // Get the author info.1373 $author = get_userdata($postdata['post_author']);1374 1375 $allow_comments = ('open' == $postdata['comment_status']) ? 1 : 0;1376 $allow_pings = ('open' == $postdata['ping_status']) ? 1 : 0;1377 1378 $resp = array(1379 'dateCreated' => new IXR_Date($post_date),1380 'userid' => $postdata['post_author'],1381 'postid' => $postdata['ID'],1382 'description' => $post['main'],1383 'title' => $postdata['post_title'],1384 'link' => $link,1385 'permaLink' => $link,1386 // commented out because no other tool seems to use this1387 // 'content' => $entry['post_content'],1388 'categories' => $categories,1389 'mt_excerpt' => $postdata['post_excerpt'],1390 'mt_text_more' => $post['extended'],1391 'mt_allow_comments' => $allow_comments,1392 'mt_allow_pings' => $allow_pings,1393 'mt_keywords' => $tagnames,1394 'wp_slug' => $postdata['post_name'],1395 'wp_password' => $postdata['post_password'],1396 'wp_author_id' => $author->ID,1397 'wp_author_display_name' => $author->display_name,1398 'date_created_gmt' => new IXR_Date($post_date_gmt),1399 'post_status' => $postdata['post_status']1400 );1401 1402 return $resp;1403 } else {1404 return new IXR_Error(404, __('Sorry, no such post.'));1405 }1406 1382 } 1407 1383 1408 1384 … … 1496 1472 /* metaweblog.getCategories ...returns the list of categories on a given blog */ 1497 1473 function mw_getCategories($args) { 1498 1474 1499 global $wpdb;1500 1501 1475 $this->escape($args); 1502 1476 1503 1477 $blog_ID = (int) $args[0]; … … 1576 1550 $name = "wpid{$old_file->ID}-{$filename}"; 1577 1551 } 1578 1552 1579 $upload = wp_upload_bits($name, $type, $bits , $overwrite);1553 $upload = wp_upload_bits($name, $type, $bits); 1580 1554 if ( ! empty($upload['error']) ) { 1581 1555 $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']); 1582 1556 logIO('O', '(MW) ' . $errorString); … … 1654 1628 /* mt.getCategoryList ...returns the list of categories on a given blog */ 1655 1629 function mt_getCategoryList($args) { 1656 1630 1657 global $wpdb;1658 1659 1631 $this->escape($args); 1660 1632 1661 1633 $blog_ID = (int) $args[0]; … … 1834 1806 1835 1807 /* pingback.ping gets a pingback and registers it */ 1836 1808 function pingback_ping($args) { 1837 global $wpdb , $wp_version;1809 global $wpdb; 1838 1810 1839 1811 $this->escape($args); 1840 1812 … … 1847 1819 $pagelinkedto = str_replace('&', '&', $pagelinkedto); 1848 1820 $pagelinkedto = str_replace('&', '&', $pagelinkedto); 1849 1821 1850 $error_code = -1;1851 1852 1822 // Check if the page linked to is in our site 1853 1823 $pos1 = strpos($pagelinkedto, str_replace(array('http://www.','http://','https://www.','https://'), '', get_option('home'))); 1854 1824 if( !$pos1 ) 1855 return new IXR_Error(0, __('Is there no link to us?'));1825 return new IXR_Error(0, __('Is there no link to us?')); 1856 1826 1857 1827 // let's find which post is linked to 1858 1828 // FIXME: does url_to_postid() cover all these cases already? … … 1912 1882 return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.')); 1913 1883 1914 1884 // Let's check that the remote site didn't already pingback this entry 1915 $ result = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'");1885 $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_ID' AND comment_author_url = '$pagelinkedfrom'"); 1916 1886 1917 1887 if ( $wpdb->num_rows ) // We already have a Pingback from this URL 1918 1888 return new IXR_Error(48, __('The pingback has already been registered.')); … … 1974 1944 $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); 1975 1945 1976 1946 $context = '[...] ' . wp_specialchars( $excerpt ) . ' [...]'; 1977 $original_pagelinkedfrom = $pagelinkedfrom;1978 1947 $pagelinkedfrom = $wpdb->escape( $pagelinkedfrom ); 1979 $original_title = $title;1980 1948 1981 1949 $comment_post_ID = (int) $post_ID; 1982 1950 $comment_author = $title;
