|  | 
| 9 | 9 |       MB_Set_Associations( $_POST[ 'well' ], explode( ',', $_POST[ 'roles' ] ) ); | 
| 10 | 10 |     } else if ( isset( $_POST[ 'install' ] ) ) { | 
| 11 | 11 |       $did_install = true; | 
| 12 |  | -      MB_install(); | 
|  | 12 | +      activateCaching(); | 
| 13 | 13 |     } | 
| 14 | 14 |   } | 
| 15 | 15 | 
 | 
| 16 | 16 |   $wells = MB_Get_System_Wells(); | 
| 17 | 17 |   $wellassoc = MB_Get_Associations(); | 
| 18 | 18 | 
 | 
| 19 | 19 |   $roles = []; | 
| 20 |  | -  foreach ( $wellassoc as $role => $well ) { | 
| 21 |  | -    if ( array_key_exists( $well, $roles ) ) { | 
| 22 |  | -      $roles[ $well ] = $roles[ $well ] . ', ' . ucfirst( $role ); | 
| 23 |  | -    } else { | 
| 24 |  | -      $roles[ $well ] = ucfirst( $role ); | 
|  | 20 | +  if ( is_array ( $wellassoc ) ) { | 
|  | 21 | +    foreach ( $wellassoc as $role => $well ) { | 
|  | 22 | +      if ( array_key_exists( $well, $roles ) ) { | 
|  | 23 | +        $roles[ $well ] = $roles[ $well ] . ', ' . ucfirst( $role ); | 
|  | 24 | +      } else { | 
|  | 25 | +        $roles[ $well ] = ucfirst( $role ); | 
|  | 26 | +      } | 
| 25 | 27 |     } | 
| 26 | 28 |   } | 
| 27 | 29 | ?> | 
| 28 | 30 | <link rel="stylesheet" href="<?php echo plugins_url( 'style.css', __FILE__ ); ?>" /> | 
| 29 | 31 | 
 | 
| 30 | 32 | <h2><?php echo MB_PROD_NAME; ?> Settings</h2> | 
| 31 | 33 | 
 | 
| 32 |  | -<?php if ( ! $_GLOBALS[ 'mb_checks' ][ 0 ] ): ?><p> | 
| 33 |  | -  Your hosting control panel is not yet supported!  Currently Membucket only | 
| 34 |  | -  supports cPanel/WHM servers. | 
| 35 |  | -</p><?php elseif ( ! $_GLOBALS[ 'mb_checks' ][ 1 ] ): ?><p> | 
| 36 |  | -  Membucket was not found on your system!  Your hosting provider does not | 
| 37 |  | -  support Membucket, or has not made it available to your user. | 
| 38 |  | -</p><?php elseif ( ! $_GLOBALS[ 'mb_checks' ][ 4 ] ): ?><p> | 
| 39 |  | -  A required PHP module was not found enabled on this system. Please ask your | 
| 40 |  | -  hosting provider to enable the PHP module called Memcache. They can do so via | 
| 41 |  | -  the "Module Installers > PHP Pecl" section of WHM. | 
| 42 |  | -</p><?php elseif ( ! $_GLOBALS[ 'mb_checks' ][ 2 ] ): ?><p> | 
| 43 |  | -  Your account does not have an access key for use with Membucket.  If you | 
| 44 |  | -  have access to SSH, please run the command: `membucket generate-key`. | 
| 45 |  | -  Otherwise, ask your hosting provider to run this command as your user. | 
| 46 |  | -</p><?php else: ?> | 
|  | 34 | +<?php | 
|  | 35 | +  $checks_failed = 0; | 
|  | 36 | +  foreach ( $_GLOBALS[ 'mb_checks' ] as $check ) { | 
|  | 37 | +    if ( false === $check ) { | 
|  | 38 | +      $checks_failed++; | 
|  | 39 | +    } | 
|  | 40 | +  } | 
|  | 41 | +?> | 
|  | 42 | + | 
|  | 43 | +<?php if ( 1 < $checks_failed || ( 1 === $checks_failed && true === $_GLOBALS[ 'mb_checks' ][ 3 ] ) ): ?> | 
|  | 44 | +  <div class="notice notice-error"> | 
|  | 45 | +    <?php if ( ! $_GLOBALS[ 'mb_checks' ][ 0 ] ): ?> | 
|  | 46 | +      <p><strong>cPanel/WHM Not Detected!</strong></p> | 
|  | 47 | +      <p>Currently, Membucket only supports cPanel/WHM control panels. We could | 
|  | 48 | +        not detect that your website is being hosted under cPanel. You cannot | 
|  | 49 | +        continue.</p> | 
|  | 50 | +    <?php elseif ( ! $_GLOBALS[ 'mb_checks' ][ 1 ] ): ?> | 
|  | 51 | +      <p><strong>Membucket Not Found</strong></p> | 
|  | 52 | +      <p>Membucket was not found on your system. Your hosting provider does not | 
|  | 53 | +        support Membucket, or it has not been made available to your user. Ask | 
|  | 54 | +       your hosting provider how to continue.</p> | 
|  | 55 | +    <?php elseif ( ! $_GLOBALS[ 'mb_checks' ][ 4 ] ): ?> | 
|  | 56 | +      <p><strong>PHP Module Not Found</strong></p> | 
|  | 57 | +      <p>We could not find the required PHP module "Memcache", which acts as a | 
|  | 58 | +        client to Membucket. Ask your hosting provider to enable this module | 
|  | 59 | +        via the "Module Installers > PHP Pecl" section of WHM.</p> | 
|  | 60 | +    <?php elseif ( ! $_GLOBALS[ 'mb_checks' ][ 2 ] ): ?> | 
|  | 61 | +      <p><strong>Membucket Not Activated</strong></p> | 
|  | 62 | +      <p>Your account does not have an access key for use with Membucket. If | 
|  | 63 | +        you have access to SSh, please run the command: "membucket generate-key". | 
|  | 64 | +        Otherwise, ask your hosting provider to run this command as your user.</p> | 
|  | 65 | +      <?php endif; ?> | 
|  | 66 | +  </div> | 
|  | 67 | +<?php endif; ?> | 
|  | 68 | + | 
|  | 69 | +<?php if ( 0 === $checks_failed || ( 1 === $checks_failed && false === $_GLOBALS[ 'mb_checks' ][ 3 ] ) ): ?> | 
|  | 70 | +<?php if ( ! empty( $wellassoc[ 'default' ] ) ): ?> | 
|  | 71 | +  <?php if ( $did_install ): ?><p> | 
|  | 72 | +    <div class="notice notice-success"> | 
|  | 73 | +      <p><strong>Caching Active!</strong></p> | 
|  | 74 | +      <p>Membucket is now active. If you load home page now, you should see | 
|  | 75 | +        data on the graphs shown in cPanel under "Membucket Stats".</p> | 
|  | 76 | +      <p>You can still adjust your well associations live below.</p> | 
|  | 77 | +    </div> | 
|  | 78 | +  <?php elseif ( ! $_GLOBALS[ 'mb_checks' ][ 3 ] ): ?> | 
|  | 79 | +  <div class="notice notice-warning"> | 
|  | 80 | +    <p><strong>One last step...</strong></p> | 
|  | 81 | +    <p>Once you are happy with your well associations:</p> | 
|  | 82 | + | 
|  | 83 | +    <p><form method="POST"> | 
|  | 84 | +      <input type="hidden" name="install" value="true"/> | 
|  | 85 | +      <input type="submit" class="button button-primary" value="Activate Caching"/> | 
|  | 86 | +    </form></p> | 
|  | 87 | +  </div> | 
|  | 88 | +  <?php endif; ?> | 
|  | 89 | +<?php endif; ?> | 
| 47 | 90 | 
 | 
| 48 | 91 | <p>Here you can assign roles to wells and customize how membucket caches your site.</p> | 
| 49 | 92 | 
 | 
|  | 
| 116 | 159 | <?php wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-core' ) ?> | 
| 117 | 160 | <script src="<?php echo plugins_url( 'script.js', __FILE__ ); ?>"></script> | 
| 118 | 161 | <?php endif; ?> | 
| 119 |  | - | 
| 120 |  | -<?php if ( ! empty( $wellassoc[ 'default' ] ) ): ?> | 
| 121 |  | -<h3>Activate Caching</h3> | 
| 122 |  | -<p><strong>Step 3)</strong> Now that you have well(s) associated...</p> | 
| 123 |  | - | 
| 124 |  | -<?php if ( $did_install ): ?><p> | 
| 125 |  | -  We copied the file "object-cache.php" into "wp-content" for you! | 
| 126 |  | -</p><?php elseif ( ! $_GLOBALS[ 'mb_checks' ][ 3 ] ): ?><form method="POST"><p> | 
| 127 |  | -  Installation of the WordPress plugin has not yet been completed!  The file | 
| 128 |  | -  "object-cache.php" must be copied into the root of the "wp-content" folder. | 
| 129 |  | -  <button type="submit" class="btn btn-primary">Click Here</button> to have us | 
| 130 |  | -  try to do it for you. <input type="hidden" name="install" value="true"/>. | 
| 131 |  | -  This should be the final step to turning cache on! | 
| 132 |  | -</p></form><?php else: ?><div class="alert alert-success"> | 
| 133 |  | -  Caching should be active! | 
| 134 |  | -</div><?php endif;?> | 
| 135 |  | -<?php endif; ?> | 
|  | 
0 commit comments