PluginProbe
SQLite Database Integration / 3.0.1
SQLite Database Integration v3.0.1
3.0.1 trunk 2.1.13 2.1.14 2.1.15 2.1.16 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.2.2 2.2.20 2.2.21 2.2.22 2.2.23 2.2.3 2.2.4 All 31 releases
sqlite-database-integration / admin-notices.php

admin-notices.php in SQLite Database Integration 3.0.1, at admin-notices.php

74 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Functions to add admin notices if necessary.
4 */
5
6 /**
7 * Add admin notices.
8 *
9 * When the plugin gets merged in wp-core, this is not to be ported.
10 */
11 function sqlite_plugin_admin_notice() {
12 if ( ! current_user_can( sqlite_plugin_get_manage_capability() ) ) {
13 return;
14 }
15
16 // Don't print notices in the plugin's admin screen.
17 global $current_screen;
18 if ( isset( $current_screen->base ) && 'settings_page_sqlite-integration' === $current_screen->base ) {
19 return;
20 }
21
22 // Bail early if the pdo_sqlite extension is not loaded.
23 if ( ! extension_loaded( 'pdo_sqlite' ) ) {
24 printf(
25 '<div class="notice notice-error"><p>%s</p></div>',
26 esc_html__( 'The SQLite Integration plugin is active, but the pdo_sqlite extension is missing from your server. Please make sure that pdo_sqlite is enabled in your PHP installation.', 'sqlite-database-integration' )
27 );
28 return;
29 }
30
31 /*
32 * If the SQLITE_DB_DROPIN_VERSION constant is not defined
33 * but there's a db.php file in the wp-content directory, then the module can't be activated.
34 * The module should not have been activated in the first place
35 * (there's a check in the can-load.php file), but this is a fallback check.
36 */
37 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) && ! defined( 'SQLITE_DB_DROPIN_VERSION' ) ) {
38 printf(
39 '<div class="notice notice-error"><p>%s</p></div>',
40 sprintf(
41 /* translators: 1: SQLITE_DB_DROPIN_VERSION constant, 2: db.php drop-in path */
42 __( 'The SQLite Integration module is active, but the %1$s constant is missing. It appears you already have another %2$s file present on your site. ', 'sqlite-database-integration' ),
43 '<code>SQLITE_DB_DROPIN_VERSION</code>',
44 '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>'
45 )
46 );
47
48 return;
49 }
50
51 if ( file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
52 return;
53 }
54
55 if ( ! wp_is_writable( WP_CONTENT_DIR ) ) {
56 printf(
57 '<div class="notice notice-error"><p>%s</p></div>',
58 esc_html__( 'The SQLite Integration plugin is active, but the wp-content/db.php file is missing and the wp-content directory is not writable. Please ensure the wp-content folder is writable, then deactivate the plugin and try again.', 'sqlite-database-integration' )
59 );
60 return;
61 }
62 // The dropin db.php is missing.
63 printf(
64 '<div class="notice notice-error"><p>%s</p></div>',
65 sprintf(
66 /* translators: 1: db.php drop-in path, 2: Admin URL to deactivate the module */
67 __( 'The SQLite Integration plugin is active, but the %1$s file is missing. Please <a href="%2$s">deactivate the plugin</a> and re-activate it to try again.', 'sqlite-database-integration' ),
68 '<code>' . esc_html( basename( WP_CONTENT_DIR ) ) . '/db.php</code>',
69 esc_url( self_admin_url( 'plugins.php' ) )
70 )
71 );
72 }
73 add_action( is_multisite() ? 'network_admin_notices' : 'admin_notices', 'sqlite_plugin_admin_notice' ); // Add the admin notices.
74