-
-
Save billerickson/4f712ee04e6e647c03729a863c1b8853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Comments Migration | |
* | |
*/ | |
function ea_comments_migration() { | |
$site_url = 'https://yoursite.com'; | |
$username = 'your_username'; | |
$password = 'your_password'; | |
$query_args = array( | |
'per_page' => 20, | |
'context' => 'edit', | |
); | |
$request_args = array( | |
'headers' => array( | |
'Authorization' => 'Basic ' . base64_encode( $username . ':' . $password ), | |
), | |
); | |
$url = add_query_arg( $query_args, trailingslashit( $site_url ) . 'wp-json/wp/v2/comments' ); | |
$response = wp_remote_get( $url, $request_args ); | |
if( '200' != wp_remote_retrieve_response_code( $response ) ) | |
return; | |
$comments = json_decode( wp_remote_retrieve_body( $response ) ); | |
if( empty( $comments ) ) | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment