fix phpcs
Some checks are pending
PHP_CodeSniffer / phpcs (push) Waiting to run
Unit Testing / phpunit (5.6, 6.2) (push) Waiting to run
Unit Testing / phpunit (7.0) (push) Waiting to run
Unit Testing / phpunit (7.2) (push) Waiting to run
Unit Testing / phpunit (7.3) (push) Waiting to run
Unit Testing / phpunit (7.4) (push) Waiting to run
Unit Testing / phpunit (8.0) (push) Waiting to run
Unit Testing / phpunit (8.1) (push) Waiting to run
Unit Testing / phpunit (8.2) (push) Waiting to run
Unit Testing / phpunit (latest) (push) Waiting to run

This commit is contained in:
André Menrath 2023-12-26 13:50:54 +01:00
parent 4494136527
commit fefa29a29f
8 changed files with 74 additions and 51 deletions

View file

@ -39,14 +39,16 @@ class Follow_Requests {
WHERE follow_request.post_type = 'ap_follow_request' WHERE follow_request.post_type = 'ap_follow_request'
AND meta.meta_key = 'activitypub_user_id' AND meta.meta_key = 'activitypub_user_id'
AND meta.meta_value = %s AND meta.meta_value = %s
ORDER BY {$orderby} {$order} ORDER BY %s %s
LIMIT %d OFFSET %d", LIMIT %d OFFSET %d",
$orderby,
$order,
$user_id, $user_id,
$per_page, $per_page,
0 0
) )
); );
$total_items = $wpdb->get_var("SELECT FOUND_ROWS()"); $total_items = $wpdb->get_var( 'SELECT FOUND_ROWS()' );
return compact( 'follow_requests', 'total_items' ); return compact( 'follow_requests', 'total_items' );
} }

View file

@ -63,7 +63,6 @@ class Follow {
if ( ! $user->get_manually_approves_followers() ) { if ( ! $user->get_manually_approves_followers() ) {
$follow_request->approve(); $follow_request->approve();
} }
} }
/** /**

View file

@ -105,7 +105,7 @@ class Follow_Request extends Base_Object {
} }
$post = get_post( $id ); $post = get_post( $id );
$follow_request = new static; $follow_request = new static();
$follow_request->set_id( $post->guid ); $follow_request->set_id( $post->guid );
$follow_request->set__id( $post->ID ); $follow_request->set__id( $post->ID );
$follow_request->set_type( 'Follow' ); $follow_request->set_type( 'Follow' );
@ -133,12 +133,11 @@ class Follow_Request extends Base_Object {
'post_status' => 'pending', 'post_status' => 'pending',
'post_parent' => $follower_id, 'post_parent' => $follower_id,
'meta_input' => $meta_input, 'meta_input' => $meta_input,
'mime_type' => 'text/plain' 'mime_type' => 'text/plain',
); );
$post_id = wp_insert_post( $args ); $post_id = wp_insert_post( $args );
return self::from_wp_id( $post_id ); return self::from_wp_id( $post_id );
} }

View file

@ -179,21 +179,30 @@ class Follow_Requests extends WP_List_Table {
} }
public function ajax_response() { public function ajax_response() {
$follow_action = $_REQUEST['follow_action']; global $_REQUEST;
$id = $_REQUEST['follow_request']; $follow_action = isset( $_REQUEST['follow_action'] ) ? sanitize_title( wp_unslash( $_REQUEST['follow_action'] ) ) : null;
wp_verify_nonce( $_REQUEST['_wpnonce'], "activitypub_{$follow_action}_follow_request" ); $follow_request_id = isset( $_REQUEST['follow_request'] ) ? (int) $_REQUEST['follow_request'] : null;
$follow_request = Follow_Request::from_wp_id( $id ); $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? (int) $_REQUEST['_wpnonce'] : null;
if ( ! $follow_action || ! $follow_request_id || ! $wp_nonce ) {
return;
}
wp_verify_nonce( $wp_nonce, "activitypub_{$follow_action}_follow_request" );
$follow_request = Follow_Request::from_wp_id( $follow_request_id );
if ( $follow_request->can_handle_follow_request() ) { if ( $follow_request->can_handle_follow_request() ) {
switch ( $follow_action ) { switch ( $follow_action ) {
case 'approve': case 'approve':
$follow_request->approve(); $follow_request->approve();
wp_die( 'approved' ); wp_die( 'approved' );
break;
case 'reject': case 'reject':
$follow_request->reject(); $follow_request->reject();
wp_die( 'rejected' ); wp_die( 'rejected' );
break;
case 'delete': case 'delete':
$follow_request->delete(); $follow_request->delete();
wp_die( 'deleted' ); wp_die( 'deleted' );
break;
} }
} }
return; return;
@ -214,10 +223,24 @@ class Follow_Requests extends WP_List_Table {
} else { } else {
$type = 'hidden'; $type = 'hidden';
} }
switch ( $follow_action ) {
case 'approve':
$follow_action_text = __( 'Approve', 'activitypub' );
break;
case 'delete':
$follow_action_text = __( 'Delete', 'activitypub' );
break;
case 'reject':
$follow_action_text = __( 'Reject', 'activitypub' );
break;
default:
return;
}
printf( printf(
'<input type="%s" class="button" value="%s" data-action="%s">', '<input type="%s" class="button" value="%s" data-action="%s">',
esc_attr( $type ), esc_attr( $type ),
esc_attr__( ucfirst( $follow_action ), 'activitypub' ), esc_attr( $follow_action_text ),
esc_url( $url ) esc_url( $url )
); );
} }