function Packages($params = array('items_per_page' => 10, 'title' => false, 'desc' => false, 'order_by' => 'date', 'order' => 'desc', 'paging' => false, 'toolbar' => 1, 'template' => '', 'cols' => 3, 'colspad' => 2, 'colsphone' => 1, 'tags' => '', 'categorirs' => '', 'year' => '', 'month' => ''))
 {
     $params['order_by'] = isset($params['order_field']) && $params['order_field'] != '' && !isset($params['order_by']) ? $params['order_field'] : $params['order_by'];
     $scparams = $params;
     $defaults = array('items_per_page' => 10, 'title' => false, 'desc' => false, 'order_by' => 'date', 'order' => 'desc', 'paging' => false, 'toolbar' => 1, 'template' => 'link-template-panel', 'cols' => 3, 'colspad' => 2, 'colsphone' => 1);
     $params = shortcode_atts($defaults, $params, 'wpdm_packages');
     if (is_array($params)) {
         extract($params);
     }
     $cwd_class = "col-md-" . (int) (12 / $cols);
     $cwdsm_class = "col-sm-" . (int) (12 / $colspad);
     $cwdxs_class = "col-xs-" . (int) (12 / $colsphone);
     if (isset($id)) {
         $id = trim($id, ", ");
         $cids = explode(",", $id);
     }
     global $wpdb, $current_user, $post, $wp_query;
     if (isset($order_by) && !isset($order_field)) {
         $order_field = $order_by;
     }
     $order_field = isset($order_field) ? $order_field : 'date';
     $order_field = isset($_GET['orderby']) ? $_GET['orderby'] : $order_field;
     $order = isset($order) ? $order : 'desc';
     $order = isset($_GET['order']) ? $_GET['order'] : $order;
     $cp = wpdm_query_var('cp', 'num');
     if (!$cp) {
         $cp = 1;
     }
     $params = array('post_type' => 'wpdmpro', 'paged' => $cp, 'posts_per_page' => $items_per_page, 'include_children' => false);
     if (isset($scparams['month']) && $scparams['month'] != '') {
         $params['monthnum'] = $scparams['month'];
     }
     if (isset($scparams['year']) && $scparams['year'] != '') {
         $params['year'] = $scparams['year'];
     }
     if (isset($scparams['day']) && $scparams['day'] != '') {
         $params['day'] = $scparams['day'];
     }
     if (isset($scparams['search']) && $scparams['search'] != '') {
         $params['s'] = $scparams['search'];
     }
     if (isset($scparams['tag']) && $scparams['tag'] != '') {
         $params['tag'] = $scparams['tag'];
     }
     if (isset($scparams['tag_id']) && $scparams['tag_id'] != '') {
         $params['tag_id'] = $scparams['tag_id'];
     }
     if (isset($scparams['tag__and']) && $scparams['tag__and'] != '') {
         $params['tag__and'] = explode(",", $scparams['tag__and']);
     }
     if (isset($scparams['tag__in']) && $scparams['tag__in'] != '') {
         $params['tag__in'] = explode(",", $scparams['tag__in']);
     }
     if (isset($scparams['tag__not_in']) && $scparams['tag__not_in'] != '') {
         $params['tag__not_in'] = explode(",", $scparams['tag__not_in']);
     }
     if (isset($scparams['tag_slug__and']) && $scparams['tag_slug__and'] != '') {
         $params['tag_slug__and'] = explode(",", $scparams['tag_slug__and']);
     }
     if (isset($scparams['tag_slug__in']) && $scparams['tag_slug__in'] != '') {
         $params['tag_slug__in'] = explode(",", $scparams['tag_slug__in']);
     }
     if (isset($scparams['categories']) && $scparams['categories'] != '') {
         $operator = isset($scparams['operator']) ? $scparams['operator'] : 'OR';
         $params['tax_query'] = array(array('taxonomy' => 'wpdmcategory', 'field' => 'slug', 'terms' => explode(",", $scparams['categories']), 'include_children' => isset($scparams['include_children']) && $scparams['include_children'] != '' ? $scparams['include_children'] : false, 'operator' => $operator));
     }
     if (get_option('_wpdm_hide_all', 0) == 1) {
         $params['meta_query'] = array(array('key' => '__wpdm_access', 'value' => '"guest"', 'compare' => 'LIKE'));
         if (is_user_logged_in()) {
             global $current_user;
             $params['meta_query'][] = array('key' => '__wpdm_access', 'value' => $current_user->roles[0], 'compare' => 'LIKE');
             $params['meta_query']['relation'] = 'OR';
         }
     }
     $order_fields = array('__wpdm_download_count', '__wpdm_view_count', '__wpdm_package_size_b');
     if (!in_array("__wpdm_" . $order_field, $order_fields)) {
         $params['orderby'] = $order_field;
         $params['order'] = $order;
     } else {
         $params['orderby'] = 'meta_value_num';
         $params['meta_key'] = "__wpdm_" . $order_field;
         $params['order'] = $order;
     }
     $params = apply_filters("wpdm_packages_query_params", $params);
     $packs = new \WP_Query($params);
     $total = $packs->found_posts;
     $pages = ceil($total / $items_per_page);
     $page = isset($_GET['cp']) ? $_GET['cp'] : 1;
     $start = ($page - 1) * $items_per_page;
     if (!isset($paging) || intval($paging) == 1) {
         $pag = new \WPDM\libs\Pagination();
         $pag->items($total);
         $pag->nextLabel(' ► ');
         $pag->prevLabel(' ◄ ');
         $pag->limit($items_per_page);
         $pag->currentPage($page);
     }
     $burl = get_permalink();
     $url = $_SERVER['REQUEST_URI'];
     //get_permalink();
     $url = strpos($url, '?') ? $url . '&' : $url . '?';
     $url = preg_replace("/[\\&]*cp=[0-9]+[\\&]*/", "", $url);
     $url = strpos($url, '?') ? $url . '&' : $url . '?';
     if (!isset($paging) || intval($paging) == 1) {
         $pag->urlTemplate($url . "cp=[%PAGENO%]");
     }
     $html = '';
     $templates = maybe_unserialize(get_option("_fm_link_templates", true));
     if (isset($templates[$template])) {
         $template = $templates[$template]['content'];
     }
     //global $post;
     while ($packs->have_posts()) {
         $packs->the_post();
         $pack = (array) $post;
         $repeater = "<div class='{$cwd_class} {$cwdsm_class} {$cwdxs_class}'>" . \WPDM\Package::FetchTemplate($template, $pack) . "</div>";
         $html .= $repeater;
     }
     wp_reset_query();
     $html = "<div class='row'>{$html}</div>";
     if (!isset($paging) || intval($paging) == 1) {
         $pgn = "<div style='clear:both'></div>" . $pag->show() . "<div style='clear:both'></div>";
     } else {
         $pgn = "";
     }
     global $post;
     $sap = get_option('permalink_structure') ? '?' : '&';
     $burl = $burl . $sap;
     if (isset($_GET['p']) && $_GET['p'] != '') {
         $burl .= 'p=' . $_GET['p'] . '&';
     }
     if (isset($_GET['src']) && $_GET['src'] != '') {
         $burl .= 'src=' . $_GET['src'] . '&';
     }
     $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'create_date';
     $order = ucfirst($order);
     $title = isset($title) && $title != '' ? "<h3>{$title}</h3>" : "";
     return "<div class='w3eden'>" . $title . $desc . $html . $pgn . "<div style='clear:both'></div></div>";
 }
/**
 * @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);
}