Changeset 55365 for trunk/src/wp-includes/class-wp-xmlrpc-server.php
- Timestamp:
- 02/19/2023 03:03:50 PM (4 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-xmlrpc-server.php (modified) (60 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-xmlrpc-server.php
r55316 r55365 1530 1530 $post_data['ID'] = get_default_post_to_edit( $post_data['post_type'], true )->ID; 1531 1531 } 1532 $post_ ID= $post_data['ID'];1532 $post_id = $post_data['ID']; 1533 1533 1534 1534 if ( 'post' === $post_data['post_type'] ) { … … 1542 1542 // Empty value deletes, non-empty value adds/updates. 1543 1543 if ( ! $post_data['post_thumbnail'] ) { 1544 delete_post_thumbnail( $post_ ID);1544 delete_post_thumbnail( $post_id ); 1545 1545 } elseif ( ! get_post( absint( $post_data['post_thumbnail'] ) ) ) { 1546 1546 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 1547 1547 } 1548 set_post_thumbnail( $post_ ID, $post_data['post_thumbnail'] );1548 set_post_thumbnail( $post_id, $post_data['post_thumbnail'] ); 1549 1549 unset( $content_struct['post_thumbnail'] ); 1550 1550 } 1551 1551 1552 1552 if ( isset( $post_data['custom_fields'] ) ) { 1553 $this->set_custom_fields( $post_ ID, $post_data['custom_fields'] );1553 $this->set_custom_fields( $post_id, $post_data['custom_fields'] ); 1554 1554 } 1555 1555 … … 1657 1657 1658 1658 if ( isset( $post_data['post_format'] ) ) { 1659 $format = set_post_format( $post_ ID, $post_data['post_format'] );1659 $format = set_post_format( $post_id, $post_data['post_format'] ); 1660 1660 1661 1661 if ( is_wp_error( $format ) ) { … … 1668 1668 // Handle enclosures. 1669 1669 $enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null; 1670 $this->add_enclosure_if_new( $post_ ID, $enclosure );1671 1672 $this->attach_uploads( $post_ ID, $post_data['post_content'] );1670 $this->add_enclosure_if_new( $post_id, $enclosure ); 1671 1672 $this->attach_uploads( $post_id, $post_data['post_content'] ); 1673 1673 1674 1674 /** … … 1690 1690 ); 1691 1691 1692 $post_ ID= $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true );1693 if ( is_wp_error( $post_ ID) ) {1694 return new IXR_Error( 500, $post_ ID->get_error_message() );1695 } 1696 1697 if ( ! $post_ ID) {1692 $post_id = $update ? wp_update_post( $post_data, true ) : wp_insert_post( $post_data, true ); 1693 if ( is_wp_error( $post_id ) ) { 1694 return new IXR_Error( 500, $post_id->get_error_message() ); 1695 } 1696 1697 if ( ! $post_id ) { 1698 1698 if ( $update ) { 1699 1699 return new IXR_Error( 401, __( 'Sorry, the post could not be updated.' ) ); … … 1703 1703 } 1704 1704 1705 return (string) $post_ ID;1705 return (string) $post_id; 1706 1706 } 1707 1707 … … 4943 4943 $this->escape( $args ); 4944 4944 4945 $post_ ID= (int) $args[1];4945 $post_id = (int) $args[1]; 4946 4946 $username = $args[2]; 4947 4947 $password = $args[3]; … … 4952 4952 } 4953 4953 4954 $post_data = get_post( $post_ ID, ARRAY_A );4954 $post_data = get_post( $post_id, ARRAY_A ); 4955 4955 if ( ! $post_data ) { 4956 4956 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 4957 4957 } 4958 4958 4959 if ( ! current_user_can( 'edit_post', $post_ ID) ) {4959 if ( ! current_user_can( 'edit_post', $post_id ) ) { 4960 4960 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); 4961 4961 } … … 4964 4964 do_action( 'xmlrpc_call', 'blogger.getPost', $args, $this ); 4965 4965 4966 $categories = implode( ',', wp_get_post_categories( $post_ ID) );4966 $categories = implode( ',', wp_get_post_categories( $post_id ) ); 4967 4967 4968 4968 $content = '<title>' . wp_unslash( $post_data['post_title'] ) . '</title>'; … … 5129 5129 $post_data = compact( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_category', 'post_status' ); 5130 5130 5131 $post_ ID= wp_insert_post( $post_data );5132 if ( is_wp_error( $post_ ID) ) {5133 return new IXR_Error( 500, $post_ ID->get_error_message() );5134 } 5135 5136 if ( ! $post_ ID) {5131 $post_id = wp_insert_post( $post_data ); 5132 if ( is_wp_error( $post_id ) ) { 5133 return new IXR_Error( 500, $post_id->get_error_message() ); 5134 } 5135 5136 if ( ! $post_id ) { 5137 5137 return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) ); 5138 5138 } 5139 5139 5140 $this->attach_uploads( $post_ ID, $post_content );5140 $this->attach_uploads( $post_id, $post_content ); 5141 5141 5142 5142 /** … … 5145 5145 * @since 3.4.0 5146 5146 * 5147 * @param int $post_ IDID of the new post.5147 * @param int $post_id ID of the new post. 5148 5148 * @param array $args An array of new post arguments. 5149 5149 */ 5150 do_action( 'xmlrpc_call_success_blogger_newPost', $post_ ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase5151 5152 return $post_ ID;5150 do_action( 'xmlrpc_call_success_blogger_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase 5151 5152 return $post_id; 5153 5153 } 5154 5154 … … 5174 5174 $this->escape( $args ); 5175 5175 5176 $post_ ID= (int) $args[1];5176 $post_id = (int) $args[1]; 5177 5177 $username = $args[2]; 5178 5178 $password = $args[3]; … … 5188 5188 do_action( 'xmlrpc_call', 'blogger.editPost', $args, $this ); 5189 5189 5190 $actual_post = get_post( $post_ ID, ARRAY_A );5190 $actual_post = get_post( $post_id, ARRAY_A ); 5191 5191 5192 5192 if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { … … 5196 5196 $this->escape( $actual_post ); 5197 5197 5198 if ( ! current_user_can( 'edit_post', $post_ ID) ) {5198 if ( ! current_user_can( 'edit_post', $post_id ) ) { 5199 5199 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); 5200 5200 } … … 5224 5224 * @since 3.4.0 5225 5225 * 5226 * @param int $post_ IDID of the updated post.5226 * @param int $post_id ID of the updated post. 5227 5227 * @param array $args An array of arguments for the post to edit. 5228 5228 */ 5229 do_action( 'xmlrpc_call_success_blogger_editPost', $post_ ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase5229 do_action( 'xmlrpc_call_success_blogger_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase 5230 5230 5231 5231 return true; … … 5250 5250 $this->escape( $args ); 5251 5251 5252 $post_ ID= (int) $args[1];5252 $post_id = (int) $args[1]; 5253 5253 $username = $args[2]; 5254 5254 $password = $args[3]; … … 5262 5262 do_action( 'xmlrpc_call', 'blogger.deletePost', $args, $this ); 5263 5263 5264 $actual_post = get_post( $post_ ID, ARRAY_A );5264 $actual_post = get_post( $post_id, ARRAY_A ); 5265 5265 5266 5266 if ( ! $actual_post || 'post' !== $actual_post['post_type'] ) { … … 5268 5268 } 5269 5269 5270 if ( ! current_user_can( 'delete_post', $post_ ID) ) {5270 if ( ! current_user_can( 'delete_post', $post_id ) ) { 5271 5271 return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this post.' ) ); 5272 5272 } 5273 5273 5274 $result = wp_delete_post( $post_ ID);5274 $result = wp_delete_post( $post_id ); 5275 5275 5276 5276 if ( ! $result ) { … … 5283 5283 * @since 3.4.0 5284 5284 * 5285 * @param int $post_ IDID of the deleted post.5285 * @param int $post_id ID of the deleted post. 5286 5286 * @param array $args An array of arguments to delete the post. 5287 5287 */ 5288 do_action( 'xmlrpc_call_success_blogger_deletePost', $post_ ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase5288 do_action( 'xmlrpc_call_success_blogger_deletePost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase 5289 5289 5290 5290 return true; … … 5581 5581 $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', 'page_template' ); 5582 5582 5583 $post_ ID= get_default_post_to_edit( $post_type, true )->ID;5584 $postdata['ID'] = $post_ ID;5583 $post_id = get_default_post_to_edit( $post_type, true )->ID; 5584 $postdata['ID'] = $post_id; 5585 5585 5586 5586 // Only posts can be sticky. … … 5595 5595 5596 5596 if ( isset( $content_struct['custom_fields'] ) ) { 5597 $this->set_custom_fields( $post_ ID, $content_struct['custom_fields'] );5597 $this->set_custom_fields( $post_id, $content_struct['custom_fields'] ); 5598 5598 } 5599 5599 5600 5600 if ( isset( $content_struct['wp_post_thumbnail'] ) ) { 5601 if ( set_post_thumbnail( $post_ ID, $content_struct['wp_post_thumbnail'] ) === false ) {5601 if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) { 5602 5602 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 5603 5603 } … … 5608 5608 // Handle enclosures. 5609 5609 $thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null; 5610 $this->add_enclosure_if_new( $post_ ID, $thisEnclosure );5611 5612 $this->attach_uploads( $post_ ID, $post_content );5610 $this->add_enclosure_if_new( $post_id, $thisEnclosure ); 5611 5612 $this->attach_uploads( $post_id, $post_content ); 5613 5613 5614 5614 // Handle post formats if assigned, value is validated earlier 5615 5615 // in this function. 5616 5616 if ( isset( $content_struct['wp_post_format'] ) ) { 5617 set_post_format( $post_ ID, $content_struct['wp_post_format'] );5618 } 5619 5620 $post_ ID= wp_insert_post( $postdata, true );5621 if ( is_wp_error( $post_ ID) ) {5622 return new IXR_Error( 500, $post_ ID->get_error_message() );5623 } 5624 5625 if ( ! $post_ ID) {5617 set_post_format( $post_id, $content_struct['wp_post_format'] ); 5618 } 5619 5620 $post_id = wp_insert_post( $postdata, true ); 5621 if ( is_wp_error( $post_id ) ) { 5622 return new IXR_Error( 500, $post_id->get_error_message() ); 5623 } 5624 5625 if ( ! $post_id ) { 5626 5626 return new IXR_Error( 500, __( 'Sorry, the post could not be created.' ) ); 5627 5627 } … … 5632 5632 * @since 3.4.0 5633 5633 * 5634 * @param int $post_ IDID of the new post.5634 * @param int $post_id ID of the new post. 5635 5635 * @param array $args An array of arguments to create the new post. 5636 5636 */ 5637 do_action( 'xmlrpc_call_success_mw_newPost', $post_ ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase5638 5639 return (string) $post_ ID;5637 do_action( 'xmlrpc_call_success_mw_newPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase 5638 5639 return (string) $post_id; 5640 5640 } 5641 5641 … … 5645 5645 * @since 2.8.0 5646 5646 * 5647 * @param int $post_ IDPost ID.5647 * @param int $post_id Post ID. 5648 5648 * @param array $enclosure Enclosure data. 5649 5649 */ 5650 public function add_enclosure_if_new( $post_ ID, $enclosure ) {5650 public function add_enclosure_if_new( $post_id, $enclosure ) { 5651 5651 if ( is_array( $enclosure ) && isset( $enclosure['url'] ) && isset( $enclosure['length'] ) && isset( $enclosure['type'] ) ) { 5652 5652 $encstring = $enclosure['url'] . "\n" . $enclosure['length'] . "\n" . $enclosure['type'] . "\n"; 5653 5653 $found = false; 5654 $enclosures = get_post_meta( $post_ ID, 'enclosure' );5654 $enclosures = get_post_meta( $post_id, 'enclosure' ); 5655 5655 if ( $enclosures ) { 5656 5656 foreach ( $enclosures as $enc ) { … … 5663 5663 } 5664 5664 if ( ! $found ) { 5665 add_post_meta( $post_ ID, 'enclosure', $encstring );5665 add_post_meta( $post_id, 'enclosure', $encstring ); 5666 5666 } 5667 5667 } … … 5675 5675 * @global wpdb $wpdb WordPress database abstraction object. 5676 5676 * 5677 * @param int $post_ IDPost ID.5677 * @param int $post_id Post ID. 5678 5678 * @param string $post_content Post Content for attachment. 5679 5679 */ 5680 public function attach_uploads( $post_ ID, $post_content ) {5680 public function attach_uploads( $post_id, $post_content ) { 5681 5681 global $wpdb; 5682 5682 … … 5686 5686 foreach ( $attachments as $file ) { 5687 5687 if ( ! empty( $file->guid ) && strpos( $post_content, $file->guid ) !== false ) { 5688 $wpdb->update( $wpdb->posts, array( 'post_parent' => $post_ ID), array( 'ID' => $file->ID ) );5688 $wpdb->update( $wpdb->posts, array( 'post_parent' => $post_id ), array( 'ID' => $file->ID ) ); 5689 5689 } 5690 5690 } … … 5711 5711 $this->escape( $args ); 5712 5712 5713 $post_ ID= (int) $args[0];5713 $post_id = (int) $args[0]; 5714 5714 $username = $args[1]; 5715 5715 $password = $args[2]; … … 5725 5725 do_action( 'xmlrpc_call', 'metaWeblog.editPost', $args, $this ); 5726 5726 5727 $postdata = get_post( $post_ ID, ARRAY_A );5727 $postdata = get_post( $post_id, ARRAY_A ); 5728 5728 5729 5729 /* … … 5735 5735 } 5736 5736 5737 if ( ! current_user_can( 'edit_post', $post_ ID) ) {5737 if ( ! current_user_can( 'edit_post', $post_id ) ) { 5738 5738 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); 5739 5739 } … … 5984 5984 5985 5985 if ( isset( $content_struct['custom_fields'] ) ) { 5986 $this->set_custom_fields( $post_ ID, $content_struct['custom_fields'] );5986 $this->set_custom_fields( $post_id, $content_struct['custom_fields'] ); 5987 5987 } 5988 5988 … … 5991 5991 // Empty value deletes, non-empty value adds/updates. 5992 5992 if ( empty( $content_struct['wp_post_thumbnail'] ) ) { 5993 delete_post_thumbnail( $post_ ID);5993 delete_post_thumbnail( $post_id ); 5994 5994 } else { 5995 if ( set_post_thumbnail( $post_ ID, $content_struct['wp_post_thumbnail'] ) === false ) {5995 if ( set_post_thumbnail( $post_id, $content_struct['wp_post_thumbnail'] ) === false ) { 5996 5996 return new IXR_Error( 404, __( 'Invalid attachment ID.' ) ); 5997 5997 } … … 6002 6002 // Handle enclosures. 6003 6003 $thisEnclosure = isset( $content_struct['enclosure'] ) ? $content_struct['enclosure'] : null; 6004 $this->add_enclosure_if_new( $post_ ID, $thisEnclosure );6004 $this->add_enclosure_if_new( $post_id, $thisEnclosure ); 6005 6005 6006 6006 $this->attach_uploads( $ID, $post_content ); … … 6008 6008 // Handle post formats if assigned, validation is handled earlier in this function. 6009 6009 if ( isset( $content_struct['wp_post_format'] ) ) { 6010 set_post_format( $post_ ID, $content_struct['wp_post_format'] );6010 set_post_format( $post_id, $content_struct['wp_post_format'] ); 6011 6011 } 6012 6012 … … 6016 6016 * @since 3.4.0 6017 6017 * 6018 * @param int $post_ IDID of the updated post.6018 * @param int $post_id ID of the updated post. 6019 6019 * @param array $args An array of arguments to update the post. 6020 6020 */ 6021 do_action( 'xmlrpc_call_success_mw_editPost', $post_ ID, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase6021 do_action( 'xmlrpc_call_success_mw_editPost', $post_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase 6022 6022 6023 6023 return true; … … 6041 6041 $this->escape( $args ); 6042 6042 6043 $post_ ID= (int) $args[0];6043 $post_id = (int) $args[0]; 6044 6044 $username = $args[1]; 6045 6045 $password = $args[2]; … … 6050 6050 } 6051 6051 6052 $postdata = get_post( $post_ ID, ARRAY_A );6052 $postdata = get_post( $post_id, ARRAY_A ); 6053 6053 if ( ! $postdata ) { 6054 6054 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 6055 6055 } 6056 6056 6057 if ( ! current_user_can( 'edit_post', $post_ ID) ) {6057 if ( ! current_user_can( 'edit_post', $post_id ) ) { 6058 6058 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); 6059 6059 } … … 6069 6069 6070 6070 $categories = array(); 6071 $catids = wp_get_post_categories( $post_ ID);6071 $catids = wp_get_post_categories( $post_id ); 6072 6072 foreach ( $catids as $catid ) { 6073 6073 $categories[] = get_cat_name( $catid ); … … 6075 6075 6076 6076 $tagnames = array(); 6077 $tags = wp_get_post_tags( $post_ ID);6077 $tags = wp_get_post_tags( $post_id ); 6078 6078 if ( ! empty( $tags ) ) { 6079 6079 foreach ( $tags as $tag ) { … … 6100 6100 6101 6101 // Get post format. 6102 $post_format = get_post_format( $post_ ID);6102 $post_format = get_post_format( $post_id ); 6103 6103 if ( empty( $post_format ) ) { 6104 6104 $post_format = 'standard'; … … 6106 6106 6107 6107 $sticky = false; 6108 if ( is_sticky( $post_ ID) ) {6108 if ( is_sticky( $post_id ) ) { 6109 6109 $sticky = true; 6110 6110 } 6111 6111 6112 6112 $enclosure = array(); 6113 foreach ( (array) get_post_custom( $post_ ID) as $key => $val ) {6113 foreach ( (array) get_post_custom( $post_id ) as $key => $val ) { 6114 6114 if ( 'enclosure' === $key ) { 6115 6115 foreach ( (array) $val as $enc ) { … … 6146 6146 'date_created_gmt' => $post_date_gmt, 6147 6147 'post_status' => $postdata['post_status'], 6148 'custom_fields' => $this->get_custom_fields( $post_ ID),6148 'custom_fields' => $this->get_custom_fields( $post_id ), 6149 6149 'wp_post_format' => $post_format, 6150 6150 'sticky' => $sticky, … … 6604 6604 $this->escape( $args ); 6605 6605 6606 $post_ ID= (int) $args[0];6606 $post_id = (int) $args[0]; 6607 6607 $username = $args[1]; 6608 6608 $password = $args[2]; … … 6613 6613 } 6614 6614 6615 if ( ! get_post( $post_ ID) ) {6615 if ( ! get_post( $post_id ) ) { 6616 6616 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 6617 6617 } 6618 6618 6619 if ( ! current_user_can( 'edit_post', $post_ ID) ) {6619 if ( ! current_user_can( 'edit_post', $post_id ) ) { 6620 6620 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); 6621 6621 } … … 6625 6625 6626 6626 $categories = array(); 6627 $catids = wp_get_post_categories( (int) $post_ ID);6627 $catids = wp_get_post_categories( (int) $post_id ); 6628 6628 // First listed category will be the primary category. 6629 6629 $isPrimary = true; … … 6658 6658 $this->escape( $args ); 6659 6659 6660 $post_ ID= (int) $args[0];6660 $post_id = (int) $args[0]; 6661 6661 $username = $args[1]; 6662 6662 $password = $args[2]; … … 6671 6671 do_action( 'xmlrpc_call', 'mt.setPostCategories', $args, $this ); 6672 6672 6673 if ( ! get_post( $post_ ID) ) {6673 if ( ! get_post( $post_id ) ) { 6674 6674 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 6675 6675 } 6676 6676 6677 if ( ! current_user_can( 'edit_post', $post_ ID) ) {6677 if ( ! current_user_can( 'edit_post', $post_id ) ) { 6678 6678 return new IXR_Error( 401, __( 'Sorry, you are not allowed to edit this post.' ) ); 6679 6679 } … … 6684 6684 } 6685 6685 6686 wp_set_post_categories( $post_ ID, $catids );6686 wp_set_post_categories( $post_id, $catids ); 6687 6687 6688 6688 return true; … … 6729 6729 * @global wpdb $wpdb WordPress database abstraction object. 6730 6730 * 6731 * @param int $post_ ID6731 * @param int $post_id 6732 6732 * @return array|IXR_Error 6733 6733 */ 6734 public function mt_getTrackbackPings( $post_ ID) {6734 public function mt_getTrackbackPings( $post_id ) { 6735 6735 global $wpdb; 6736 6736 6737 6737 /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ 6738 do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_ ID, $this );6739 6740 $actual_post = get_post( $post_ ID, ARRAY_A );6738 do_action( 'xmlrpc_call', 'mt.getTrackbackPings', $post_id, $this ); 6739 6740 $actual_post = get_post( $post_id, ARRAY_A ); 6741 6741 6742 6742 if ( ! $actual_post ) { … … 6744 6744 } 6745 6745 6746 $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) );6746 $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 ) ); 6747 6747 6748 6748 if ( ! $comments ) { … … 6783 6783 $this->escape( $args ); 6784 6784 6785 $post_ ID= (int) $args[0];6785 $post_id = (int) $args[0]; 6786 6786 $username = $args[1]; 6787 6787 $password = $args[2]; … … 6795 6795 do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this ); 6796 6796 6797 $postdata = get_post( $post_ ID, ARRAY_A );6797 $postdata = get_post( $post_id, ARRAY_A ); 6798 6798 if ( ! $postdata ) { 6799 6799 return new IXR_Error( 404, __( 'Invalid post ID.' ) ); 6800 6800 } 6801 6801 6802 if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_ ID) ) {6802 if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) { 6803 6803 return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) ); 6804 6804 } … … 6807 6807 6808 6808 // Retain old categories. 6809 $postdata['post_category'] = wp_get_post_categories( $post_ ID);6809 $postdata['post_category'] = wp_get_post_categories( $post_id ); 6810 6810 $this->escape( $postdata ); 6811 6811 … … 6871 6871 */ 6872 6872 $urltest = parse_url( $pagelinkedto ); 6873 $post_ ID= url_to_postid( $pagelinkedto );6874 if ( $post_ ID) {6873 $post_id = url_to_postid( $pagelinkedto ); 6874 if ( $post_id ) { 6875 6875 // $way 6876 6876 } elseif ( isset( $urltest['path'] ) && preg_match( '#p/[0-9]{1,}#', $urltest['path'], $match ) ) { 6877 6877 // The path defines the post_ID (archives/p/XXXX). 6878 6878 $blah = explode( '/', $match[0] ); 6879 $post_ ID= (int) $blah[1];6879 $post_id = (int) $blah[1]; 6880 6880 } elseif ( isset( $urltest['query'] ) && preg_match( '#p=[0-9]{1,}#', $urltest['query'], $match ) ) { 6881 6881 // The query string defines the post_ID (?p=XXXX). 6882 6882 $blah = explode( '=', $match[0] ); 6883 $post_ ID= (int) $blah[1];6883 $post_id = (int) $blah[1]; 6884 6884 } elseif ( isset( $urltest['fragment'] ) ) { 6885 6885 // An #anchor is there, it's either... 6886 6886 if ( (int) $urltest['fragment'] ) { 6887 6887 // ...an integer #XXXX (simplest case), 6888 $post_ ID= (int) $urltest['fragment'];6888 $post_id = (int) $urltest['fragment']; 6889 6889 } elseif ( preg_match( '/post-[0-9]+/', $urltest['fragment'] ) ) { 6890 6890 // ...a post ID in the form 'post-###', 6891 $post_ ID= preg_replace( '/[^0-9]+/', '', $urltest['fragment'] );6891 $post_id = preg_replace( '/[^0-9]+/', '', $urltest['fragment'] ); 6892 6892 } elseif ( is_string( $urltest['fragment'] ) ) { 6893 6893 // ...or a string #title, a little more complicated. 6894 6894 $title = preg_replace( '/[^a-z0-9]/i', '.', $urltest['fragment'] ); 6895 6895 $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title RLIKE %s", $title ); 6896 $post_ ID= $wpdb->get_var( $sql );6897 if ( ! $post_ ID) {6896 $post_id = $wpdb->get_var( $sql ); 6897 if ( ! $post_id ) { 6898 6898 // Returning unknown error '0' is better than die()'ing. 6899 6899 return $this->pingback_error( 0, '' ); … … 6904 6904 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); 6905 6905 } 6906 $post_ ID = (int) $post_ID;6907 6908 $post = get_post( $post_ ID);6906 $post_id = (int) $post_id; 6907 6908 $post = get_post( $post_id ); 6909 6909 6910 6910 if ( ! $post ) { // Post not found. … … 6912 6912 } 6913 6913 6914 if ( url_to_postid( $pagelinkedfrom ) == $post_ ID) {6914 if ( url_to_postid( $pagelinkedfrom ) == $post_id ) { 6915 6915 return $this->pingback_error( 0, __( 'The source URL and the target URL cannot both point to the same resource.' ) ); 6916 6916 } … … 6922 6922 6923 6923 // Let's check that the remote site didn't already pingback this entry. 6924 if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_ ID, $pagelinkedfrom ) ) ) {6924 if ( $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_author_url = %s", $post_id, $pagelinkedfrom ) ) ) { 6925 6925 return $this->pingback_error( 48, __( 'The pingback has already been registered.' ) ); 6926 6926 } … … 7021 7021 $pagelinkedfrom = $this->escape( $pagelinkedfrom ); 7022 7022 7023 $comment_post_id = (int) $post_ ID;7023 $comment_post_id = (int) $post_id; 7024 7024 $comment_author = $title; 7025 7025 $comment_author_email = ''; … … 7083 7083 $url = $this->escape( $url ); 7084 7084 7085 $post_ ID= url_to_postid( $url );7086 if ( ! $post_ ID) {7085 $post_id = url_to_postid( $url ); 7086 if ( ! $post_id ) { 7087 7087 // We aren't sure that the resource is available and/or pingback enabled. 7088 7088 return $this->pingback_error( 33, __( 'The specified target URL cannot be used as a target. It either does not exist, or it is not a pingback-enabled resource.' ) ); 7089 7089 } 7090 7090 7091 $actual_post = get_post( $post_ ID, ARRAY_A );7091 $actual_post = get_post( $post_id, ARRAY_A ); 7092 7092 7093 7093 if ( ! $actual_post ) { … … 7096 7096 } 7097 7097 7098 $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) );7098 $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 ) ); 7099 7099 7100 7100 if ( ! $comments ) {
Note:
See TracChangeset
for help on using the changeset viewer.