is_blog_installed()
Checks if the site is installed. It checks for the presence of the siteurl option and tables in the database. The result is cached.
After checking the siteurl option (if it is not present), the function checks for the presence of tables in the DB. If tables are found, you will see the error __( 'Error establishing a database connection' ). This situation can occur when the options table is corrupted and the siteurl option cannot be retrieved, but the site is still installed. Therefore, if the siteurl option could not be found, the function checks for the presence of tables. If there are no tables in the DB, then the site is not installed.
The function does nothing and always returns true if we are in database repair/restore mode.
No Hooks.
Returns
true|false.
Usage
if( is_blog_installed() ){
// the site is installed!
}
Examples
#1 Check if the site is installed, before registering the widget
function widgets_init() {
if ( ! is_blog_installed() ) {
return;
}
register_widget( 'WP_Widget_Black_Studio_TinyMCE' );
}
Notes
- Global. wpdb. $wpdb WordPress database abstraction object.
Changelog
| Since 2.1.0 | Introduced. |