notifications.php (10861B)
1 <?php 2 3 4 function extendthemes_remote_notifications_handle($data) 5 { 6 $url = "https://extendthemes.com/materialis/"; 7 if ($data['coupon_code']) { 8 $data['buttons']['primary'] = array( 9 'text' => 'Get the offer', 10 'url' => add_query_arg('coupon', $data['coupon_code'], $url), 11 ); 12 } 13 14 ?> 15 <div class="extendthemes-remote-notification extendthemes-remote-notification-<?php echo esc_attr($data['notification_id']); ?>"> 16 17 <div class="left-container"> 18 <div class="message"> 19 <?php echo wpautop(trim($data['message'])); ?> 20 </div> 21 </div> 22 23 <div class="right-container"> 24 <?php foreach ($data['buttons'] as $key => $button_data): ?> 25 <?php if ( ! $button_data) { 26 continue; 27 } ?> 28 <a target="_blank" href="<?php echo $button_data['url']; ?>" class="button button-<?php echo esc_attr($key); ?>"><?php echo esc_html($button_data['text']); ?></a> 29 <?php endforeach; ?> 30 </div> 31 <style> 32 [data-cp-notification-name="extendthemes_remote_notification_materialis_<?php echo $data['notification_id']; ?>"] { 33 background-image: url("<?php echo $data['background_image'];?>"); 34 background-size: cover; 35 background-repeat: no-repeat; 36 } 37 38 [data-cp-notification-name="extendthemes_remote_notification_materialis_<?php echo $data['notification_id']; ?>"] .message p:first-child { 39 font-size: 20px; 40 } 41 42 <?php echo str_replace("#ID","[data-cp-notification-name=\"extendthemes_remote_notification_materialis_{$data['notification_id']}\"]",$data['custom_css']); ?> 43 </style> 44 </div> 45 <?php 46 } 47 48 49 // some notifications style 50 51 add_action('admin_head', function () { 52 ?> 53 <style type="text/css"> 54 55 .extendthemes-remote-notification { 56 display: -webkit-box; 57 display: -webkit-flex; 58 display: -moz-flex; 59 display: -ms-flexbox; 60 display: flex; 61 -webkit-box-flex: 0; 62 -webkit-flex: 0 1 auto; 63 -moz-box-flex: 0; 64 -moz-flex: 0 1 auto; 65 -ms-flex: 0 1 auto; 66 flex: 0 1 auto; 67 -webkit-box-direction: normal; 68 -webkit-flex-direction: row; 69 -moz-flex-direction: row; 70 -ms-flex-direction: row; 71 flex-direction: row; 72 -webkit-flex-wrap: wrap; 73 -moz-flex-wrap: wrap; 74 -ms-flex-wrap: wrap; 75 flex-wrap: wrap; 76 margin-right: -15px; 77 margin-left: -15px; 78 -webkit-flex-basis: auto; 79 -moz-flex-basis: auto; 80 -ms-flex-preferred-size: auto; 81 flex-basis: auto; 82 -webkit-box-align: center; 83 -ms-flex-align: center; 84 -webkit-align-items: center; 85 -moz-align-items: center; 86 align-items: center; 87 } 88 89 .extendthemes-remote-notification .left-container { 90 display: flex; 91 align-items: center; 92 flex-basis: 0; 93 flex-grow: 1; 94 } 95 96 .extendthemes-remote-notification .right-container { 97 display: flex; 98 -webkit-flex-shrink: 0; 99 -moz-flex-shrink: 0; 100 -ms-flex-negative: 0; 101 flex-shrink: 0; 102 -webkit-flex-basis: auto; 103 -moz-flex-basis: auto; 104 -ms-flex-preferred-size: auto; 105 flex-basis: auto; 106 -webkit-box-flex: 0; 107 -webkit-flex-grow: 0; 108 -moz-flex-grow: 0; 109 -ms-flex-positive: 0; 110 flex-grow: 0; 111 max-width: 100%; 112 padding-right: 20px; 113 } 114 115 .extendthemes-remote-notification .message { 116 padding-left: 20px; 117 } 118 119 .notice-cp-announcement { 120 border-left-width: 0px; 121 padding: 10px 10px 10px 30px; 122 background-image: linear-gradient(145deg, #c53a0b 0%, #4e273d 100%); 123 background-size: 5px 100%; 124 background-repeat: no-repeat; 125 background-position: top left; 126 } 127 128 .cp-notification.easter, 129 .cp-notification.winter { 130 position: relative; 131 overflow: hidden; 132 } 133 134 .cp-notification.easter > div, 135 .cp-notification.winter > div { 136 z-index: 10; 137 position: relative; 138 } 139 140 .cp-notification.easter:before, 141 .cp-notification.winter:before { 142 content: ''; 143 display: block; 144 z-index: 0; 145 position: absolute; 146 width: 100%; 147 height: 100%; 148 background-image: url(https://extendthemes.com/assets/general/flakes.png); 149 background-size: 40%; 150 background-repeat: repeat; 151 opacity: 0.20; 152 left: 0; 153 top: 0; 154 } 155 156 .cp-notification.easter:before { 157 background-image: url(https://extendthemes.com/assets/general/easter-bg.jpg); 158 opacity: 0.175; 159 160 } 161 162 .extendthemes-remote-notification .button-primary, 163 .extendthemes-remote-notification .button-primary:focus, 164 .extendthemes-remote-notification .button-primary:hover, 165 .notice-cp-announcement .button-primary.main, 166 .notice-cp-announcement .button-primary.main:focus, 167 .notice-cp-announcement .button-primary.main:hover { 168 outline: none; 169 border: none; 170 background-color: transparent; 171 background-image: linear-gradient(145deg, #c53107 0%, #4e273d 100%); 172 text-shadow: none; 173 transition: all .3s linear; 174 box-shadow: 0 1px 0px 0px rgba(0, 0, 0, 0.1); 175 height: auto; 176 min-width: 7em; 177 text-align: center; 178 padding: 0.1em 1em; 179 } 180 181 .notice-cp-announcement .button-primary.main:hover { 182 box-shadow: 0 2px 2px 1px rgba(0, 0, 0, 0.28); 183 } 184 185 .notice-cp-announcement .buttons-holder { 186 padding-top: 6px; 187 } 188 189 .notice-cp-announcement .buttons-holder a { 190 margin-right: 4px; 191 } 192 193 .notice-cp-announcement .buttons-holder a:last-of-type { 194 margin-right: 0px; 195 } 196 </style> 197 <?php 198 }); 199 200 201 // the notifications content display actions 202 203 function cp_notification_winter_holiday_2017_active_callback() 204 { 205 $compareTO = "materialis"; 206 $ss = get_stylesheet(); 207 208 /** @var WP_Theme $theme */ 209 $theme = wp_get_theme(); 210 211 $template = $theme->get('Template'); 212 if ($template) { 213 $ss = $template; 214 } 215 216 if ($ss === $compareTO) { 217 return true; 218 } else { 219 return false; 220 } 221 } 222 223 function cp_notification_discount_offer($data) 224 { 225 $props = isset($data['props']) ? $data['props'] : array(); 226 $props = array_merge( 227 array( 228 'message' => 'Discount offer', 229 'coupon' => false, 230 'buttons' => array(), 231 ), $props 232 ); 233 234 ?> 235 <div> 236 <div> 237 <div style="float: left;"> 238 <p style="font-size: 20px;"><?php echo $props['message']; ?></p> 239 </div> 240 <div style="float: right;width: 50%;text-align: right; padding-top: 0.63em;padding-right: 2em;"> 241 <?php if ($props['coupon']): ?> 242 <p class="coupon-code"><?php echo $props['coupon']; ?></p> 243 <?php endif; ?> 244 <div class="buttons-holder"> 245 <?php foreach ($props['buttons'] as $button): ?> 246 <?php $button = array_merge( 247 array( 248 'class' => 'primary', 249 'link' => '#', 250 'label' => 'Click Me', 251 ), 252 $button 253 ); ?> 254 <a href="<?php echo $button['link']; ?>" target="_blank" class="button button-<?php echo $button['class']; ?>"><?php echo $button['label']; ?></a> 255 <?php endforeach; ?> 256 </div> 257 </div> 258 <div class="wp-clearfix"></div> 259 </div> 260 261 262 </div> 263 <?php 264 } 265 266 // the notifications list 267 268 return array( 269 array( 270 "name" => "winter_holiday_2017", 271 "dismissible" => true, 272 "start" => '20-12-2017', 273 "end" => '10-1-2018', 274 "type" => "cp-announcement winter", 275 "handle" => "cp_notification_discount_offer", 276 "active_callback" => "cp_notification_winter_holiday_2017_active_callback", 277 "props" => array( 278 "message" => "Winter Holidays Special Offer - <span style='color:red'>20% discount </span> for <strong>Materialis PRO</strong>", 279 "buttons" => array( 280 array( 281 'class' => 'primary main', 282 'link' => 'https://extendthemes.com/mesmerize/#pricing', 283 'label' => 'Get the offer', 284 ), 285 array( 286 'class' => 'primary', 287 'label' => 'See PRO Features', 288 'link' => 'https://extendthemes.com/mesmerize/#content-1', 289 ), 290 ), 291 ), 292 293 ), 294 295 array( 296 "name" => "summer_sale_2018", 297 "dismissible" => true, 298 "start" => '10-08-2018', 299 "end" => '27-08-2018', 300 "type" => "cp-announcement ", 301 "handle" => "cp_notification_discount_offer", 302 "active_callback" => "cp_notification_winter_holiday_2017_active_callback", 303 "props" => array( 304 "message" => "Summer Sale - <span style='color:red'>20% discount </span> for all <strong>Materialis PRO</strong> licenses", 305 "buttons" => array( 306 array( 307 'class' => 'primary main', 308 'link' => 'https://extendthemes.com/mesmerize/#pricing', 309 'label' => 'Get the offer', 310 ), 311 array( 312 'class' => 'primary', 313 'label' => 'See PRO Features', 314 'link' => 'https://extendthemes.com/mesmerize/#content-1', 315 ), 316 ), 317 ), 318 319 ), 320 );