Make WordPress Core


Ignore:
Timestamp:
05/23/2015 07:46:45 PM (9 years ago)
Author:
DrewAPicture
Message:

Add missing or incomplete argument and return descriptions for wp_xmlrpc_server->wp_editPost().

Also includes many small syntax fixes for inline documentation throughout the file.

See #32246.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-xmlrpc-server.php

    r32564 r32565  
    734734     * @access protected
    735735     *
    736      * @param array $post The unprepared post data
    737      * @param array $fields The subset of post type fields to return
    738      * @return array The prepared post data
     736     * @param array $post   The unprepared post data.
     737     * @param array $fields The subset of post type fields to return.
     738     * @return array The prepared post data.
    739739     */
    740740    protected function _prepare_post( $post, $fields ) {
    741         // holds the data for this post. built up based on $fields
     741        // Holds the data for this post. built up based on $fields.
    742742        $_post = array( 'post_id' => strval( $post['ID'] ) );
    743743
    744         // prepare common post fields
     744        // Prepare common post fields.
    745745        $post_fields = array(
    746746            'post_title'        => $post['post_title'],
     
    766766        );
    767767
    768         // Thumbnail
     768        // Thumbnail.
    769769        $post_fields['post_thumbnail'] = array();
    770770        $thumbnail_id = get_post_thumbnail_id( $post['ID'] );
     
    774774        }
    775775
    776         // Consider future posts as published
     776        // Consider future posts as published.
    777777        if ( $post_fields['post_status'] === 'future' )
    778778            $post_fields['post_status'] = 'publish';
    779779
    780         // Fill in blank post format
     780        // Fill in blank post format.
    781781        $post_fields['post_format'] = get_post_format( $post['ID'] );
    782782        if ( empty( $post_fields['post_format'] ) )
    783783            $post_fields['post_format'] = 'standard';
    784784
    785         // Merge requested $post_fields fields into $_post
     785        // Merge requested $post_fields fields into $_post.
    786786        if ( in_array( 'post', $fields ) ) {
    787787            $_post = array_merge( $_post, $post_fields );
     
    833833     * @access protected
    834834     *
    835      * @param object $post_type Post type object
    836      * @param array $fields The subset of post fields to return
    837      * @return array The prepared post type data
     835     * @param object $post_type Post type object.
     836     * @param array  $fields    The subset of post fields to return.
     837     * @return array The prepared post type data.
    838838     */
    839839    protected function _prepare_post_type( $post_type, $fields ) {
     
    883883     * @access protected
    884884     *
    885      * @param object $media_item The unprepared media item data
    886      * @param string $thumbnail_size The image size to use for the thumbnail URL
    887      * @return array The prepared media item data
     885     * @param object $media_item     The unprepared media item data.
     886     * @param string $thumbnail_size The image size to use for the thumbnail URL.
     887     * @return array The prepared media item data.
    888888     */
    889889    protected function _prepare_media_item( $media_item, $thumbnail_size = 'thumbnail' ) {
     
    922922     * @access protected
    923923     *
    924      * @param object $page The unprepared page data
    925      * @return array The prepared page data
     924     * @param object $page The unprepared page data.
     925     * @return array The prepared page data.
    926926     */
    927927    protected function _prepare_page( $page ) {
     
    10031003     * @access protected
    10041004     *
    1005      * @param object $comment The unprepared comment data
    1006      * @return array The prepared comment data
     1005     * @param object $comment The unprepared comment data.
     1006     * @return array The prepared comment data.
    10071007     */
    10081008    protected function _prepare_comment( $comment ) {
     
    10521052     * @access protected
    10531053     *
    1054      * @param WP_User $user The unprepared user object
    1055      * @param array $fields The subset of user fields to return
    1056      * @return array The prepared user data
     1054     * @param WP_User $user   The unprepared user object.
     1055     * @param array   $fields The subset of user fields to return.
     1056     * @return array The prepared user data.
    10571057     */
    10581058    protected function _prepare_user( $user, $fields ) {
     
    11771177
    11781178    /**
    1179      * Helper method for wp_newPost and wp_editPost, containing shared logic.
     1179     * Helper method for wp_newPost() and wp_editPost(), containing shared logic.
    11801180     *
    11811181     * @since 3.4.0
    1182      * @uses wp_insert_post()
    1183      *
    1184      * @param WP_User $user The post author if post_author isn't set in $content_struct.
     1182     * @access protected
     1183     *
     1184     * @see wp_insert_post()
     1185     *
     1186     * @param WP_User         $user           The post author if post_author isn't set in $content_struct.
    11851187     * @param array|IXR_Error $content_struct Post data to insert.
    11861188     * @return IXR_Error|string
     
    12511253            unset( $post_data['ping_status'] );
    12521254
    1253         // Do some timestamp voodoo
     1255        // Do some timestamp voodoo.
    12541256        if ( ! empty( $post_data['post_date_gmt'] ) ) {
    1255             // We know this is supposed to be GMT, so we're going to slap that Z on there by force
     1257            // We know this is supposed to be GMT, so we're going to slap that Z on there by force.
    12561258            $dateCreated = rtrim( $post_data['post_date_gmt']->getIso(), 'Z' ) . 'Z';
    12571259        } elseif ( ! empty( $post_data['post_date'] ) ) {
     
    12871289
    12881290        if ( isset( $post_data['post_thumbnail'] ) ) {
    1289             // empty value deletes, non-empty value adds/updates
     1291            // empty value deletes, non-empty value adds/updates.
    12901292            if ( ! $post_data['post_thumbnail'] )
    12911293                delete_post_thumbnail( $post_ID );
     
    13021304            $post_type_taxonomies = get_object_taxonomies( $post_data['post_type'], 'objects' );
    13031305
    1304             // accumulate term IDs from terms and terms_names
     1306            // Accumulate term IDs from terms and terms_names.
    13051307            $terms = array();
    13061308
    1307             // first validate the terms specified by ID
     1309            // First validate the terms specified by ID.
    13081310            if ( isset( $post_data['terms'] ) && is_array( $post_data['terms'] ) ) {
    13091311                $taxonomies = array_keys( $post_data['terms'] );
    13101312
    1311                 // validating term ids
     1313                // Validating term ids.
    13121314                foreach ( $taxonomies as $taxonomy ) {
    13131315                    if ( ! array_key_exists( $taxonomy , $post_type_taxonomies ) )
     
    13301332            }
    13311333
    1332             // now validate terms specified by name
     1334            // Now validate terms specified by name.
    13331335            if ( isset( $post_data['terms_names'] ) && is_array( $post_data['terms_names'] ) ) {
    13341336                $taxonomies = array_keys( $post_data['terms_names'] );
     
    13411343                        return new IXR_Error( 401, __( 'Sorry, you are not allowed to assign a term to one of the given taxonomies.' ) );
    13421344
    1343                     // for hierarchical taxonomies, we can't assign a term when multiple terms in the hierarchy share the same name
     1345                    /*
     1346                     * For hierarchical taxonomies, we can't assign a term when multiple terms
     1347                     * in the hierarchy share the same name.
     1348                     */
    13441349                    $ambiguous_terms = array();
    13451350                    if ( is_taxonomy_hierarchical( $taxonomy ) ) {
    13461351                        $tax_term_names = get_terms( $taxonomy, array( 'fields' => 'names', 'hide_empty' => false ) );
    13471352
    1348                         // count the number of terms with the same name
     1353                        // Count the number of terms with the same name.
    13491354                        $tax_term_names_count = array_count_values( $tax_term_names );
    13501355
    1351                         // filter out non-ambiguous term names
     1356                        // Filter out non-ambiguous term names.
    13521357                        $ambiguous_tax_term_counts = array_filter( $tax_term_names_count, array( $this, '_is_greater_than_one') );
    13531358
     
    13631368
    13641369                        if ( ! $term ) {
    1365                             // term doesn't exist, so check that the user is allowed to create new terms
     1370                            // Term doesn't exist, so check that the user is allowed to create new terms.
    13661371                            if ( ! current_user_can( $post_type_taxonomies[$taxonomy]->cap->edit_terms ) )
    13671372                                return new IXR_Error( 401, __( 'Sorry, you are not allowed to add a term to one of the given taxonomies.' ) );
    13681373
    1369                             // create the new term
     1374                            // Create the new term.
    13701375                            $term_info = wp_insert_term( $term_name, $taxonomy );
    13711376                            if ( is_wp_error( $term_info ) )
     
    13831388            unset( $post_data['terms'], $post_data['terms_names'] );
    13841389        } else {
    1385             // do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names'
     1390            // Do not allow direct submission of 'tax_input', clients must use 'terms' and/or 'terms_names'.
    13861391            unset( $post_data['tax_input'], $post_data['post_category'], $post_data['tags_input'] );
    13871392        }
     
    13961401        }
    13971402
    1398         // Handle enclosures
     1403        // Handle enclosures.
    13991404        $enclosure = isset( $post_data['enclosure'] ) ? $post_data['enclosure'] : null;
    14001405        $this->add_enclosure_if_new( $post_ID, $enclosure );
     
    14331438     *     Method parameters, in this order:
    14341439     *
    1435      *     @type int    $blog_id (unused)
    1436      *     @type string $username
    1437      *     @type string $password
    1438      *     @type int    $post_id
    1439      *     @type array  $content_struct
     1440     *     @type int    $blog_id        Blog ID (unused).
     1441     *     @type string $username       Username.
     1442     *     @type string $password       Password.
     1443     *     @type int    $post_id        Post ID.
     1444     *     @type array  $content_struct Extra content arguments.
    14401445     * }
    1441      * @return true|IXR_Error true on success
     1446     * @return true|IXR_Error True on success, IXR_Error on failure.
    14421447     */
    14431448    public function wp_editPost( $args ) {
Note: See TracChangeset for help on using the changeset viewer.