Changeset 38768 for trunk/src/wp-includes/class-wp-xmlrpc-server.php
- Timestamp:
- 10/10/2016 06:37:02 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-xmlrpc-server.php
r38747 r38768 55 55 56 56 /** 57 * @since 4.7.058 * @access protected59 * @var wpdb60 */61 protected $db;62 63 /**64 57 * Registers all of the XMLRPC methods that XMLRPC server understands. 65 58 * … … 71 64 */ 72 65 public function __construct() { 73 $this->db = $GLOBALS['wpdb'];74 75 66 $this->methods = array( 76 67 // WordPress API … … 2895 2886 * @since 2.2.0 2896 2887 * 2888 * @global wpdb $wpdb WordPress database abstraction object. 2889 * 2897 2890 * @param array $args { 2898 2891 * Method arguments. Note: arguments must be ordered as documented. … … 2905 2898 */ 2906 2899 public function wp_getPageList( $args ) { 2900 global $wpdb; 2901 2907 2902 $this->escape( $args ); 2908 2903 … … 2920 2915 2921 2916 // Get list of pages ids and titles 2922 $page_list = $ this->db->get_results("2917 $page_list = $wpdb->get_results(" 2923 2918 SELECT ID page_id, 2924 2919 post_title page_title, … … 2927 2922 post_date, 2928 2923 post_status 2929 FROM {$ this->db->posts}2924 FROM {$wpdb->posts} 2930 2925 WHERE post_type = 'page' 2931 2926 ORDER BY ID … … 5144 5139 * @since 2.1.0 5145 5140 * 5141 * @global wpdb $wpdb WordPress database abstraction object. 5142 * 5146 5143 * @param int $post_ID Post ID. 5147 5144 * @param string $post_content Post Content for attachment. 5148 5145 */ 5149 5146 public function attach_uploads( $post_ID, $post_content ) { 5147 global $wpdb; 5148 5150 5149 // find any unattached files 5151 $attachments = $ this->db->get_results( "SELECT ID, guid FROM {$this->db->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );5150 $attachments = $wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); 5152 5151 if ( is_array( $attachments ) ) { 5153 5152 foreach ( $attachments as $file ) { 5154 if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) { 5155 $this->db->update( $this->db->posts, array( 'post_parent' => $post_ID ), array( 'ID' => $file->ID ) ); 5156 } 5153 if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) 5154 $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); 5157 5155 } 5158 5156 } … … 5774 5772 * @since 1.5.0 5775 5773 * 5774 * @global wpdb $wpdb WordPress database abstraction object. 5775 * 5776 5776 * @param array $args { 5777 5777 * Method arguments. Note: arguments must be ordered as documented. … … 5785 5785 */ 5786 5786 public function mw_newMediaObject( $args ) { 5787 global $wpdb; 5788 5787 5789 $username = $this->escape( $args[1] ); 5788 5790 $password = $this->escape( $args[2] ); … … 6110 6112 * @since 1.5.0 6111 6113 * 6114 * @global wpdb $wpdb WordPress database abstraction object. 6115 * 6112 6116 * @param int $post_ID 6113 6117 * @return array|IXR_Error 6114 6118 */ 6115 6119 public function mt_getTrackbackPings( $post_ID ) { 6120 global $wpdb; 6121 6116 6122 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ 6117 6123 do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); … … 6122 6128 return new IXR_Error(404, __('Sorry, no such post.')); 6123 6129 6124 $comments = $ this->db->get_results( $this->db->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM {$this->db->comments}WHERE comment_post_ID = %d", $post_ID) );6130 $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); 6125 6131 6126 6132 if ( !$comments ) … … 6257 6263 // ...or a string #title, a little more complicated 6258 6264 $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']); 6259 $sql = $ this->db->prepare("SELECT ID FROM {$this->db->posts}WHERE post_title RLIKE %s", $title );6260 if (! ($post_ID = $ this->db->get_var($sql)) ) {6265 $sql = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title ); 6266 if (! ($post_ID = $wpdb->get_var($sql)) ) { 6261 6267 // returning unknown error '0' is better than die()ing 6262 6268 return $this->pingback_error( 0, '' ); … … 6282 6288 6283 6289 // Let's check that the remote site didn't already pingback this entry 6284 if ( $ this->db->get_results( $this->db->prepare("SELECT * FROM {$this->db->comments}WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) )6290 if ( $wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) ) 6285 6291 return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); 6286 6292 … … 6409 6415 * @since 1.5.0 6410 6416 * 6417 * @global wpdb $wpdb WordPress database abstraction object. 6418 * 6411 6419 * @param string $url 6412 6420 * @return array|IXR_Error 6413 6421 */ 6414 6422 public function pingback_extensions_getPingbacks( $url ) { 6423 global $wpdb; 6424 6415 6425 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ 6416 6426 do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); … … 6431 6441 } 6432 6442 6433 $comments = $ this->db->get_results( $this->db->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM {$this->db->comments}WHERE comment_post_ID = %d", $post_ID) );6443 $comments = $wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->comments WHERE comment_post_ID = %d", $post_ID) ); 6434 6444 6435 6445 if ( !$comments )
Note: See TracChangeset
for help on using the changeset viewer.