Skip to content

Commit 0cb3bc7

Browse files
committed
Simplify nested conditions
1 parent b170a8c commit 0cb3bc7

File tree

1 file changed

+44
-46
lines changed

1 file changed

+44
-46
lines changed

admin-page.php

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -46,68 +46,66 @@ function sqlite_integration_admin_screen() {
4646
);
4747
?>
4848
</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' ) ); ?>">
49+
<?php elseif ( ! extension_loaded( 'pdo_sqlite' ) ) : ?>
50+
<div class="notice notice-error">
51+
<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>
52+
</div>
53+
<?php elseif ( file_exists( WP_CONTENT_DIR . '/db.php' ) && ! defined( 'SQLITE_DB_DROPIN_VERSION' ) ) : ?>
54+
<?php if ( defined( 'PERFLAB_SQLITE_DB_DROPIN_VERSION' ) ) : ?>
55+
<div class="notice notice-warning">
56+
<p>
6857
<?php
6958
printf(
7059
/* translators: %s: db.php drop-in path */
71-
esc_html__( 'Update %s file', 'sqlite-database-integration' ),
60+
esc_html__( 'An older %s file was detected. Please click the button below to update the file.', 'sqlite-database-integration' ),
7261
'<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
7362
);
7463
?>
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 ) ) : ?>
64+
</p>
65+
</div>
66+
<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' ) ); ?>">
67+
<?php
68+
printf(
69+
/* translators: %s: db.php drop-in path */
70+
esc_html__( 'Update %s file', 'sqlite-database-integration' ),
71+
'<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
72+
);
73+
?>
74+
</a>
75+
<?php else : ?>
9076
<div class="notice notice-error">
9177
<p>
9278
<?php
9379
printf(
9480
/* translators: %s: db.php drop-in path */
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>'
81+
esc_html__( 'The SQLite plugin cannot be activated because a different %s drop-in already exists.', 'sqlite-database-integration' ),
82+
'<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
9783
);
9884
?>
9985
</p>
10086
</div>
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>
108-
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>
11087
<?php endif; ?>
88+
<?php elseif ( ! is_writable( WP_CONTENT_DIR ) ) : ?>
89+
<div class="notice notice-error">
90+
<p>
91+
<?php
92+
printf(
93+
/* translators: %s: db.php drop-in path */
94+
esc_html__( 'The SQLite plugin cannot be activated because the %s directory is not writable.', 'sqlite-database-integration' ),
95+
'<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '</code>'
96+
);
97+
?>
98+
</p>
99+
</div>
100+
<?php else : ?>
101+
<div class="notice notice-success">
102+
<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>
103+
</div>
104+
<h2><?php esc_html_e( 'Important note', 'sqlite-database-integration' ); ?></h2>
105+
<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>
106+
<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>
107+
108+
<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>
111109
<?php endif; ?>
112110
</div>
113111
<?php

0 commit comments

Comments
 (0)