Changeset 38275 for trunk/src/wp-includes/class-wp-xmlrpc-server.php
- Timestamp:
- 08/18/2016 06:20:55 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-xmlrpc-server.php
r38077 r38275 55 55 56 56 /** 57 * @since 4.7.0 58 * @access protected 59 * @var wpdb 60 */ 61 protected $db; 62 63 /** 57 64 * Registers all of the XMLRPC methods that XMLRPC server understands. 58 65 * … … 64 71 */ 65 72 public function __construct() { 73 $this->db = $GLOBALS['wpdb']; 74 66 75 $this->methods = array( 67 76 // WordPress API … … 2883 2892 * @since 2.2.0 2884 2893 * 2885 * @global wpdb $wpdb WordPress database abstraction object.2886 *2887 2894 * @param array $args { 2888 2895 * Method arguments. Note: arguments must be ordered as documented. … … 2895 2902 */ 2896 2903 public function wp_getPageList( $args ) { 2897 global $wpdb;2898 2899 2904 $this->escape( $args ); 2900 2905 … … 2912 2917 2913 2918 // Get list of pages ids and titles 2914 $page_list = $ wpdb->get_results("2919 $page_list = $this->db->get_results(" 2915 2920 SELECT ID page_id, 2916 2921 post_title page_title, … … 2919 2924 post_date, 2920 2925 post_status 2921 FROM {$ wpdb->posts}2926 FROM {$this->db->posts} 2922 2927 WHERE post_type = 'page' 2923 2928 ORDER BY ID … … 5131 5136 * @since 2.1.0 5132 5137 * 5133 * @global wpdb $wpdb WordPress database abstraction object.5134 *5135 5138 * @param int $post_ID Post ID. 5136 5139 * @param string $post_content Post Content for attachment. 5137 5140 */ 5138 5141 public function attach_uploads( $post_ID, $post_content ) { 5139 global $wpdb;5140 5141 5142 // find any unattached files 5142 $attachments = $ wpdb->get_results( "SELECT ID, guid FROM {$wpdb->posts} WHERE post_parent = '0' AND post_type = 'attachment'" );5143 $attachments = $this->db->get_results( "SELECT ID, guid FROM {$this->db->posts} WHERE post_parent = '0' AND post_type = 'attachment'" ); 5143 5144 if ( is_array( $attachments ) ) { 5144 5145 foreach ( $attachments as $file ) { 5145 if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) 5146 $wpdb->update($wpdb->posts, array('post_parent' => $post_ID), array('ID' => $file->ID) ); 5146 if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) { 5147 $this->db->update( $this->db->posts, array( 'post_parent' => $post_ID ), array( 'ID' => $file->ID ) ); 5148 } 5147 5149 } 5148 5150 } … … 5764 5766 * @since 1.5.0 5765 5767 * 5766 * @global wpdb $wpdb WordPress database abstraction object.5767 *5768 5768 * @param array $args { 5769 5769 * Method arguments. Note: arguments must be ordered as documented. … … 5777 5777 */ 5778 5778 public function mw_newMediaObject( $args ) { 5779 global $wpdb;5780 5781 5779 $username = $this->escape( $args[1] ); 5782 5780 $password = $this->escape( $args[2] ); … … 6103 6101 * @since 1.5.0 6104 6102 * 6105 * @global wpdb $wpdb WordPress database abstraction object.6106 *6107 6103 * @param int $post_ID 6108 6104 * @return array|IXR_Error 6109 6105 */ 6110 6106 public function mt_getTrackbackPings( $post_ID ) { 6111 global $wpdb;6112 6113 6107 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ 6114 6108 do_action( 'xmlrpc_call', 'mt.getTrackbackPings' ); … … 6119 6113 return new IXR_Error(404, __('Sorry, no such post.')); 6120 6114 6121 $comments = $ wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->commentsWHERE comment_post_ID = %d", $post_ID) );6115 $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) ); 6122 6116 6123 6117 if ( !$comments ) … … 6193 6187 * @since 1.5.0 6194 6188 * 6195 * @global wpdb $wpdb WordPress database abstraction object.6196 6189 * @global string $wp_version 6197 6190 * … … 6205 6198 */ 6206 6199 public function pingback_ping( $args ) { 6207 global $wp db, $wp_version;6200 global $wp_version; 6208 6201 6209 6202 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ … … 6259 6252 // ...or a string #title, a little more complicated 6260 6253 $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']); 6261 $sql = $ wpdb->prepare("SELECT ID FROM $wpdb->postsWHERE post_title RLIKE %s", $title );6262 if (! ($post_ID = $ wpdb->get_var($sql)) ) {6254 $sql = $this->db->prepare("SELECT ID FROM {$this->db->posts} WHERE post_title RLIKE %s", $title ); 6255 if (! ($post_ID = $this->db->get_var($sql)) ) { 6263 6256 // returning unknown error '0' is better than die()ing 6264 6257 return $this->pingback_error( 0, '' ); … … 6284 6277 6285 6278 // Let's check that the remote site didn't already pingback this entry 6286 if ( $ wpdb->get_results( $wpdb->prepare("SELECT * FROM $wpdb->commentsWHERE comment_post_ID = %d AND comment_author_url = %s", $post_ID, $pagelinkedfrom) ) )6279 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) ) ) 6287 6280 return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); 6288 6281 … … 6409 6402 * @since 1.5.0 6410 6403 * 6411 * @global wpdb $wpdb WordPress database abstraction object.6412 *6413 6404 * @param string $url 6414 6405 * @return array|IXR_Error 6415 6406 */ 6416 6407 public function pingback_extensions_getPingbacks( $url ) { 6417 global $wpdb;6418 6419 6408 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ 6420 6409 do_action( 'xmlrpc_call', 'pingback.extensions.getPingbacks' ); … … 6435 6424 } 6436 6425 6437 $comments = $ wpdb->get_results( $wpdb->prepare("SELECT comment_author_url, comment_content, comment_author_IP, comment_type FROM $wpdb->commentsWHERE comment_post_ID = %d", $post_ID) );6426 $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) ); 6438 6427 6439 6428 if ( !$comments )
Note: See TracChangeset
for help on using the changeset viewer.