| | 756 | * Prepares page data for return in an XML-RPC object. |
| | 757 | * |
| | 758 | * @access protected |
| | 759 | * |
| | 760 | * @param object $page The unprepared page data |
| | 761 | * @return array The prepared page data |
| | 762 | */ |
| | 763 | protected function _prepare_page( $page ) { |
| | 764 | // Get all of the page content and link. |
| | 765 | $full_page = get_extended( $page->post_content ); |
| | 766 | $link = post_permalink( $page->ID ); |
| | 767 | |
| | 768 | // Get info the page parent if there is one. |
| | 769 | $parent_title = ""; |
| | 770 | if ( ! empty( $page->post_parent ) ) { |
| | 771 | $parent = get_page( $page->post_parent ); |
| | 772 | $parent_title = $parent->post_title; |
| | 773 | } |
| | 774 | |
| | 775 | // Determine comment and ping settings. |
| | 776 | $allow_comments = comments_open( $page->ID ) ? 1 : 0; |
| | 777 | $allow_pings = pings_open( $page->ID ) ? 1 : 0; |
| | 778 | |
| | 779 | // Format page date. |
| | 780 | $page_date = $this->_convert_date( $page->post_date ); |
| | 781 | $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date ); |
| | 782 | |
| | 783 | // Pull the categories info together. |
| | 784 | $categories = array(); |
| | 785 | foreach ( wp_get_post_categories( $page->ID ) as $cat_id ) { |
| | 786 | $categories[] = get_cat_name( $cat_id ); |
| | 787 | } |
| | 788 | |
| | 789 | // Get the author info. |
| | 790 | $author = get_userdata( $page->post_author ); |
| | 791 | |
| | 792 | $page_template = get_page_template_slug( $page->ID ); |
| | 793 | if ( empty( $page_template ) ) |
| | 794 | $page_template = 'default'; |
| | 795 | |
| | 796 | $_page = array( |
| | 797 | 'dateCreated' => $page_date, |
| | 798 | 'userid' => $page->post_author, |
| | 799 | 'page_id' => $page->ID, |
| | 800 | 'page_status' => $page->post_status, |
| | 801 | 'description' => $full_page['main'], |
| | 802 | 'title' => $page->post_title, |
| | 803 | 'link' => $link, |
| | 804 | 'permaLink' => $link, |
| | 805 | 'categories' => $categories, |
| | 806 | 'excerpt' => $page->post_excerpt, |
| | 807 | 'text_more' => $full_page['extended'], |
| | 808 | 'mt_allow_comments' => $allow_comments, |
| | 809 | 'mt_allow_pings' => $allow_pings, |
| | 810 | 'wp_slug' => $page->post_name, |
| | 811 | 'wp_password' => $page->post_password, |
| | 812 | 'wp_author' => $author->display_name, |
| | 813 | 'wp_page_parent_id' => $page->post_parent, |
| | 814 | 'wp_page_parent_title' => $parent_title, |
| | 815 | 'wp_page_order' => $page->menu_order, |
| | 816 | 'wp_author_id' => (string) $author->ID, |
| | 817 | 'wp_author_display_name' => $author->display_name, |
| | 818 | 'date_created_gmt' => $page_date_gmt, |
| | 819 | 'custom_fields' => $this->get_custom_fields( $page->ID ), |
| | 820 | 'wp_page_template' => $page_template |
| | 821 | ); |
| | 822 | |
| | 823 | return apply_filters( 'xmlrpc_prepare_page', $_page, $page ); |
| | 824 | } |
| | 825 | |
| | 826 | /** |
| 1831 | | // Get all of the page content and link. |
| 1832 | | $full_page = get_extended($page->post_content); |
| 1833 | | $link = post_permalink($page->ID); |
| 1834 | | |
| 1835 | | // Get info the page parent if there is one. |
| 1836 | | $parent_title = ""; |
| 1837 | | if ( !empty($page->post_parent) ) { |
| 1838 | | $parent = get_page($page->post_parent); |
| 1839 | | $parent_title = $parent->post_title; |
| 1840 | | } |
| 1841 | | |
| 1842 | | // Determine comment and ping settings. |
| 1843 | | $allow_comments = comments_open($page->ID) ? 1 : 0; |
| 1844 | | $allow_pings = pings_open($page->ID) ? 1 : 0; |
| 1845 | | |
| 1846 | | // Format page date. |
| 1847 | | $page_date = $this->_convert_date( $page->post_date ); |
| 1848 | | $page_date_gmt = $this->_convert_date_gmt( $page->post_date_gmt, $page->post_date ); |
| 1849 | | |
| 1850 | | // Pull the categories info together. |
| 1851 | | $categories = array(); |
| 1852 | | foreach ( wp_get_post_categories($page->ID) as $cat_id ) { |
| 1853 | | $categories[] = get_cat_name($cat_id); |
| 1854 | | } |
| 1855 | | |
| 1856 | | // Get the author info. |
| 1857 | | $author = get_userdata($page->post_author); |
| 1858 | | |
| 1859 | | $page_template = get_page_template_slug( $page->ID ); |
| 1860 | | if ( empty( $page_template ) ) |
| 1861 | | $page_template = 'default'; |
| 1862 | | |
| 1863 | | $page_struct = array( |
| 1864 | | 'dateCreated' => $page_date, |
| 1865 | | 'userid' => $page->post_author, |
| 1866 | | 'page_id' => $page->ID, |
| 1867 | | 'page_status' => $page->post_status, |
| 1868 | | 'description' => $full_page['main'], |
| 1869 | | 'title' => $page->post_title, |
| 1870 | | 'link' => $link, |
| 1871 | | 'permaLink' => $link, |
| 1872 | | 'categories' => $categories, |
| 1873 | | 'excerpt' => $page->post_excerpt, |
| 1874 | | 'text_more' => $full_page['extended'], |
| 1875 | | 'mt_allow_comments' => $allow_comments, |
| 1876 | | 'mt_allow_pings' => $allow_pings, |
| 1877 | | 'wp_slug' => $page->post_name, |
| 1878 | | 'wp_password' => $page->post_password, |
| 1879 | | 'wp_author' => $author->display_name, |
| 1880 | | 'wp_page_parent_id' => $page->post_parent, |
| 1881 | | 'wp_page_parent_title' => $parent_title, |
| 1882 | | 'wp_page_order' => $page->menu_order, |
| 1883 | | 'wp_author_id' => (string) $author->ID, |
| 1884 | | 'wp_author_display_name' => $author->display_name, |
| 1885 | | 'date_created_gmt' => $page_date_gmt, |
| 1886 | | 'custom_fields' => $this->get_custom_fields($page_id), |
| 1887 | | 'wp_page_template' => $page_template |
| 1888 | | ); |
| 1889 | | |
| 1890 | | return($page_struct); |
| | 1902 | return $this->_prepare_page( $page ); |