Wie kann ich meine Anfrage-URL über Ajax bearbeiten?

Entschuldigung, wenn das wie eine lächerliche Frage erscheint, habe ich mir 3 Tage lang die Haare ausgerissen, um herauszufinden, wie das geht …

Ich möchte im Wesentlichen diese (Abfrage Var?) Herausziehen und die Parameter in meiner aktuellen function verwenden …

?vote=up&comment_id=8 

Hier ist meine derzeitige function:

 add_action( 'init', function() { if ( ! is_user_logged_in() ) { return; } if ( ! isset( $_GET[ 'vote' ] ) && ! isset( $_GET[ 'comment_id' ] ) ) { return; } $up_or_down = esc_attr( $_GET[ 'vote' ]) ; if ( ! in_array( $up_or_down, [ 'up', 'down' ] ) ) { return; } $comment_id = (int) esc_attr( $_GET[ 'comment_id' ] ); if ( $comment_id < 1 ) { return; } // Retreive the existing comment up/down vote ID's - we don't know who did what at this point.. $vote_user_ids = get_comment_meta( $comment_id, '_vote_user_ids', true ); // If the comment upvote count isn't set, create an empty array. // This will always be the case on the first instance of a user "upvoting" a comment if ( ! is_array( $vote_user_ids ) ) { $vote_user_ids = []; } // Check if the user has already "voted" if ( array_key_exists( get_current_user_id(), $vote_user_ids ) ) { // If the user HAS voted and they are repeating themselves (eg the voted up and are trying to do this again) ignore them.. if ( $up_or_down === $vote_user_ids[ $user_id ] ) { return; } else { // The user voted already but have changed their vote - update this //$vote_user_ids[ get_current_user_id() ] = $up_or_down; unset ( $vote_user_ids[ get_current_user_id() ] ); } } else { // The user HAS NOT voted, add them $vote_user_ids[ get_current_user_id() ] = $up_or_down; } // Whatever the results of ^^ we need to update now $update_result = update_comment_meta( $comment_id, '_vote_user_ids', $vote_user_ids ); delete_transient( "comment_vote_count_comment_{$comment_id}" ); if ( ! $update_result ) { error_log( "Error updating comment meta to update $comment_id to set user ID $user_id $up_or_down." ); } }, 10, 0 ); 

Solutions Collecting From Web of "Wie kann ich meine Anfrage-URL über Ajax bearbeiten?"