| @@ -4,19 +4,55 @@ | ||
| 4 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | 5 | exit; |
| 6 | 6 | } |
| 7 | 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'; | |
| 8 | 25 | ?> |
| 9 | -<div class="patchstack-plan" style="margin-bottom: 64px;"> | |
| 26 | +<div class="patchstack-font"> | |
| 10 | 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> | |
| 11 | 39 | |
| 12 | - <p><strong>To activate Patchstack on your multisite network, follow these steps:</strong></p> | |
| 13 | - | |
| 14 | - <ol style="margin-left: 20px;"> | |
| 15 | - <li><strong>Add all your network sites to Patchstack:</strong><br>Go to <a href="https://app.patchstack.com/sites/overview?add=1" target="_blank">app.patchstack.com</a> and add each of your multisite URLs individually.<br><br></li> | |
| 16 | - <li><strong>Activate API credentials on each site:</strong><br>For each site in your network, visit its individual WordPress admin panel and go to <strong>Settings → Security</strong> to add the API credentials. An overview of sites and its settings page can be found <a href="admin.php?page=patchstack-multisite">here</a>.</li> | |
| 17 | - </ol> | |
| 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> | |
| 18 | 47 | |
| 19 | - <p> | |
| 20 | - <strong>Note:</strong> All sites in your multisite network must be added to your Patchstack account individually and then activated with API keys on each site. For more information, visit the <a href="https://docs.patchstack.com/patchstack-plugin/installing-patchstack-on-a-multisite" target="_blank">multisite setup documentation</a>. | |
| 21 | - </p> | |
| 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 | + ?> | |
| 22 | 58 | </div> |