| @@ -25,23 +25,8 @@ | ||
| 25 | 25 | /** |
| 26 | 26 | * The admin page contents. |
| 27 | 27 | */ |
| 28 | 28 | function sqlite_integration_admin_screen() { |
| 29 | - $db_dropin_path = WP_CONTENT_DIR . '/db.php'; | |
| 30 | - | |
| 31 | - /* | |
| 32 | - * When an existing "db.php" drop-in is detected, let's check if it's a known | |
| 33 | - * plugin that we can continue supporting even when we override the drop-in. | |
| 34 | - */ | |
| 35 | - $override_db_dropin = false; | |
| 36 | - if ( file_exists( $db_dropin_path ) && ! defined( 'SQLITE_DB_DROPIN_VERSION' ) ) { | |
| 37 | - // Check for the Query Monitor plugin. | |
| 38 | - // When "QM_DB" exists, it must have been loaded via the "db.php" file. | |
| 39 | - if ( class_exists( 'QM_DB', false ) ) { | |
| 40 | - $override_db_dropin = true; | |
| 41 | - } | |
| 42 | - } | |
| 43 | - | |
| 44 | 29 | ?> |
| 45 | 30 | <div class="wrap"> |
| 46 | 31 | <h1><?php esc_html_e( 'SQLite integration.', 'sqlite-database-integration' ); ?></h1> |
| 47 | 32 | </div> |
| @@ -60,84 +45,70 @@ | ||
| 60 | 45 | '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>' |
| 61 | 46 | ); |
| 62 | 47 | ?> |
| 63 | 48 | </p> |
| 64 | - <?php elseif ( ! extension_loaded( 'pdo_sqlite' ) ) : ?> | |
| 65 | - <div class="notice notice-error"> | |
| 66 | - <p><?php esc_html_e( 'We detected that the PDO SQLite driver is missing from your server (the pdo_sqlite extension is not loaded). Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p> | |
| 67 | - </div> | |
| 68 | - <?php elseif ( file_exists( $db_dropin_path ) && ! defined( 'SQLITE_DB_DROPIN_VERSION' ) && ! $override_db_dropin ) : ?> | |
| 69 | - <?php if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) ) : ?> | |
| 70 | - <div class="notice notice-warning"> | |
| 71 | - <p> | |
| 49 | + <?php else : ?> | |
| 50 | + <?php if ( ! extension_loaded( 'pdo_sqlite' ) ) : ?> | |
| 51 | + <div class="notice notice-error"> | |
| 52 | + <p><?php esc_html_e( 'We detected that the PDO SQLite driver is missing from your server (the pdo_sqlite extension is not loaded). Please make sure that SQLite is enabled in your PHP installation before proceeding.', 'sqlite-database-integration' ); ?></p> | |
| 53 | + </div> | |
| 54 | + <?php elseif ( file_exists( WP_CONTENT_DIR . '/db.php' ) && ! defined( 'SQLITE_DB_DROPIN_VERSION' ) ) : ?> | |
| 55 | + <?php if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) ) : ?> | |
| 56 | + <div class="notice notice-warning"> | |
| 57 | + <p> | |
| 58 | + <?php | |
| 59 | + printf( | |
| 60 | + /* translators: %s: db.php drop-in path */ | |
| 61 | + esc_html__( 'An older %s file was detected. Please click the button below to update the file.', 'sqlite-database-integration' ), | |
| 62 | + '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>' | |
| 63 | + ); | |
| 64 | + ?> | |
| 65 | + </p> | |
| 66 | + </div> | |
| 67 | + <a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sqlite-integration&confirm-install&upgrade-from-pl' ), 'sqlite-install' ) ); ?>"> | |
| 72 | 68 | <?php |
| 73 | 69 | printf( |
| 74 | 70 | /* translators: %s: db.php drop-in path */ |
| 75 | - esc_html__( 'An older %s file was detected. Please click the button below to update the file.', 'sqlite-database-integration' ), | |
| 71 | + esc_html__( 'Update %s file', 'sqlite-database-integration' ), | |
| 76 | 72 | '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>' |
| 77 | 73 | ); |
| 78 | 74 | ?> |
| 79 | - </p> | |
| 80 | - </div> | |
| 81 | - <a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sqlite-integration&confirm-install&upgrade-from-pl' ), 'sqlite-install' ) ); ?>"> | |
| 82 | - <?php | |
| 83 | - printf( | |
| 84 | - /* translators: %s: db.php drop-in path */ | |
| 85 | - esc_html__( 'Update %s file', 'sqlite-database-integration' ), | |
| 86 | - '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>' | |
| 87 | - ); | |
| 88 | - ?> | |
| 89 | - </a> | |
| 90 | - <?php else : ?> | |
| 75 | + </a> | |
| 76 | + <?php else : ?> | |
| 77 | + <div class="notice notice-error"> | |
| 78 | + <p> | |
| 79 | + <?php | |
| 80 | + printf( | |
| 81 | + /* translators: %s: db.php drop-in path */ | |
| 82 | + esc_html__( 'The SQLite plugin cannot be activated because a different %s drop-in already exists.', 'sqlite-database-integration' ), | |
| 83 | + '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>' | |
| 84 | + ); | |
| 85 | + ?> | |
| 86 | + </p> | |
| 87 | + </div> | |
| 88 | + <?php endif; ?> | |
| 89 | + <?php elseif ( ! is_writable( WP_CONTENT_DIR ) ) : ?> | |
| 91 | 90 | <div class="notice notice-error"> |
| 92 | 91 | <p> |
| 93 | 92 | <?php |
| 94 | 93 | printf( |
| 95 | 94 | /* translators: %s: db.php drop-in path */ |
| 96 | - esc_html__( 'The SQLite plugin cannot be activated because a different %s drop-in already exists.', 'sqlite-database-integration' ), | |
| 97 | - '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>' | |
| 95 | + esc_html__( 'The SQLite plugin cannot be activated because the %s directory is not writable.', 'sqlite-database-integration' ), | |
| 96 | + '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '</code>' | |
| 98 | 97 | ); |
| 99 | 98 | ?> |
| 100 | 99 | </p> |
| 101 | 100 | </div> |
| 102 | - <?php endif; ?> | |
| 103 | - <?php elseif ( ! is_writable( WP_CONTENT_DIR ) ) : ?> | |
| 104 | - <div class="notice notice-error"> | |
| 105 | - <p> | |
| 106 | - <?php | |
| 107 | - printf( | |
| 108 | - /* translators: %s: db.php drop-in path */ | |
| 109 | - esc_html__( 'The SQLite plugin cannot be activated because the %s directory is not writable.', 'sqlite-database-integration' ), | |
| 110 | - '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '</code>' | |
| 111 | - ); | |
| 112 | - ?> | |
| 113 | - </p> | |
| 114 | - </div> | |
| 115 | - <?php else : ?> | |
| 116 | - <div class="notice notice-success"> | |
| 117 | - <p><?php esc_html_e( 'All checks completed successfully, your site can use an SQLite database. You can proceed with the installation.', 'sqlite-database-integration' ); ?></p> | |
| 118 | - </div> | |
| 119 | - <h2><?php esc_html_e( 'Important note', 'sqlite-database-integration' ); ?></h2> | |
| 120 | - <p><?php esc_html_e( 'This plugin will switch to a separate database and install WordPress in it. You will need to reconfigure your site, and start with a fresh site. Disabling the plugin you will get back to your previous MySQL database, with all your previous data intact.', 'sqlite-database-integration' ); ?></p> | |
| 101 | + <?php else : ?> | |
| 102 | + <div class="notice notice-success"> | |
| 103 | + <p><?php esc_html_e( 'All checks completed successfully, your site can use an SQLite database. You can proceed with the installation.', 'sqlite-database-integration' ); ?></p> | |
| 104 | + </div> | |
| 105 | + <h2><?php esc_html_e( 'Important note', 'sqlite-database-integration' ); ?></h2> | |
| 106 | + <p><?php esc_html_e( 'This plugin will switch to a separate database and install WordPress in it. You will need to reconfigure your site, and start with a fresh site. Disabling the plugin you will get back to your previous MySQL database, with all your previous data intact.', 'sqlite-database-integration' ); ?></p> | |
| 107 | + <p><?php esc_html_e( 'By clicking the button below, you will be redirected to the WordPress installation screen to setup your new database', 'sqlite-database-integration' ); ?></p> | |
| 121 | 108 | |
| 122 | - <?php if ( $override_db_dropin ) : ?> | |
| 123 | - <p> | |
| 124 | - <strong>NOTE:</strong> | |
| 125 | - <?php | |
| 126 | - printf( | |
| 127 | - /* translators: %s: db.php drop-in path */ | |
| 128 | - esc_html__( 'We’ve detected an existing database drop-in file at %s, created by the Query Monitor plugin.', 'sqlite-database-integration' ), | |
| 129 | - '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>' | |
| 130 | - ); | |
| 131 | - ?> | |
| 132 | - <?php esc_html_e( 'To enable SQLite support, this file will need to be replaced.', 'sqlite-database-integration' ); ?> | |
| 133 | - <?php esc_html_e( 'The Query Monitor plugin will continue to function correctly after the change. You can safely proceed with the installation.', 'sqlite-database-integration' ); ?> | |
| 134 | - </p> | |
| 109 | + <a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sqlite-integration&confirm-install' ), 'sqlite-install' ) ); ?>"><?php esc_html_e( 'Install SQLite database', 'sqlite-database-integration' ); ?></a> | |
| 135 | 110 | <?php endif; ?> |
| 136 | - | |
| 137 | - <p><?php esc_html_e( 'By clicking the button below, you will be redirected to the WordPress installation screen to setup your new database', 'sqlite-database-integration' ); ?></p> | |
| 138 | - | |
| 139 | - <a class="button button-primary" href="<?php echo esc_url( wp_nonce_url( admin_url( 'admin.php?page=sqlite-integration&confirm-install' ), 'sqlite-install' ) ); ?>"><?php esc_html_e( 'Install SQLite database', 'sqlite-database-integration' ); ?></a> | |
| 140 | 111 | <?php endif; ?> |
| 141 | 112 | </div> |
| 142 | 113 | <?php |
| 143 | 114 | } |