Ticket #49905: 49905.diff
File 49905.diff, 3.8 KB (added by , 5 years ago) |
---|
-
src/wp-includes/functions.php
722 722 } 723 723 724 724 /** 725 * Retrieve post title from XMLRPC XML.725 * Retrieves post title from XML-RPC XML. 726 726 * 727 * If the title element is not part of the XML, then the default post title from728 * the $post_default_titlewill be used instead.727 * If the title element is not found, the default post title 728 * from the $post_default_title global will be used instead. 729 729 * 730 730 * @since 0.71 731 731 * 732 732 * @global string $post_default_title Default XML-RPC post title. 733 733 * 734 * @param string $content XML RPC XML Request content735 * @return string Post title 734 * @param string $content XML-RPC XML request content. 735 * @return string Post title. 736 736 */ 737 737 function xmlrpc_getposttitle( $content ) { 738 738 global $post_default_title; 739 740 if ( ! isset( $post_default_title ) ) { 741 $post_default_title = ''; 742 } 743 739 744 if ( preg_match( '/<title>(.+?)<\/title>/is', $content, $matchtitle ) ) { 740 745 $post_title = $matchtitle[1]; 741 746 } else { 742 747 $post_title = $post_default_title; 743 748 } 749 744 750 return $post_title; 745 751 } 746 752 747 753 /** 748 * Retrieve the post category or categories from XMLRPC XML.754 * Retrieves the post category or categories from XML-RPC XML. 749 755 * 750 * If the category element is not found, then the default post category will be 751 * used. The return type then would be what $post_default_category. If the 752 * category is found, then it will always be an array. 756 * If the category element is not found, the default post category 757 * from the $post_default_category global will be used instead. 753 758 * 754 759 * @since 0.71 755 760 * 756 * @global string $post_default_category Default XML-RPC post category.761 * @global int $post_default_category Default XML-RPC post category ID. 757 762 * 758 * @param string $content XML RPC XML Request content759 * @return string|array List of categories or category name.763 * @param string $content XML-RPC XML request content. 764 * @return int[] Array of category IDs. 760 765 */ 761 766 function xmlrpc_getpostcategory( $content ) { 762 767 global $post_default_category; 768 769 if ( ! isset( $post_default_category ) ) { 770 $post_default_category = (int) get_option( 'default_category' ); 771 } 772 763 773 if ( preg_match( '/<category>(.+?)<\/category>/is', $content, $matchcat ) ) { 764 774 $post_category = trim( $matchcat[1], ',' ); 765 $post_category = explode( ',', $post_category);775 $post_category = array_map( 'intval', explode( ',', $post_category ) ); 766 776 } else { 767 $post_category = $post_default_category;777 $post_category = array( $post_default_category ); 768 778 } 779 769 780 return $post_category; 770 781 } 771 782 772 783 /** 773 * XML RPC XML content without title and category elements.784 * XML-RPC XML content without title and category elements. 774 785 * 775 786 * @since 0.71 776 787 * 777 * @param string $content XML-RPC XML Request content.778 * @return string XML RPC XML Request content without title and category elements.788 * @param string $content XML-RPC XML request content. 789 * @return string XML-RPC XML request content without title and category elements. 779 790 */ 780 791 function xmlrpc_removepostdata( $content ) { 781 792 $content = preg_replace( '/<title>(.+?)<\/title>/si', '', $content ); 782 793 $content = preg_replace( '/<category>(.+?)<\/category>/si', '', $content ); 783 794 $content = trim( $content ); 795 784 796 return $content; 785 797 } 786 798 -
src/xmlrpc.php
65 65 require_once ABSPATH . WPINC . '/class-wp-xmlrpc-server.php'; 66 66 67 67 /** 68 * Posts submitted via the XML-RPC interface get that title69 *70 * @name post_default_title71 * @var string72 */73 $post_default_title = '';74 75 /**76 68 * Filters the class used for handling XML-RPC requests. 77 69 * 78 70 * @since 3.1.0