Changeset 20807 for trunk/wp-includes/class-wp-xmlrpc-server.php
- Timestamp:
- 05/16/2012 06:06:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-xmlrpc-server.php
r20785 r20807 755 755 756 756 /** 757 * Prepares page data for return in an XML-RPC object. 758 * 759 * @access protected 760 * 761 * @param object $page The unprepared page data 762 * @return array The prepared page data 763 */ 764 protected function _prepare_page( $page ) { 765 // Get all of the page content and link. 766 $full_page = get_extended( $page->post_content ); 767 $link = post_permalink( $page->ID ); 768 769 // Get info the page parent if there is one. 770 $parent_title = ""; 771 if ( ! empty( $page->post_parent ) ) { 772 $parent = get_page( $page->post_parent ); 773 $parent_title = $parent->post_title; 774 } 775 776 // Determine comment and ping settings. 777 $allow_comments = comments_open( $page->ID ) ? 1 : 0; 778 $allow_pings = pings_open( $page->ID ) ? 1 : 0; 779 780 // Format page date. 781 $page_date = $this->_convert_date( $page->post_date ); 782 $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date ); 783 784 // Pull the categories info together. 785 $categories = array(); 786 foreach ( wp_get_post_categories( $page->ID ) as $cat_id ) { 787 $categories[] = get_cat_name( $cat_id ); 788 } 789 790 // Get the author info. 791 $author = get_userdata( $page->post_author ); 792 793 $page_template = get_page_template_slug( $page->ID ); 794 if ( empty( $page_template ) ) 795 $page_template = 'default'; 796 797 $_page = array( 798 'dateCreated' => $page_date, 799 'userid' => $page->post_author, 800 'page_id' => $page->ID, 801 'page_status' => $page->post_status, 802 'description' => $full_page['main'], 803 'title' => $page->post_title, 804 'link' => $link, 805 'permaLink' => $link, 806 'categories' => $categories, 807 'excerpt' => $page->post_excerpt, 808 'text_more' => $full_page['extended'], 809 'mt_allow_comments' => $allow_comments, 810 'mt_allow_pings' => $allow_pings, 811 'wp_slug' => $page->post_name, 812 'wp_password' => $page->post_password, 813 'wp_author' => $author->display_name, 814 'wp_page_parent_id' => $page->post_parent, 815 'wp_page_parent_title' => $parent_title, 816 'wp_page_order' => $page->menu_order, 817 'wp_author_id' => (string) $author->ID, 818 'wp_author_display_name' => $author->display_name, 819 'date_created_gmt' => $page_date_gmt, 820 'custom_fields' => $this->get_custom_fields( $page->ID ), 821 'wp_page_template' => $page_template 822 ); 823 824 return apply_filters( 'xmlrpc_prepare_page', $_page, $page ); 825 } 826 827 /** 757 828 * Create a new post for any registered post type. 758 829 * … … 1834 1905 // If we found the page then format the data. 1835 1906 if ( $page->ID && ($page->post_type == 'page') ) { 1836 // Get all of the page content and link. 1837 $full_page = get_extended($page->post_content); 1838 $link = post_permalink($page->ID); 1839 1840 // Get info the page parent if there is one. 1841 $parent_title = ""; 1842 if ( !empty($page->post_parent) ) { 1843 $parent = get_page($page->post_parent); 1844 $parent_title = $parent->post_title; 1845 } 1846 1847 // Determine comment and ping settings. 1848 $allow_comments = comments_open($page->ID) ? 1 : 0; 1849 $allow_pings = pings_open($page->ID) ? 1 : 0; 1850 1851 // Format page date. 1852 $page_date = $this->_convert_date( $page->post_date ); 1853 $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date ); 1854 1855 // Pull the categories info together. 1856 $categories = array(); 1857 foreach ( wp_get_post_categories($page->ID) as $cat_id ) { 1858 $categories[] = get_cat_name($cat_id); 1859 } 1860 1861 // Get the author info. 1862 $author = get_userdata($page->post_author); 1863 1864 $page_template = get_page_template_slug( $page->ID ); 1865 if ( empty( $page_template ) ) 1866 $page_template = 'default'; 1867 1868 $page_struct = array( 1869 'dateCreated' => $page_date, 1870 'userid' => $page->post_author, 1871 'page_id' => $page->ID, 1872 'page_status' => $page->post_status, 1873 'description' => $full_page['main'], 1874 'title' => $page->post_title, 1875 'link' => $link, 1876 'permaLink' => $link, 1877 'categories' => $categories, 1878 'excerpt' => $page->post_excerpt, 1879 'text_more' => $full_page['extended'], 1880 'mt_allow_comments' => $allow_comments, 1881 'mt_allow_pings' => $allow_pings, 1882 'wp_slug' => $page->post_name, 1883 'wp_password' => $page->post_password, 1884 'wp_author' => $author->display_name, 1885 'wp_page_parent_id' => $page->post_parent, 1886 'wp_page_parent_title' => $parent_title, 1887 'wp_page_order' => $page->menu_order, 1888 'wp_author_id' => (string) $author->ID, 1889 'wp_author_display_name' => $author->display_name, 1890 'date_created_gmt' => $page_date_gmt, 1891 'custom_fields' => $this->get_custom_fields($page_id), 1892 'wp_page_template' => $page_template 1893 ); 1894 1895 return($page_struct); 1907 return $this->_prepare_page( $page ); 1896 1908 } 1897 1909 // If the page doesn't exist indicate that. … … 1936 1948 $pages_struct = array(); 1937 1949 1938 for ( $i = 0; $i < $num_pages; $i++ ) { 1939 $page = wp_xmlrpc_server::wp_getPage(array( 1940 $blog_id, $pages[$i]->ID, $username, $password 1941 )); 1942 $pages_struct[] = $page; 1950 foreach ($pages as $page) { 1951 if ( current_user_can( 'edit_page', $page->ID ) ) 1952 $pages_struct[] = $this->_prepare_page( $page ); 1943 1953 } 1944 1954
Note: See TracChangeset
for help on using the changeset viewer.