HTML
1 year ago
views
5 months ago
Apply.php
6 months ago
Cron.php
1 year ago
CronJob.php
7 months ago
CronJobs.php
2 months ago
Crypt.php
1 month ago
DownloadStats.php
5 months ago
Email.php
5 days ago
EmailCron.php
1 year ago
FileSystem.php
1 year ago
Installer.php
1 day ago
Messages.php
1 year ago
Query.php
4 months ago
Session.php
1 day ago
Settings.php
4 years ago
SimpleMath.php
4 years ago
TempStorage.php
1 day ago
Template.php
5 months ago
UI.php
6 months ago
Updater.php
4 years ago
UserAgent.php
2 years ago
__.php
1 month ago
__MailUI.php
3 years ago
Messages.php
123 lines
| 1 | <?php |
| 2 | namespace WPDM\__; |
| 3 | |
| 4 | class Messages { |
| 5 | |
| 6 | public $template = "blank"; |
| 7 | |
| 8 | public static function fullPage($title, $msg, $type = 'error'){ |
| 9 | include Template::locate("message.php", __DIR__.'/views'); |
| 10 | die(); |
| 11 | } |
| 12 | |
| 13 | public static function message($msg, $die = 0, $style = 'embed'){ |
| 14 | if(is_array($msg)) { |
| 15 | $title = esc_js($msg['title']); |
| 16 | $type = sanitize_html_class($msg['type']); |
| 17 | $_message = esc_js($msg['message']); |
| 18 | if($style === 'modal') |
| 19 | $message = "<script>WPDM.bootAlert('{$title}', '<div class=\'text-{$type}\'>{$_message}</div>')</script>"; |
| 20 | else if($style === 'notify') |
| 21 | $message = "<script>WPDM.notify('<strong>{$msg['title']}</strong><br/>{$_message}', '{$msg['type']}', 'top-right')</script>"; |
| 22 | else |
| 23 | $message = "<div class='w3eden'><div class='alert alert-{$msg['type']}' data-title='{$msg['title']}'>{$_message}</div></div>"; |
| 24 | } |
| 25 | else { |
| 26 | $msg = esc_js($msg); |
| 27 | if($style === 'mpdal') |
| 28 | $message = "<script>WPDM.bootAlert('Attention Please!', '{$msg}')</script>"; |
| 29 | else if($style === 'notify') |
| 30 | $message = "<script>WPDM.notify('{$msg}', 'info', 'top-right')</script>"; |
| 31 | else |
| 32 | $message = $msg; |
| 33 | } |
| 34 | if($die==-1) return $message; |
| 35 | if($die==0) |
| 36 | echo wp_kses_post($message); |
| 37 | if($die==1) { |
| 38 | wp_die($message); |
| 39 | } |
| 40 | return true; |
| 41 | } |
| 42 | |
| 43 | public static function error($msg, $die = 0, $style = 'embed'){ |
| 44 | if(!is_array($msg)) { |
| 45 | $message = $msg; |
| 46 | $msg = array(); |
| 47 | $msg['message'] = $message; |
| 48 | } |
| 49 | if(!isset($msg['title'])) $msg['title'] = 'Error!'; |
| 50 | $msg['type'] = 'danger'; |
| 51 | $msg['icon'] = 'exclamation-triangle'; |
| 52 | return self::Message($msg, $die, $style); |
| 53 | } |
| 54 | |
| 55 | public static function warning($msg, $die = 0, $style = 'embed'){ |
| 56 | if(!is_array($msg)) { |
| 57 | $message = $msg; |
| 58 | $msg = array(); |
| 59 | $msg['message'] = $message; |
| 60 | } |
| 61 | if(!isset($msg['title'])) $msg['title'] = 'Warning!'; |
| 62 | $msg['type'] = 'warning'; |
| 63 | $msg['icon'] = 'exclamation-circle'; |
| 64 | return self::Message($msg, $die, $style); |
| 65 | } |
| 66 | |
| 67 | public static function info($msg, $die = 0, $style = 'embed'){ |
| 68 | if(!is_array($msg)) { |
| 69 | $message = $msg; |
| 70 | $msg = array(); |
| 71 | $msg['message'] = $message; |
| 72 | } |
| 73 | if(!isset($msg['title'])) $msg['title'] = 'Attention!'; |
| 74 | $msg['type'] = 'info'; |
| 75 | $msg['icon'] = 'info-circle'; |
| 76 | return self::Message($msg, $die, $style); |
| 77 | } |
| 78 | |
| 79 | public static function success($msg, $die = 0, $style = 'embed'){ |
| 80 | if(!is_array($msg)) { |
| 81 | $message = $msg; |
| 82 | $msg = array(); |
| 83 | $msg['message'] = $message; |
| 84 | } |
| 85 | if(!isset($msg['title'])) $msg['title'] = 'Awesome!'; |
| 86 | $msg['type'] = 'success'; |
| 87 | $msg['icon'] = 'check-circle'; |
| 88 | return self::Message($msg, $die, $style); |
| 89 | } |
| 90 | |
| 91 | public static function decode_html($html){ |
| 92 | $html = htmlspecialchars_decode($html); |
| 93 | $html = html_entity_decode($html, ENT_QUOTES); |
| 94 | $html = stripslashes_deep($html); |
| 95 | return $html; |
| 96 | } |
| 97 | |
| 98 | public static function download_limit_exceeded($ID = null){ |
| 99 | $message = get_option("__wpdm_download_limit_exceeded"); |
| 100 | $message = self::decode_html($message); |
| 101 | $message = __::sanitize_var($message, 'kses'); |
| 102 | $message = trim($message) !== '' ? $message : __( "Download Limit Exceeded!", "download-manager" ); |
| 103 | return $message; |
| 104 | } |
| 105 | |
| 106 | public static function login_required($ID = null){ |
| 107 | $message = get_option("wpdm_login_msg"); |
| 108 | $message = self::decode_html($message); |
| 109 | $message = __::sanitize_var($message, 'kses'); |
| 110 | $message = trim($message) !== '' ? $message : WPDM()->user->login->modalLoginFormBtn(['class' => 'btn btn-danger', 'label' => '<i class="fas fa-lock mr-3"></i>'.__( "Login", "download-manager" )]); |
| 111 | return $message; |
| 112 | } |
| 113 | |
| 114 | public static function permission_denied($ID = null, $default = ''){ |
| 115 | $message = get_option("__wpdm_permission_denied_msg"); |
| 116 | $message = self::decode_html($message); |
| 117 | $message = __::sanitize_var($message, 'kses'); |
| 118 | if(trim($message === '')) $message = wpdm_escs($default); |
| 119 | $message = trim($message) !== '' ? $message : WPDM()->ui->button('<i class="fas fa-lock mr-3"></i>'.__( "Access Denied", "download-manager" ), ['class' => 'btn btn-danger']); |
| 120 | return $message; |
| 121 | } |
| 122 | } |
| 123 |