ÿØÿà JFIF ÿÛ „ ( %"1!%)+...383,7(-.+
-+++--++++---+-+-----+---------------+---+-++7-----ÿÀ ß â" ÿÄ ÿÄ H !1AQaq"‘¡2B±ÁÑð#R“Ò Tbr‚²á3csƒ’ÂñDS¢³$CÿÄ ÿÄ % !1AQa"23‘ÿÚ ? ôÿ ¨pŸªáÿ —åYõõ\?àÒü©ŠÄï¨pŸªáÿ —åYõõ\?àÓü©ŠÄá 0Ÿªáÿ Ÿå[úƒ ú®ði~TÁbqÐ8OÕpÿ ƒOò¤Oè`–RÂáœá™êi€ßÉ< FtŸI“öÌ8úDf´°å}“¾œ6
öFá°y¥jñÇh†ˆ¢ã/ÃÐ:ªcÈ
"Y¡ðÑl>ÿ ”ÏËte:qž\oäŠe÷ó²·˜HT4&ÿ ÓÐü6ö®¿øþßèô Ÿ•7Ñi’•j|“ñì>b…þS?*Óôÿ ÓÐü*h¥£ír¶ü UãS炟[AÐaè[ûª•õ&õj?†Éö+EzP—WeÒírJFt ‘BŒ†Ï‡%#tE Øz ¥OÛ«!1›üä±Í™%ºÍãö]°î(–:@<‹ŒÊö×òÆt¦ãº+‡¦%Ìòh´OƒJŒtMÜ>ÀÜÊw3Y´•牋4ÇýÊTì>œú=Íwhyë,¾Ôò×õ¿ßÊa»«þˆÑªQ|%6ž™A õ%:øj<>É—ÿ Å_ˆCbõ¥š±ý¯Ýƒï…¶|RëócÍf溪“t.СøTÿ *Ä¿-{†çàczůŽ_–^XþŒ±miB[X±d 1,é”zEù»&
î9gœf™9Ð'.;—™i}!ôšåîqêÛ٤ёý£½ÆA–àôe"A$ËÚsäÿ
÷Û #°xŸëí(l
»ý3—¥5m!
rt`†0~'j2(]S¦¦kv,ÚÇl¦øJA£Šƒ
J3E8ÙiŽ:cÉžúeZ°€¯\®kÖ(79«Ž:¯X”¾³Š&¡* ….‰Ž(ÜíŸ2¥ª‡×Hi²TF¤ò[¨íÈRëÉä¢mgÑ.Ÿ<öäS0í„ǹÁU´f#Vß;Õ–…P@3ío<ä-±»Ž.L|kªÀê›fÂ6@»eu‚|ÓaÞÆŸ…¨ááå>åŠ?cKü6ùTÍÆ”†sĤÚ;H2RÚ†õ\Ö·Ÿn'¾ ñ#ºI¤Å´%çÁ‚â7›‹qT3Iï¨ÖÚ5I7Ë!ÅOóŸ¶øÝñØôת¦$Tcö‘[«Ö³šÒ';Aþ ¸èíg
A2Z"i¸vdÄ÷.iõ®§)¿]¤À†–‡É&ä{V¶iŽ”.Ó×Õÿ û?h¬Mt–íª[ÿ Ñÿ ÌV(í}=ibÔ¡›¥¢±b Lô¥‡piη_Z<‡z§èŒ)iÖwiÇ 2hÙ3·=’d÷8éŽ1¦¸c¤µ€7›7Ø ð\á)} ¹fËí›pAÃL%âc2 í§æQz¿;T8sæ°qø)QFMð‰XŒÂ±N¢aF¨…8¯!U Z©RÊ ÖPVÄÀÍin™Ì-GˆªÅËŠ›•zË}º±ŽÍFò¹}Uw×#ä5B¤{î}Ð<ÙD
é©¤&‡ïDbàÁôMÁ.package->zip($package['ID']);
}
/**
* Download contents as a file
* @param $filename
* @param $content
*/
function wpdm_download_data($filename, $content)
{
WPDM()->fileSystem->downloadData($filename, $content);
}
/**
* @usage Create ZIP from given file list
* @param $files
* @param $zipname
* @return bool|string
*/
function wpdm_zip_files($files, $zipname)
{
return \WPDM\__\FileSystem::zipFiles($files, $zipname);
}
/**
* @usage Download Given File
* @param $filepath
* @param $filename
* @param int $speed
* @param int $resume_support
* @param array $extras
*/
function wpdm_download_file($filepath, $filename, $speed = 0, $resume_support = 1, $extras = array())
{
do_action("wpdm_download_success", $extras);
if (!file_exists($filepath)) Messages::fullPage("Download Error", "
" . __("File Not Found!", "download-manager") . "
");
if (isset($_GET['play'])) $extras['play'] = sanitize_text_field($_GET['play']);
\WPDM\__\FileSystem::downloadFile($filepath, $filename, $speed, $resume_support, $extras);
}
/**
* @param $id
* @usage Returns the user roles who has access to specified package
* @return array|mixed
*/
function wpdm_allowed_roles($id)
{
return WPDM()->package->allowedRoles($id);
}
/**
* @usage Check if current user has access to package or category
* @param $id
* @param string $type
*
* @return bool
*/
function wpdm_user_has_access($id, $type = 'package')
{
return WPDM()->package->userCanAccess($id, $type);
}
/**
* @usage Verify Email Address
* @param $email
* @return bool
*/
function wpdm_verify_email($email)
{
$dns_verify = get_option('__wpdm_verify_dns', 0);
$blocked_domains = explode("\n", str_replace("\r", "", get_option('__wpdm_blocked_domains', '')));
$blocked_emails = explode("\n", str_replace("\r", "", get_option('__wpdm_blocked_emails', '')));
$eparts = explode("@", $email);
if (!isset($eparts[1])) return false;
$domain = $eparts[1];
if (!is_email($email)) return false;
if (in_array($email, $blocked_emails)) return false;
if (in_array($domain, $blocked_domains)) return false;
if ($dns_verify && !checkdnsrr($domain, 'MX')) return false;
return true;
}
/**
* @usage Count files in a package
* @param $id
* @return int
*/
function wpdm_package_filecount($id)
{
return WPDM()->package->fileCount($id);
}
/**
* @usage Calculate package size
* @param $id
* @return float|int|mixed|string
*/
function wpdm_package_size($id)
{
return WPDM()->package->Size($id);
}
/**
* @usage Calculate file size
* @param $file
* @return float|int|mixed|string
*/
function wpdm_file_size($file)
{
$file = WPDM()->fileSystem->absPath($file);
if(!$file) return '0.00 KB';
$size = filesize($file);
$size = $size / 1024;
if ($size > 1024) $size = number_format($size / 1024, 2) . ' MB';
else $size = number_format($size, 2) . ' KB';
return $size;
}
/**
* Get post excerpt
* @param $post
* @param int $length
* @param bool $word_break
* @param string $continue
* @return string
*/
function wpdm_get_excerpt($post, $length = 100, $word_break = false, $continue = "...")
{
$post = is_object($post) ? $post : get_post($post);
if (!is_object($post)) return '';
$excerpt = get_the_excerpt($post);
if (!$excerpt) $excerpt = $post->post_content;
$excerpt = strip_tags($excerpt);
$excerpt = substr(trim($excerpt), 0, $length);
if (!$word_break) {
$excerpt = explode(" ", $excerpt);
array_pop($excerpt);
$excerpt = implode(" ", $excerpt);
}
return $excerpt . $continue;
}
/**
* @param $file
* @return array|mixed
*/
function wpdm_basename($file)
{
if (strpos("~" . $file, "\\"))
$basename = explode("\\", $file);
else
$basename = explode("/", $file);
$basename = end($basename);
return $basename;
}
/**
* @usage Generate thumbnail dynamically
* @param $path
* @param $size
* @return mixed
*/
function wpdm_dynamic_thumb($path, $size, $crop = false, $cache = true)
{
return \WPDM\__\FileSystem::imageThumbnail($path, $size[0], $size[1], $crop, $cache);
}
/**
* @usage Return Post Thumbail
* @param string $size
* @param bool $echo
* @param null $extra
* @return mixed|string|void
*/
function wpdm_post_thumb($size = '', $echo = true, $extra = null)
{
global $post;
$size = $size ? $size : 'thumbnail';
$class = isset($extra['class']) ? $extra['class'] : '';
$crop = isset($extra['crop']) ? $extra['crop'] : get_option('__wpdm_crop_thumbs', false);
$alt = $post->post_title;
if (is_array($size)) {
$large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
$large_image_url = isset($large_image_url[0]) ? $large_image_url[0] : '';
if ($large_image_url == '' && isset($extra['default'])) $large_image_url = $extra['default'];
if ($large_image_url != '') {
$path = str_replace(site_url('/'), ABSPATH, $large_image_url);
$thumb = wpdm_dynamic_thumb($path, $size, $crop);
$thumb = str_replace(ABSPATH, site_url('/'), $thumb);
$alt = get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true);
$img = "
";
if ($echo) {
echo $img;
return true;
} else
return $img;
}
}
if ($echo && has_post_thumbnail($post->ID))
echo get_the_post_thumbnail($post->ID, $size, $extra);
else if (!$echo && has_post_thumbnail($post->ID))
return get_the_post_thumbnail($post->ID, $size, $extra);
else if ($echo)
echo "";
else
return "";
}
/**
* @usage Generate Thumnail for the given package
* @param $post
* @param string $size
* @param bool $echo
* @param null $extra
* @return mixed|string|void
*/
function wpdm_thumb($post, $size = '', $echo = true, $extra = null)
{
if (is_int($post))
$post = get_post($post);
if(!$post) return '';
$size = $size ? $size : 'thumbnail';
$class = isset($extra['class']) ? $extra['class'] : '';
$crop = isset($extra['crop']) ? $extra['crop'] : get_option('__wpdm_crop_thumbs', false);
$alt = $post->post_title;
if (is_array($size)) {
$large_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full');
if (!$large_image_url) return '';
$large_image_url = $large_image_url[0];
if ($large_image_url != '') {
$thumb = wpdm_dynamic_thumb($large_image_url, $size, $crop);
$thumb = str_replace(ABSPATH, site_url('/'), $thumb);
$alt = get_post_meta(get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true);
if ($echo === 'url') return $thumb;
if ($alt === '') $alt = esc_attr(strip_tags(get_the_title($post->ID)));
$img = "
";
if ($echo) {
echo $img;
return;
} else
return $img;
}
}
if ($echo && has_post_thumbnail($post->ID))
echo get_the_post_thumbnail($post->ID, $size, $extra);
else if (!$echo && has_post_thumbnail($post->ID))
return get_the_post_thumbnail($post->ID, $size, $extra);
else if ($echo)
echo "";
else
return "";
}
function wpdm_media_field($data)
{
ob_start();
$attrs = '';
if (isset($data['attrs'])) {
foreach ($data['attrs'] as $attr => $value) {
$attrs .= "$attr='$value' ";
}
}
?>
type="url"
name=""
id="" class="form-control"
value=""/>
$value) {
$attrs .= "$attr='$value' ";
}
}
$id = isset($data['id']) ? sanitize_text_field($data['id']) : uniqid();
?>
$value) {
$attrs .= "$attr='$value' ";
}
}
$default = isset($data['default']) ? $data['default'] : WPDM_BASE_URL . 'assets/images/image.png';
$id = isset($data['id']) ? sanitize_text_field($data['id']) : uniqid();
?>
{$data['description']}" : "";
$class = isset($data['class']) ? $data['class'] : "";
$data['placeholder'] = isset($data['placeholder']) ? $data['placeholder'] : '';
switch ($data['type']):
case 'text':
return "$desc";
break;
case 'select':
case 'dropdown':
$html = "";
return $html . $desc;
break;
case 'radio':
$html = "";
foreach ($data['options'] as $value => $label) {
$html .= "";
}
$html .= "";
return $html . $desc;
break;
case 'notice':
return "$data[notice]
" . $desc;
case 'textarea':
return "$desc";
break;
case 'checkbox':
return "" . $desc;
break;
case 'callback':
return call_user_func($data['dom_callback'], $data['dom_callback_params']) . $desc;
break;
case 'heading':
return "" . $data['label'] . "
";
break;
case 'media':
return wpdm_media_field($data);
break;
default:
return "$desc";
break;
break;
endswitch;
}
/**
* @param $options
* @return string
*/
function wpdm_option_page($options)
{
$html = "";
foreach ($options as $id => $option) {
if (!isset($option['id'])) $option['id'] = $id;
if (!isset($option['name'])) $option['name'] = $id;
if (!isset($option['label'])) $option['label'] = '';
if (in_array($option['type'], array('checkbox', 'radio')))
$html .= "
";
else if ($option['type'] == 'heading')
$html .= "
{$option['label']}
";
else
$html .= "
" . wpdm_option_field($option) . "
";
}
$html .= "
";
return $html;
}
/**
* @param $name
* @param $options
* @return string
*/
function wpdm_settings_section($name, $options)
{
return "{$name}
" . wpdm_option_page($options) . "
";
}
/**
* @usage Get All Custom Data of a Package
* @param $pid
* @return array
*/
function wpdm_custom_data($pid)
{
return WPDM()->package->metaData($pid);
}
/**
* @usage Organize package data using all available variable
* @param $vars
* @param string $template
* @return array
*/
function wpdm_setup_package_data($vars, $template = '')
{
if (isset($vars['formatted'])) return $vars;
if (!isset($vars['ID'])) return $vars;
$pack = new Package($vars['ID']);
$pack->prepare($vars['ID'], $template);
return $pack->packageData;
}
/**
* @usage Check if a package is locked or public
* @param $id
* @return bool
*/
function wpdm_is_locked($id)
{
return WPDM()->package->isLocked($id);
}
/**
* @usage Fetch link/page template and return generated html
* @param $template
* @param $vars
* @param string $type
* @return mixed|string|void
*/
function FetchTemplate($template, $vars, $type = 'link')
{
return WPDM()->package->fetchTemplate($template, $vars, $type);
}
/**
* @usage Fetch link/page template and return generated html
* @param $template
* @param $vars
* @param string $type
* @return mixed|string|void
*/
function wpdm_fetch_template($template, $vars, $type = 'link')
{
return WPDM()->package->fetchTemplate($template, $vars, $type);
}
/**
* @usage Callback function for [wpdm_login_form] short-code
* @return string
*/
function wpdm_loginform()
{
return wpdm_login_form(array('redirect' => __::valueof($_SERVER, 'REQUEST_URI', ['validate' => 'txt'])));
}
/**
* @return bool
*/
function wpdm_is_ajax()
{
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
return true;
return false;
}
/**
* @usage Get Package Data By Package ID
* @param $ID
* @return bool|mixed|null|void|WP_Post
*/
function wpdm_get_package($ID)
{
return WPDM()->package->get($ID);
}
/**
* @usage Get download manager package data
* @param $ID
* @param $meta
* @return mixed
*/
function get_package_data($ID, $key, $default = '')
{
$data = WPDM()->package->get($ID, $key);
$data = $data ? $data : $default;
return $data;
}
/**
* @usage Show Login Form
*/
function wpdm_login_form($params = array())
{
return WPDM()->user->login->form($params);
}
function wpdm_user_dashboard_url($params = array())
{
$id = get_option('__wpdm_user_dashboard', 0);
if ($id > 0) {
$url = add_query_arg($params, get_permalink($id));
} else $url = home_url('/');
return $url;
}
function wpdm_registration_url()
{
$id = get_option('__wpdm_register_url', 0);
if ($id > 0) {
$url = get_permalink($id);
} else $url = wp_registration_url();
return $url;
}
function wpdm_login_url($redirect = '')
{
$id = get_option('__wpdm_login_url', 0);
if ($id > 0) {
$url = get_permalink($id);
if ($redirect != '')
$url .= (strstr($url, '?') ? '&' : '?') . 'redirect_to=' . $redirect;
} else $url = wp_login_url($redirect);
return $url;
}
function wpdm_lostpassword_url()
{
return add_query_arg(array('action' => 'lostpassword'), wpdm_login_url());
}
function wpdm_logout_url($redirect = '')
{
$logout_url = home_url("/?logout=" . wp_create_nonce(NONCE_KEY));
return $redirect != '' ? add_query_arg(array('redirect_to' => $redirect), $logout_url) : $logout_url;
}
function wpdm_rest_url($request)
{
return get_rest_url(null, "wpdm/{$request}");
}
/**
* @usage Returns download manager template file path
* @param $file
* @param string $tpldir
* @return string
*/
function wpdm_tpl_path($file, $tpldir = '', $fallback = '')
{
return Template::locate($file, $tpldir, $fallback);
}
/**
* @usage Returns download manager template file path
* @param $file
* @param string $tpldir
* @return string
*/
function wpdm_admin_tpl_path($file, $tpldir = '', $fallback = '')
{
if (file_exists(get_stylesheet_directory() . '/download-manager/admin/' . $file))
$path = get_stylesheet_directory() . '/download-manager/admin/' . $file;
else if (file_exists(get_template_directory() . '/download-manager/admin/' . $file))
$path = get_template_directory() . '/download-manager/admin/' . $file;
else if ($tpldir != '' && file_exists($tpldir . '/' . $file))
$path = $tpldir . '/' . $file;
else if ($tpldir != '' && file_exists(get_template_directory() . '/download-manager/admin/' . $tpldir . '/' . $file))
$path = get_template_directory() . '/download-manager/admin/' . $tpldir . '/' . $file;
else $path = WPDM_BASE_DIR . "src/Admin/views/" . $file;
/* Fallack template directory*/
if ($fallback != '' && !file_exists($path))
$path = $fallback . $file;
return $path;
}
function wpdm_user_space_limit($uid = null)
{
global $current_user;
$global = get_option('__wpdm_author_space', 500);
$uid = $uid ? $uid : $current_user->ID;
$user = get_user_meta($uid, '__wpdm_space', true);
$space = $user > 0 ? $user : $global;
return $space;
}
/**
* Validate the given string is an url or not
* @param $url
* @return mixed|void
*/
function wpdm_is_url($url)
{
return __::is_url($url);
}
function wpdm_total_downloads($uid = null, $pid = null)
{
global $wpdb;
if ($uid > 0 && !$pid)
$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}'");
else if ($pid > 0 && !$uid)
$download_count = $wpdb->get_var("select sum(pm.meta_value) from {$wpdb->prefix}postmeta where meta_key='__wpdm_download_count' and post_id = '{$pid}'");
else if ($uid > 0 && $pid > 0)
$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}'");
else
$download_count = $wpdb->get_var("select sum(meta_value) from {$wpdb->prefix}postmeta where meta_key='__wpdm_download_count'");
return (int)$download_count;
}
function wpdm_total_views($uid = null)
{
global $wpdb;
if (isset($uid) && $uid > 0)
$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}'");
else
$download_count = $wpdb->get_var("select sum(meta_value) from {$wpdb->prefix}postmeta where meta_key='__wpdm_view_count'");
return $download_count;
}
/**
* Find if user is downloaded an item or not
* @param $pid
* @param $uid
* @return bool
*/
function wpdm_is_user_downloaded($pid, $uid)
{
global $wpdb;
$uid = (int)$uid;
$pid = (int)$pid;
$ret = $wpdb->get_var("select uid from {$wpdb->prefix}ahm_download_stats where uid='$uid' and pid = '$pid'");
if ($ret && $ret == $uid) return true;
return false;
}
/**
* @param $ip
* @param $range
* @return bool
*/
function wpdm_ip_in_range($ip, $range)
{
// Check IP range
list($subnet, $bits) = explode('/', $range);
// Convert subnet to binary string of $bits length
$subnet = unpack('H*', inet_pton($subnet)); // Subnet in Hex
foreach ($subnet as $i => $h) $subnet[$i] = base_convert($h, 16, 2); // Array of Binary
$subnet = substr(implode('', $subnet), 0, $bits); // Subnet in Binary, only network bits
// Convert remote IP to binary string of $bits length
$ip = unpack('H*', inet_pton($ip)); // IP in Hex
foreach ($ip as $i => $h) $ip[$i] = base_convert($h, 16, 2); // Array of Binary
$ip = substr(implode('', $ip), 0, $bits); // IP in Binary, only network bits
// Check network bits match
if ($subnet == $ip) {
return true;
}
return false;
}
/**
* @param null $ip
* @return bool
*/
function wpdm_ip_blocked($ip = null)
{
$ip = $ip ? $ip : wpdm_get_client_ip();
$allblocked = get_option('__wpdm_blocked_ips', '');
$allblocked = explode("\n", str_replace("\r", "", $allblocked));
$isblocked = false;
foreach ($allblocked as $blocked) {
if (strstr($blocked, '/'))
$isblocked = wpdm_ip_in_range($ip, $blocked);
else if (strstr($blocked, '*')) {
preg_match('/' . $blocked . '/', $ip, $matches);
$isblocked = count($matches) > 0 ? true : false;
} else if ($ip == $blocked)
$isblocked = true;
if ($isblocked == true) return $isblocked;
}
return $isblocked;
}
/**
* @return string or bool
*/
function wpdm_get_client_ip()
{
return __::get_client_ip();
}
/**
* Validate download link
* @param $ID
* @param $_key
* @param bool $execute
* @return bool|int
* @since 4.7.4
*/
function is_wpdmkey_valid($ID, $_key, $update = false)
{
if ($_key == '') return 0; // Invalid
$ID = (int)$ID;
$_key = wpdm_sanitize_var($_key);
$key = "__wpdmkey_{$_key}";
$xlimit = TempStorage::get("{$key}_{$ID}");
if (!$xlimit)
$xlimit = get_post_meta($ID, $key, true);
if (!$xlimit) return 0; // Invalid
if (!is_array($xlimit) && (int)$xlimit > 0) {
$xlimit = array('use' => (int)$xlimit, 'expire' => time() + 360);
}
$xlimit = maybe_unserialize($xlimit);
if (!is_array($xlimit)) return 0;
$limit = isset($xlimit['use']) ? (int)$xlimit['use'] : 0;
$expired = false;
if ($limit <= 0) {
delete_post_meta($ID, $key);
TempStorage::kill("{$key}_{$ID}");
return -1; // Limit exceeded
} else {
$limit--;
$xlimit['use'] = $limit;
if ((int)$xlimit['expire'] < time()) {
$xlimit['use'] = $limit = 0;
$expired = true;
delete_post_meta($ID, $key);
TempStorage::kill("{$key}_{$ID}");
}
if ($update) {
update_post_meta($ID, $key, $xlimit);
TempStorage::set("{$key}_{$ID}", $xlimit);
}
if ($expired) return -2; // Time expired
}
return 1;
}
/**
* @param $var
* @param $index
* @param array $params
* @return array|bool|float|int|mixed|string|string[]|null
*/
function wpdm_valueof( $var, $index, $default_or_params = [], $validate = '' ) {
return __::valueof( $var, $index, $default_or_params, $validate );
}
/**
* Validate and sanitize input data
* @param $var
* @param array $validate
* @param null $default
* @return array|float|int|mixed|string|string[]|null
*/
function wpdm_query_var($var, $validate = array(), $default = null)
{
return __::query_var($var, $validate, $default);
}
/**
* Sanitize an array or any single value
* @param $array
* @return mixed
*/
function wpdm_sanitize_array($array, $sanitize = 'kses')
{
return __::sanitize_array($array, $sanitize);
}
/**
* Sanitize any single value
* @param $value
* @return string
*/
function wpdm_sanitize_var($value, $sanitize = 'kses')
{
return __::sanitize_var($value, $sanitize);
}
function wpdm_tzoffset() {
return __::timezoneOffset();
}
/**
* @param $total
* @param $item_per_page
* @param int $page
* @param string $var
* @return string
*/
function wpdm_paginate_links($total, $items_per_page, $current_page = 1, $var = 'cp', $params = array())
{
$items_per_page = $items_per_page > 0 ? $items_per_page : 10;
$pages = ceil($total / $items_per_page);
if($current_page < 1) $current_page = 1;
$format = isset($params['format']) ? $params['format'] : "?{$var}=%#%";
$args = array(
//'base' => '%_%',
'format' => $format,
'total' => $pages,
'current' => $current_page,
//'show_all' => false,
'end_size' => 2,
//'mid_size' => 1,
'prev_next' => true,
'prev_text' => isset($params['prev_text']) ? $params['prev_text'] : __('Previous'),
'next_text' => isset($params['prev_text']) ? $params['next_text'] : __('Next'),
'type' => 'array',
//'add_args' => false,
//'add_fragment' => '',
//'before_page_number' => '',
//'after_page_number' => ''
);
if (isset($params['base'])) {
$args['base'] = $params['base'];
}
//wpdmprecho($args);
$pags = paginate_links($args);
//wpdmprecho($pags);
$phtml = "";
if (is_array($pags)) {
foreach ($pags as $pagl) {
if (isset($params['container'])) {
$pagl = str_replace("";
return $phtml;
}
/**
* @usage Escape script tag
* @param $html
* @return null|string|string[]
*/
function wpdm_escs($html)
{
return preg_replace('##is', '', $html);
}
/**
* @param null $page_template
* @param null $pacakge_ID
* @return mixed|string
*/
function wpdm_download_button_style($page_template = false, $pacakge_ID = null)
{
if (is_singular('wpdmpro') || $page_template === true)
$ui_button = get_option('__wpdm_ui_download_button');
else
$ui_button = get_option('__wpdm_ui_download_button_sc');
$ui_button = wpdm_sanitize_array($ui_button);
$class = "btn " . (isset($ui_button['color']) ? $ui_button['color'] : 'btn-primary') . " " . (isset($ui_button['size']) ? $ui_button['size'] : '');
$class = apply_filters("wpdm_download_button_style", $class, $pacakge_ID);
return $class;
}
function wpdm_hex2rgb($hex)
{
list($r, $g, $b) = sscanf($hex, "#%02x%02x%02x");
return "$r, $g, $b";
}
/*** developer fns **/
function wpdmdd(...$data)
{
foreach ($data as $d) {
echo "" . print_r( $d, 1 ) . "
";
}
die();
}
function wpdmprecho($data, $ret = 0)
{
$echo = "" . print_r($data, 1) . "
";
if ($ret == 1) return $echo;
echo $echo;
}
/*** developer fns **/
add_action("admin_head", function (){
$pages = ['settings', 'wpdm-asset-manager', 'importable-files', 'wpdm-stats', 'templates', 'wpdm-subscribers', 'wpdm-addons', 'orders', 'pp-license', 'pp-coupon-codes', 'customers', 'payouts'];
$pages = apply_filters("wpdm_admin_notices", $pages);
if(wpdm_query_var('post_type') !== 'wpdmpro' || !in_array(wpdm_query_var('page'), $pages)) return;
?>