Created
May 4, 2020 15:05
-
-
Save maheshwaghmare/9b320dbe8a726ca4b379e63a52a3e20a to your computer and use it in GitHub Desktop.
Rest API - Update the WordPress settings with Rest API
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 | |
if( function_exists( 'prefix_update_wordpress_settings' ) ) : | |
/** | |
* Update the WordPress settings with Rest API | |
* | |
* @since 1.0.0 | |
* @return void | |
*/ | |
function prefix_update_wordpress_settings() { | |
$username = ''; | |
$password = ''; | |
$site_url = 'http://localhost/dev.test/'; | |
$request = wp_remote_post( $site_url . 'wp-json/mw/v1/settings/', array( | |
'body' => array( | |
'title' => 'Mahesh Waghmare', | |
), | |
'headers' => array( | |
'Authorization' => 'Basic ' . base64_encode( $username . ':' . $password ), | |
), | |
) ); | |
} | |
add_action( 'admin_head', 'prefix_update_wordpress_settings' ); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment