subclass global bits of addons

This commit is contained in:
John Bintz 2009-07-08 20:07:52 -04:00
parent 65075f1849
commit cd77f0a83d
3 changed files with 37 additions and 5 deletions

View File

@ -1,6 +1,6 @@
<?php <?php
class ComicPressAddonCore { class ComicPressAddonCore extends ComicPressAddon {
function init($comicpress) { function init($comicpress) {
add_action('admin_init', array(&$this, 'add_theme_page')); add_action('admin_init', array(&$this, 'add_theme_page'));
@ -109,6 +109,8 @@ class ComicPressAddonCore {
} }
} }
$this->comicpress->save(); $this->comicpress->save();
$this->info("ComicPress configuration updated.");
} }
} }

View File

@ -0,0 +1,27 @@
<?php
class ComicPressAddon {
var $messages = array(
'info' => array(),
'warn' => array(),
'error' => array()
);
function info($message) { $this->messages['info'][] = $message; }
function warn($message) { $this->messages['warn'][] = $message; }
function error($message) { $this->messages['error'][] = $message; }
function display_messages() {
foreach ($this->messages as $type => $messages) {
if (!empty($messages)) {
echo '<div class="updated fade cp-' . $type . '">';
foreach ($messages as $message) {
echo '<p>' . $message . '</p>';
}
echo '</div>';
}
}
}
}
?>

View File

@ -57,10 +57,13 @@ function __comicpress_init() {
if (class_exists($classname)) { if (class_exists($classname)) {
$addon = new $classname(); $addon = new $classname();
$addon->init(&$comicpress); $addon->init(&$comicpress);
if (is_array($_POST['cp'])) { if (is_admin()) {
if (isset($_POST['cp']['_nonce'])) { add_action('admin_notices', array(&$addon, 'display_messages'));
if (wp_verify_nonce($_POST['cp']['_nonce'], 'comicpress')) { if (is_array($_POST['cp'])) {
$addon->handle_update(); if (isset($_POST['cp']['_nonce'])) {
if (wp_verify_nonce($_POST['cp']['_nonce'], 'comicpress')) {
$addon->handle_update();
}
} }
} }
} }