Advertisement
Guest User

flat.php

a guest
Jul 11th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.90 KB | None | 0 0
  1.  
  2.  
  3.     <div class="w3eden">
  4.         <div class="row">
  5.             <div class="col-md-3">
  6.                 <div class="list-group apc-sidebar">
  7.                     <?php
  8.                     $xid = uniqid();
  9.                     $parent = 0;
  10.  
  11.  
  12.                     if(isset($params['category'])) {
  13.  
  14.                         $params['category'] = str_replace(' ','', $params['category']);
  15.                         $cats = explode(',', $params['category']);
  16.                         foreach ($cats as $cat) {
  17.                             $term = get_term_by("id", $cat, "wpdmcategory");
  18.  
  19.                             // 1. Skip if current user does not have access to this category ( Manage role based category access from category settings page )
  20.                             // 2. If following line is active, category roles access must be defined or it will not be listed
  21.                             //if( ! wpdm_user_has_access( $term->term_id, 'category' ) ) continue;
  22.                             if(!is_wp_error($term) && isset($term->term_id))
  23.                                 echo "<a class='list-group-item apc-item-{$xid} apc-cat-{$term->term_id}' href='#' data-item-id='{$term->term_id}'><i class=\"fas fa-folder\"></i>&nbsp;{$term->name}</a>";
  24.                         }
  25.  
  26.                     }else {
  27.  
  28.                         $terms = get_terms('wpdmcategory', array('hide_empty' => false,'parent' => $parent));
  29.  
  30.                         foreach ($terms as $term) {
  31.  
  32.                             // 1. Skip if current user does not have access to this category ( Manage role based category access from category settings page )
  33.                             // 2. If following line is active, category roles access must be defined or it will not be listed
  34.                             //if( ! wpdm_user_has_access( $term->term_id, 'category' ) ) continue;
  35.  
  36.                             echo "<a class='list-group-item apc-item-{$xid} apc-cat-{$term->term_id}' href='#' data-item-id='{$term->term_id}'><i class=\"fas fa-folder\"></i>&nbsp;{$term->name}</a>";
  37.                         }
  38.                     }
  39.                     ?>
  40.                 </div>
  41.             </div>
  42.             <div class="col-md-9">
  43.                 <div class="wpdm-loading" id="wpdm-loading-<?php echo $xid; ?>" style="border-radius:0;display:none;right:15px;"><i class="fa fa-sun fa-spin"></i> <?php _e('Loading...','wpdm-archive-page'); ?></div>
  44.                 <div id="ap-content-<?php echo $xid; ?>">
  45.  
  46.  
  47.                     <div class="breadcrumb fetfont" style="border-radius:0;">
  48.                         <?php _e('Newest Items','wpdm-archive-page'); ?>
  49.                     </div>
  50.  
  51.                     <table class="table table-border table-striped">
  52.  
  53.                         <?php
  54.                         global $post;
  55.                         $cparams['posts_per_page'] = $params['items_per_page'];
  56.                         $cparams['post_type'] = 'wpdmpro';
  57.                         if(isset($cats) && count($cats) > 0) {
  58.                             $cparams['tax_query'] = array(array(
  59.                                 'taxonomy' => 'wpdmcategory',
  60.                                 'include_children' => false,
  61.                                 'field' => 'term_id',
  62.                                 'terms' => $cats
  63.                             ));
  64.                         }
  65.  
  66.                         //order parameter
  67.                         $order_by = isset($params['order_by'])? $params['order_by'] : 'date';
  68.                         $order    = isset($params['order'])? $params['order'] : 'desc';
  69.  
  70.                         if(isset($order_by) && $order_by != '') {
  71.                             //order parameter
  72.                             if($order_by == 'view_count' || $order_by == 'download_count' || $order_by == 'package_size_b'){
  73.                                 $cparams['meta_key'] = '__wpdm_' . $order_by;
  74.                                 $cparams['orderby'] = 'meta_value_num';
  75.                             }
  76.                             else {
  77.                                 $cparams['orderby'] = $order_by;
  78.                             }
  79.                             if($order == '') $order = 'ASC';
  80.                             $cparams['order'] = $order;
  81.  
  82.                         }
  83.                         //wpdmprecho($cparams);
  84.                         $packs = new WP_Query($cparams);
  85.  
  86.                         while( $packs->have_posts() ){
  87.                             $packs->the_post();
  88.  
  89.                             if( !wpdm_user_has_access( get_the_ID() ) ) continue;
  90.  
  91.                             $icon = get_post_meta( get_the_ID(), '__wpdm_icon', true );
  92.                             $icon = ( $icon == '' ) ? WPDM_BASE_URL.'assets/file-type-icons/wpdm.svg' : $icon;
  93.                             if(strpos($icon, 'file-type-icons/') && !strpos($icon, 'assets/file-type-icons/')) $icon = str_replace('file-type-icons/', 'assets/file-type-icons/', $icon);
  94.                             ?>
  95.                             <tr>
  96.                                 <td><img src="<?php echo $icon; ?>" style="float: left;width: 20px;margin: 0 10px 0 0;" /> <?php the_title(); ?></td>
  97.                                 <td><?php echo get_the_modified_date(); ?></td>
  98.                                 <td class="text-right">
  99.                                     <?= WPDM()->package->downloadLink(get_the_ID(), false, ['btnclass' => 'btn btn-xs btn-success mr-2']); ?>
  100.                                     <a href="#" class="btn btn-xs btn-primary btn-apc-sidebar apc-pack-<?php echo $xid; ?>" data-item-id="<?php the_ID(); ?>"><?php _e('View Details', 'wpdm-archive-page'); ?></a>
  101.                                 </td>
  102.                             </tr>
  103.                             <?php
  104.                         }
  105.                         ?>
  106.                     </table>
  107.  
  108.                 </div>
  109.             </div>
  110.         </div>
  111.     </div>
  112.  
  113.     <script>
  114.         var wpdmap_params = '<?= \WPDM\__\Crypt::encrypt($params) ?>';
  115.  
  116.         jQuery(function($){
  117.  
  118.             $('body').on('click', '.apc-item-<?php echo $xid; ?>', function(){
  119.                 $('#wpdm-loading-<?php echo $xid; ?>').fadeIn();
  120.                 $('.apc-item-<?php echo $xid; ?> i.fas').removeClass('fa-folder-open').addClass('fa-folder');
  121.                 $('.apc-cat-'+$(this).data('item-id')+' i.fas').removeClass('fa-folder').addClass('fa-folder-open');
  122.                 $('#ap-content-<?php echo $xid; ?>').load("<?php echo admin_url('admin-ajax.php'); ?>", {action:'load_ap_content', cid: $(this).data('item-id'), xid: '<?php echo $xid; ?>', order_by: '<?php echo $order_by; ?>', order: '<?php echo $order; ?>' }, function(){ $('#wpdm-loading-<?php echo $xid; ?>').fadeOut(); });
  123.                 return false;
  124.             });
  125.  
  126.             $('body').on('click', '.breadcrumb .folder', function(){
  127.                 $('#wpdm-loading-<?php echo $xid; ?>').fadeIn();
  128.                 $('.apc-cat-<?php echo $xid; ?> i.fas').removeClass('fa-folder-open').addClass('fa-folder');
  129.                 $('.apc-cat-'+$(this).data('cat')+' i.fas').removeClass('fa-folder').addClass('fa-folder-open');
  130.                 $('#ap-content-<?php echo $xid; ?>').load("<?php echo admin_url('admin-ajax.php'); ?>", {action:'load_ap_content', cid: $(this).data('cat'), xid: '<?php echo $xid; ?>', order_by: '<?php echo $order_by; ?>', order: '<?php echo $order; ?>'}, function(){ $('#wpdm-loading-<?php echo $xid; ?>').fadeOut(); });
  131.                 return false;
  132.             });
  133.  
  134.             $('body').on('click', '.apc-pack-<?php echo $xid; ?>', function(){
  135.                 $('#wpdm-loading-<?php echo $xid; ?>').fadeIn();
  136.                 $('#ap-content-<?php echo $xid; ?>').load("<?php echo admin_url('admin-ajax.php'); ?>", {action:'load_ap_content', pid: $(this).data('item-id'), pagetemplate: '<?php echo isset($params['page_template'])?$params['page_template']:''; ?>', xid: '<?php echo $xid; ?>'}, function(){ $('#wpdm-loading-<?php echo $xid; ?>').fadeOut(); });
  137.                 return false;
  138.             });
  139.         });
  140.     </script>
  141.     <style>
  142.         .w3eden .breadcrumb {
  143.             background: #f5f5f5;
  144.             border-radius: 2px;
  145.             padding: 15px;
  146.             margin-bottom: 15px;
  147.         }
  148.         .w3eden .breadcrumb a,
  149.         .w3eden .breadcrumb i{
  150.             line-height: 21px;
  151.             margin: 0 2px;
  152.         }
  153.         .w3eden .list-group-item .fas{
  154.             margin-right: 5px;
  155.         }
  156.         .w3eden .list-group{
  157.             margin-bottom: 15px;
  158.         }
  159.         .w3eden .list-group, .list-group-item{
  160.             border-radius: 0 !important;
  161.             position: relative;
  162.         }
  163.         .w3eden .table-border{
  164.             border: 1px solid #dddddd;
  165.         }
  166.         .w3eden .table-border td img{
  167.             box-shadow: none;
  168.         }
  169.         .w3eden .table-border td{
  170.             padding: 10px 15px !important;
  171.             vertical-align: middle !important;
  172.         }
  173.     </style>
  174.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement