PluginProbe ʕ •ᴥ•ʔ
Download Manager / 3.3.62
Download Manager v3.3.62
3.3.62 3.3.61 3.3.60 3.3.59 3.3.58 3.3.57 3.3.56 trunk 2.1.3 2.3.0 2.5.96 2.5.97 2.6.2 2.6.96 2.8.3 2.9.99 3.0.4 3.1.05 3.1.07 3.1.08 3.1.11 3.1.12 3.1.14 3.1.17 3.1.18 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.2.04 3.2.13 3.2.14 3.2.16 3.2.18 3.2.19 3.2.21 3.2.22 3.2.23 3.2.24 3.2.25 3.2.27 3.2.28 3.2.29 3.2.30 3.2.31 3.2.32 3.2.33 3.2.34 3.2.35 3.2.37 3.2.38 3.2.39 3.2.40 3.2.41 3.2.42 3.2.43 3.2.44 3.2.45 3.2.46 3.2.47 3.2.48 3.2.49 3.2.50 3.2.51 3.2.52 3.2.53 3.2.54 3.2.55 3.2.56 3.2.57 3.2.58 3.2.59 3.2.60 3.2.61 3.2.63 3.2.64 3.2.65 3.2.66 3.2.67 3.2.68 3.2.69 3.2.70 3.2.71 3.2.72 3.2.73 3.2.74 3.2.75 3.2.76 3.2.77 3.2.78 3.2.79 3.2.80 3.2.81 3.2.82 3.2.83 3.2.84 3.2.85 3.2.86 3.2.87 3.2.88 3.2.89 3.2.90 3.2.91 3.2.92 3.2.93 3.2.94 3.2.95 3.2.96 3.2.97 3.2.98 3.2.99 3.3.00 3.3.01 3.3.02 3.3.03 3.3.04 3.3.05 3.3.06 3.3.07 3.3.08 3.3.09 3.3.10 3.3.11 3.3.12 3.3.13 3.3.14 3.3.15 3.3.16 3.3.17 3.3.18 3.3.19 3.3.20 3.3.21 3.3.22 3.3.23 3.3.24 3.3.25 3.3.26 3.3.27 3.3.28 3.3.29 3.3.30 3.3.31 3.3.32 3.3.33 3.3.34 3.3.35 3.3.36 3.3.37 3.3.38 3.3.39 3.3.40 3.3.41 3.3.42 3.3.43 3.3.44 3.3.45 3.3.46 3.3.47 3.3.48 3.3.49 3.3.50 3.3.51 3.3.52 3.3.53 3.3.54 3.3.55
download-manager / src / wpdm-functions.php
download-manager / src Last commit date
Admin 1 week ago AssetManager 1 week ago Category 2 years ago Form 6 months ago MediaLibrary 4 days ago Package 4 days ago User 4 days ago Widgets 2 years ago __ 4 days ago wpdm-core.php 5 months ago wpdm-functions.php 4 days ago wpdm-start-download.php 4 months ago wpdm-strings.php 3 years ago
wpdm-functions.php
1284 lines
1 <?php
2 global $wpdm_message, $btnclass;
3
4
5 use WPDM\__\__;
6 use WPDM\__\Email;
7 use WPDM\__\Crypt;
8 use WPDM\__\Messages;
9 use WPDM\__\Session;
10 use WPDM\__\Template;
11 use WPDM\__\TempStorage;
12 use WPDM\Category\CategoryController;
13 use WPDM\Package\Package;
14 use WPDM\Package\PackageLocks;
15
16 function wpdm_zip_package($package)
17 {
18 return WPDM()->package->zip($package['ID']);
19 }
20
21 /**
22 * Download contents as a file
23 * @param $filename
24 * @param $content
25 */
26 function wpdm_download_data($filename, $content)
27 {
28 WPDM()->fileSystem->downloadData($filename, $content);
29 }
30
31
32 /**
33 * @usage Create ZIP from given file list
34 * @param $files
35 * @param $zipname
36 * @return bool|string
37 */
38 function wpdm_zip_files($files, $zipname)
39 {
40 return \WPDM\__\FileSystem::zipFiles($files, $zipname);
41 }
42
43 /**
44 * @usage Download Given File
45 * @param $filepath
46 * @param $filename
47 * @param int $speed
48 * @param int $resume_support
49 * @param array $extras
50 */
51
52 function wpdm_download_file($filepath, $filename, $speed = 0, $resume_support = 1, $extras = array())
53 {
54 do_action("wpdm_download_success", $extras);
55 if (!file_exists($filepath)) Messages::fullPage("Download Error", "<div class='card bg-danger text-white text-left' style='min-width: 300px'><div class='card-header'>" . __("Download Error", "download-manager") . "</div><div class='card-body'>" . __("File Not Found!", "download-manager") . "</div></div>");
56 if (isset($_GET['play'])) $extras['play'] = sanitize_text_field($_GET['play']);
57 \WPDM\__\FileSystem::downloadFile($filepath, $filename, $speed, $resume_support, $extras);
58 }
59
60
61 /**
62 * @param $id
63 * @usage Returns the user roles who has access to specified package
64 * @return array|mixed
65 */
66 function wpdm_allowed_roles($id)
67 {
68 return WPDM()->package->allowedRoles($id);
69 }
70
71
72 /**
73 * @usage Check if current user has access to package or category
74 * @param $id
75 * @param string $type
76 *
77 * @return bool
78 */
79 function wpdm_user_has_access($id, $type = 'package')
80 {
81 return WPDM()->package->userCanAccess($id, $type);
82 }
83
84 /**
85 * @usage Verify Email Address
86 * @param $email
87 * @return bool
88 */
89 function wpdm_verify_email($email)
90 {
91 $dns_verify = get_option('__wpdm_verify_dns', 0);
92 $blocked_domains = explode("\n", str_replace("\r", "", get_option('__wpdm_blocked_domains', '')));
93 $blocked_emails = explode("\n", str_replace("\r", "", get_option('__wpdm_blocked_emails', '')));
94 $eparts = explode("@", $email);
95 if (!isset($eparts[1])) return false;
96 $domain = $eparts[1];
97 if (!is_email($email)) return false;
98 if (in_array($email, $blocked_emails)) return false;
99 if (in_array($domain, $blocked_domains)) return false;
100 if ($dns_verify && !checkdnsrr($domain, 'MX')) return false;
101 return true;
102 }
103
104
105 /**
106 * @usage Count files in a package
107 * @param $id
108 * @return int
109 */
110 function wpdm_package_filecount($id)
111 {
112 return WPDM()->package->fileCount($id);
113
114 }
115
116 /**
117 * @usage Calculate package size
118 * @param $id
119 * @return float|int|mixed|string
120 */
121 function wpdm_package_size($id)
122 {
123 return WPDM()->package->Size($id);
124 }
125
126 /**
127 * @usage Calculate file size
128 * @param $file
129 * @return float|int|mixed|string
130 */
131 function wpdm_file_size($file)
132 {
133 $file = WPDM()->fileSystem->absPath($file);
134 if(!$file) return '0.00 KB';
135 $size = filesize($file);
136 $size = $size / 1024;
137 if ($size > 1024) $size = number_format($size / 1024, 2) . ' MB';
138 else $size = number_format($size, 2) . ' KB';
139 return $size;
140 }
141
142 /**
143 * Get post excerpt
144 * @param $post
145 * @param int $length
146 * @param bool $word_break
147 * @param string $continue
148 * @return string
149 */
150 function wpdm_get_excerpt($post, $length = 100, $word_break = false, $continue = "...")
151 {
152 $post = is_object($post) ? $post : get_post($post);
153 if (!is_object($post)) return '';
154 $excerpt = get_the_excerpt($post);
155 if (!$excerpt) $excerpt = $post->post_content;
156 $excerpt = strip_tags($excerpt);
157 $excerpt = substr(trim($excerpt), 0, $length);
158 if (!$word_break) {
159 $excerpt = explode(" ", $excerpt);
160 array_pop($excerpt);
161 $excerpt = implode(" ", $excerpt);
162 }
163 return $excerpt . $continue;
164 }
165
166 /**
167 * @param $file
168 * @return array|mixed
169 */
170 function wpdm_basename($file)
171 {
172 if (strpos("~" . $file, "\\"))
173 $basename = explode("\\", $file);
174 else
175 $basename = explode("/", $file);
176 $basename = end($basename);
177 return $basename;
178 }
179
180 /**
181 * @usage Generate thumbnail dynamically
182 * @param $path
183 * @param $size
184 * @return mixed
185 */
186
187 function wpdm_dynamic_thumb($path, $size, $crop = false, $cache = true)
188 {
189 return \WPDM\__\FileSystem::imageThumbnail($path, $size[0], $size[1], $crop, $cache);
190 }
191
192
193 /**
194 * @usage Return Post Thumbail
195 * @param string $size
196 * @param bool $echo
197 * @param null $extra
198 * @return mixed|string|void
199 */
200 function wpdm_post_thumb($size = '', $echo = true, $extra = null)
201 {
202 global $post;
203 $size = $size ? $size : 'thumbnail';
204 $class = isset($extra['class']) ? $extra['class'] : '';
205 $crop = isset($extra['crop']) ? $extra['crop'] : get_option('__wpdm_crop_thumbs', false);
206 $alt = $post->post_title;
207 if (is_array($size)) {
208 $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
209 $large_image_url = isset($large_image_url[0]) ? $large_image_url[0] : '';
210 if ($large_image_url == '' && isset($extra['default'])) $large_image_url = $extra['default'];
211 if ($large_image_url != '') {
212 $path = str_replace(site_url('/'), ABSPATH, $large_image_url);
213 $thumb = wpdm_dynamic_thumb($path, $size, $crop);
214 $thumb = str_replace(ABSPATH, site_url('/'), $thumb);
215 $alt = get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true);
216 $img = "<img src='" . $thumb . "' alt='".esc_attr($alt)."' class='".esc_attr($class)."' />";
217 if ($echo) {
218 echo $img;
219 return true;
220 } else
221 return $img;
222 }
223 }
224 if ($echo && has_post_thumbnail($post->ID))
225 echo get_the_post_thumbnail($post->ID, $size, $extra);
226 else if (!$echo && has_post_thumbnail($post->ID))
227 return get_the_post_thumbnail($post->ID, $size, $extra);
228 else if ($echo)
229 echo "";
230 else
231 return "";
232 }
233
234 /**
235 * @usage Generate Thumnail for the given package
236 * @param $post
237 * @param string $size
238 * @param bool $echo
239 * @param null $extra
240 * @return mixed|string|void
241 */
242 function wpdm_thumb($post, $size = '', $echo = true, $extra = null)
243 {
244 if (is_int($post))
245 $post = get_post($post);
246 if(!$post) return '';
247 $size = $size ? $size : 'thumbnail';
248 $class = isset($extra['class']) ? $extra['class'] : '';
249 $crop = isset($extra['crop']) ? $extra['crop'] : get_option('__wpdm_crop_thumbs', false);
250 $alt = $post->post_title;
251 if (is_array($size)) {
252 $large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
253 if (!$large_image_url) return '';
254 $large_image_url = $large_image_url[0];
255 if ($large_image_url != '') {
256 $thumb = wpdm_dynamic_thumb($large_image_url, $size, $crop);
257 $thumb = str_replace(ABSPATH, site_url('/'), $thumb);
258 $alt = get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true);
259 if ($echo === 'url') return $thumb;
260 if ($alt === '') $alt = esc_attr(strip_tags(get_the_title($post->ID)));
261 $img = "<img src='" . $thumb . "' alt='".esc_attr($alt)."' class='".esc_attr($class)."' />";
262 if ($echo) {
263 echo $img;
264 return;
265 } else
266 return $img;
267 }
268 }
269 if ($echo && has_post_thumbnail($post->ID))
270 echo get_the_post_thumbnail($post->ID, $size, $extra);
271 else if (!$echo && has_post_thumbnail($post->ID))
272 return get_the_post_thumbnail($post->ID, $size, $extra);
273 else if ($echo)
274 echo "";
275 else
276 return "";
277 }
278
279 function wpdm_media_field($data)
280 {
281 ob_start();
282 $attrs = '';
283 if (isset($data['attrs'])) {
284 foreach ($data['attrs'] as $attr => $value) {
285 $attrs .= "$attr='$value' ";
286 }
287 }
288 ?>
289 <div class="input-group">
290 <input placeholder="<?php echo $data['placeholder']; ?>" <?php echo $attrs; ?> type="url"
291 name="<?php echo $data['name']; ?>"
292 id="<?php echo isset($data['id']) ? $data['id'] : ($id = uniqid()); ?>" class="form-control"
293 value="<?php echo isset($data['value']) ? $data['value'] : ''; ?>"/>
294 <span class="input-group-btn">
295 <button class="btn btn-secondary btn-media-upload" type="button"
296 rel="#<?php echo isset($data['id']) ? $data['id'] : $id; ?>"><i
297 class="far fa-image"></i></button>
298 </span>
299 </div>
300 <?php
301 return ob_get_clean();
302 }
303
304 function wpdm_image_selector($data)
305 {
306 ob_start();
307 $attrs = '';
308 if (isset($data['attrs'])) {
309 foreach ($data['attrs'] as $attr => $value) {
310 $attrs .= "$attr='$value' ";
311 }
312 }
313 $id = isset($data['id']) ? sanitize_text_field($data['id']) : uniqid();
314 ?>
315 <div class="panel panel-default text-center image-selector-panel" style="width: 250px">
316 <div class="panel-body">
317 <img id="<?php echo esc_attr($id); ?>"
318 src="<?php echo isset($data['value']) && $data['value'] != '' ? esc_attr(esc_url($data['value'])) : esc_attr(WPDM_BASE_URL . 'assets/images/image.png'); ?>"/>
319 </div>
320 <div class="panel-footer">
321 <input id="<?php echo esc_attr($id); ?>_hidden" type="hidden"
322 name="<?php echo esc_attr($data['name']); ?>"
323 value="<?php echo isset($data['value']) ? esc_attr($data['value']) : ''; ?>"/>
324 <button class="btn btn-info btn-block btn-image-selector" type="button"
325 rel="#<?php echo esc_attr($id); ?>"><i
326 class="far fa-image"></i> <?php isset($data['btnlabel']) ? esc_html($data['btnlabel']) : esc_html__('Select Image', 'download-manager'); ?>
327 </button>
328 </div>
329 </div>
330 <?php
331 return ob_get_clean();
332 }
333
334 function wpdm_image_uploader($data)
335 {
336 ob_start();
337 $attrs = '';
338 if (isset($data['attrs'])) {
339 foreach ($data['attrs'] as $attr => $value) {
340 $attrs .= "$attr='$value' ";
341 }
342 }
343 $default = isset($data['default']) ? $data['default'] : WPDM_BASE_URL . 'assets/images/image.png';
344 $id = isset($data['id']) ? sanitize_text_field($data['id']) : uniqid();
345 ?>
346 <div id="wpdm-upload-ui" class="panel panel-default text-center image-selector-panel" style="width: 250px">
347 <div class="panel-header text-muted" id="del-img">
348 Delete Image
349 </div>
350 <div id="wpdm-drag-drop-area">
351 <div class="panel-body">
352 <img id="<?php echo esc_attr($id); ?>"
353 src="<?php echo isset($data['value']) && $data['value'] != '' ? esc_attr($data['value']) : esc_attr($default); ?>"/>
354 </div>
355 <div class="panel-footer">
356 <input id="<?php echo esc_attr($id); ?>_hidden" type="hidden"
357 name="<?php echo esc_attr($data['name']); ?>"
358 value="<?php echo isset($data['value']) ? esc_attr($data['value']) : ''; ?>"/>
359
360 <button id="wpdm-browse-button" style="font-size: 9px;text-transform: unset" type="button"
361 class="btn btn-info btn-block"><?php echo isset($data['btnlabel']) ? esc_html($data['btnlabel']) : esc_html__('SELECT IMAGE', 'download-manager'); ?></button>
362 <div class="progress" id="wmprogressbar"
363 style="height: 30px !important;border-radius: 3px !important;margin: 0;position: relative;background: #0d406799;display: none;box-shadow: none">
364 <div id="wmprogress" class="progress-bar progress-bar-striped progress-bar-animated"
365 role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"
366 style="width: 0%;line-height: 30px;background-color: #007bff"></div>
367 <div class="fetfont"
368 style="font-size:9px;position: absolute;line-height: 30px;height: 30px;width: 100%;z-index: 999;text-align: center;color: #ffffff;font-weight: 800;letter-spacing: 1px">
369 UPLOADING... <span id="wmloaded">0</span>%
370 </div>
371 </div>
372
373 <?php
374
375 $plupload_init = array(
376 'runtimes' => 'html5,silverlight,flash,html4',
377 'browse_button' => 'wpdm-browse-button',
378 'container' => 'wpdm-upload-ui',
379 'drop_element' => 'wpdm-drag-drop-area',
380 'file_data_name' => 'wpdm_file',
381 'multiple_queues' => false,
382 'url' => admin_url('admin-ajax.php'),
383 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
384 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
385 'filters' => array(array('title' => __('Allowed Files'), 'extensions' => 'png,jpg,jpeg')),
386 'multipart' => true,
387 'urlstream_upload' => true,
388
389 // additional post data to send to our ajax hook
390 'multipart_params' => array(
391 '_ajax_nonce' => wp_create_nonce(NONCE_KEY),
392 'action' => esc_attr($data['action']), // the ajax action name
393 ),
394 );
395
396 $plupload_init['max_file_size'] = wp_max_upload_size() . 'b';
397
398 // we should probably not apply this filter, plugins may expect wp's media uploader...
399 $plupload_init = apply_filters('plupload_init', $plupload_init); ?>
400 <style>
401 #del-img {
402 position: absolute;
403 width: 100%;
404 padding: 5px;
405 z-index: 999999;
406 background: rgba(255, 255, 255, 0.9);
407 display: none;
408 cursor: pointer;
409 }
410
411 #wpdm-upload-ui:hover #del-img {
412 display: block;
413 }
414 </style>
415 <script type="text/javascript">
416
417 jQuery(function ($) {
418
419
420 var uploader = new plupload.Uploader(<?php echo json_encode($plupload_init); ?>);
421
422 uploader.bind('Init', function (up) {
423 var uploaddiv = $('#wpdm-upload-ui');
424
425 if (up.features.dragdrop) {
426 uploaddiv.addClass('drag-drop');
427 $('#drag-drop-area')
428 .bind('dragover.wp-uploader', function () {
429 uploaddiv.addClass('drag-over');
430 })
431 .bind('dragleave.wp-uploader, drop.wp-uploader', function () {
432 uploaddiv.removeClass('drag-over');
433 });
434
435 } else {
436 uploaddiv.removeClass('drag-drop');
437 $('#drag-drop-area').unbind('.wp-uploader');
438 }
439 });
440
441 uploader.init();
442
443 uploader.bind('Error', function (uploader, error) {
444 wpdm_bootModal('Error', error.message);
445 $('#wmprogressbar').hide();
446 $('#wpdm-browse-button').show();
447 });
448
449
450 uploader.bind('FilesAdded', function (up, files) {
451 /*var hundredmb = 100 * 1024 * 1024, max = parseInt(up.settings.max_file_size, 10); */
452
453 $('#wpdm-browse-button').hide(); /*attr('disabled', 'disabled'); */
454 $('#wmprogressbar').show();
455
456 plupload.each(files, function (file) {
457 $('#wmprogress').css('width', file.percent + "%");
458 $('#wmloaded').html(file.percent);
459 /*jQuery('#wpdm-browse-button').hide(); //.html('<span id="' + file.id + '"><i class="fas fa-sun fa-spin"></i> Uploading (<span>' + plupload.formatSize(0) + '</span>/' + plupload.formatSize(file.size) + ') </span>');*/
460 });
461
462 up.refresh();
463 up.start();
464 });
465
466 uploader.bind('UploadProgress', function (up, file) {
467 /*jQuery('#' + file.id + " span").html(plupload.formatSize(parseInt(file.size * file.percent / 100)));*/
468 $('#wmprogress').css('width', file.percent + "%");
469 $('#wmloaded').html(file.percent);
470 });
471
472
473 uploader.bind('FileUploaded', function (up, file, response) {
474 res = JSON.parse(response.response);
475 $('#<?php echo isset($data['id']) ? $data['id'] : $id; ?>').attr('src', res.image_url);
476 $('#wmprogressbar').hide();
477 $('#wpdm-browse-button').show();
478
479
480 });
481
482 $('#del-img').on('click', function () {
483 $(this).html('<i class="fa fa-sun fa-spin"></i> Deleting...');
484 $.post(wpdm_url.ajax, {action: 'delete_<?php echo $data['name']; ?>'}, res => {
485 $('#<?php echo isset($data['id']) ? $data['id'] : $id; ?>').attr('src', '<?php echo WPDM_BASE_URL . 'assets/images/image.png'; ?>');
486 $('#<?php echo isset($data['id']) ? $data['id'] : $id; ?>_hidden').val('');
487 $('#del-img').html('Delete Image');
488 });
489 });
490
491 });
492
493 </script>
494 <div id="filelist"></div>
495
496 <div class="clear"></div>
497
498 </div>
499 </div>
500 </div>
501 <?php
502 return ob_get_clean();
503 }
504
505
506 /**
507 * @usage Generate option fields
508 * @param $data
509 * @return mixed|string
510 */
511 function wpdm_option_field($data)
512 {
513 $desc = isset($data['description']) ? "<em class='note'>{$data['description']}</em>" : "";
514 $class = isset($data['class']) ? $data['class'] : "";
515 $data['placeholder'] = isset($data['placeholder']) ? $data['placeholder'] : '';
516 switch ($data['type']):
517 case 'text':
518 return "<input type='text' name='$data[name]' class='form-control {$class}' id='$data[id]' value='$data[value]' placeholder='{$data['placeholder']}' />$desc";
519 break;
520 case 'select':
521 case 'dropdown':
522 $html = "<select name='{$data['name']}' id='{$data['id']}' class='form-control {$class}' style='width:100%;min-width:150px;' >";
523 foreach ($data['options'] as $value => $label) {
524
525 $html .= "<option value='{$value}' " . selected($data['selected'], $value, false) . ">$label</option>";
526 }
527 $html .= "</select>";
528 return $html . $desc;
529 break;
530 case 'radio':
531 $html = "";
532 foreach ($data['options'] as $value => $label) {
533 $html .= "<label style='display: inline-block;margin-right: 5px'><input type='radio' name='{$data['name']}' class='{$class}' value='{$value}' " . selected($data['selected'], $value, false) . " /> $label</label>";
534 }
535 $html .= "";
536 return $html . $desc;
537 break;
538 case 'notice':
539 return "<div class='alert alert-info' style='margin: 0'>$data[notice]</div>" . $desc;
540 case 'textarea':
541 return "<textarea name='$data[name]' id='$data[id]' class='form-control {$class}' style='min-height: 100px'>$data[value]</textarea>$desc";
542 break;
543 case 'checkbox':
544 return "<input type='hidden' name='$data[name]' value='0' /><input type='checkbox' class='{$class}' name='$data[name]' id='$data[id]' value='$data[value]' " . checked($data['checked'], $data['value'], false) . " />" . $desc;
545 break;
546 case 'callback':
547 return call_user_func($data['dom_callback'], $data['dom_callback_params']) . $desc;
548 break;
549 case 'heading':
550 return "<h3>" . $data['label'] . "</h3>";
551 break;
552 case 'media':
553 return wpdm_media_field($data);
554 break;
555 default:
556 return "<input type='{$data['type']}' name='$data[name]' class='form-control {$class}' id='$data[id]' value='$data[value]' placeholder='{$data['placeholder']}' />$desc";
557 break;
558 break;
559 endswitch;
560 }
561
562 /**
563 * @param $options
564 * @return string
565 */
566 function wpdm_option_page($options)
567 {
568 $html = "<div class='wpdm-settings-fields'>";
569 foreach ($options as $id => $option) {
570 if (!isset($option['id'])) $option['id'] = $id;
571 if (!isset($option['name'])) $option['name'] = $id;
572 if (!isset($option['label'])) $option['label'] = '';
573 if (in_array($option['type'], array('checkbox', 'radio')))
574 $html .= "<div class='form-group'><label>" . wpdm_option_field($option) . " {$option['label']}</label></div>";
575 else if ($option['type'] == 'heading')
576 $html .= "<h3>{$option['label']}</h3>";
577 else
578 $html .= "<div class='form-group'><label>{$option['label']}</label>" . wpdm_option_field($option) . "</div>";
579 }
580 $html .= "</div>";
581 return $html;
582 }
583
584
585 /**
586 * @param $name
587 * @param $options
588 * @return string
589 */
590 function wpdm_settings_section($name, $options)
591 {
592 return "<div class='panel panel-default'><div class='panel-heading'>{$name}</div><div class='panel-body'>" . wpdm_option_page($options) . "</div></div>";
593 }
594
595
596 /**
597 * @usage Get All Custom Data of a Package
598 * @param $pid
599 * @return array
600 */
601 function wpdm_custom_data($pid)
602 {
603 return WPDM()->package->metaData($pid);
604 }
605
606 /**
607 * @usage Organize package data using all available variable
608 * @param $vars
609 * @param string $template
610 * @return array
611 */
612 function wpdm_setup_package_data($vars, $template = '')
613 {
614 if (isset($vars['formatted'])) return $vars;
615 if (!isset($vars['ID'])) return $vars;
616 $pack = new Package($vars['ID']);
617 $pack->prepare($vars['ID'], $template);
618 return $pack->packageData;
619 }
620
621 /**
622 * @usage Check if a package is locked or public
623 * @param $id
624 * @return bool
625 */
626 function wpdm_is_locked($id)
627 {
628
629 return WPDM()->package->isLocked($id);
630
631 }
632
633
634 /**
635 * @usage Fetch link/page template and return generated html
636 * @param $template
637 * @param $vars
638 * @param string $type
639 * @return mixed|string|void
640 */
641 function FetchTemplate($template, $vars, $type = 'link')
642 {
643 return WPDM()->package->fetchTemplate($template, $vars, $type);
644 }
645
646 /**
647 * @usage Fetch link/page template and return generated html
648 * @param $template
649 * @param $vars
650 * @param string $type
651 * @return mixed|string|void
652 */
653 function wpdm_fetch_template($template, $vars, $type = 'link')
654 {
655 return WPDM()->package->fetchTemplate($template, $vars, $type);
656 }
657
658 /**
659 * @usage Callback function for [wpdm_login_form] short-code
660 * @return string
661 */
662 function wpdm_loginform()
663 {
664 return wpdm_login_form(array('redirect' => __::valueof($_SERVER, 'REQUEST_URI', ['validate' => 'txt'])));
665 }
666
667
668 /**
669 * @return bool
670 */
671 function wpdm_is_ajax()
672 {
673 if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
674 return true;
675 return false;
676 }
677
678
679 /**
680 * @usage Get Package Data By Package ID
681 * @param $ID
682 * @return bool|mixed|null|void|WP_Post
683 */
684 function wpdm_get_package($ID)
685 {
686 return WPDM()->package->get($ID);
687 }
688
689 /**
690 * @usage Get download manager package data
691 * @param $ID
692 * @param $meta
693 * @return mixed
694 */
695 function get_package_data($ID, $key, $default = '')
696 {
697 $data = WPDM()->package->get($ID, $key);
698 $data = $data ? $data : $default;
699 return $data;
700 }
701
702 /**
703 * @usage Show Login Form
704 */
705 function wpdm_login_form($params = array())
706 {
707 return WPDM()->user->login->form($params);
708 }
709
710 function wpdm_user_dashboard_url($params = array())
711 {
712 $id = get_option('__wpdm_user_dashboard', 0);
713 if ($id > 0) {
714 $url = add_query_arg($params, get_permalink($id));
715 } else $url = home_url('/');
716 return $url;
717 }
718
719 function wpdm_registration_url()
720 {
721 $id = get_option('__wpdm_register_url', 0);
722 if ($id > 0) {
723 $url = get_permalink($id);
724
725 } else $url = wp_registration_url();
726 return $url;
727 }
728
729 function wpdm_login_url($redirect = '')
730 {
731 $id = get_option('__wpdm_login_url', 0);
732 if ($id > 0) {
733 $url = get_permalink($id);
734 if ($redirect != '')
735 $url .= (strstr($url, '?') ? '&' : '?') . 'redirect_to=' . $redirect;
736
737 } else $url = wp_login_url($redirect);
738 return $url;
739 }
740
741 function wpdm_lostpassword_url()
742 {
743 return add_query_arg(array('action' => 'lostpassword'), wpdm_login_url());
744 }
745
746 function wpdm_logout_url($redirect = '')
747 {
748 $logout_url = home_url("/?logout=" . wp_create_nonce(NONCE_KEY));
749 return $redirect != '' ? add_query_arg(array('redirect_to' => $redirect), $logout_url) : $logout_url;
750 }
751
752 function wpdm_rest_url($request)
753 {
754 return get_rest_url(null, "wpdm/{$request}");
755 }
756
757 /**
758 * @usage Returns download manager template file path
759 * @param $file
760 * @param string $tpldir
761 * @return string
762 */
763 function wpdm_tpl_path($file, $tpldir = '', $fallback = '')
764 {
765 return Template::locate($file, $tpldir, $fallback);
766 }
767
768 /**
769 * @usage Returns download manager template file path
770 * @param $file
771 * @param string $tpldir
772 * @return string
773 */
774 function wpdm_admin_tpl_path($file, $tpldir = '', $fallback = '')
775 {
776 if (file_exists(get_stylesheet_directory() . '/download-manager/admin/' . $file))
777 $path = get_stylesheet_directory() . '/download-manager/admin/' . $file;
778 else if (file_exists(get_template_directory() . '/download-manager/admin/' . $file))
779 $path = get_template_directory() . '/download-manager/admin/' . $file;
780 else if ($tpldir != '' && file_exists($tpldir . '/' . $file))
781 $path = $tpldir . '/' . $file;
782 else if ($tpldir != '' && file_exists(get_template_directory() . '/download-manager/admin/' . $tpldir . '/' . $file))
783 $path = get_template_directory() . '/download-manager/admin/' . $tpldir . '/' . $file;
784 else $path = WPDM_BASE_DIR . "src/Admin/views/" . $file;
785
786 /* Fallack template directory*/
787 if ($fallback != '' && !file_exists($path))
788 $path = $fallback . $file;
789
790 return $path;
791
792 }
793
794 function wpdm_user_space_limit($uid = null)
795 {
796 global $current_user;
797 $global = get_option('__wpdm_author_space', 500);
798 $uid = $uid ? $uid : $current_user->ID;
799 $user = get_user_meta($uid, '__wpdm_space', true);
800 $space = $user > 0 ? $user : $global;
801 return $space;
802 }
803
804 /**
805 * Validate the given string is an url or not
806 * @param $url
807 * @return mixed|void
808 */
809 function wpdm_is_url($url)
810 {
811 return __::is_url($url);
812 }
813
814 function wpdm_total_downloads($uid = null, $pid = null)
815 {
816 global $wpdb;
817
818 if ($uid > 0 && !$pid)
819 $download_count = $wpdb->get_var("select sum(pm.meta_value) from {$wpdb->prefix}postmeta pm, {$wpdb->prefix}posts p where meta_key='__wpdm_download_count' and p.ID = pm.post_id and p.post_author = '{$uid}'");
820 else if ($pid > 0 && !$uid)
821 $download_count = $wpdb->get_var("select sum(pm.meta_value) from {$wpdb->prefix}postmeta where meta_key='__wpdm_download_count' and post_id = '{$pid}'");
822 else if ($uid > 0 && $pid > 0)
823 $download_count = $wpdb->get_var("select sum(pm.meta_value) from {$wpdb->prefix}postmeta pm, {$wpdb->prefix}posts p where meta_key='__wpdm_download_count' and p.ID = pm.post_id and p.post_author = '{$uid}' and pm.post_id = '{$pid}'");
824 else
825 $download_count = $wpdb->get_var("select sum(meta_value) from {$wpdb->prefix}postmeta where meta_key='__wpdm_download_count'");
826 return (int)$download_count;
827 }
828
829 function wpdm_total_views($uid = null)
830 {
831 global $wpdb;
832 if (isset($uid) && $uid > 0)
833 $download_count = $wpdb->get_var("select sum(pm.meta_value) from {$wpdb->prefix}postmeta pm, {$wpdb->prefix}posts p where meta_key='__wpdm_view_count' and p.ID = pm.post_id and p.post_author = '{$uid}'");
834 else
835 $download_count = $wpdb->get_var("select sum(meta_value) from {$wpdb->prefix}postmeta where meta_key='__wpdm_view_count'");
836 return $download_count;
837 }
838
839 /**
840 * Find if user is downloaded an item or not
841 * @param $pid
842 * @param $uid
843 * @return bool
844 */
845 function wpdm_is_user_downloaded($pid, $uid)
846 {
847 global $wpdb;
848 $uid = (int)$uid;
849 $pid = (int)$pid;
850 $ret = $wpdb->get_var("select uid from {$wpdb->prefix}ahm_download_stats where uid='$uid' and pid = '$pid'");
851 if ($ret && $ret == $uid) return true;
852 return false;
853 }
854
855
856 /**
857 * @param $ip
858 * @param $range
859 * @return bool
860 */
861 function wpdm_ip_in_range($ip, $range)
862 {
863 // Check IP range
864 list($subnet, $bits) = explode('/', $range);
865 // Convert subnet to binary string of $bits length
866 $subnet = unpack('H*', inet_pton($subnet)); // Subnet in Hex
867 foreach ($subnet as $i => $h) $subnet[$i] = base_convert($h, 16, 2); // Array of Binary
868 $subnet = substr(implode('', $subnet), 0, $bits); // Subnet in Binary, only network bits
869
870 // Convert remote IP to binary string of $bits length
871 $ip = unpack('H*', inet_pton($ip)); // IP in Hex
872 foreach ($ip as $i => $h) $ip[$i] = base_convert($h, 16, 2); // Array of Binary
873 $ip = substr(implode('', $ip), 0, $bits); // IP in Binary, only network bits
874
875 // Check network bits match
876 if ($subnet == $ip) {
877 return true;
878 }
879 return false;
880 }
881
882 /**
883 * @param null $ip
884 * @return bool
885 */
886 function wpdm_ip_blocked($ip = null)
887 {
888 $ip = $ip ? $ip : wpdm_get_client_ip();
889 $allblocked = get_option('__wpdm_blocked_ips', '');
890 $allblocked = explode("\n", str_replace("\r", "", $allblocked));
891 $isblocked = false;
892 foreach ($allblocked as $blocked) {
893 if (strstr($blocked, '/'))
894 $isblocked = wpdm_ip_in_range($ip, $blocked);
895 else if (strstr($blocked, '*')) {
896 preg_match('/' . $blocked . '/', $ip, $matches);
897 $isblocked = count($matches) > 0 ? true : false;
898 } else if ($ip == $blocked)
899 $isblocked = true;
900
901 if ($isblocked == true) return $isblocked;
902
903 }
904 return $isblocked;
905 }
906
907 /**
908 * @return string or bool
909 */
910 function wpdm_get_client_ip()
911 {
912 return __::get_client_ip();
913 }
914
915 /**
916 * Validate download link
917 * @param $ID
918 * @param $_key
919 * @param bool $execute
920 * @return bool|int
921 * @since 4.7.4
922 */
923 function is_wpdmkey_valid($ID, $_key, $update = false)
924 {
925 if ($_key == '') return 0; // Invalid
926 $ID = (int)$ID;
927 $_key = wpdm_sanitize_var($_key);
928 $key = "__wpdmkey_{$_key}";
929
930 // Resolve from a SINGLE store; remember which so we only touch that one.
931 // session => device-bound token (unlock, same browser) -> Session
932 // global => durable shareable/emailed link -> ahm_sessions 'wpdmkey' scope
933 // meta => legacy global tokens issued before the migration -> post_meta (fallback)
934 $store = null;
935 $xlimit = Session::get("{$key}_{$ID}");
936 if ($xlimit) {
937 $store = 'session';
938 } elseif ($xlimit = TempStorage::get("{$key}_{$ID}", TempStorage::DURABLE_SCOPE)) {
939 $store = 'global';
940 } else {
941 $xlimit = get_post_meta($ID, $key, true);
942 if ($xlimit) $store = 'meta';
943 }
944
945 if (!$xlimit) return 0; // Invalid
946
947 if (!is_array($xlimit) && (int)$xlimit > 0) {
948 $xlimit = array('use' => (int)$xlimit, 'expire' => time() + 360);
949 }
950
951 $xlimit = maybe_unserialize($xlimit);
952
953 if (!is_array($xlimit)) return 0;
954
955 $limit = isset($xlimit['use']) ? (int)$xlimit['use'] : 0;
956
957 $expired = false;
958
959 if ($limit <= 0) {
960 if ($store === 'session') Session::clear("{$key}_{$ID}");
961 elseif ($store === 'global') TempStorage::kill("{$key}_{$ID}", TempStorage::DURABLE_SCOPE);
962 else delete_post_meta($ID, $key);
963 return -1; // Limit exceeded
964 } else {
965
966 $limit--;
967 $xlimit['use'] = $limit;
968
969 if ((int)$xlimit['expire'] < time()) {
970 $xlimit['use'] = $limit = 0;
971 $expired = true;
972 if ($store === 'session') Session::clear("{$key}_{$ID}");
973 elseif ($store === 'global') TempStorage::kill("{$key}_{$ID}", TempStorage::DURABLE_SCOPE);
974 else delete_post_meta($ID, $key);
975 }
976 if ($update && !$expired) {
977 if ($store === 'session') {
978 Session::set("{$key}_{$ID}", $xlimit, max(1, (int)$xlimit['expire'] - time()));
979 } elseif ($store === 'global') {
980 TempStorage::set("{$key}_{$ID}", $xlimit, max(1, (int)$xlimit['expire'] - time()), TempStorage::DURABLE_SCOPE);
981 } else {
982 update_post_meta($ID, $key, $xlimit);
983 }
984 }
985 if ($expired) return -2; // Time expired
986 }
987
988 return 1;
989 }
990
991 /**
992 * @param $var
993 * @param $index
994 * @param array $params
995 * @return array|bool|float|int|mixed|string|string[]|null
996 */
997
998 function wpdm_valueof( $var, $index, $default_or_params = [], $validate = '' ) {
999 return __::valueof( $var, $index, $default_or_params, $validate );
1000 }
1001
1002 /**
1003 * Validate and sanitize input data
1004 * @param $var
1005 * @param array $validate
1006 * @param null $default
1007 * @return array|float|int|mixed|string|string[]|null
1008 */
1009 function wpdm_query_var($var, $validate = array(), $default = null)
1010 {
1011 return __::query_var($var, $validate, $default);
1012 }
1013
1014 /**
1015 * Sanitize an array or any single value
1016 * @param $array
1017 * @return mixed
1018 */
1019 function wpdm_sanitize_array($array, $sanitize = 'kses')
1020 {
1021 return __::sanitize_array($array, $sanitize);
1022 }
1023
1024 /**
1025 * Sanitize any single value
1026 * @param $value
1027 * @return string
1028 */
1029 function wpdm_sanitize_var($value, $sanitize = 'kses')
1030 {
1031 return __::sanitize_var($value, $sanitize);
1032 }
1033
1034 function wpdm_tzoffset() {
1035 return __::timezoneOffset();
1036 }
1037
1038 /**
1039 * @param $total
1040 * @param $item_per_page
1041 * @param int $page
1042 * @param string $var
1043 * @return string
1044 */
1045 function wpdm_paginate_links($total, $items_per_page, $current_page = 1, $var = 'cp', $params = array())
1046 {
1047 $items_per_page = $items_per_page > 0 ? $items_per_page : 10;
1048 $pages = ceil($total / $items_per_page);
1049 if($current_page < 1) $current_page = 1;
1050 $format = isset($params['format']) ? $params['format'] : "?{$var}=%#%";
1051 $args = array(
1052 //'base' => '%_%',
1053 'format' => $format,
1054 'total' => $pages,
1055 'current' => $current_page,
1056 //'show_all' => false,
1057 'end_size' => 2,
1058 //'mid_size' => 1,
1059 'prev_next' => true,
1060 'prev_text' => isset($params['prev_text']) ? $params['prev_text'] : __('Previous'),
1061 'next_text' => isset($params['prev_text']) ? $params['next_text'] : __('Next'),
1062 'type' => 'array',
1063 //'add_args' => false,
1064 //'add_fragment' => '',
1065 //'before_page_number' => '',
1066 //'after_page_number' => ''
1067 );
1068 if (isset($params['base'])) {
1069 $args['base'] = $params['base'];
1070 }
1071 //wpdmprecho($args);
1072 $pags = paginate_links($args);
1073 //wpdmprecho($pags);
1074 $phtml = "";
1075 if (is_array($pags)) {
1076 foreach ($pags as $pagl) {
1077 if (isset($params['container'])) {
1078 $pagl = str_replace("<a", "<a data-container='{$params['container']}'", $pagl);
1079 }
1080 $phtml .= "<li>{$pagl}</li>";
1081 }
1082 }
1083 $async = isset($params['async']) && $params['async'] ? ' async' : '';
1084 $phtml = "<div class='text-center'><ul class='pagination wpdm-pagination pagination-centered text-center{$async}'>{$phtml}</ul></div>";
1085 return $phtml;
1086 }
1087
1088 /**
1089 * @usage Escape script tag
1090 * @param $html
1091 * @return null|string|string[]
1092 */
1093 function wpdm_escs($html)
1094 {
1095 return preg_replace('#<script(.*?)>(.*?)</script>#is', '', $html);
1096 }
1097
1098 /**
1099 * @param null $page_template
1100 * @param null $pacakge_ID
1101 * @return mixed|string
1102 */
1103 function wpdm_download_button_style($page_template = false, $pacakge_ID = null)
1104 {
1105 if (is_singular('wpdmpro') || $page_template === true)
1106 $ui_button = get_option('__wpdm_ui_download_button');
1107 else
1108 $ui_button = get_option('__wpdm_ui_download_button_sc');
1109 $ui_button = wpdm_sanitize_array($ui_button);
1110 $class = "btn " . (isset($ui_button['color']) ? $ui_button['color'] : 'btn-primary') . " " . (isset($ui_button['size']) ? $ui_button['size'] : '');
1111 $class = apply_filters("wpdm_download_button_style", $class, $pacakge_ID);
1112 return $class;
1113 }
1114
1115 function wpdm_hex2rgb($hex)
1116 {
1117 list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
1118 return "$r, $g, $b";
1119 }
1120
1121 /*** developer fns **/
1122 function wpdmdd(...$data)
1123 {
1124 foreach ($data as $d) {
1125 echo "<pre style='margin-bottom: 5px;padding: 10px;background: #eef1f5;border-radius: 8px'>" . print_r( $d, 1 ) . "</pre>";
1126 }
1127 die();
1128 }
1129
1130 function wpdmprecho($data, $ret = 0)
1131 {
1132 $echo = "<pre style='margin-bottom: 5px;padding: 10px;background: #eef1f5;border-radius: 8px'>" . print_r($data, 1) . "</pre>";
1133 if ($ret == 1) return $echo;
1134 echo $echo;
1135 }
1136 /*** developer fns **/
1137
1138 add_action("admin_head", function (){
1139 $pages = ['settings', 'wpdm-asset-manager', 'importable-files', 'wpdm-stats', 'templates', 'wpdm-subscribers', 'wpdm-addons', 'orders', 'pp-license', 'pp-coupon-codes', 'customers', 'payouts'];
1140 $pages = apply_filters("wpdm_admin_notices", $pages);
1141 if(wpdm_query_var('post_type') !== 'wpdmpro' || !in_array(wpdm_query_var('page'), $pages)) return;
1142 ?>
1143 <style>
1144 #wpbody-content > .notice,
1145 .wrap > .notice{
1146 display: none;
1147 }
1148 #wpdm-an-side-panel.hide{
1149 display: none !important;
1150 }
1151 #wpdm-an-side-panel{
1152 width: 400px;
1153 position: fixed;
1154 right: -400px;
1155 top: 0;
1156 height: 100%;
1157 transition: all ease-in-out 300ms;
1158 z-index: 999999 !important;
1159 }
1160 #wpdm-an-side-panel.panel-open {
1161 right: 0;
1162 }
1163 #wpdm-an-side-panel-body,
1164 #wpdm-an-side-panel #wpdm-an-side-panel-trigger{
1165 background: #f4f6ff;
1166 position: absolute;
1167 }
1168 #wpdm-an-side-panel #wpdm-an-side-panel-trigger{
1169 top: 160px;
1170 left: -56px;
1171 width: 58px;
1172 height: 54px;
1173 line-height: 54px;
1174 padding: 0;
1175 text-align: center;
1176 color: #355eff;
1177 border-radius: 3px 0 0 3px;
1178 font-size: 16pt;
1179 cursor: pointer;
1180 z-index: 999;
1181 border: 1px solid #d5d9ec;
1182 border-right: 0;
1183 }
1184 #wpdm-an-side-panel-body{
1185 height: 100%;
1186 width: 400px;
1187 left: 0px;
1188 padding: 32px;
1189 z-index: 998;
1190 border-left: 1px solid #d5d9ec;
1191 }
1192 #wpdm-an-side-panel-body .alert {
1193 position: relative;
1194 }
1195 #wpdm-an-side-panel-body .alert .dismiss {
1196 position: absolute;
1197 right: -9px;
1198 top: -9px;
1199 border-radius: 500px;
1200 width: 20px;
1201 height: 20px;
1202 background: #ffffff;
1203 border: 1px solid var(--color-danger-active);
1204 color: var(--color-danger) !important;
1205 font-size: 10px;
1206 line-height: 17px;
1207 text-align: center;
1208 box-shadow: 0 0 0 2px #ec000036;
1209 opacity: 0;
1210 transition: all ease-in-out 300ms;
1211 cursor: pointer;
1212 }
1213 #wpdm-an-side-panel-body .alert:hover .dismiss {
1214 opacity: 1;
1215 }
1216 #wpdm-an-side-panel-body .alert .dismiss i.fa{
1217 color: var(--color-danger) !important;
1218 }
1219 #wpdm-an-notif-count {
1220 line-height: 12px;
1221 font-size: 8px;
1222 position: absolute;
1223 color: #fff;
1224 border-radius: 500px;
1225 background: #c163ec;
1226 border: 2px solid #f4f6ff;
1227 height: 16px;
1228 top: 12px;
1229 left: 30px;
1230 padding: 0 4px;
1231 }
1232 </style>
1233 <?php
1234 });
1235 add_action("admin_footer", function (){
1236 $pages = ['settings', 'wpdm-asset-manager', 'importable-files', 'wpdm-stats', 'templates', 'wpdm-subscribers', 'wpdm-addons', 'orders', 'pp-license', 'pp-coupon-codes', 'customers', 'payouts'];
1237 $pages = apply_filters("wpdm_admin_notices", $pages);
1238 if(wpdm_query_var('post_type') !== 'wpdmpro' || !in_array(wpdm_query_var('page'), $pages)) return;
1239 ?>
1240 <div id="wpdm-an-side-panel" class="w3eden hide">
1241 <div id="wpdm-an-side-panel-trigger">
1242 <div id="wpdm-an-notif-count">0</div>
1243 <i class="fas fa-bell"></i>
1244 </div>
1245 <div id="wpdm-an-side-panel-body">
1246 </div>
1247 </div>
1248 <script>
1249 jQuery(function ($) {
1250 var notif = 0;
1251 $('.notice:not(.hide-if-js):not(.hidden)').each(function (index) {
1252 var _type = 'info';
1253 var _class = $(this).attr('class');
1254 if(_class.indexOf('error') > 0) _type = 'danger';
1255 else if(_class.indexOf('success') > 0) _type = 'success';
1256 else if(_class.indexOf('info') > 0) _type = 'info';
1257 else if(_class.indexOf('warning') > 0) _type = 'warning';
1258 var notice = $(this).html();
1259 var notice_txt = $(this).text().trim();
1260 if(notice_txt !== '') {
1261 var hash = "notif_"+notice.wpdm_hash();
1262 if(!localStorage.getItem(hash)) {
1263 $('#wpdm-an-side-panel-body').append("<div id='" + hash + "' class='alert alert-" + _type + "'>" + notice + "<div class='dismiss' data-target='" + hash + "'><i class='fa fa-times'></i></div></div>");
1264 notif++;
1265 }
1266 }
1267 });
1268 $('#wpdm-an-notif-count').html(notif);
1269 if(notif > 0) $('#wpdm-an-side-panel').removeClass('hide');
1270 $('#wpdm-an-side-panel-trigger').on('click', function () {
1271 $('#wpdm-an-side-panel').toggleClass('panel-open')
1272 });
1273
1274 $('body').on('click', '#wpdm-an-side-panel-body .alert .dismiss', function (){
1275 var $this = $(this);
1276 var alert = '#' + $this.data('target');
1277 localStorage.setItem($this.data('target'), 1);
1278 $(alert).slideUp();
1279 });
1280 })
1281 </script>
1282 <?php
1283 });
1284