# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: C:\xampp\htdocs\wordtrunk\wp-includes
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
|
|
|
596 | 596 | |
597 | 597 | do_action( 'xmlrpc_call', 'wp.newPost' ); |
598 | 598 | |
599 | | unset( $content_struct['ID'] ); |
600 | | |
601 | | return $this->_wp_insertPost( $user, $content_struct ); |
602 | | } |
603 | | |
604 | | /* |
605 | | * Helper method for filtering out elements from an array. |
606 | | */ |
607 | | function _is_greater_than_one( $count ){ |
608 | | return $count > 1; |
609 | | } |
610 | | |
611 | | /* |
612 | | * Helper method for wp_newPost and wp_editPost, containing shared logic. |
613 | | */ |
614 | | function _wp_insertPost( $user, $content_struct ) { |
615 | | $defaults = array( 'post_status' => 'draft', 'post_type' => 'post', 'post_author' => 0, |
616 | | 'post_password' => '', 'post_excerpt' => '', 'post_content' => '', 'post_title' => '', 'sticky' => 0 ); |
617 | | |
618 | | $post_data = wp_parse_args( $content_struct, $defaults ); |
619 | | |
620 | | $post_type = get_post_type_object( $post_data['post_type'] ); |
| 599 | $post_type = get_post_type_object( $content_struct['post_type'] ); |
621 | 600 | if( ! ( (bool) $post_type ) ) |
622 | 601 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
623 | 602 | |
624 | 603 | if( ! current_user_can( $post_type->cap->edit_posts ) ) |
625 | 604 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
626 | 605 | |
627 | | switch ( $post_data['post_status'] ) { |
| 606 | switch ( $content_struct['post_status'] ) { |
628 | 607 | case 'draft': |
629 | 608 | case 'pending': |
630 | 609 | break; |
… |
… |
|
638 | 617 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts in this post type' )); |
639 | 618 | break; |
640 | 619 | default: |
641 | | $post_data['post_status'] = 'draft'; |
| 620 | $content_struct['post_status'] = 'draft'; |
642 | 621 | break; |
643 | 622 | } |
644 | 623 | |
645 | | if ( ! empty( $post_data['post_password'] ) && ! current_user_can( $post_type->cap->publish_posts ) ) |
| 624 | if ( ! empty( $content_struct['post_password'] ) && ! current_user_can( $post_type->cap->publish_posts ) ) |
646 | 625 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create password protected posts in this post type' ) ); |
647 | 626 | |
| 627 | unset( $content_struct['ID'] ); |
648 | 628 | |
| 629 | return $this->_wp_insertPost( $user, $content_struct ); |
| 630 | } |
| 631 | |
| 632 | /* |
| 633 | * Helper method for filtering out elements from an array. |
| 634 | */ |
| 635 | function _is_greater_than_one( $count ){ |
| 636 | return $count > 1; |
| 637 | } |
| 638 | |
| 639 | /* |
| 640 | * Helper method for wp_newPost and wp_editPost, containing shared logic. |
| 641 | */ |
| 642 | function _wp_insertPost( $user, $content_struct ) { |
| 643 | $defaults = array( 'post_status' => 'draft', 'post_type' => 'post', 'post_author' => 0, |
| 644 | 'post_password' => '', 'post_excerpt' => '', 'post_content' => '', 'post_title' => '', 'sticky' => 0 ); |
| 645 | |
| 646 | $post_data = wp_parse_args( $content_struct, $defaults ); |
| 647 | |
649 | 648 | $post_data['post_author'] = absint( $post_data['post_author'] ); |
650 | 649 | if( ! empty( $post_data['post_author'] ) && $post_data['post_author'] != $user->ID ) { |
651 | 650 | if( ! current_user_can( $post_type->cap->edit_others_posts ) ) |
… |
… |
|
852 | 851 | |
853 | 852 | do_action( 'xmlrpc_call', 'wp.editPost' ); |
854 | 853 | |
855 | | // User Capabilities are checked in _wp_insertPost. |
856 | | |
857 | 854 | $post = get_post( $post_id, ARRAY_A ); |
858 | | |
859 | 855 | if ( empty( $post["ID"] ) ) |
860 | 856 | return new IXR_Error( 404, __( 'Invalid post ID.' ) ); |
861 | 857 | |
… |
… |
|
872 | 868 | $this->escape( $post ); |
873 | 869 | $merged_content_struct = array_merge( $post, $content_struct ); |
874 | 870 | |
| 871 | $post_type = get_post_type_object( $merged_content_struct['post_type'] ); |
| 872 | if( ! ( (bool) $post_type ) ) |
| 873 | return new IXR_Error( 403, __( 'Invalid post type' ) ); |
| 874 | |
| 875 | if( ! current_user_can( $post_type->cap->edit_post, $post_id ) ) |
| 876 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to post on this site.' ) ); |
| 877 | |
| 878 | switch ( $merged_content_struct['post_status'] ) { |
| 879 | case 'draft': |
| 880 | case 'pending': |
| 881 | break; |
| 882 | case 'private': |
| 883 | if( ! current_user_can( $post_type->cap->publish_post, $post_id ) ) |
| 884 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create private posts in this post type' )); |
| 885 | break; |
| 886 | case 'publish': |
| 887 | case 'future': |
| 888 | if( ! current_user_can( $post_type->cap->publish_post, $post_id ) ) |
| 889 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts in this post type' )); |
| 890 | break; |
| 891 | default: |
| 892 | $post_data['post_status'] = 'draft'; |
| 893 | break; |
| 894 | } |
| 895 | |
| 896 | if ( ! empty( $merged_content_struct['post_password'] ) && ! current_user_can( $post_type->cap->publish_post, $post_id ) ) |
| 897 | return new IXR_Error( 401, __( 'Sorry, you are not allowed to create password protected posts in this post type' ) ); |
| 898 | |
875 | 899 | $retval = $this->_wp_insertPost( $user, $merged_content_struct ); |
876 | 900 | if ( $retval instanceof IXR_Error ) |
877 | 901 | return $retval; |