Download Manager Shortcodes

Below, you’ll find a detailed guide on how to add the Download Manager Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Download Manager Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Download Manager Plugin and the shortcodes it provides:

Plugin Icon
Download Manager

"Download Manager is a reliable WordPress plugin made to enhance and streamline all your downloading operations. It offers efficient file management, secure downloads, and user accessibility control."

★★★★✩ (936) Active Installs: 100000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [wpdm_asset]
  • [wpdm_category]
  • [wpdm_category_link]
  • [wpdm_media]
  • [wpdm_package]
  • [wpdm_direct_link]
  • [wpdm_packages]
  • [wpdm_tag]
  • [wpdm_download_count]
  • [wpdm_package_count]
  • [wpdm_all_packages]
  • [wpdm_search_result]
  • [wpdm_user_dashboard]
  • [wpdm_edit_profile]
  • [wpdm_login_form]
  • [wpdm_modal_login_form]
  • [wpdm_logout_url]
  • [wpdm_user_favourites]
  • [wpdm_members]

Download Manager [wpdm_asset] Shortcode

The WP Download Manager shortcode is used to embed a downloadable asset into a post or page. It requires an ‘id’ parameter that corresponds to the asset’s ID. If the asset is not found, it returns an error message. The asset is retrieved and then displayed using the ’embed-asset.php’ template.

Shortcode: [wpdm_asset]

Parameters

Here is a list of all possible wpdm_asset shortcode parameters and attributes:

  • id – Unique identifier for the downloadable asset

Examples and Usage

Basic example – A simple usage of the shortcode to display a specific asset by referencing its ID.

[wpdm_asset id=1 /]

Advanced examples

Using the shortcode to display an asset by its ID. If the asset is not found, it will display an error message.

[wpdm_asset id=1 /]

Another advanced usage of the shortcode can be to display multiple assets by their IDs. This can be useful when you want to display a collection of assets in a single place.

[wpdm_asset id=1,2,3 /]

Please note that the ‘id’ parameter in the shortcode accepts a single value or a comma-separated list of values. Each value should be the ID of an asset you want to display.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_asset] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_asset', array($this, 'wpdmAsset'));

Shortcode PHP function:

function wpdmAsset($params)
    {
        if (!isset($params['id'])) return \WPDM\__\Messages::error(__("Asset not found!", "download-manager"), -1);
        $path_or_id = (int)$params['id'];
        $asset = new Asset();
        $asset->get($path_or_id);
        ob_start();
        include Template::locate("embed-asset.php", __DIR__.'/views');
        $content = ob_get_clean();
        return $content;
    }

Code file location:

download-manager/download-manager/src/AssetManager/AssetManager.php

Download Manager [wpdm_category] Shortcode

The WPDM Category shortcode is a powerful tool that allows you to display a list of packages from specified categories. The function ‘listPackages’ accepts an array of parameters that can be customized, such as the number of items per page, sort order, and display settings. It then fetches the relevant categories and their associated packages, returning them in the desired format.

Shortcode: [wpdm_category]

Parameters

Here is a list of all possible wpdm_category shortcode parameters and attributes:

  • id – Unique identifier for the download category
  • operator – Defines the type of comparison for category selection
  • items_per_page – Number of download items to display per page
  • title – Shows the title of the download package if set to true
  • desc – Shows the description of the download package if set to true
  • orderby – Defines the order attribute of the download packages
  • order – Determines the sorting order, either ascending or descending
  • paging – Enables pagination if set to true
  • toolbar – Shows the toolbar for category navigation if set to 1
  • template – Defines the template for displaying the download packages
  • cols – Number of columns to display on desktop screens
  • colspad – Number of columns to display on tablet screens
  • colsphone – Number of columns to display on mobile screens
  • morelink – Shows a ‘More’ link if set to 1

Examples and Usage

Basic example – The following shortcode displays a list of packages from a specific category. The category is identified by its ID.

[wpdm_category id=3 /]

Advanced examples

In this example, the shortcode is used to display a list of packages from a specific category, with the number of items per page set to 5, and the order of the items set by their creation date in ascending order.

[wpdm_category id=3 items_per_page=5 orderby=create_date order=asc /]

In this next example, the shortcode is used to display a list of packages from multiple categories. The categories are identified by their IDs, and the ‘operator’ parameter is set to ‘AND’, meaning that only packages that belong to all specified categories will be displayed.

[wpdm_category id="3,5,7" operator=AND /]

Finally, this example demonstrates how to use the shortcode to display a list of packages from a specific category, with a custom template and a specific number of columns for the display.

[wpdm_category id=3 template="custom_template" cols=4 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_category] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("wpdm_category", [$this, 'listPackages']);

Shortcode PHP function:

function listPackages($params = array('id' => '', 'operator' => 'IN', 'items_per_page' => 10, 'title' => false, 'desc' => false, 'orderby' => 'create_date', 'order' => 'desc', 'paging' => false, 'toolbar' => 1, 'template' => '', 'cols' => 3, 'colspad' => 2, 'colsphone' => 1, 'morelink' => 1))
    {
        $params['categories'] = $params['id'];
        $params['catsc'] = 1;
        unset($params['id']);

        if(!in_array(wpdm_valueof($params, 'cat_field'), ['id', 'term_id'])) {
            $ids = [];
            foreach (explode(",", $params['categories']) as $slug) {
                $term = get_term_by('slug', $slug, 'wpdmcategory');
                if($term)
                    $ids[] = $term->term_id;
            }
            if(count($ids) > 0) {
                $params['categories'] = implode(",", $ids);
                $params['cat_field'] = 'id';
            }
        }
        return WPDM()->package->shortCodes->packages($params);

    }

Code file location:

download-manager/download-manager/src/Category/Shortcodes.php

Download Manager [wpdm_category_link] Shortcode

The WPDM_Category_Link shortcode is used to generate a link to a specific download category. This shortcode retrieves the category details based on the ‘id’ parameter. If the category exists, it prepares the data, including the category icon, and outputs it using a specified template. If no template is provided, it defaults to ‘category-link-shortcode.php’.

Shortcode: [wpdm_category_link]

Parameters

Here is a list of all possible wpdm_category_link shortcode parameters and attributes:

  • id – The unique identifier for the category.
  • template – Specifies the template to use, defaults to ‘category-link-shortcode.php’.

Examples and Usage

Basic example – A simple usage of the ‘wpdm_category_link’ shortcode to fetch the link of a category using its ID.

[wpdm_category_link id=3 /]

Advanced examples

Using the ‘wpdm_category_link’ shortcode to fetch the link of a category with its ID and display the category using a specific template file.

[wpdm_category_link id=3 template="my-template.php" /]

Using the ‘wpdm_category_link’ shortcode to fetch the link of a category with its ID and display the category using a specific template file located in the views directory.

[wpdm_category_link id=3 template="views/my-template.php" /]

Remember, the ‘template’ parameter accepts the name of a PHP file that should be located in the theme or plugin directory. If the specified template is not found, the shortcode will use the default ‘category-link-shortcode.php’ file.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_category_link] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_category_link', [$this, 'categoryLink']);

Shortcode PHP function:

function categoryLink($params)
    {
        $category = new Category(wpdm_valueof($params, 'id'));
        if(!$category->ID) return '';
        $cat = (array)$category;
        $cat['icon'] = $category->icon ? "<img src='{category->icon}' alt='{$category->name}' />" : "";
        $template = isset($params['template']) && $params['template'] != '' ? $params['template'] : 'category-link-shortcode.php';
        return Template::output($template, $cat, __DIR__.'/views');
    }

Code file location:

download-manager/download-manager/src/Category/Shortcodes.php

Download Manager [wpdm_media] Shortcode

The WP Download Manager shortcode, ‘wpdm_media’, is designed to manage media files. It fetches media data based on the given ID, calculates the file size, and generates a thumbnail. If the ID is missing or invalid, it returns an error message. The shortcode also includes a template for displaying the media file.

Shortcode: [wpdm_media]

Parameters

Here is a list of all possible wpdm_media shortcode parameters and attributes:

  • id – The unique identifier for the media file

Examples and Usage

Basic example – Utilizes the ‘wpdm_media’ shortcode to display a media file based on its ID in WordPress.

[wpdm_media id=1 /]

Advanced examples

Here, the ‘wpdm_media’ shortcode is used to display a media file based on its ID, and the media file’s metadata is also displayed using the ‘show_meta’ attribute. The metadata includes information such as file size and thumbnail.

[wpdm_media id=1 show_meta=true /]

In this example, the ‘wpdm_media’ shortcode is used to display a media file based on its ID, with custom styling applied using the ‘style’ attribute. The ‘style’ attribute can be used to customize the appearance of the media file on the webpage.

[wpdm_media id=1 style="width:100%; height:auto;" /]

Finally, the ‘wpdm_media’ shortcode is used to display a media file based on its ID, with a custom class applied using the ‘class’ attribute. The ‘class’ attribute can be used to apply custom CSS styles to the media file.

[wpdm_media id=1 class="my-custom-class" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_media] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_media', array($this, 'mediaShortcode'));

Shortcode PHP function:

function mediaShortcode($params){
        if(!isset($params['id']) || (int)$params['id'] < 1) return __( "Missing ID!", "download-manager" );
        $media = get_post($params['id']);
        $media->path = str_replace(home_url('/'), ABSPATH.'/', $media->guid);
        $media->filesize = wpdm_file_size($media->path);
        $media->icon = wp_get_attachment_image($media->ID, 'thumbnail', true);
        ob_start();
        include Template::locate("media-shortcode.php", __DIR__.'/views');
        $content = ob_get_clean();
        return $content;
    }

Code file location:

download-manager/download-manager/src/MediaLibrary/MediaAccessControl.php

Download Manager [wpdm_package] Shortcode

The WPDM Package shortcode is used to display a single download package on your WordPress site. The shortcode retrieves a package using its ID. If the ID is invalid or the post type doesn’t match ‘wpdmpro’, it returns an empty string. It then fetches the corresponding template for the package and returns the HTML content within a ‘w3eden’ div class.

Shortcode: [wpdm_package]

Parameters

Here is a list of all possible wpdm_package shortcode parameters and attributes:

  • id – Unique identifier for the download package
  • template – Specifies the layout design of the download link

Examples and Usage

Basic example – A simple way to use the shortcode to display a download package by referencing its ID.

[wpdm_package id=123 /]

Advanced examples

Displaying a download package using a custom template. This shortcode will display the download package with ID 123 using the ‘custom-template.php’ template.

[wpdm_package id=123 template='custom-template.php' /]

Displaying a download package without specifying an ID. If used on a single download package page, this shortcode will display the current package with the default template.

[wpdm_package /]

Displaying a download package using a custom template without specifying an ID. If used on a single download package page, this shortcode will display the current package with the ‘custom-template.php’ template.

[wpdm_package template='custom-template.php' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_package] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("wpdm_package", [$this, 'singlePackage']);

Shortcode PHP function:

function singlePackage($params = [])
    {
        $id = wpdm_valueof($params, 'id', [ 'validate' => 'int' ]);

        if(!$id && is_singular('wpdmpro')) $id = get_the_ID();

        //Return if id is invalid
        if (!$id || get_post_type($id) !== 'wpdmpro') return '';

        //Link template
        $template = isset($params['template']) ? $params['template'] : get_post_meta($id, '__wpdm_template', true);
        if ($template == '') $template = 'link-template-default.php';
        $pack = new Package($id);
        $html = "<div class='w3eden'>" . $pack->fetchTemplate($template, $id, 'link') . "</div>";

        return $html;
    }

Code file location:

download-manager/download-manager/src/Package/Shortcodes.php

Download Manager [wpdm_direct_link] Shortcode

The WPDM Direct Link shortcode is a WordPress plugin that generates a direct download link. It utilizes the ‘wpdm_direct_link’ function to extract parameters like ID, extras, target, class, style, rel, eid, and label. If the package is locked, it returns the permalink of the package; otherwise, it generates a home URL with the package ID. It then compiles these parameters into an HTML anchor tag, creating a direct link.

Shortcode: [wpdm_direct_link]

Parameters

Here is a list of all possible wpdm_direct_link shortcode parameters and attributes:

  • id – The unique identifier of the download package
  • extras – Additional attributes for the download link
  • target – Defines where to open the downloaded file
  • class – Applies a CSS class to the download link
  • style – Applies inline CSS styles to the download link
  • rel – Specifies the relationship between the current document and the linked document
  • eid – Sets a unique ID for the download link
  • label – Customizes the text of the download link

Examples and Usage

Basic example – The simplest use of the shortcode. This example will create a direct link to the download with the ID of 1.

[wpdm_direct_link id=1 /]

Advanced examples – These examples demonstrate the use of additional parameters to customize the appearance and behavior of the direct link.

Here, the shortcode is used to create a direct link with a custom label. The link will open in a new window or tab because of the ‘target’ parameter set to ‘_blank’.

[wpdm_direct_link id=1 label="Download Now" target="_blank" /]

In the next example, the shortcode is used to create a direct link with a custom CSS class and style. The ‘class’ parameter is set to ‘my-link’ and the ‘style’ parameter is set to ‘color: red;’.

[wpdm_direct_link id=1 class="my-link" style="color: red;" /]

This final example demonstrates the use of the ‘rel’ and ‘eid’ parameters. The ‘rel’ parameter is set to ‘nofollow’ to prevent search engines from following the link, and the ‘eid’ parameter is set to ‘my-link’ to provide a unique identifier for the link.

[wpdm_direct_link id=1 rel="nofollow" eid="my-link" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_direct_link] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_direct_link', [$this, 'directLink']);

Shortcode PHP function:

function directLink($params, $content = "")
    {
        extract($params);

        global $wpdb;
        $ID = (int)$params['id'];

        if (WPDM()->package->isLocked($ID))
            $linkURL = get_permalink($ID);
        else
            $linkURL = home_url("/?wpdmdl=" . $ID);

        $extras = isset($params['extras']) ? wpdm_sanitize_var($params['extras'], 'txt') : "";
        $target = isset($params['target']) ? "target='" . wpdm_sanitize_var($params['target'], 'txt') . "'" : "";
        $class = isset($params['class']) ? "class='" . wpdm_sanitize_var($params['class'], 'txt') . "'" : "";
        $style = isset($params['style']) ? "style='" . wpdm_sanitize_var($params['style'], 'txt') . "'" : "";
        $rel = isset($params['rel']) ? "rel='" . wpdm_sanitize_var($params['rel'], 'txt') . "'" : "";
        $eid = isset($params['eid']) ? "id='" . wpdm_sanitize_var($params['eid'], 'txt') . "'" : "";
        $linkLabel = isset($params['label']) && !empty($params['label']) ? $params['label'] : get_post_meta($ID, '__wpdm_link_label', true);
        $linkLabel = empty($linkLabel) ? get_the_title($ID) : $linkLabel;
        $linkLabel = wpdm_sanitize_var($linkLabel, 'kses');
        return "<a {$target} {$class} {$eid} {$style} {$rel} {$extras} href='$linkURL'>$linkLabel</a>";

    }

Code file location:

download-manager/download-manager/src/Package/Shortcodes.php

Download Manager [wpdm_packages] Shortcode

The WPDM Packages shortcode is a powerful tool in the WordPress Download Manager plugin. It allows for the display and customization of download packages on your website. The shortcode provides parameters to regulate the number of items per page, order of display, inclusion of a toolbar, and more. It also includes a login form for visitors if the ‘login’ parameter is set to 1. The shortcode generates unique IDs for multiple uses on a page. It also processes category and tag parameters, allowing for the display of packages based on specific categories or tags. The shortcode supports date filtering, allowing for the display of packages from specific dates. If no downloads are available, a customizable message is displayed. The shortcode also supports pagination for easy navigation through the download packages. In conclusion, the WPDM Packages shortcode offers a versatile way to manage and display download packages on your WordPress site.

Shortcode: [wpdm_packages]

Parameters

Here is a list of all possible wpdm_packages shortcode parameters and attributes:

  • items_per_page – determines the number of packages displayed per page
  • title – sets the title for the download package section
  • desc – sets the description for the download package section
  • orderby – sets the field by which packages are sorted
  • order – sets the order of sorting, either ascending (ASC) or descending (DESC)
  • paging – enables or disables pagination
  • page_numbers – enables or disables the display of page numbers
  • toolbar – enables or disables the toolbar
  • template – sets the template used to display packages
  • cols – sets the number of columns for large devices
  • colspad – sets the number of columns for medium devices
  • colsphone – sets the number of columns for small devices
  • tags – filters packages by tags
  • categories – filters packages by categories
  • year – filters packages by year
  • month – filters packages by month
  • s – filters packages by search term
  • css_class – adds a custom CSS class to the download packages
  • scid – sets a unique ID for the shortcode
  • async – enables or disables asynchronous loading of packages
  • tax – filters packages by custom taxonomy
  • terms – filters packages by custom terms
  • not_found – sets a custom message when no packages are found

Examples and Usage

Basic example – Display a list of download packages with default settings.

[wpdm_packages /]

Advanced examples

Display a list of download packages with a specific number of items per page and ordered by title in ascending order.

[wpdm_packages items_per_page="5" orderby="title" order="ASC" /]

Display a list of download packages with a custom title and description, and display a login form for guests/visitors.

[wpdm_packages title="My Download Packages" desc="Please login to download" login="1" /]

Display a list of download packages from specific categories and tags, and with a custom ‘not found’ message.

[wpdm_packages categories="category1,category2" tags="tag1,tag2" not_found="No packages found!" /]

Display a list of download packages with a custom CSS class and with pagination disabled.

[wpdm_packages css_class="my-custom-class" paging="0" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_packages] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_packages', [$this, 'packages']);

Shortcode PHP function:

function packages($params = array('items_per_page' => 10, 'title' => '', 'desc' => '', 'orderby' => 'date', 'order' => 'DESC', 'paging' => false, 'page_numbers' => true, 'toolbar' => 1, 'template' => '', 'cols' => 3, 'colspad' => 2, 'colsphone' => 1, 'tags' => '', 'categories' => '', 'year' => '', 'month' => '', 's' => '', 'css_class' => 'wpdm_packages', 'scid' => '', 'async' => 1, 'tax' => '', 'terms' => '', 'not_found' => 'No downloads available!'))
    {
        global $current_user, $post;

        static $wpdm_packages = 0;

	    $params = __::a($params, ['items_per_page' => 10, 'title' => '', 'desc' => '', 'orderby' => 'date', 'order' => 'DESC', 'paging' => false, 'page_numbers' => true, 'toolbar' => 1, 'template' => '', 'cols' => 3, 'colspad' => 2, 'colsphone' => 1, 'tags' => '', 'categories' => '', 'year' => '', 'month' => '', 's' => '', 'css_class' => 'wpdm_packages', 'scid' => '', 'async' => 1, 'tax' => '', 'terms' => '', 'not_found' => 'No downloads available!']);

        // When login=1, show login form for guests/visitors
        if (isset($params['login']) && $params['login'] == 1 && !is_user_logged_in())
            return WPDM()->user->login->form($params);

        // To generate unique sections ID when someone uses multiple shortcode on a page
        $wpdm_packages++;

        // $scparams = Initial unprocessed shortcode parameters
        $scparams = $params;



        $async = __::valueof($params, 'async', ['default' => 0, 'validate' => 'int']);
        $items_per_page = __::valueof($params, 'items_per_page', 10);
        if($items_per_page < 1) $items_per_page = 10;
        $scid = __::valueof($params, 'scid', ['default' => 'wpdm_package_'.$wpdm_packages, 'validate' => 'txt']);
        $cwd_class = "col-lg-" . (int)(12 / __::valueof($params, 'cols', ['default' => 3, 'validate' => 'int']));
        $cwdsm_class = "col-md-" . (int)(12 /  __::valueof($params, 'colspad', ['default' => 2, 'validate' => 'int']));
        $cwdxs_class = "col-" . (int)(12 /  __::valueof($params, 'colsphone', ['default' => 1, 'validate' => 'int']));

        $title = __::valueof($params, 'title', ['validate' => 'txt']);
        $desc = __::valueof($params, 'desc', ['validate' => 'txt']);
        $toolbar = __::valueof($params, 'toolbar', ['default' => 1, 'validate' => 'int']);
        $paging = __::valueof($params, 'paging', ['default' => 1, 'validate' => 'int']);

        $order_field = __::valueof($params, 'orderby', 'date');
        $order_field = isset($_REQUEST['orderby'])? wpdm_query_var('orderby') : $order_field;
        $order = __::valueof($params, 'order', 'desc');
        $order = isset($_REQUEST['order'])? wpdm_query_var('order') : $order;

        $currentPage = __::query_var('cp', 'int');
        if (!$currentPage) $currentPage = 1;

        $query = new Query();
        $query->items_per_page(wpdm_valueof($params, 'items_per_page', 10));
        $query->paged($currentPage);
        $query->sort($order_field, $order);

        foreach ($scparams as $key => $value) {
            if (method_exists($query, $key) && !in_array($key, ['categories', 'tags'])) {
                $query->$key($value);
            }
        }

        /**
         * Process "categories" parameter
         * Usually values are category slug(s), users may use id(s) too
         * If users uses slugs, convert slugs into ids
         **/
        if(wpdm_valueof($scparams, 'categories') !== '') {
            $categories = wpdm_valueof($scparams, 'categories');
            $categories = explode(",", $categories);
            /**
             * Convert slugs to ID
             */
            foreach ($categories as &$cat) {
                if (!is_numeric($cat) && $cat !== '') {
                    $catObj = get_term_by('slug', $cat, 'wpdmcategory');
                    $cat = $catObj->term_id;
                }
            }
            $operator = wpdm_valueof($scparams, 'operator', ['default' => 'IN']);
            $include_children = wpdm_valueof($scparams, 'include_children', ['default' => false]);
            $query->categories($categories, 'term_id', $operator, $include_children);
        }

        if(wpdm_valueof($scparams, 'tags') !== '') {
            $tags = wpdm_valueof($scparams, 'tags');
            $operator = wpdm_valueof($scparams, 'operator', ['default' => 'IN']);
            $query->tags($tags, 'slug', $operator);
        }

        if (wpdm_query_var('skw', 'txt') != '') {
            $query->s(wpdm_query_var('skw', 'txt'));
        }

        if(wpdm_valueof($scparams, 'tax') !== '') {
            $_terms = explode("|", wpdm_valueof($scparams, 'terms'));
            $taxos = explode("|", wpdm_valueof($scparams, 'tax'));
            foreach ($taxos as $index => $_taxo) {
                $terms = wpdm_valueof($_terms, $index);
                $terms = explode(",", $terms);
                if(count($terms) > 0) {

                    $query->taxonomy($_taxo, $terms);
                }
            }
        }

        $query->taxonomy_relation(wpdm_valueof($scparams, 'relation', ['default' => 'AND']));

        if (get_option('_wpdm_hide_all', 0) == 1) {
            $query->meta("__wpdm_access", '"guest"');

            if (is_user_logged_in()) {
                foreach ($current_user->roles as $role) {
                    $query->meta("__wpdm_access", $role);
                }
                $query->meta_relation('OR');
            }
        }

        // Date filter
        if (isset($scparams['year']) || isset($scparams['month']) || isset($scparams['day'])) {

            if (isset($scparams['day'])) {
                $day = ($scparams['day'] == 'today') ? date('d') : $scparams['day'];
                $query->filter('day', $day);
            }

            if (isset($scparams['month'])) {
                $month = ($scparams['month'] == 'this') ? date('Ym') : $scparams['month'];
                $query->filter('m', $month);
            }

            if (isset($scparams['year'])) {
                $year = ($scparams['year'] == 'this') ? date('Y') : $scparams['year'];
                $query->filter('year', $year);
            }

            if (isset($scparams['week'])) {
                $week = ($scparams['week'] == 'this') ? date('W') : $scparams['week'];
                $query->filter('week', $week);
            }
        }

        $query->post_status('publish');
        $query->process();
        $total = $query->count;
        $packages = $query->packages();

        $pages = ceil($total / $items_per_page);
        $page = isset($_GET['cp']) ? (int)$_GET['cp'] : 1;
        $start = ($page - 1) * $items_per_page;


        $html = '';

        foreach ($packages as $pack){
            $pack = (array)$pack;
            //$repeater = "<div class='{$cwd_class} {$cwdsm_class} {$cwdxs_class}'>" . \WPDM\Package::fetchTemplate(wpdm_valueof($scparams, 'template', 'link-template-default.php'), $pack) . "</div>";
            $repeater = "<div class='{$cwd_class} {$cwdsm_class} {$cwdxs_class}'>" . WPDM()->package->fetchTemplate(wpdm_valueof($scparams, 'template', 'link-template-default.php'), $pack) . "</div>";
            $html .= $repeater;

        }

		$not_found_msg = wpdm_valueof($scparams, 'not_found') ?: __('No downloads found!', WPDM_TEXT_DOMAIN);
		if($total === 0) $html = "<div class='col-md-12'>{$not_found_msg}</div>";

        $html = "<div class='row'>{$html}</div>";

        $_scparams = Crypt::encrypt($scparams);
        if (!isset($paging) || intval($paging) == 1) {
            //sc_params={$_scparams}&
            $pag_links = wpdm_paginate_links($total, $items_per_page, $page, 'cp', array( 'format' => "?cp=%#%",'container' => '#content_' . $scid, 'async' => $async, 'next_text' => ' <i style="display: inline-block;width: 8px;height: 8px;border-right: 2px solid;border-top: 2px solid;transform: rotate(45deg);margin-left: -2px;margin-top: -2px;"></i> ', 'prev_text' => ' <i style="display: inline-block;width: 8px;height: 8px;border-right: 2px solid;border-bottom: 2px solid;transform: rotate(135deg);margin-left: 2px;margin-top: -2px;"></i> '));
            $pagination = "<div style='clear:both'></div>" . $pag_links . "<div style='clear:both'></div>";
        } else
            $pagination = "";

        global $post;

        $burl = get_permalink();
        $sap = get_option('permalink_structure') ? '?' : '&';
        $burl = $burl . $sap;
        if (isset($_GET['p']) && $_GET['p'] != '') $burl .= 'p=' . wpdm_query_var('p', 'txt') . '&';
        if (isset($_GET['src']) && $_GET['src'] != '') $burl .= 'src=' . wpdm_query_var('src', 'txt') . '&';
        $orderby = isset($_GET['orderby']) ? wpdm_query_var('orderby', 'txt') : 'date';
        $order = ucfirst($order);

        $order_field = " " . __(ucwords(str_replace("_", " ", $order_field)), "wpdmpro");
        $ttitle = __("Title", "download-manager");
        $tdls = __("Downloads", "download-manager");
        $tcdate = __("Publish Date", "download-manager");
        $tudate = __("Update Date", "download-manager");
        $tasc = __("Asc", "download-manager");
        $tdsc = __("Desc", "download-manager");
        $tsrc = __("Search", "download-manager");
        $ord = __("Order", "download-manager");
        $order_by_label = __("Order By", "download-manager");

        $css_class = isset($scparams['css_class']) ? sanitize_text_field($scparams['css_class']) : '';
        $desc = isset($scparams['desc']) ? sanitize_text_field($scparams['desc']) : '';

        $toolbar = isset($toolbar) ? $toolbar : 0;

        ob_start();
        include Template::locate("packages-shortcode.php", __DIR__.'/views');
        $content = ob_get_clean();
        return $content;
    }

Code file location:

download-manager/download-manager/src/Package/Shortcodes.php

Download Manager [wpdm_tag] Shortcode

The WPDM_Tag shortcode is a function in the WordPress Download Manager plugin. It fetches and displays packages based on their tag. In the PHP code, the function ‘packagesByTag’ takes ‘id’ as a parameter, which is actually the tag of the packages. It then calls another function ‘packages’ to return the packages with the specified tag.

Shortcode: [wpdm_tag]

Parameters

Here is a list of all possible wpdm_tag shortcode parameters and attributes:

  • id – Unique tag identifier used to display packages

Examples and Usage

Basic Example: – Displays the packages associated with a specific tag ID.

[wpdm_tag id=1 /]

Advanced Examples:

Displaying the packages associated with multiple tag IDs. The packages will be listed according to the order of the IDs provided.

[wpdm_tag id=1,2,3 /]

Using the shortcode to display packages by referencing both ID and other parameters. The packages will be listed according to the parameters provided.

[wpdm_tag id=1 order_by="date" order="desc" /]

Here, ‘order_by’ parameter is used to sort the packages and ‘order’ parameter is used to specify the sorting order. In this example, the packages are sorted by date in descending order.

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_tag] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("wpdm_tag", [$this, 'packagesByTag']);

Shortcode PHP function:

function packagesByTag($params)
    {
        if(!$params || !isset($params['id'])) return '';

        $params['tags'] = $params['id'];
        unset($params['id']);
        return $this->packages($params);

    }

Code file location:

download-manager/download-manager/src/Package/Shortcodes.php

Download Manager [wpdm_download_count] Shortcode

The WPDM Download Count shortcode is a feature that allows you to track the total number of downloads. This shortcode fetches the sum of the ‘meta_value’ from the postmeta table where the ‘meta_key’ is ‘__wpdm_download_count’. This value represents the total number of downloads.

Shortcode: [wpdm_download_count]

Examples and Usage

Basic Example – Displays the total number of downloads across all files.

[wpdm_download_count]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_download_count] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_download_count', [$this, 'totalDownloads']);

Shortcode PHP function:

function totalDownloads($params = array())
    {
        global $wpdb;
        $download_count = $wpdb->get_var("select sum(meta_value) from {$wpdb->prefix}postmeta where meta_key='__wpdm_download_count'");
        return $download_count;
    }

Code file location:

download-manager/download-manager/src/Package/Shortcodes.php

Download Manager [wpdm_package_count] Shortcode

The WPDM Package Count shortcode is designed to return the total number of packages in a specific category, by author, or overall. It checks if a category is set and returns the count of packages in that category. If an author is set, it returns the number of packages by that author. If neither is set, it returns the total number of published, draft, or pending packages.

Shortcode: [wpdm_package_count]

Parameters

Here is a list of all possible wpdm_package_count shortcode parameters and attributes:

  • cat – slug of the category to get its package count
  • author – ID of the author to count their packages
  • status – package status (‘publish’, ‘draft’, ‘pending’) to filter the count

Examples and Usage

Basic example – The basic usage of the shortcode ‘wpdm_package_count’ without any parameters, this will return the total count of published ‘wpdmpro’ custom post types.

[wpdm_package_count /]

Advanced examples

Using the shortcode ‘wpdm_package_count’ with the ‘cat’ parameter. This will return the total count of ‘wpdmpro’ custom post types in a specific category. Replace ‘category_slug’ with the slug of your desired category.

[wpdm_package_count cat="category_slug" /]

Using the shortcode ‘wpdm_package_count’ with the ‘author’ parameter. This will return the total count of ‘wpdmpro’ custom post types authored by a specific user. Replace ‘user_id’ with the ID of the user.

[wpdm_package_count author="user_id" /]

Using the shortcode ‘wpdm_package_count’ with the ‘status’ parameter. This will return the total count of ‘wpdmpro’ custom post types with a specific status. Replace ‘status_name’ with ‘draft’ or ‘pending’ to get the count of posts with those statuses.

[wpdm_package_count status="status_name" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_package_count] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_package_count', [$this, 'totalPackages']);

Shortcode PHP function:

function totalPackages($params = array())
    {
        if (isset($params['cat'])) {
            $term = get_term_by("slug", $params['cat']);
            if (is_object($term) && isset($term->count)) return $term->count;
            return 0;
        }
        if (isset($params['author'])) {
            $user_post_count = count_user_posts($params['author'], 'wpdmpro');
            return $user_post_count;
        }
        $count_posts = wp_count_posts('wpdmpro');
        $status = isset($params['status']) ? $params['status'] : 'publish';
        if ($status == 'draft') return $count_posts->draft;
        if ($status == 'pending') return $count_posts->pending;
        return $count_posts->publish;
    }

Code file location:

download-manager/download-manager/src/Package/Shortcodes.php

Download Manager [wpdm_all_packages] Shortcode

The ‘wpdm_all_packages’ shortcode from the Download Manager plugin lists all packages available for download. It allows customization of the number of items displayed per page, specific categories, and tags. The shortcode also includes a login validation check. If the user is not logged in and the ‘login’ parameter is set, it will return a login form. This ensures secure access to downloads. The code also supports pagination, allowing users to navigate through multiple pages of downloads. It uses the ‘cp’ query variable to determine the current page and calculate the offset for the database query. The shortcode uses a template file ‘all-packages-shortcode.php’ for the output, ensuring a consistent and customizable display.

Shortcode: [wpdm_all_packages]

Parameters

Here is a list of all possible wpdm_all_packages shortcode parameters and attributes:

  • items_per_page – Determines the number of packages displayed per page
  • jstable – If set to 1, it increases the items per page to 2000
  • categories – Filters packages by specific categories, separated by commas
  • tag – Filters packages by a specific tag
  • login – If set to 1, only logged-in users can view the packages

Examples and Usage

Basic Example – Displays all packages with a default limit of 20 items per page.

[wpdm_all_packages]

Advanced Examples – These examples demonstrate the use of different parameters/atts to customize the output.

Displays the packages from specific categories. Replace ‘category1, category2’ with the slugs of the categories you want to display.

[wpdm_all_packages categories="category1, category2"]

Displays the packages with a specific tag. Replace ‘tagname’ with the tag you want to display.

[wpdm_all_packages tag="tagname"]

Displays the packages in a JavaScript table with a limit of 2000 items per page.

[wpdm_all_packages jstable=1]

Displays the packages with a custom limit of items per page. Replace ’30’ with the number of items you want to display per page.

[wpdm_all_packages items_per_page=30]

Displays a login form if the user is not logged in.

[wpdm_all_packages login=1]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_all_packages] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_all_packages', [$this, 'allPackages']);

Shortcode PHP function:

function allPackages($params = array())
    {
        global $wpdb, $current_user, $wp_query;

	    $params = __::a($params, ['items_per_page' => 20]);

        $items = isset($params['items_per_page']) && $params['items_per_page'] > 0 ? $params['items_per_page'] : 20;
        $offset = $cp = 0;
        if (isset($params['jstable']) && $params['jstable'] == 1) {
            $items = 2000;
        } else {
            $cp = wpdm_query_var('cp', ['validate' => 'int', 'default' => 1]);
            $offset = ($cp - 1) * $items;

        }
        $terms = isset($params['categories']) ? explode(",", $params['categories']) : array();
        $tag = isset($params['tag']) ? $params['tag'] : '';
        if (isset($_GET['wpdmc'])) $terms = array(wpdm_query_var('wpdmc', 'txt'));
        $total_files = wp_count_posts('wpdmpro')->publish;
        if (count($terms) > 0) {
            $tax_query = array(array(
                'taxonomy' => 'wpdmcategory',
                'field' => 'slug',
                'terms' => $terms,
                'operator' => 'IN',
                'include_children' => false
            ));
        }
        if ($tag != '') {
            $params['tag'] = $tag;
        }
        if (isset($params['login']) && $params['login'] == 1 && !is_user_logged_in())
            return WPDM()->user->login->form($params);
        else {
            ob_start();
            //include(wpdm_tpl_path("wpdm-all-downloads.php"));
            include Template::locate("all-packages-shortcode.php", __DIR__.'/views');
            $data = ob_get_clean();
            return $data;
        }
    }

Code file location:

download-manager/download-manager/src/Package/Shortcodes.php

Download Manager [wpdm_search_result] Shortcode

The WP Download Manager plugin shortcode ‘wpdm_search_result’ generates a search form and displays search results. It uses parameters like template, items per page, and columns to customize the output. This shortcode enables users to search for specific downloads within the website, enhancing user experience. It dynamically generates HTML for the search form and results, making it a versatile tool.

Shortcode: [wpdm_search_result]

Parameters

Here is a list of all possible wpdm_search_result shortcode parameters and attributes:

  • template – determines the template used for the search results
  • async – controls whether the search is performed asynchronously
  • strm – search term used in the search query
  • cols – number of columns in the search results
  • items_per_page – number of items displayed per page in search results
  • colspad – padding between columns in search results
  • colsphone – number of columns in search results on a phone
  • init – determines whether the search is performed initially

Examples and Usage

Basic example – Displays the search results using the default template and settings.

[wpdm_search_result /]

Advanced examples

Displaying the search results using a custom template and setting the number of items per page.

[wpdm_search_result template="link-template-calltoaction3" items_per_page="10" /]

Using the shortcode to initiate the search results even if the search term is empty. Also, it sets the number of columns for different devices.

[wpdm_search_result init="1" cols="3" colsphone="2" colspad="1" /]

Enabling asynchronous loading for the search results and setting the padding for the columns.

[wpdm_search_result async="1" colspad="2" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_search_result] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_search_result', [$this, 'searchResult']);

Shortcode PHP function:

function searchResult($params = array())
	{
		global $wpdb;

		if (is_array($params))
			@extract($params);
		$template = isset($template) && $template != '' ? $template : 'link-template-calltoaction3';
		$async = isset($async) ? $async : 0;
		update_post_meta(get_the_ID(), "__wpdm_link_template", $template);
		$strm = wpdm_query_var('search', 'esc_attr');
		if ($strm === '') $strm = wpdm_query_var('s', 'esc_attr');
		//$strm = esc_attr($strm);
		$html = '';
		$cols = isset($cols) ? $cols : 1;
		$items_per_page = isset($items_per_page) ? $items_per_page : $cols * 6;
		update_post_meta(get_the_ID(), "__wpdm_items_per_page", $items_per_page);
		$colspad = isset($colspad) ? $colspad : 1;
		$colsphone = isset($colsphone) ? $colsphone : 1;
		if (($strm == '' && isset($init) && $init == 1) || $strm != '')
			$html = $this->packages(array('items_per_page' => $items_per_page, 'template' => $template, 's' => $strm, 'paging' => true, 'toolbar' => 0, 'cols' => $cols, 'colsphone' => $colsphone, 'colspad' => $colspad, 'async' => $async));
		$html = "<div class='w3eden'><form id='wpdm-search-form' style='margin-bottom: 20px'><div class='input-group input-group-lg'><div class='input-group-addon input-group-prepend'><span class=\"input-group-text\"><i class='fas fa-search'></i></span></div><input type='text' name='search' value='" . $strm . "' class='form-control input-lg' /></div></form>{$html}</div>";
		return str_replace(array("\r", "\n"), "", $html);
	}

Code file location:

download-manager/download-manager/src/Package/Shortcodes.php

Download Manager [wpdm_user_dashboard] Shortcode

The WPDM User Dashboard shortcode is used to create a personalized user dashboard. It checks if a user is logged in, then generates a dashboard based on user-specific data. It further customizes the dashboard with specific icons for different sections like purchases, messages, download history, and more. The shortcode also allows for the inclusion of additional dashboard menu items. Shortcode: [wpdm_user_dashboard]

Shortcode: [wpdm_user_dashboard]

Examples and Usage

Basic example – Display the user dashboard for the logged in user. If the user is not logged in, it will display a login form.

[wpdm_user_dashboard /]

Advanced examples

Display the user dashboard with custom parameters. The parameters can be used to modify the behavior of the shortcode. In this example, we are passing a ‘udb_page’ parameter to the shortcode. This parameter is used to determine which page of the user dashboard to display.

[wpdm_user_dashboard udb_page="purchases" /]

Here is another advanced example where we are passing multiple parameters to the shortcode. The ‘udb_page’ parameter is used to determine which page of the user dashboard to display, and the ‘icon’ parameter is used to specify the icon for the dashboard.

[wpdm_user_dashboard udb_page="purchases" icon="fas fa-file-download color-success" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_user_dashboard] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("wpdm_user_dashboard", array($this, 'dashboard'));

Shortcode PHP function:

function dashboard($params = array())
    {
        global $wp_query, $WPDM;

        ob_start();
        if (!is_user_logged_in()) {
            echo WPDM()->user->login->form($params);
        } else {

            if (!isset($params) || !is_array($params)) $params = array();
            $all_dashboard_menu_items = array();
            if (is_array($this->dashboard_menu)) {
                foreach ($this->dashboard_menu as $section) {
                    $all_dashboard_menu_items += $section['items'];
                }
            }
            $udb_page = isset($wp_query->query_vars['udb_page']) ? $wp_query->query_vars['udb_page'] : '';
            $udb_page_parts = explode("/", $udb_page);
            $udb_page = $udb_page_parts[0];
            $udb_page_parts = array_merge($udb_page_parts, $params);
            if (isset($all_dashboard_menu_items[$udb_page]['callback']))
                $dashboard_contents = call_user_func($all_dashboard_menu_items[$udb_page]['callback'], $udb_page_parts);
            else if (isset($all_dashboard_menu_items[$udb_page]['shortcode']))
                $dashboard_contents = do_shortcode($all_dashboard_menu_items[$udb_page]['shortcode']);
            else if (isset($all_dashboard_menu_items[$udb_page]))
                $dashboard_contents = call_user_func($all_dashboard_menu_items[$udb_page], $udb_page_parts);
            //else if(isset($this->dashboard_menu_actions[$udb_page]['shortcode']))
            //    $dashboard_contents = do_shortcode($this->dashboard_menu_actions[$udb_page]['shortcode']);

            $default_icons[''] = 'far fa-user-circle color-primary';
            $default_icons['purchases'] = 'fas fa-file-download color-success';
            $default_icons['messages'] = 'fa fa-comments color-success';
            $default_icons['download-history'] = 'fa fa-history color-info';
            $default_icons['edit-profile'] = 'fa fa-user-edit color-green';
            $default_icons['subscription-plan'] = 'fa fa-crown color-info';
            $default_icons['subscription-download-area'] = 'fa fa-tasks color-info';
            $default_icons['affiliate-stats'] = 'fa fa-share-alt color-info';
            $default_icons['affiliates'] = 'fa fa-share-alt color-info';
            $default_icons['file-cart'] = 'fa fa-cart-arrow-down color-info';
            $default_icons['my-downloads'] = 'fa fa-arrow-down color-info';
            $default_icons['account-credits'] = 'fa fa-credit-card color-success';

            $default_icons = apply_filters("wpdm_user_dashboard_icons", $default_icons);

            include Template::locate("dashboard/dashboard.php", __DIR__ . '/views');
        }
        return ob_get_clean();
    }

Code file location:

download-manager/download-manager/src/User/Dashboard.php

Download Manager [wpdm_edit_profile] Shortcode

The WPDM Edit Profile shortcode is a vital tool for profile customization. It allows users to modify their profiles directly from the frontend. The related PHP code initiates an output buffer, includes a template file for the edit-profile page, then returns the buffered output. This ensures the changes made by users are saved and displayed correctly.

Shortcode: [wpdm_edit_profile]

Examples and Usage

Basic example – Utilizes the default shortcode to edit the profile in the download manager plugin.

[wpdm_edit_profile]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_edit_profile] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("wpdm_edit_profile", [$this, 'editProfile']);

Shortcode PHP function:

function editProfile()
    {
        ob_start();
        include Template::locate("dashboard/edit-profile.php", __DIR__ . '/views');
        return ob_get_clean();
    }

Code file location:

download-manager/download-manager/src/User/EditProfile.php

Download Manager [wpdm_login_form] Shortcode

The WPDM Login Form shortcode is used to display a login form on a WordPress page. It handles various scenarios like user registration, password recovery, and redirection after login. The shortcode extracts parameters for redirection, registration URL, and logo. It also validates the redirection URL to ensure it’s from the same server. It checks if a user is logged in and accordingly displays the relevant template. Finally, it returns the content after applying any filters to it.

Shortcode: [wpdm_login_form]

Parameters

Here is a list of all possible wpdm_login_form shortcode parameters and attributes:

  • redirect – sets the URL to redirect users after login
  • regurl – sets the URL for the registration page
  • logo – sets the URL for the logo to display on the login form

Examples and Usage

Basic example – Display the login form using default settings.

[wpdm_login_form]

Advanced examples

Display the login form with a specific redirect URL. Upon successful login, the user will be redirected to the specified URL.

[wpdm_login_form redirect="https://yourwebsite.com/your-page/"]

Display the login form with a custom logo. The URL of the logo image should be specified.

[wpdm_login_form logo="https://yourwebsite.com/path-to-your-logo.jpg"]

Display the login form with a specific redirect URL and a custom logo. This example combines the two parameters.

[wpdm_login_form redirect="https://yourwebsite.com/your-page/" logo="https://yourwebsite.com/path-to-your-logo.jpg"]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_login_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_login_form', [$this, 'form']);

Shortcode PHP function:

function form($params = array())
    {

        global $current_user;

        if (!isset($params) || !is_array($params)) $params = array();

        if (isset($params) && is_array($params))
            extract($params);
        if (!isset($redirect)) $redirect = get_permalink(get_option('__wpdm_user_dashboard'));

        if (!isset($regurl)) {
            $regurl = get_option('__wpdm_register_url');
            if ($regurl > 0)
                $regurl = get_permalink($regurl);
        }
        $log_redirect = __::valueof($_SERVER, 'REQUEST_URI', ['validate' => 'txt']);
        if (isset($params['redirect'])) $log_redirect = esc_url_raw($params['redirect']);
        if (isset($_GET['redirect_to'])) $log_redirect = esc_url_raw($_GET['redirect_to']);

        $up = parse_url($log_redirect);
        if (isset($up['host']) && $up['host'] != $_SERVER['SERVER_NAME']) $log_redirect = __::valueof($_SERVER, 'REQUEST_URI', ['validate' => 'txt']);

        $log_redirect = strip_tags($log_redirect);

        if (!isset($params['logo'])) $params['logo'] = get_site_icon_url();

        $__wpdm_social_login = get_option('__wpdm_social_login');
        $__wpdm_social_login = is_array($__wpdm_social_login) ? $__wpdm_social_login : array();

        ob_start();

        if (is_user_logged_in())
            $template = Template::locate("already-logged-in.php", __DIR__.'/views');
        else {
            if (__::query_var('action') === 'lostpassword')
                $template = Template::locate('lost-password-form.php', __DIR__.'/views');
            else if (__::query_var('action') === 'rp')
                $template = Template::locate('reset-password-form.php', __DIR__.'/views');
            else
                $template = Template::locate('login-form.php', __DIR__.'/views');
        }

        include($template);

        $content = ob_get_clean();
        $content = apply_filters("wpdm_login_form_html", $content);

        return $content;
    }

Code file location:

download-manager/download-manager/src/User/Login.php

Download Manager [wpdm_modal_login_form] Shortcode

The WP Download Manager shortcode allows for a modal login form. It lets users log in without leaving the current page. The shortcode displays a login button that triggers a pop-up form. It supports customization of class, redirect URL, logo, label, and id. The ‘redirect’ parameter redirects users after successful login, while ‘logo’ allows for a custom logo.

Shortcode: [wpdm_modal_login_form]

Parameters

Here is a list of all possible wpdm_modal_login_form shortcode parameters and attributes:

  • class – defines the CSS class for styling the button
  • redirect – URL to redirect users after successful login
  • logo – URL of the logo image to display on the login form
  • label – the text displayed on the login button
  • id – unique identifier of the login button

Examples and Usage

Basic example – A simple usage of the shortcode to display a login button with default settings.

[wpdm_modal_login_form /]

Advanced examples

1. Customizing the shortcode to display a login button with a specific CSS class and a custom label.

[wpdm_modal_login_form class="my-custom-class" label="Click to Login" /]

2. Further customization of the shortcode to display a login button with a custom redirect URL and a logo.

[wpdm_modal_login_form redirect="https://www.example.com/welcome" logo="https://www.example.com/logo.png" /]

3. An advanced usage of the shortcode to display a login button with a custom CSS class, redirect URL, logo, label, and a unique ID.

[wpdm_modal_login_form class="my-custom-class" redirect="https://www.example.com/welcome" logo="https://www.example.com/logo.png" label="Click to Login" id="unique-login-button" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_modal_login_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_modal_login_form', [$this, 'modalLoginFormBtn']);

Shortcode PHP function:

function modalLoginFormBtn($params = array())
    {
        if ((int)get_option('__wpdm_modal_login', 0) !== 1) return "";
        $defaults = array('class' => '', 'redirect' => '', 'logo' => '', 'label' => __('Login', 'download-manager'), 'id' => 'wpdmmodalloginbtn');
        $params = shortcode_atts($defaults, $params, 'wpdm_modal_login_form');
        $redirect = isset($params['redirect']) && $params['redirect'] !== '' ? "data-redirect='".esc_attr($params['redirect'])."'" : '';
        $logo = isset($params['logo']) && $params['logo'] !== '' ? "data-logo='{".esc_attr($params['logo'])."}'" : '';
        ob_start();
        ?>
        <div class="w3eden d-inline-block"><a href="#" <?php echo $redirect; ?> <?php echo $logo; ?> type="button"
                                              id="<?php echo esc_attr($params['id']); ?>" class="<?php echo esc_attr($params['class']); ?>"
                                              data-toggle="modal"
                                              data-target="#wpdmloginmodal"><?php echo __::sanitize_var($params['label'], 'kses'); ?></a></div>
        <?php
        $btncode = ob_get_clean();
        return $btncode;
    }

Code file location:

download-manager/download-manager/src/User/Login.php

Download Manager [wpdm_logout_url] Shortcode

The ‘wpdm_logout_url’ shortcode is a function in the Download Manager plugin. It generates a URL that logs out users from the WordPress site. The shortcode accepts a parameter ‘r’ that redirects users to a specific URL after logout. If no redirect URL is specified, users are redirected to the homepage.

Shortcode: [wpdm_logout_url]

Parameters

Here is a list of all possible wpdm_logout_url shortcode parameters and attributes:

  • r – URL to redirect to after logging out

Examples and Usage

Basic Usage Example – The basic shortcode for the logout URL without any redirect parameter.

[wpdm_logout_url]

Advanced Examples

Using the shortcode to log out and redirect to a specific page by referencing the page ID. If the page ID is not found, it will redirect to the homepage.

[wpdm_logout_url r=2]

Using the shortcode to log out and redirect to a specific page by referencing the page slug or name. If the page slug or name is not found, it will redirect to the homepage.

[wpdm_logout_url r="page-slug"]

Using the shortcode to log out and redirect to a specific URL. If the URL is not found or inaccessible, it will redirect to the homepage.

[wpdm_logout_url r="http://www.example.com"]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_logout_url] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_logout_url', array($this, 'logoutURLShortcode'));

Shortcode PHP function:

function logoutURLShortcode($params)
    {
        $redirect = isset($params['r']) ? $params['r'] : '';
        return wpdm_logout_url($redirect);
    }

Code file location:

download-manager/download-manager/src/User/Login.php

Download Manager [wpdm_user_favourites] Shortcode

The WP Download Manager shortcode, “wpdm_user_favourites”, allows users to view their favorite downloads. It checks if a user is logged in and, if not, prompts them to log in.

Shortcode: [wpdm_user_favourites]

Examples and Usage

Basic example – The shortcode displays the favourite downloads of the currently logged-in user. If no user is logged in, it will display a login form.

[wpdm_user_favourites /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_user_favourites] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode("wpdm_user_favourites", [$this, 'favourites']);

Shortcode PHP function:

function favourites($params = array())
    {
        global $wpdb, $current_user;
        if (!isset($params['user']) && !is_user_logged_in()) return WPDM()->user->login->form();
        ob_start();
        include  Template::locate('user-favourites.php', __DIR__.'/views');
        return ob_get_clean();
    }

Code file location:

download-manager/download-manager/src/User/User.php

Download Manager [wpdm_members] Shortcode

The WP Download Manager shortcode enables the display of members on a page. It fetches member details using parameters and updates the post meta-data. The shortcode accepts ‘sid’ as a parameter. If ‘sid’ isn’t provided, it defaults to an empty string. The shortcode then updates the post meta-data with the given parameters. It uses output buffering to capture the HTML generated from the member’s template file. The buffered content is then returned and displayed on the page.

Shortcode: [wpdm_members]

Parameters

Here is a list of all possible wpdm_members shortcode parameters and attributes:

  • sid – unique identifier for specific shortcode instance

Examples and Usage

Basic example – A basic usage of the shortcode allows you to call the ‘members’ function without any parameters. This will load the default ‘members.php’ template from the views directory.

[wpdm_members /]

Advanced examples

Passing the ‘sid’ parameter to the shortcode – This allows you to specify a unique ID for the shortcode. The function will then update the post meta for the current post with the given parameters, under a key that includes the specified ‘sid’.

[wpdm_members sid="123" /]

Passing multiple parameters to the shortcode – You can also pass multiple parameters to the shortcode. These parameters will be included in the post meta update, and can be used in the ‘members.php’ template to customize its output.

[wpdm_members sid="123" param1="value1" param2="value2" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [wpdm_members] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('wpdm_members', [$this, 'members']);

Shortcode PHP function:

function members($params = array())
    {
        $sid = isset($params['sid']) ? $params['sid'] : '';
        update_post_meta(get_the_ID(), '__wpdm_users_params' . $sid, $params);
        ob_start();
        include Template::locate("members.php", __DIR__.'/views');
        return ob_get_clean();
    }

Code file location:

download-manager/download-manager/src/User/User.php

Conclusion

Now that you’ve learned how to embed the Download Manager Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *