function gnt_after_install() { if (!is_admin()) { return; } $installed = get_transient('_gnt_installed'); // Exit if not in admin or the transient doesn't exist if (false === $installed) { return; } // Create the customers database (this ensures it creates it on multisite instances where it is network activated) $notification_db = new GNT_Notification_DB(); $notification_db->create_table(); }
/** * Prepare all the items to be displayed * * @access public * @return void */ public function prepare_items() { $columns = $this->get_columns(); $sortable = $this->get_sortable_columns(); $hidden = array(); $this->_column_headers = array($columns, $hidden, $sortable); $per_page = 20; $current_page = $this->get_pagenum(); $total_items = $this->get_total(); $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page)); $notification_db = new GNT_Notification_DB(); if (!isset($_GET['status']) || isset($_GET['status']) && $_GET['status'] == 'all') { $this->items = $notification_db->get_data(); } else { if (isset($_GET['status']) && $_GET['status'] == 'active') { $this->items = $notification_db->get_active_data(); } else { $this->items = $notification_db->get_inactive_data(); } } }
* GNU General Public License for more details. * * ================================================================= */ ?> <?php include_once 'header.php'; ?> <h1><?php _e('Add New', GET_NOTIFIED_TEXT_DOMAIN); ?> </h1> <?php $notification_db = new GNT_Notification_DB(); if (isset($_GET['id'])) { $notification = $notification_db->get_data_from_id($_GET['id']); } else { $notification = $notification_db->default_data(); } ?> <form method="post"> <table class="form-table"> <tbody> <!-- Name --> <tr>
/** * Display on the Contents of the Add New Page * * @access public * @return void */ function gnt_add_new_content() { $notification_db = new GNT_Notification_DB(); // Save a Notification if (isset($_POST['submit']) && check_admin_referer('save-notification')) { // Edit if (isset($_GET['action']) && $_GET['action'] == 'edit') { $data = $notification_db->get_data_from_id($_GET['id']); $data['name'] = isset($_POST[GET_NOTIFIED_PREFIX . 'name']) ? $notification_db->clean_data($_POST[GET_NOTIFIED_PREFIX . 'name']) : 'My Notification'; $notification_db->update_data($_GET['id'], $data); } else { $data['name'] = isset($_POST[GET_NOTIFIED_PREFIX . 'name']) ? $notification_db->clean_data($_POST[GET_NOTIFIED_PREFIX . 'name']) : 'My Notification'; $notification_db->add_data($data); } } include GET_NOTIFIED_PLUGIN_DIR . 'views/add-new-page.php'; }