| 1 |
<?php |
| 2 |
|
| 3 |
// Do not allow the file to be called directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
// Determine which sites need activation or not. |
| 9 |
$i = 0; |
| 10 |
$checkbox_list = ''; |
| 11 |
$activated = ''; |
| 12 |
$sites = get_sites(); |
| 13 |
foreach ( $sites as $site ) { |
| 14 |
if ( get_blog_option( $site->id, 'patchstack_clientid' ) == '' ) { |
| 15 |
$checkbox_list .= '<div style="margin-bottom: 10px;"><input type="checkbox" name="sites[]" id="site-' . esc_attr( $site->blog_id ) . '" value="' . esc_url( $site->siteurl ) . '"><label for="site-' . esc_attr( $site->blog_id ) . '">' . esc_url( $site->siteurl ) . '</label></div>'; |
| 16 |
$i++; |
| 17 |
} else { |
| 18 |
$activated .= esc_url( $site->siteurl ) . '<br />'; |
| 19 |
} |
| 20 |
} |
| 21 |
|
| 22 |
$has_token = !is_null( $this->plugin->api->get_access_token() ); |
| 23 |
$main_host = parse_url( get_home_url( get_main_site_id() ) ); |
| 24 |
$main_admin_url = get_admin_url( get_main_site_id() ) . '/options-general.php?page=patchstack&tab=license'; |
| 25 |
?> |
| 26 |
<div class="patchstack-font"> |
| 27 |
<h2 style="padding: 0;">Multisite Activation</h2> |
| 28 |
<p><?php echo wp_kses( $this->plugin->multisite->error, $this->allowed_html ); ?> |
| 29 |
<?php |
| 30 |
if ( ! $has_token ) { |
| 31 |
?> |
| 32 |
You must first manually add your WordPress network's primary site (<?php echo esc_html( $main_host['host'] ); ?>) to Patchstack before you can add the others.<br><br>You can do so by creating an account <a href="https://app.patchstack.com/register" target="_blank">here</a> and then by adding this site <a href="https://app.patchstack.com/apps/overview?add=1" target="_blank">here</a>.<br><br>Once you have obtained the API credentials, the credentials for your site <?php echo esc_html( $main_host['host'] ); ?> can be added <a href="<?php echo esc_url( $main_admin_url ); ?>">here</a>. |
| 33 |
<?php |
| 34 |
} else { |
| 35 |
?> |
| 36 |
Select the sites on which you would like to activate the Patchstack plugin. These sites must be accessible from the public internet.<br /><br> |
| 37 |
Note that these sites must be added to Patchstack as well, which you can do at <a href="https://app.patchstack.com/apps/overview?add=1" target="_blank">app.patchstack.com</a>. Keep in mind that this might affect your upcoming bill depending on your current subscription plan.<br /><br /> |
| 38 |
If you are an AppSumo user or have a limited amount of sites you can add, you must select the proper number of sites that can still be added to your account.</p> |
| 39 |
|
| 40 |
<h2 style="padding: 20px 0 0 0; display: <?php echo $i > 0 ? 'block' : 'none'; ?>;">Not Activated</h2> |
| 41 |
<form action="" method="POST" style="display: <?php echo $i > 0 ? 'block' : 'none'; ?>;"> |
| 42 |
<input type="hidden" name="patchstack_do" value="do_licenses"> |
| 43 |
<input type="hidden" value="<?php echo wp_create_nonce( 'patchstack-multisite-activation' ); ?>" name="PatchstackNonce"> |
| 44 |
<?php echo wp_kses( $checkbox_list, $this->allowed_html ); ?> |
| 45 |
<input type="submit" class="button-primary" value="Activate" /> |
| 46 |
</form> |
| 47 |
|
| 48 |
<?php |
| 49 |
if ( $activated != '' ) { |
| 50 |
?> |
| 51 |
<br /> |
| 52 |
<h2 style="padding: 0;">Activated</h2> |
| 53 |
<?php |
| 54 |
echo wp_kses( $activated, $this->allowed_html ); |
| 55 |
} |
| 56 |
} |
| 57 |
?> |
| 58 |
</div> |
| 59 |
|