Skip to content

Instantly share code, notes, and snippets.

@maheshwaghmare
Created May 4, 2020 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maheshwaghmare/9b320dbe8a726ca4b379e63a52a3e20a to your computer and use it in GitHub Desktop.
Save maheshwaghmare/9b320dbe8a726ca4b379e63a52a3e20a to your computer and use it in GitHub Desktop.
Rest API - Update the WordPress settings with Rest API
<?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