Skip to content

Instantly share code, notes, and snippets.

@paulgoodchild
Created December 12, 2020 11:37
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 paulgoodchild/ba9aa01f21be6f5f490e02439ee02dc4 to your computer and use it in GitHub Desktop.
Save paulgoodchild/ba9aa01f21be6f5f490e02439ee02dc4 to your computer and use it in GitHub Desktop.
Automatically add WordPress site to your iControlWP control panel from ManageWP (or other)
<?php
/**
* You may automatically add any WordPress site to your iControlWP account by using the "code run"
* or "code snippets" feature in ManageWP.
*
* Please follow these steps:
*
* 1) Install and activate the iControlWP plugin on your WordPress site.
* 2) Grab your "AUTHENTICATION_KEY" from your iControlWP account:
* - https://app.icontrolwp.com/profile/preferences
* 3) Enter your AUTHENTICATION_KEY and registered iControlWP email address below where indicated.
* - ensure to keep the single quotes in-place.
* 4) Check the $path variable. This assumes your WP Content and plugins folders are "normal" and unchanged
* from defaults.
* 5) Copy and paste all the code into the "code snippets" tool. You don't need these comments, and
* please ensure the file starts with "<?php"
*/
$path = path_join( ABSPATH, 'wp-content/plugins/worpit-admin-dashboard-plugin/auto_add.php' );
$res = file_put_contents(
$path,
wp_json_encode( [
'api-key' => 'AUTHENTICATION_KEY',
'email' => 'REGISTERED_EMAIL_ADDRESS',
] )
);
if ( $res !== false && $res > 0 ) {
echo 'Auto-Add site configuration created. Site will be automatically added to your iControlWP account shortly.';
}
else {
echo 'Failed to create Auto-Add site configuration. You may not have file system permissions, or your directory structure is not as expected';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment