~canonical-sysadmins/wordpress/4.8.2

« back to all changes in this revision

Viewing changes to wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

  • Committer: Barry Price
  • Date: 2017-06-09 02:09:58 UTC
  • mfrom: (1.1.26 upstream)
  • Revision ID: barry.price@canonical.com-20170609020958-838whhwt2196f2vk
Merge WP4.8 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
                                'args'     => array(
77
77
                                        'context'          => $this->get_context_param( array( 'default' => 'view' ) ),
78
78
                                        'password' => array(
79
 
                                                'description' => __( 'The password for the post if it is password protected.' ),
 
79
                                                'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
80
80
                                                'type'        => 'string',
81
81
                                        ),
82
82
                                ),
98
98
                                                'description' => __( 'Whether to bypass trash and force deletion.' ),
99
99
                                        ),
100
100
                                        'password' => array(
101
 
                                                'description' => __( 'The password for the post if it is password protected.' ),
 
101
                                                'description' => __( 'The password for the parent post of the comment (if the post is password protected).' ),
102
102
                                                'type'        => 'string',
103
103
                                        ),
104
104
                                ),
576
576
                 * Filters a comment before it is inserted via the REST API.
577
577
                 *
578
578
                 * Allows modification of the comment right before it is inserted via wp_insert_comment().
 
579
                 * Returning a WP_Error value from the filter will shortcircuit insertion and allow
 
580
                 * skipping further processing.
579
581
                 *
580
582
                 * @since 4.7.0
 
583
                 * @since 4.8.0 $prepared_comment can now be a WP_Error to shortcircuit insertion.
581
584
                 *
582
 
                 * @param array           $prepared_comment The prepared comment data for wp_insert_comment().
 
585
                 * @param array|WP_Error  $prepared_comment The prepared comment data for wp_insert_comment().
583
586
                 * @param WP_REST_Request $request          Request used to insert the comment.
584
587
                 */
585
588
                $prepared_comment = apply_filters( 'rest_pre_insert_comment', $prepared_comment, $request );
 
589
                if ( is_wp_error( $prepared_comment ) ) {
 
590
                        return $prepared_comment;
 
591
                }
586
592
 
587
593
                $comment_id = wp_insert_comment( wp_filter_comment( wp_slash( (array) $prepared_comment ) ) );
588
594
 
731
737
 
732
738
                $comment = get_comment( $id );
733
739
 
734
 
                /* This action is documented in lib/endpoints/class-wp-rest-comments-controller.php */
 
740
                /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php */
735
741
                do_action( 'rest_insert_comment', $comment, $request, false );
736
742
 
737
743
                $schema = $this->get_item_schema();
1612
1618
         * string is allowed when a comment is being updated.
1613
1619
         *
1614
1620
         * @since 4.7.0
 
1621
         * @access public
1615
1622
         *
1616
1623
         * @param string          $value   Author email value submitted.
1617
1624
         * @param WP_REST_Request $request Full details about the request.