### Create an Alert
To create and display an alert just coding:
$alert = new WPDKUIAlert( 'my-alert', 'Hello World!' );
$alert->display();
OR
class myAlert extends WPDKUIAlert {
Internal construct
public function __construct()
{
parent::__construct( $id, false, $type, $title );
}
Override content
public function content()
{
echo 'Hello...';
}
}
/** * Fires at the end of the 'Personal Options' settings table on the user editing screen. * * @since WP 2.7.0 * * @param WP_User $profileuser The current WP_User object. */ public function personal_options($profileuser) { $message = __('This view <strong>is enhanced</strong> by wpXtreme and WPDK framework. Please, <strong><a href="#wpdk">have a look below</a></strong> for additional information.', WPDK_TEXTDOMAIN); $alert = new WPDKUIAlert('wpdk-alert-personal_options', $message, WPDKUIAlertType::INFORMATION); $alert->dismissPermanent = true; $alert->display(); }
/** * Return TRUE to stop the display of list item table, FALSE otherwise. Default return FALSE if you do not override. * * You can override this method to process the action request sent from list table. * You can processing bulk and single action. This method must return a boolean in order to re-processed the items * list view. * * @brief Process the bulk actions and standard actions * * @return bool */ public function process_bulk_action() { // Process the action result $action_result = $this->action_result(); if (is_object($action_result)) { // Get content $content = $action_result->data; // Sanitize content if (!is_string($content)) { WPDKHTML::startCompress(); var_dump($action_result->data); $content = WPDKHTML::endCompress(); } // Get type $type = $action_result->type; // Alert $alert = new WPDKUIAlert(false, $content, $type, $action_result->message); $alert->display(); } elseif (!empty($action_result)) { $alert = new WPDKUIAlert(false, __('Operation successfully!', WPDK_TEXTDOMAIN), WPDKUIAlertType::SUCCESS, __('Information', WPDK_TEXTDOMAIN)); $alert->display(); } return false; }
/** * Drawing control * * @brief Draw */ public function draw() { $value = isset($this->item['value']) ? $this->item['value'] : ''; $title = isset($this->item['title']) ? $this->item['title'] : ''; $alert_type = isset($this->item['alert_type']) ? $this->item['alert_type'] : WPDKUIAlertType::INFORMATION; $alert = new WPDKUIAlert($this->id, $value, $alert_type, $title); $alert->dismissButton = isset($this->item['dismiss_button']) ? $this->item['dismiss_button'] : true; // @deprecated 'permanent_dismiss' since 1.5.6 - use 'dismiss_permanent' instead $alert->dismissPermanent = isset($this->item['permanent_dismiss']) ? $this->item['permanent_dismiss'] : false; // TODO Backward compatibility - $alert->dismissPermanent = isset($this->item['dismiss_permanent']) ? $this->item['dismiss_permanent'] : $alert->dismissPermanent; $alert->class = isset($this->item['classes']) ? $this->item['classes'] : isset($this->item['class']) ? $this->item['class'] : ''; echo $this->contentWithKey('prepend'); $alert->display(); echo $this->contentWithKey('append'); }
/** * Hook for feedback. See `error` property too. * * @brief Feedback * * @return array */ public function wpdk_preferences_import_export_feedback() { $title = __('Warning!', WPDK_TEXTDOMAIN); $content = ''; switch ($this->error) { // ALL OK case self::ERROR_NONE: $title = __('Successfully!', WPDK_TEXTDOMAIN); $content = __('Import complete.', WPDK_TEXTDOMAIN); break; // ERROR while reading upload file // ERROR while reading upload file case self::ERROR_READ_FILE: $content = sprintf('%s %s', __('Error while read file! Error code:', WPDK_TEXTDOMAIN), $_FILES['file']['error']); break; // ERROR while uncompress upload file // ERROR while uncompress upload file case self::ERROR_MALFORMED_FILE: $content = __('Malformed file.', WPDK_TEXTDOMAIN); break; // Version export error // Version export error case self::ERROR_VERSION: $content = __('Wrong file version! You are try to import a most recent of export file. Please update your plugin before continue.', WPDK_TEXTDOMAIN); break; } $alert = new WPDKUIAlert('feedback', $content, empty($this->error) ? WPDKUIAlertType::SUCCESS : WPDKUIAlertType::WARNING, $title); $alert->display(); }