Plugin Directory

Changeset 3446872


Ignore:
Timestamp:
01/26/2026 06:57:39 AM (2 months ago)
Author:
codename065
Message:
  • Fixed REST API validation error for "login" attribute in datatable and packages blocks
  • Fixed template path issue causing "Path cannot be empty" error
  • Fixed scandir path error in posts block template discovery
Location:
wpdm-gutenberg-blocks/trunk
Files:
23 edited

Legend:

Unmodified
Added
Removed
  • wpdm-gutenberg-blocks/trunk/build/blocks/call2action/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/call2action",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Call To Action",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/category-cards/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/category-blocks",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Category Cards",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/category/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/category",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Categories",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/container/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "custom-block/container",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Custom Container",
    77  "category": "common",
  • wpdm-gutenberg-blocks/trunk/build/blocks/dashboard/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/dashboard",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Dashboard",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/datatable/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/datatable",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "All Downloads Table",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/dropzone/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/dropzone",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "DropZone",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/package/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/package",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Package",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/packages/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/packages",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Packages",
    77  "category": "wpdm-blocks",
     
    2121  },
    2222  "attributes": {
     23    "login": {
     24      "type": "boolean",
     25      "default": false
     26    },
    2327    "title": {
    2428      "type": "string",
  • wpdm-gutenberg-blocks/trunk/build/blocks/search/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/search",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Search Results",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/section/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/section",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Section",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/signin-form/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/signin-form",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Login Form",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/build/blocks/signup-form/block.json

    r3446798 r3446872  
    33  "apiVersion": 3,
    44  "name": "download-manager/signup-form",
    5   "version": "2.4.2",
     5  "version": "3.0.0",
    66  "title": "Signup Form",
    77  "category": "wpdm-blocks",
  • wpdm-gutenberg-blocks/trunk/libs/blocks/category-cards.php

    r3056997 r3446872  
    3434                    'default' => 'rgb(0, 115, 255)'
    3535                ),
    36                 'border_color' => array(
    37                     'type'    => 'string',
    38                     'default' => 'rgb(0, 115, 255)'
    39                 ),
    4036                'hover_color'      => array(
    4137                    'type'      => 'string',
     
    6258        if(shortcode_exists('wpdm_category_blocks')){
    6359            $attributes['cats'] = trim($attributes['cats'], ",");
    64             return "<section class='__wpdm_gb_category_cards'>".do_shortcode("[wpdm_category_blocks categories='{$attributes['cats']}' cols='{$attributes['cols']}' border_color='{$attributes['border_color']}' button_color='{$attributes['button_color']}' hover_color='{$attributes['hover_color']}' container='{$attributes['className']}']")."</section>";
     60            return "<section class='__wpdm_gb_category_cards'>".do_shortcode("[wpdm_category_blocks categories='{$attributes['cats']}' cols='{$attributes['cols']}' button_color='{$attributes['button_color']}' hover_color='{$attributes['hover_color']}' container='{$attributes['className']}']")."</section>";
    6561        }
    66         return Messages::info("<div style='padding: 10px 0'>This block requires <a target='_blank' href='https://www.wpdownloadmanager.com/download/wpdm-directory-add-on/'><strong>WPDM - Directory Add-on</strong></a></div>", -1);
     62        return "<div class='w3eden'><div class='alert alert-info' style='padding: 10px'>This block requires <a target='_blank' href='https://www.wpdownloadmanager.com/download/wpdm-directory-add-on/'><strong>WPDM - Directory Add-on</strong></a></div></div>";
    6763    }
    6864
  • wpdm-gutenberg-blocks/trunk/libs/blocks/datatable.php

    r3446798 r3446872  
    1010use WPDM\__\Messages;
    1111use WPDM\__\Template;
    12 use WPDM\Block\traits\BlockJsonTrait;
    13 use WPDM\Block\traits\DataTableQueryTrait;
    1412
    1513if (!defined('ABSPATH')) die();
    1614
    1715class DataTable{
    18     use BlockJsonTrait;
    19     use DataTableQueryTrait;
    20 
    21     /**
    22      * Runtime defaults not defined in block.json (for shortcode/template use)
    23      */
    24     private const RUNTIME_DEFAULTS = [
    25         'author_name' => '',
    26         'page_numbers' => true,
    27         'cols' => 3,
    28         'colspad' => 2,
    29         'colsphone' => 1,
    30         'css_class' => 'wpdm_packages',
    31         'order_by' => 'date',
    32     ];
    3316
    3417    function __construct(){
    35         self::setBlockJsonPath(__WPDM_GBDIR__ . '/src/blocks/datatable/block.json');
    3618        add_action( 'init', array($this, 'block'), 9 );
    3719    }
    3820
    3921    function block(){
    40         // Get attributes from block.json (single source of truth)
    41         register_block_type('download-manager/datatable', [
    42             'attributes' => self::getBlockAttributes(),
    43             'render_callback' => [$this, 'output'],
    44         ]);
     22
     23        register_block_type( 'download-manager/datatable', array(
     24            'attributes'      => array(
     25                'login' => array(
     26                    'type'    => 'boolean',
     27                    'default' => false
     28                ),
     29                'categories' => array(
     30                    'type'    => 'string',
     31                    'default' => ""
     32                ),
     33                'include_children' => array(
     34                    'type'    => 'boolean',
     35                    'default' => false
     36                ),
     37                'operator' => array(
     38                    'type'    => 'string',
     39                    'default' => "IN"
     40                ),
     41                'xcats' => array(
     42                    'type'    => 'string',
     43                    'default' => ""
     44                ),
     45                'tag' => array(
     46                    'type'    => 'string',
     47                    'default' => ""
     48                ),
     49                'tag__not_in' => array(
     50                    'type'    => 'string',
     51                    'default' => ""
     52                ),
     53                'author' => array(
     54                    'type'    => 'string',
     55                    'default' => ""
     56                ),
     57                'author__not_in' => array(
     58                    'type'    => 'string',
     59                    'default' => ""
     60                ),
     61                'title' => array(
     62                    'type'    => 'string',
     63                    'default' => ""
     64                ),
     65                'desc' => array(
     66                    'type'    => 'string',
     67                    'default' => ""
     68                ),
     69                'toolbar' => array(
     70                    'type'    => 'string',
     71                    'default' => "1"
     72                ),
     73                'items_per_page' => array(
     74                    'type'    => 'string',
     75                    'default' => "10"
     76                ),
     77                'paging' => array(
     78                    'type'    => 'string',
     79                    'default' => "1"
     80                ),
     81                'cols' => array(
     82                    'type'    => 'string',
     83                    'default' => ""
     84                ),
     85                'colheads' => array(
     86                    'type'    => 'string',
     87                    'default' => ""
     88                ),
     89
     90                'orderby' => array(
     91                    'type'    => 'string',
     92                    'default' => ""
     93                ),
     94                'order' => array(
     95                    'type'    => 'string',
     96                    'default' => ""
     97                ),
     98                'async' => array(
     99                    'type'    => 'string',
     100                    'default' => "1"
     101                ),
     102                'template'      => array(
     103                    'type'      => 'string',
     104                    'default'   => 'link-template-panel'
     105                ),
     106                'className'      => array(
     107                    'type'      => 'string',
     108                    'default'   => ''
     109                )
     110            ),
     111            'render_callback' => array($this, 'output'),
     112        ) );
    45113    }
    46114
    47115    /**
    48      * DataTable block output
    49      * Uses DataTableQueryTrait for query building
    50      *
    51      * @param array $shortcode_params Shortcode parameters
    52      * @return string HTML output
     116     * @param array $params
     117     * @return string
    53118     */
    54     function dataTable($shortcode_params = array())
     119    function dataTable($params = array('items_per_page' => 10, 'title' => false, 'desc' => false, 'order_by' => 'date', 'order' => 'DESC', 'paging' => false, 'page_numbers' => true, 'toolbar' => 1, 'template' => '', 'cols' => "", 'colheads' => "", 'tags' => '', 'categories' => '', 'year' => '', 'month' => '', 's' => '', 'css_class' => 'wpdm_packages', 'scid' => '', 'async' => 1))
    55120    {
    56         global $post;
     121        global $current_user, $post;
    57122
    58123        static $wpdm_packages = 0;
    59124
    60         // Login check
    61         if (isset($shortcode_params['login']) && $shortcode_params['login'] == 1 && !is_user_logged_in()) {
    62             return WPDM()->user->login->form($shortcode_params);
    63         }
     125        if (isset($params['login']) && $params['login'] == 1 && !is_user_logged_in())
     126            return WPDM()->user->login->form($params);
    64127
    65128        $wpdm_packages++;
    66129
    67         // Store original params for later use
    68         $scparams = $shortcode_params;
    69 
    70         // Get defaults from block.json (single source of truth) + runtime defaults
    71         $runtimeDefaults = array_merge(self::RUNTIME_DEFAULTS, [
    72             'scid' => 'wpdm_packages_' . $wpdm_packages,
    73         ]);
    74         $scparams = $this->applyBlockDefaults($scparams, $runtimeDefaults, 'wpdm_packages');
    75 
    76         // Extract variables for template use
    77         $items_per_page = (int)($scparams['items_per_page'] ?: 10);
    78         $title = $scparams['title'];
    79         $toolbar = $scparams['toolbar'] ?? 0;
    80         $order = $scparams['order'] ?? 'desc';
    81         $order_field = $scparams['order_by'] ?? 'date';
    82 
    83         // Override from GET params if present
     130        //$params['order_by']  = isset($params['order_field']) && $params['order_field'] != '' && !isset($params['order_by'])?$params['order_field']:$params['order_by'];
     131        $scparams = $params;
     132        $defaults = array('author' => '', 'author_name' => '', 'items_per_page' => 10, 'title' => false, 'desc' => false, 'order_by' => 'date', 'order' => 'DESC', 'paging' => false, 'page_numbers' => true, 'toolbar' => 1, 'template' => 'link-template-panel', 'cols' => 3, 'colspad' => 2, 'colsphone' => 1, 'css_class' => 'wpdm_packages', 'scid' => 'wpdm_packages_' . $wpdm_packages, 'async' => 1);
     133        $params = shortcode_atts($defaults, $params, 'wpdm_packages');
     134
     135        if (is_array($params))
     136            extract($params);
     137
     138        if (!isset($items_per_page) || $items_per_page < 1) $items_per_page = 10;
     139
     140        if (isset($order_by) && !isset($order_field)) $order_field = $order_by;
     141        $order_field = isset($order_field) ? $order_field : 'date';
    84142        $order_field = isset($_GET['orderby']) ? esc_attr($_GET['orderby']) : $order_field;
     143        $order = isset($order) ? $order : 'desc';
    85144        $order = isset($_GET['order']) ? esc_attr($_GET['order']) : $order;
    86 
    87         // Build query using trait method
    88         $params = $this->buildPackageQuery($scparams);
    89 
    90         // Execute query
     145        $cp = wpdm_query_var('cp', 'num');
     146        if (!$cp) $cp = 1;
     147
     148        $params = array(
     149            'post_type' => 'wpdmpro',
     150            'paged' => $cp,
     151            'posts_per_page' => $items_per_page,
     152        );
     153
     154        if (isset($scparams['s']) && $scparams['s'] != '') $params['s'] = $scparams['s'];
     155        if (isset($_GET['skw']) && $_GET['skw'] != '') $params['s'] = wpdm_query_var('skw', 'txt');
     156        if (isset($scparams['author']) && $scparams['author'] != '') $params['author'] = $scparams['author'];
     157        if (isset($scparams['author_name']) && $scparams['author_name'] != '') $params['author_name'] = $scparams['author_name'];
     158        if (isset($scparams['author__not_in']) && $scparams['author__not_in'] != '') $params['author__not_in'] = explode(",", $scparams['author__not_in']);
     159        if (isset($scparams['search']) && $scparams['search'] != '') $params['s'] = $scparams['search'];
     160        if (isset($scparams['tag']) && $scparams['tag'] != '') $params['tag'] = $scparams['tag'];
     161        if (isset($scparams['tag_id']) && $scparams['tag_id'] != '') $params['tag_id'] = $scparams['tag_id'];
     162        if (isset($scparams['tag__and']) && $scparams['tag__and'] != '') $params['tag__and'] = explode(",", $scparams['tag__and']);
     163        if (isset($scparams['tag__in']) && $scparams['tag__in'] != '') $params['tag__in'] = explode(",", $scparams['tag__in']);
     164        if (isset($scparams['tag__not_in']) && $scparams['tag__not_in'] != '') {
     165            $params['tag__not_in'] = explode(",", $scparams['tag__not_in']);
     166            foreach ($params['tag__not_in'] as &$tg) {
     167                if (!is_numeric($tg)) {
     168                    $tgg = get_term_by('slug', $tg, 'post_tag');
     169                    $tg = $tgg->term_id;
     170                }
     171            }
     172        }
     173
     174        if (isset($scparams['post__in']) && $scparams['post__in'] != '') $params['post__in'] = explode(",", $scparams['post__in']);
     175        if (isset($scparams['post__not_in']) && $scparams['post__not_in'] != '') $params['post__not_in'] = explode(",", $scparams['post__not_in']);
     176
     177        if (isset($scparams['tag_slug__and']) && $scparams['tag_slug__and'] != '') $params['tag_slug__and'] = explode(",", $scparams['tag_slug__and']);
     178        if (isset($scparams['tag_slug__in']) && $scparams['tag_slug__in'] != '') $params['tag_slug__in'] = explode(",", $scparams['tag_slug__in']);
     179        if (isset($scparams['categories']) && $scparams['categories'] != '') {
     180            $operator = isset($scparams['operator']) ? $scparams['operator'] : 'IN';
     181            $scparams['categories'] = trim($scparams['categories'], ",");
     182            $params['tax_query'] = array(array(
     183                'taxonomy' => 'wpdmcategory',
     184                'field' => 'slug',
     185                'terms' => explode(",", $scparams['categories']),
     186                'include_children' => (isset($scparams['include_children']) && $scparams['include_children'] != '') ? $scparams['include_children'] : false,
     187                'operator' => $operator
     188            ));
     189        }
     190
     191        if (isset($scparams['xcats']) && $scparams['xcats'] != '') {
     192            $xcats = explode(",", $scparams['xcats']);
     193            foreach ($xcats as &$xcat) {
     194                if (!is_numeric($xcat) && $xcat !== '') {
     195                    $xct = get_term_by('slug', $xcat, 'wpdmcategory');
     196                    $xcat = $xct->term_id;
     197                }
     198            }
     199            $params['tax_query'][] = array(
     200                'taxonomy' => 'wpdmcategory',
     201                'field' => 'term_id',
     202                'terms' => $xcats,
     203                'operator' => 'NOT IN',
     204            );
     205        }
     206
     207        if (isset($params['tax_query']) && count($params['tax_query']) > 1)
     208            $params['tax_query']['relation'] = 'AND';
     209
     210
     211        if (get_option('_wpdm_hide_all', 0) == 1) {
     212            $params['meta_query'] = array(
     213                array(
     214                    'key' => '__wpdm_access',
     215                    'value' => '"guest"',
     216                    'compare' => 'LIKE'
     217                )
     218            );
     219            if (is_user_logged_in()) {
     220                $params['meta_query'][] = array(
     221                    'key' => '__wpdm_access',
     222                    'value' => $current_user->roles[0],
     223                    'compare' => 'LIKE'
     224                );
     225                $params['meta_query']['relation'] = 'OR';
     226            }
     227        }
     228
     229        if (isset($scparams['year']) || isset($scparams['month']) || isset($scparams['day'])) {
     230            $date_query = array();
     231
     232            if (isset($scparams['day']) && $scparams['day'] == 'today') $scparams['day'] = date('d');
     233            if (isset($scparams['year']) && $scparams['year'] == 'this') $scparams['year'] = date('Y');
     234            if (isset($scparams['month']) && $scparams['month'] == 'this') $scparams['month'] = date('m');
     235            if (isset($scparams['week']) && $scparams['week'] == 'this') $scparams['week'] = date('W');
     236
     237            if (isset($scparams['year'])) $date_query['year'] = $scparams['year'];
     238            if (isset($scparams['month'])) $date_query['month'] = $scparams['month'];
     239            if (isset($scparams['week'])) $date_query['week'] = $scparams['week'];
     240            if (isset($scparams['day'])) $date_query['day'] = $scparams['day'];
     241            $params['date_query'][] = $date_query;
     242        }
     243
     244        $order_fields = array('__wpdm_download_count', '__wpdm_view_count', '__wpdm_package_size_b');
     245        if (!in_array("__wpdm_" . $order_field, $order_fields)) {
     246            $params['orderby'] = $order_field;
     247            $params['order'] = $order;
     248        } else {
     249            $params['orderby'] = 'meta_value_num';
     250            $params['meta_key'] = "__wpdm_" . $order_field;
     251            $params['order'] = $order;
     252        }
     253
     254        $params = apply_filters("wpdm_packages_query_params", $params);
     255
     256        //wpdmprecho($params);
    91257        $packs = new \WP_Query($params);
    92258
     
    136302
    137303    function output( $attributes, $content){
    138         if(version_compare(WPDM_VERSION, '5.0', '<')) return Messages::info("This  block is only available with <a href='https://www.wpdownloadmanager.com/pricing/' target=_blank >WordPress Download Manager Pro</a>", -1);
    139         if(isset($attributes['cols']) && $attributes['cols'] === '') unset($attributes['cols']);
    140         if(isset($attributes['colheads']) && $attributes['colheads'] === '') unset($attributes['colheads']);
     304        if(version_compare(WPDM_VERSION, '5.0', '<')) return "<div class='w3eden'><div class='alert alert-info'>This block is only available with <a href='https://www.wpdownloadmanager.com/pricing/' target='_blank'>WordPress Download Manager Pro</a></div></div>";
     305        if($attributes['cols'] === '') unset($attributes['cols']);
     306        if($attributes['colheads'] === '') unset($attributes['colheads']);
    141307        return $this->dataTable($attributes);
    142308    }
  • wpdm-gutenberg-blocks/trunk/libs/blocks/packages.php

    r3446798 r3446872  
    99
    1010use WPDM\__\Messages;
    11 use WPDM\Block\traits\BlockJsonTrait;
    1211
    1312if (!defined('ABSPATH')) die();
    1413
    1514class Packages{
    16     use BlockJsonTrait;
    1715
    1816    function __construct(){
    19         self::setBlockJsonPath(__WPDM_GBDIR__ . '/src/blocks/packages/block.json');
    2017        add_action( 'init', array($this, 'block'), 9 );
    2118    }
    2219
    2320    function block(){
    24         // Get attributes from block.json (single source of truth)
    25         register_block_type('download-manager/packages', [
    26             'attributes' => self::getBlockAttributes(),
    27             'render_callback' => [$this, 'output'],
    28         ]);
     21
     22        register_block_type( 'download-manager/packages', array(
     23            'attributes'      => array(
     24                'login' => array(
     25                    'type'    => 'boolean',
     26                    'default' => false
     27                ),
     28                'search' => array(
     29                    'type'    => 'string',
     30                    'default' => ""
     31                ),
     32                'categories' => array(
     33                    'type'    => 'string',
     34                    'default' => ""
     35                ),
     36                'include_children' => array(
     37                    'type'    => 'boolean',
     38                    'default' => false
     39                ),
     40                'operator' => array(
     41                    'type'    => 'string',
     42                    'default' => "IN"
     43                ),
     44                'xcats' => array(
     45                    'type'    => 'string',
     46                    'default' => ""
     47                ),
     48                'tag' => array(
     49                    'type'    => 'string',
     50                    'default' => ""
     51                ),
     52                'tag__not_in' => array(
     53                    'type'    => 'string',
     54                    'default' => ""
     55                ),
     56                'author' => array(
     57                    'type'    => 'string',
     58                    'default' => ""
     59                ),
     60                'author__not_in' => array(
     61                    'type'    => 'string',
     62                    'default' => ""
     63                ),
     64                'title' => array(
     65                    'type'    => 'string',
     66                    'default' => ""
     67                ),
     68                'desc' => array(
     69                    'type'    => 'string',
     70                    'default' => ""
     71                ),
     72                'toolbar' => array(
     73                    'type'    => 'string',
     74                    'default' => "1"
     75                ),
     76                'tbgrid' => array(
     77                    'type'    => 'string',
     78                    'default' => "5,2,2,3"
     79                ),
     80                'items_per_page' => array(
     81                    'type'    => 'string',
     82                    'default' => "10"
     83                ),
     84                'paging' => array(
     85                    'type'    => 'string',
     86                    'default' => "1"
     87                ),
     88                'cols' => array(
     89                    'type'    => 'string',
     90                    'default' => "1"
     91                ),
     92                'colspad' => array(
     93                    'type'    => 'string',
     94                    'default' => "1"
     95                ),
     96                'colsphone' => array(
     97                    'type'    => 'string',
     98                    'default' => "1"
     99                ),
     100                'orderby' => array(
     101                    'type'    => 'string',
     102                    'default' => ""
     103                ),
     104                'order' => array(
     105                    'type'    => 'string',
     106                    'default' => ""
     107                ),
     108                'async' => array(
     109                    'type'    => 'string',
     110                    'default' => "1"
     111                ),
     112                'template'      => array(
     113                    'type'      => 'string',
     114                    'default'   => 'link-template-panel'
     115                ),
     116                'className'      => array(
     117                    'type'      => 'string',
     118                    'default'   => ''
     119                )
     120            ),
     121            'render_callback' => array($this, 'output'),
     122        ) );
    29123    }
    30124
     
    44138                }
    45139            }
    46             if(isset($attributes['tag'])) $attributes['tags'] = $attributes['tag'];
    47140            return "<section class='__wpdm_gb_section __wpdm_gb_packages'>".WPDM()->package->shortCodes->packages($attributes)."</section>";
    48141        }
    49142        else
    50             return Messages::info("Block is available with the pro version only!");
     143            return "<div class='w3eden'><div class='alert alert-info'>Block is available with the pro version only!</div></div>";
    51144    }
    52145
  • wpdm-gutenberg-blocks/trunk/libs/blocks/posts.php

    r3446798 r3446872  
    126126        $wpdm_posts++;
    127127
    128         // Store original params
     128        //$params['order_by']  = isset($params['order_field']) && $params['order_field'] != '' && !isset($params['order_by'])?$params['order_field']:$params['order_by'];
    129129        $scparams = $params;
    130 
    131         // Apply defaults
    132         $defaults = array(
    133             'author' => '',
    134             'author_name' => '',
    135             'items_per_page' => 10,
    136             'title' => false,
    137             'desc' => false,
    138             'order_by' => 'date',
    139             'order' => 'DESC',
    140             'paging' => false,
    141             'page_numbers' => true,
    142             'toolbar' => 1,
    143             'template' => 'link-template-panel',
    144             'cols' => 3,
    145             'colspad' => 2,
    146             'colsphone' => 1,
    147             'css_class' => 'wpdm_packages',
    148             'e_id' => 'wpdm_packages_' . $wpdm_posts,
    149             'async' => 1
    150         );
    151         $scparams = shortcode_atts($defaults, $scparams);
    152 
    153         // Extract needed variables explicitly (avoid extract())
    154         $items_per_page = (int)($scparams['items_per_page'] ?: 10);
    155         $cols = (int)($scparams['cols'] ?: 3);
    156         $colspad = (int)($scparams['colspad'] ?: 2);
    157         $colsphone = (int)($scparams['colsphone'] ?: 1);
    158         $title = $scparams['title'];
    159         $desc = $scparams['desc'];
    160         $paging = $scparams['paging'];
    161         $toolbar = $scparams['toolbar'];
    162         $template = $scparams['template'];
    163         $css_class = $scparams['css_class'];
    164         $e_id = $scparams['e_id'];
    165         $async = $scparams['async'];
    166 
    167         $cwd_class = "col-md-" . (int)(12 / $cols);
    168         $cwdsm_class = "col-sm-" . (int)(12 / $colspad);
    169         $cwdxs_class = "col-xs-" . (int)(12 / $colsphone);
    170 
    171         // Determine order field and order
    172         $order_field = $scparams['order_by'] ?: 'date';
     130        $defaults = array('author' => '', 'author_name' => '', 'items_per_page' => 10, 'title' => false, 'desc' => false, 'order_by' => 'date', 'order' => 'DESC', 'paging' => false, 'page_numbers' => true, 'toolbar' => 1, 'template' => 'link-template-panel','cols'=>3, 'colspad'=>2, 'colsphone' => 1, 'css_class' => 'wpdm_packages', 'e_id' => 'wpdm_packages_'.$wpdm_posts, 'async' => 1);
     131        $params = shortcode_atts($defaults, $params );
     132
     133        if(is_array($params))
     134            extract($params);
     135
     136        if(!isset($items_per_page) || $items_per_page < 1) $items_per_page = 10;
     137
     138        $cwd_class = "col-md-".(int)(12/$cols);
     139        $cwdsm_class = "col-sm-".(int)(12/$colspad);
     140        $cwdxs_class = "col-xs-".(int)(12/$colsphone);
     141
     142        if(isset($order_by) && !isset($order_field)) $order_field = $order_by;
     143        $order_field = isset($order_field) ? $order_field : 'date';
    173144        $order_field = isset($_GET['orderby']) ? esc_attr($_GET['orderby']) : $order_field;
    174         $order = $scparams['order'] ?: 'desc';
     145        $order = isset($order) ? $order : 'desc';
    175146        $order = isset($_GET['order']) ? esc_attr($_GET['order']) : $order;
    176147        $cp = wpdm_query_var('cp','num');
  • wpdm-gutenberg-blocks/trunk/libs/blocks/search.php

    r2581322 r3446872  
    6363        }
    6464        else
    65             return Messages::info("Block is available with the pro version only!",  -1);
     65            return "<div class='w3eden'><div class='alert alert-info'>Block is available with the pro version only!</div></div>";
    6666    }
    6767
  • wpdm-gutenberg-blocks/trunk/libs/blocks/signup-form.php

    r3342092 r3446872  
    2424        $role_ids = get_option("__wpdm_signup_roles", array());
    2525        foreach ($role_ids as $role){
    26             if(isset($roles[$role]))
    27                 $options[] = array("label" => $roles[$role], "value" => $role);
     26            $options[] = array("label" => $roles[$role], "value" => $role);
    2827        }
    2928        ?>
  • wpdm-gutenberg-blocks/trunk/libs/blocks/tpls/datatable.php

    r3446798 r3446872  
    1111//$all_downloads
    1212if(!isset($scid)) $scid = uniqid();
    13 //wpdmprecho($scparams);
     13//wpdmdd($scparams);
    1414$_scparams =  \WPDM\__\Crypt::encrypt($scparams);
    1515
     
    8989    }
    9090    #card_datatable_<?php echo $scid;  ?> td.__dt_col_download_link .btn{
    91         display: block;
    9291        width: 100%;
    9392    }
     
    132131    .w3eden .table-striped tbody tr:nth-of-type(2n+1) {
    133132        background-color: rgba(0,0,0,0.015);
     133    }
     134
     135    /* Dark Mode Support */
     136    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?>,
     137    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .card {
     138        background: var(--dm-bg-secondary, #1e293b);
     139        border-color: var(--dm-border, rgba(255,255,255,0.1));
     140        color: var(--dm-text, #f1f5f9);
     141    }
     142    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .card-header,
     143    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .card-footer {
     144        background: var(--dm-bg-tertiary, #334155) !important;
     145        border-color: var(--dm-border, rgba(255,255,255,0.1));
     146    }
     147    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> th {
     148        background-color: var(--dm-bg-tertiary, #334155);
     149        color: var(--dm-text-secondary, #cbd5e1);
     150        border-color: var(--dm-border, rgba(255,255,255,0.1));
     151    }
     152    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> td {
     153        border-color: var(--dm-border, rgba(255,255,255,0.1));
     154    }
     155    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .form-control,
     156    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .custom-select {
     157        background-color: var(--dm-bg-secondary, #1e293b);
     158        border-color: var(--dm-border, rgba(255,255,255,0.15));
     159        color: var(--dm-text, #f1f5f9);
     160    }
     161    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .search-field {
     162        background-color: var(--dm-bg-secondary, #1e293b);
     163        background-image: url(data:image/svg+xml;base64,PHN2ZyBpZD0iTGF5ZXJfMiIgaGVpZ2h0PSI1MTIiIHZpZXdCb3g9IjAgMCAyNCAyNCIgd2lkdGg9IjUxMiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgZGF0YS1uYW1lPSJMYXllciAyIj48bGluZWFyR3JhZGllbnQgaWQ9Ik9yYW5nZV9ZZWxsb3ciIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4MT0iLTEuNzYyIiB4Mj0iMjAuOTg0IiB5MT0iMjUuMzY3IiB5Mj0iNi44ODYiPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iI2ZmZjMzYiIvPjxzdG9wIG9mZnNldD0iLjA0IiBzdG9wLWNvbG9yPSIjZmVlNzJlIi8+PHN0b3Agb2Zmc2V0PSIuMTE3IiBzdG9wLWNvbG9yPSIjZmVkNTFiIi8+PHN0b3Agb2Zmc2V0PSIuMTk2IiBzdG9wLWNvbG9yPSIjZmRjYTEwIi8+PHN0b3Agb2Zmc2V0PSIuMjgxIiBzdG9wLWNvbG9yPSIjZmRjNzBjIi8+PHN0b3Agb2Zmc2V0PSIuNjY5IiBzdG9wLWNvbG9yPSIjZjM5MDNmIi8+PHN0b3Agb2Zmc2V0PSIuODg4IiBzdG9wLWNvbG9yPSIjZWQ2ODNjIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZTkzZTNhIi8+PC9saW5lYXJHcmFkaWVudD48cGF0aCBkPSJtMjIuNzA3IDIxLjI5My01LjEwNy01LjExMWE5LjM1NSA5LjM1NSAwIDEgMCAtMS40MTggMS40MThsNS4xMTEgNS4xMTFhMSAxIDAgMCAwIDEuNDE0LTEuNDE0em0tMTkuNzA3LTEwLjk2YTcuMzM0IDcuMzM0IDAgMSAxIDcuMzMzIDcuMzM0IDcuMzQyIDcuMzQyIDAgMCAxIC03LjMzMy03LjMzNHoiIGZpbGw9InVybCgjT3JhbmdlX1llbGxvdykiLz48L3N2Zz4=);
     164    }
     165    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .table-striped tbody tr:nth-of-type(2n+1) {
     166        background-color: rgba(255,255,255,0.02);
     167    }
     168    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .package-title {
     169        color: var(--dm-text, #f1f5f9);
     170    }
     171    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .pagination .page-link {
     172        background: var(--dm-bg-secondary, #1e293b);
     173        border-color: var(--dm-border, rgba(255,255,255,0.1));
     174        color: var(--dm-text, #f1f5f9);
     175    }
     176    .w3eden.dark-mode #card_datatable_<?php echo $scid; ?> .pagination .page-item.active .page-link {
     177        background: var(--color-primary);
     178        border-color: var(--color-primary);
     179    }
     180
     181    /* System preference dark mode */
     182    @media (prefers-color-scheme: dark) {
     183        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?>,
     184        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .card {
     185            background: var(--dm-bg-secondary, #1e293b);
     186            border-color: var(--dm-border, rgba(255,255,255,0.1));
     187            color: var(--dm-text, #f1f5f9);
     188        }
     189        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .card-header,
     190        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .card-footer {
     191            background: var(--dm-bg-tertiary, #334155) !important;
     192            border-color: var(--dm-border, rgba(255,255,255,0.1));
     193        }
     194        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> th {
     195            background-color: var(--dm-bg-tertiary, #334155);
     196            color: var(--dm-text-secondary, #cbd5e1);
     197            border-color: var(--dm-border, rgba(255,255,255,0.1));
     198        }
     199        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> td {
     200            border-color: var(--dm-border, rgba(255,255,255,0.1));
     201        }
     202        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .form-control,
     203        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .custom-select {
     204            background-color: var(--dm-bg-secondary, #1e293b);
     205            border-color: var(--dm-border, rgba(255,255,255,0.15));
     206            color: var(--dm-text, #f1f5f9);
     207        }
     208        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .search-field {
     209            background-color: var(--dm-bg-secondary, #1e293b);
     210        }
     211        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .table-striped tbody tr:nth-of-type(2n+1) {
     212            background-color: rgba(255,255,255,0.02);
     213        }
     214        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .package-title {
     215            color: var(--dm-text, #f1f5f9);
     216        }
     217        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .pagination .page-link {
     218            background: var(--dm-bg-secondary, #1e293b);
     219            border-color: var(--dm-border, rgba(255,255,255,0.1));
     220            color: var(--dm-text, #f1f5f9);
     221        }
     222        .w3eden:not(.light-mode) #card_datatable_<?php echo $scid; ?> .pagination .page-item.active .page-link {
     223            background: var(--color-primary);
     224            border-color: var(--color-primary);
     225        }
    134226    }
    135227
     
    198290        <thead>
    199291        <tr>
    200             <?php  foreach ($colheads as $index => $colhead){ ?>
    201                 <th class="<?php echo $cols[$index] ?>"><?= esc_attr__($colhead, WPDM_TEXT_DOMAIN); ?></th>
     292            <?php  foreach ($colheads as $index => $colhead){ if(!isset($cols[$index]) || trim($cols[$index]) === '') continue; ?>
     293                <th class="<?php echo esc_attr($cols[$index]); ?>" id="<?php echo esc_attr($cols[$index]); ?>"><?php echo esc_html__($colhead, 'download-manager'); ?></th>
    202294            <?php  } ?>
    203295        </tr>
     
    205297        <tbody id="wpdm_datatable_<?php echo $scid;  ?>">
    206298        <tr v-for="package in packages">
    207             <?php  foreach ($cols as $col){ ?>
    208                 <td  class="<?php echo  $col; ?>"><span v-html="package.<?php echo str_replace(",", "__", $col); ?>"></span></td>
     299            <?php  foreach ($cols as $col){ if(trim($col) === '') continue; ?>
     300                <td  class="__dt_col_<?php echo esc_attr($col); ?>"><span v-html="package.<?php echo esc_js(str_replace(",", "__", $col)); ?>"></span></td>
    209301            <?php  } ?>
    210302        </tr>
  • wpdm-gutenberg-blocks/trunk/package.json

    r3446798 r3446872  
    11{
    22  "name": "wpdm-gutenberg-blocks",
    3   "version": "3.0.0",
     3  "version": "3.0.1",
    44  "description": "Editor Blocks for WordPress Download Manager",
    55  "main": "build/index.js",
  • wpdm-gutenberg-blocks/trunk/readme.txt

    r3446798 r3446872  
    3939== Changelog ==
    4040
     41= 3.0.1 - 2026.01.26 =
     42🐞 Fixed REST API validation error for "login" attribute in datatable and packages blocks
     43🐞 Fixed template path issue causing "Path cannot be empty" error
     44🐞 Fixed scandir path error in posts block template discovery
     45
    4146= 3.0.0 - 2026.01.26 =
    4247✅ Completely rebuilt Table Builder UI with modern React-based interface
  • wpdm-gutenberg-blocks/trunk/wpdm-gutenberg-blocks.php

    r3446798 r3446872  
    55 * Description: Editor Blocks for Download Manager
    66 * Author: WordPress Download Manager
    7  * Version:  3.0.0
     7 * Version:  3.0.1
    88 * Author URI: https://www.wpdownloadmanager.com/
    99 * Text Domain: wpdm-gblocks
     
    2121
    2222// Plugin constants
    23 define('WPDM_GB_VERSION', '3.0.0');
     23define('WPDM_GB_VERSION', '3.0.1');
    2424define('__WPDM_GB__', __FILE__);
    2525define('__WPDM_GBDIR__', __DIR__);
Note: See TracChangeset for help on using the changeset viewer.