Adding a mechanism to display admin notices.
This commit is contained in:
parent
77850f09a1
commit
53f84f87f5
|
@ -33,6 +33,7 @@ if (!class_exists("Owark")) {
|
||||||
private $post_id = -1;
|
private $post_id = -1;
|
||||||
private $post_type = "";
|
private $post_type = "";
|
||||||
private $version = '0.1';
|
private $version = '0.1';
|
||||||
|
private $notices = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
|
@ -77,6 +78,7 @@ if (!class_exists("Owark")) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function sanity_checks(){
|
function sanity_checks(){
|
||||||
|
|
||||||
$installed_ver = get_option( "owark_db_version" );
|
$installed_ver = get_option( "owark_db_version" );
|
||||||
if ($installed_ver != $this->version) {
|
if ($installed_ver != $this->version) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
@ -93,8 +95,28 @@ if (!class_exists("Owark")) {
|
||||||
dbDelta($sql);
|
dbDelta($sql);
|
||||||
|
|
||||||
update_option( "owark_db_version", $this->version );
|
update_option( "owark_db_version", $this->version );
|
||||||
|
$this->notices = "<div class=\"updated fade\"><p><strong>The owark table has been installed or upgraded to version {$this->version}</strong></p></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->notices != '') {
|
||||||
|
add_action('admin_notices', array($this, 'admin_notices'));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show admin notices
|
||||||
|
*
|
||||||
|
* @package owark
|
||||||
|
* @since 0.1
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function admin_notices(){
|
||||||
|
|
||||||
|
echo $this->notices;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue