Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu...
File: class-wp-xmlrpc-server.php
if ( ! current_user_can( 'delete_term', $category_id ) ) {
[3500] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you are not allowed to delete this category.' ) );
[3501] Fix | Delete
}
[3502] Fix | Delete
[3503] Fix | Delete
$status = wp_delete_term( $category_id, 'category' );
[3504] Fix | Delete
[3505] Fix | Delete
if ( true == $status ) {
[3506] Fix | Delete
/**
[3507] Fix | Delete
* Fires after a category has been successfully deleted via XML-RPC.
[3508] Fix | Delete
*
[3509] Fix | Delete
* @since 3.4.0
[3510] Fix | Delete
*
[3511] Fix | Delete
* @param int $category_id ID of the deleted category.
[3512] Fix | Delete
* @param array $args An array of arguments to delete the category.
[3513] Fix | Delete
*/
[3514] Fix | Delete
do_action( 'xmlrpc_call_success_wp_deleteCategory', $category_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[3515] Fix | Delete
}
[3516] Fix | Delete
[3517] Fix | Delete
return $status;
[3518] Fix | Delete
}
[3519] Fix | Delete
[3520] Fix | Delete
/**
[3521] Fix | Delete
* Retrieves category list.
[3522] Fix | Delete
*
[3523] Fix | Delete
* @since 2.2.0
[3524] Fix | Delete
*
[3525] Fix | Delete
* @param array $args {
[3526] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3527] Fix | Delete
*
[3528] Fix | Delete
* @type int $0 Blog ID (unused).
[3529] Fix | Delete
* @type string $1 Username.
[3530] Fix | Delete
* @type string $2 Password.
[3531] Fix | Delete
* @type array $3 Category
[3532] Fix | Delete
* @type int $4 Max number of results.
[3533] Fix | Delete
* }
[3534] Fix | Delete
* @return array|IXR_Error
[3535] Fix | Delete
*/
[3536] Fix | Delete
public function wp_suggestCategories( $args ) {
[3537] Fix | Delete
$this->escape( $args );
[3538] Fix | Delete
[3539] Fix | Delete
$username = $args[1];
[3540] Fix | Delete
$password = $args[2];
[3541] Fix | Delete
$category = $args[3];
[3542] Fix | Delete
$max_results = (int) $args[4];
[3543] Fix | Delete
[3544] Fix | Delete
$user = $this->login( $username, $password );
[3545] Fix | Delete
if ( ! $user ) {
[3546] Fix | Delete
return $this->error;
[3547] Fix | Delete
}
[3548] Fix | Delete
[3549] Fix | Delete
if ( ! current_user_can( 'edit_posts' ) ) {
[3550] Fix | Delete
return new IXR_Error( 401, __( 'Sorry, you must be able to edit posts on this site in order to view categories.' ) );
[3551] Fix | Delete
}
[3552] Fix | Delete
[3553] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3554] Fix | Delete
do_action( 'xmlrpc_call', 'wp.suggestCategories', $args, $this );
[3555] Fix | Delete
[3556] Fix | Delete
$category_suggestions = array();
[3557] Fix | Delete
$args = array(
[3558] Fix | Delete
'get' => 'all',
[3559] Fix | Delete
'number' => $max_results,
[3560] Fix | Delete
'name__like' => $category,
[3561] Fix | Delete
);
[3562] Fix | Delete
foreach ( (array) get_categories( $args ) as $cat ) {
[3563] Fix | Delete
$category_suggestions[] = array(
[3564] Fix | Delete
'category_id' => $cat->term_id,
[3565] Fix | Delete
'category_name' => $cat->name,
[3566] Fix | Delete
);
[3567] Fix | Delete
}
[3568] Fix | Delete
[3569] Fix | Delete
return $category_suggestions;
[3570] Fix | Delete
}
[3571] Fix | Delete
[3572] Fix | Delete
/**
[3573] Fix | Delete
* Retrieves a comment.
[3574] Fix | Delete
*
[3575] Fix | Delete
* @since 2.7.0
[3576] Fix | Delete
*
[3577] Fix | Delete
* @param array $args {
[3578] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3579] Fix | Delete
*
[3580] Fix | Delete
* @type int $0 Blog ID (unused).
[3581] Fix | Delete
* @type string $1 Username.
[3582] Fix | Delete
* @type string $2 Password.
[3583] Fix | Delete
* @type int $3 Comment ID.
[3584] Fix | Delete
* }
[3585] Fix | Delete
* @return array|IXR_Error
[3586] Fix | Delete
*/
[3587] Fix | Delete
public function wp_getComment( $args ) {
[3588] Fix | Delete
$this->escape( $args );
[3589] Fix | Delete
[3590] Fix | Delete
$username = $args[1];
[3591] Fix | Delete
$password = $args[2];
[3592] Fix | Delete
$comment_id = (int) $args[3];
[3593] Fix | Delete
[3594] Fix | Delete
$user = $this->login( $username, $password );
[3595] Fix | Delete
if ( ! $user ) {
[3596] Fix | Delete
return $this->error;
[3597] Fix | Delete
}
[3598] Fix | Delete
[3599] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3600] Fix | Delete
do_action( 'xmlrpc_call', 'wp.getComment', $args, $this );
[3601] Fix | Delete
[3602] Fix | Delete
$comment = get_comment( $comment_id );
[3603] Fix | Delete
if ( ! $comment ) {
[3604] Fix | Delete
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
[3605] Fix | Delete
}
[3606] Fix | Delete
[3607] Fix | Delete
if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
[3608] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
[3609] Fix | Delete
}
[3610] Fix | Delete
[3611] Fix | Delete
return $this->_prepare_comment( $comment );
[3612] Fix | Delete
}
[3613] Fix | Delete
[3614] Fix | Delete
/**
[3615] Fix | Delete
* Retrieves comments.
[3616] Fix | Delete
*
[3617] Fix | Delete
* Besides the common blog_id (unused), username, and password arguments,
[3618] Fix | Delete
* it takes a filter array as the last argument.
[3619] Fix | Delete
*
[3620] Fix | Delete
* Accepted 'filter' keys are 'status', 'post_id', 'offset', and 'number'.
[3621] Fix | Delete
*
[3622] Fix | Delete
* The defaults are as follows:
[3623] Fix | Delete
* - 'status' - Default is ''. Filter by status (e.g., 'approve', 'hold')
[3624] Fix | Delete
* - 'post_id' - Default is ''. The post where the comment is posted.
[3625] Fix | Delete
* Empty string shows all comments.
[3626] Fix | Delete
* - 'number' - Default is 10. Total number of media items to retrieve.
[3627] Fix | Delete
* - 'offset' - Default is 0. See WP_Query::query() for more.
[3628] Fix | Delete
*
[3629] Fix | Delete
* @since 2.7.0
[3630] Fix | Delete
*
[3631] Fix | Delete
* @param array $args {
[3632] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3633] Fix | Delete
*
[3634] Fix | Delete
* @type int $0 Blog ID (unused).
[3635] Fix | Delete
* @type string $1 Username.
[3636] Fix | Delete
* @type string $2 Password.
[3637] Fix | Delete
* @type array $3 Optional. Query arguments.
[3638] Fix | Delete
* }
[3639] Fix | Delete
* @return array|IXR_Error Array containing a collection of comments.
[3640] Fix | Delete
* See wp_xmlrpc_server::wp_getComment() for a description
[3641] Fix | Delete
* of each item contents.
[3642] Fix | Delete
*/
[3643] Fix | Delete
public function wp_getComments( $args ) {
[3644] Fix | Delete
$this->escape( $args );
[3645] Fix | Delete
[3646] Fix | Delete
$username = $args[1];
[3647] Fix | Delete
$password = $args[2];
[3648] Fix | Delete
$struct = isset( $args[3] ) ? $args[3] : array();
[3649] Fix | Delete
[3650] Fix | Delete
$user = $this->login( $username, $password );
[3651] Fix | Delete
if ( ! $user ) {
[3652] Fix | Delete
return $this->error;
[3653] Fix | Delete
}
[3654] Fix | Delete
[3655] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3656] Fix | Delete
do_action( 'xmlrpc_call', 'wp.getComments', $args, $this );
[3657] Fix | Delete
[3658] Fix | Delete
if ( isset( $struct['status'] ) ) {
[3659] Fix | Delete
$status = $struct['status'];
[3660] Fix | Delete
} else {
[3661] Fix | Delete
$status = '';
[3662] Fix | Delete
}
[3663] Fix | Delete
[3664] Fix | Delete
if ( ! current_user_can( 'moderate_comments' ) && 'approve' !== $status ) {
[3665] Fix | Delete
return new IXR_Error( 401, __( 'Invalid comment status.' ) );
[3666] Fix | Delete
}
[3667] Fix | Delete
[3668] Fix | Delete
$post_id = '';
[3669] Fix | Delete
if ( isset( $struct['post_id'] ) ) {
[3670] Fix | Delete
$post_id = absint( $struct['post_id'] );
[3671] Fix | Delete
}
[3672] Fix | Delete
[3673] Fix | Delete
$post_type = '';
[3674] Fix | Delete
if ( isset( $struct['post_type'] ) ) {
[3675] Fix | Delete
$post_type_object = get_post_type_object( $struct['post_type'] );
[3676] Fix | Delete
if ( ! $post_type_object || ! post_type_supports( $post_type_object->name, 'comments' ) ) {
[3677] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post type.' ) );
[3678] Fix | Delete
}
[3679] Fix | Delete
$post_type = $struct['post_type'];
[3680] Fix | Delete
}
[3681] Fix | Delete
[3682] Fix | Delete
$offset = 0;
[3683] Fix | Delete
if ( isset( $struct['offset'] ) ) {
[3684] Fix | Delete
$offset = absint( $struct['offset'] );
[3685] Fix | Delete
}
[3686] Fix | Delete
[3687] Fix | Delete
$number = 10;
[3688] Fix | Delete
if ( isset( $struct['number'] ) ) {
[3689] Fix | Delete
$number = absint( $struct['number'] );
[3690] Fix | Delete
}
[3691] Fix | Delete
[3692] Fix | Delete
$comments = get_comments(
[3693] Fix | Delete
array(
[3694] Fix | Delete
'status' => $status,
[3695] Fix | Delete
'post_id' => $post_id,
[3696] Fix | Delete
'offset' => $offset,
[3697] Fix | Delete
'number' => $number,
[3698] Fix | Delete
'post_type' => $post_type,
[3699] Fix | Delete
)
[3700] Fix | Delete
);
[3701] Fix | Delete
[3702] Fix | Delete
$comments_struct = array();
[3703] Fix | Delete
if ( is_array( $comments ) ) {
[3704] Fix | Delete
foreach ( $comments as $comment ) {
[3705] Fix | Delete
$comments_struct[] = $this->_prepare_comment( $comment );
[3706] Fix | Delete
}
[3707] Fix | Delete
}
[3708] Fix | Delete
[3709] Fix | Delete
return $comments_struct;
[3710] Fix | Delete
}
[3711] Fix | Delete
[3712] Fix | Delete
/**
[3713] Fix | Delete
* Deletes a comment.
[3714] Fix | Delete
*
[3715] Fix | Delete
* By default, the comment will be moved to the Trash instead of deleted.
[3716] Fix | Delete
* See wp_delete_comment() for more information on this behavior.
[3717] Fix | Delete
*
[3718] Fix | Delete
* @since 2.7.0
[3719] Fix | Delete
*
[3720] Fix | Delete
* @param array $args {
[3721] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3722] Fix | Delete
*
[3723] Fix | Delete
* @type int $0 Blog ID (unused).
[3724] Fix | Delete
* @type string $1 Username.
[3725] Fix | Delete
* @type string $2 Password.
[3726] Fix | Delete
* @type int $3 Comment ID.
[3727] Fix | Delete
* }
[3728] Fix | Delete
* @return bool|IXR_Error See wp_delete_comment().
[3729] Fix | Delete
*/
[3730] Fix | Delete
public function wp_deleteComment( $args ) {
[3731] Fix | Delete
$this->escape( $args );
[3732] Fix | Delete
[3733] Fix | Delete
$username = $args[1];
[3734] Fix | Delete
$password = $args[2];
[3735] Fix | Delete
$comment_id = (int) $args[3];
[3736] Fix | Delete
[3737] Fix | Delete
$user = $this->login( $username, $password );
[3738] Fix | Delete
if ( ! $user ) {
[3739] Fix | Delete
return $this->error;
[3740] Fix | Delete
}
[3741] Fix | Delete
[3742] Fix | Delete
if ( ! get_comment( $comment_id ) ) {
[3743] Fix | Delete
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
[3744] Fix | Delete
}
[3745] Fix | Delete
[3746] Fix | Delete
if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
[3747] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, you are not allowed to delete this comment.' ) );
[3748] Fix | Delete
}
[3749] Fix | Delete
[3750] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3751] Fix | Delete
do_action( 'xmlrpc_call', 'wp.deleteComment', $args, $this );
[3752] Fix | Delete
[3753] Fix | Delete
$status = wp_delete_comment( $comment_id );
[3754] Fix | Delete
[3755] Fix | Delete
if ( $status ) {
[3756] Fix | Delete
/**
[3757] Fix | Delete
* Fires after a comment has been successfully deleted via XML-RPC.
[3758] Fix | Delete
*
[3759] Fix | Delete
* @since 3.4.0
[3760] Fix | Delete
*
[3761] Fix | Delete
* @param int $comment_id ID of the deleted comment.
[3762] Fix | Delete
* @param array $args An array of arguments to delete the comment.
[3763] Fix | Delete
*/
[3764] Fix | Delete
do_action( 'xmlrpc_call_success_wp_deleteComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[3765] Fix | Delete
}
[3766] Fix | Delete
[3767] Fix | Delete
return $status;
[3768] Fix | Delete
}
[3769] Fix | Delete
[3770] Fix | Delete
/**
[3771] Fix | Delete
* Edits a comment.
[3772] Fix | Delete
*
[3773] Fix | Delete
* Besides the common blog_id (unused), username, and password arguments,
[3774] Fix | Delete
* it takes a comment_id integer and a content_struct array as the last argument.
[3775] Fix | Delete
*
[3776] Fix | Delete
* The allowed keys in the content_struct array are:
[3777] Fix | Delete
* - 'author'
[3778] Fix | Delete
* - 'author_url'
[3779] Fix | Delete
* - 'author_email'
[3780] Fix | Delete
* - 'content'
[3781] Fix | Delete
* - 'date_created_gmt'
[3782] Fix | Delete
* - 'status'. Common statuses are 'approve', 'hold', 'spam'. See get_comment_statuses() for more details.
[3783] Fix | Delete
*
[3784] Fix | Delete
* @since 2.7.0
[3785] Fix | Delete
*
[3786] Fix | Delete
* @param array $args {
[3787] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3788] Fix | Delete
*
[3789] Fix | Delete
* @type int $0 Blog ID (unused).
[3790] Fix | Delete
* @type string $1 Username.
[3791] Fix | Delete
* @type string $2 Password.
[3792] Fix | Delete
* @type int $3 Comment ID.
[3793] Fix | Delete
* @type array $4 Content structure.
[3794] Fix | Delete
* }
[3795] Fix | Delete
* @return true|IXR_Error True, on success.
[3796] Fix | Delete
*/
[3797] Fix | Delete
public function wp_editComment( $args ) {
[3798] Fix | Delete
$this->escape( $args );
[3799] Fix | Delete
[3800] Fix | Delete
$username = $args[1];
[3801] Fix | Delete
$password = $args[2];
[3802] Fix | Delete
$comment_id = (int) $args[3];
[3803] Fix | Delete
$content_struct = $args[4];
[3804] Fix | Delete
[3805] Fix | Delete
$user = $this->login( $username, $password );
[3806] Fix | Delete
if ( ! $user ) {
[3807] Fix | Delete
return $this->error;
[3808] Fix | Delete
}
[3809] Fix | Delete
[3810] Fix | Delete
if ( ! get_comment( $comment_id ) ) {
[3811] Fix | Delete
return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
[3812] Fix | Delete
}
[3813] Fix | Delete
[3814] Fix | Delete
if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
[3815] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
[3816] Fix | Delete
}
[3817] Fix | Delete
[3818] Fix | Delete
/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
[3819] Fix | Delete
do_action( 'xmlrpc_call', 'wp.editComment', $args, $this );
[3820] Fix | Delete
$comment = array(
[3821] Fix | Delete
'comment_ID' => $comment_id,
[3822] Fix | Delete
);
[3823] Fix | Delete
[3824] Fix | Delete
if ( isset( $content_struct['status'] ) ) {
[3825] Fix | Delete
$statuses = get_comment_statuses();
[3826] Fix | Delete
$statuses = array_keys( $statuses );
[3827] Fix | Delete
[3828] Fix | Delete
if ( ! in_array( $content_struct['status'], $statuses, true ) ) {
[3829] Fix | Delete
return new IXR_Error( 401, __( 'Invalid comment status.' ) );
[3830] Fix | Delete
}
[3831] Fix | Delete
[3832] Fix | Delete
$comment['comment_approved'] = $content_struct['status'];
[3833] Fix | Delete
}
[3834] Fix | Delete
[3835] Fix | Delete
// Do some timestamp voodoo.
[3836] Fix | Delete
if ( ! empty( $content_struct['date_created_gmt'] ) ) {
[3837] Fix | Delete
// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
[3838] Fix | Delete
$dateCreated = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';
[3839] Fix | Delete
$comment['comment_date'] = get_date_from_gmt( $dateCreated );
[3840] Fix | Delete
$comment['comment_date_gmt'] = iso8601_to_datetime( $dateCreated, 'gmt' );
[3841] Fix | Delete
}
[3842] Fix | Delete
[3843] Fix | Delete
if ( isset( $content_struct['content'] ) ) {
[3844] Fix | Delete
$comment['comment_content'] = $content_struct['content'];
[3845] Fix | Delete
}
[3846] Fix | Delete
[3847] Fix | Delete
if ( isset( $content_struct['author'] ) ) {
[3848] Fix | Delete
$comment['comment_author'] = $content_struct['author'];
[3849] Fix | Delete
}
[3850] Fix | Delete
[3851] Fix | Delete
if ( isset( $content_struct['author_url'] ) ) {
[3852] Fix | Delete
$comment['comment_author_url'] = $content_struct['author_url'];
[3853] Fix | Delete
}
[3854] Fix | Delete
[3855] Fix | Delete
if ( isset( $content_struct['author_email'] ) ) {
[3856] Fix | Delete
$comment['comment_author_email'] = $content_struct['author_email'];
[3857] Fix | Delete
}
[3858] Fix | Delete
[3859] Fix | Delete
$result = wp_update_comment( $comment, true );
[3860] Fix | Delete
if ( is_wp_error( $result ) ) {
[3861] Fix | Delete
return new IXR_Error( 500, $result->get_error_message() );
[3862] Fix | Delete
}
[3863] Fix | Delete
[3864] Fix | Delete
if ( ! $result ) {
[3865] Fix | Delete
return new IXR_Error( 500, __( 'Sorry, the comment could not be updated.' ) );
[3866] Fix | Delete
}
[3867] Fix | Delete
[3868] Fix | Delete
/**
[3869] Fix | Delete
* Fires after a comment has been successfully updated via XML-RPC.
[3870] Fix | Delete
*
[3871] Fix | Delete
* @since 3.4.0
[3872] Fix | Delete
*
[3873] Fix | Delete
* @param int $comment_id ID of the updated comment.
[3874] Fix | Delete
* @param array $args An array of arguments to update the comment.
[3875] Fix | Delete
*/
[3876] Fix | Delete
do_action( 'xmlrpc_call_success_wp_editComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase
[3877] Fix | Delete
[3878] Fix | Delete
return true;
[3879] Fix | Delete
}
[3880] Fix | Delete
[3881] Fix | Delete
/**
[3882] Fix | Delete
* Creates a new comment.
[3883] Fix | Delete
*
[3884] Fix | Delete
* @since 2.7.0
[3885] Fix | Delete
*
[3886] Fix | Delete
* @param array $args {
[3887] Fix | Delete
* Method arguments. Note: arguments must be ordered as documented.
[3888] Fix | Delete
*
[3889] Fix | Delete
* @type int $0 Blog ID (unused).
[3890] Fix | Delete
* @type string $1 Username.
[3891] Fix | Delete
* @type string $2 Password.
[3892] Fix | Delete
* @type string|int $3 Post ID or URL.
[3893] Fix | Delete
* @type array $4 Content structure.
[3894] Fix | Delete
* }
[3895] Fix | Delete
* @return int|IXR_Error See wp_new_comment().
[3896] Fix | Delete
*/
[3897] Fix | Delete
public function wp_newComment( $args ) {
[3898] Fix | Delete
$this->escape( $args );
[3899] Fix | Delete
[3900] Fix | Delete
$username = $args[1];
[3901] Fix | Delete
$password = $args[2];
[3902] Fix | Delete
$post = $args[3];
[3903] Fix | Delete
$content_struct = $args[4];
[3904] Fix | Delete
[3905] Fix | Delete
/**
[3906] Fix | Delete
* Filters whether to allow anonymous comments over XML-RPC.
[3907] Fix | Delete
*
[3908] Fix | Delete
* @since 2.7.0
[3909] Fix | Delete
*
[3910] Fix | Delete
* @param bool $allow Whether to allow anonymous commenting via XML-RPC.
[3911] Fix | Delete
* Default false.
[3912] Fix | Delete
*/
[3913] Fix | Delete
$allow_anon = apply_filters( 'xmlrpc_allow_anonymous_comments', false );
[3914] Fix | Delete
[3915] Fix | Delete
$user = $this->login( $username, $password );
[3916] Fix | Delete
[3917] Fix | Delete
if ( ! $user ) {
[3918] Fix | Delete
$logged_in = false;
[3919] Fix | Delete
if ( $allow_anon && get_option( 'comment_registration' ) ) {
[3920] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, you must be logged in to comment.' ) );
[3921] Fix | Delete
} elseif ( ! $allow_anon ) {
[3922] Fix | Delete
return $this->error;
[3923] Fix | Delete
}
[3924] Fix | Delete
} else {
[3925] Fix | Delete
$logged_in = true;
[3926] Fix | Delete
}
[3927] Fix | Delete
[3928] Fix | Delete
if ( is_numeric( $post ) ) {
[3929] Fix | Delete
$post_id = absint( $post );
[3930] Fix | Delete
} else {
[3931] Fix | Delete
$post_id = url_to_postid( $post );
[3932] Fix | Delete
}
[3933] Fix | Delete
[3934] Fix | Delete
if ( ! $post_id ) {
[3935] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[3936] Fix | Delete
}
[3937] Fix | Delete
[3938] Fix | Delete
if ( ! get_post( $post_id ) ) {
[3939] Fix | Delete
return new IXR_Error( 404, __( 'Invalid post ID.' ) );
[3940] Fix | Delete
}
[3941] Fix | Delete
[3942] Fix | Delete
if ( ! comments_open( $post_id ) ) {
[3943] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, comments are closed for this item.' ) );
[3944] Fix | Delete
}
[3945] Fix | Delete
[3946] Fix | Delete
if (
[3947] Fix | Delete
'publish' === get_post_status( $post_id ) &&
[3948] Fix | Delete
! current_user_can( 'edit_post', $post_id ) &&
[3949] Fix | Delete
post_password_required( $post_id )
[3950] Fix | Delete
) {
[3951] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
[3952] Fix | Delete
}
[3953] Fix | Delete
[3954] Fix | Delete
if (
[3955] Fix | Delete
'private' === get_post_status( $post_id ) &&
[3956] Fix | Delete
! current_user_can( 'read_post', $post_id )
[3957] Fix | Delete
) {
[3958] Fix | Delete
return new IXR_Error( 403, __( 'Sorry, you are not allowed to comment on this post.' ) );
[3959] Fix | Delete
}
[3960] Fix | Delete
[3961] Fix | Delete
$comment = array(
[3962] Fix | Delete
'comment_post_ID' => $post_id,
[3963] Fix | Delete
'comment_content' => trim( $content_struct['content'] ),
[3964] Fix | Delete
);
[3965] Fix | Delete
[3966] Fix | Delete
if ( $logged_in ) {
[3967] Fix | Delete
$display_name = $user->display_name;
[3968] Fix | Delete
$user_email = $user->user_email;
[3969] Fix | Delete
$user_url = $user->user_url;
[3970] Fix | Delete
[3971] Fix | Delete
$comment['comment_author'] = $this->escape( $display_name );
[3972] Fix | Delete
$comment['comment_author_email'] = $this->escape( $user_email );
[3973] Fix | Delete
$comment['comment_author_url'] = $this->escape( $user_url );
[3974] Fix | Delete
$comment['user_id'] = $user->ID;
[3975] Fix | Delete
} else {
[3976] Fix | Delete
$comment['comment_author'] = '';
[3977] Fix | Delete
if ( isset( $content_struct['author'] ) ) {
[3978] Fix | Delete
$comment['comment_author'] = $content_struct['author'];
[3979] Fix | Delete
}
[3980] Fix | Delete
[3981] Fix | Delete
$comment['comment_author_email'] = '';
[3982] Fix | Delete
if ( isset( $content_struct['author_email'] ) ) {
[3983] Fix | Delete
$comment['comment_author_email'] = $content_struct['author_email'];
[3984] Fix | Delete
}
[3985] Fix | Delete
[3986] Fix | Delete
$comment['comment_author_url'] = '';
[3987] Fix | Delete
if ( isset( $content_struct['author_url'] ) ) {
[3988] Fix | Delete
$comment['comment_author_url'] = $content_struct['author_url'];
[3989] Fix | Delete
}
[3990] Fix | Delete
[3991] Fix | Delete
$comment['user_id'] = 0;
[3992] Fix | Delete
[3993] Fix | Delete
if ( get_option( 'require_name_email' ) ) {
[3994] Fix | Delete
if ( strlen( $comment['comment_author_email'] ) < 6 || '' === $comment['comment_author'] ) {
[3995] Fix | Delete
return new IXR_Error( 403, __( 'Comment author name and email are required.' ) );
[3996] Fix | Delete
} elseif ( ! is_email( $comment['comment_author_email'] ) ) {
[3997] Fix | Delete
return new IXR_Error( 403, __( 'A valid email address is required.' ) );
[3998] Fix | Delete
}
[3999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function