Viewing 1 replies (of 1 total)
  • Thread Starter colingreig

    (@colingreig)

    Managed to find it on a different site:
    https://blue-anvil.com/archives/wordpress-download-monitor-3-documentation/

    Will attempt to copy it here for safe keeping incase it’s removed there too.

    Outputting your Downloads

    Download monitor provides a variety of ways to output your downloads in your pages, posts, or templates.

    Shortcodes

    Shortcodes are the best way of including downloads (these replace many of the legacy tags shown later).

    Outputting a single Download

    [download id=”1″ format=”1″ autop=”false”]

    This shortcode outputs a single download of your choosing (set the id), with an optional custom format (replace the id in ‘format’), and an optional autop (true or false; false prevents wrapping the outputted content in p tags and is default). Valid examples:

    [download id=”1″]

    [download id=”2″ format=”2″]

    Outputting multiple downloads

    [downloads query="limit=5&orderby=rand" format="1" wrap="ul" before="
    <li>" after="</li>
    " autop="false"]

    This shortcode retrieves and outputs multiple downloads in posts. All of the options are optional.

    ‘query’ takes a query string containing a variety of options (see the get_downloads() function below; they use the same query string format). By default it retrieves 5 random downloads. A common request is showing a category using this shortcode; to do that you can add &category=1 (replacing 1 with the category ID) to the query string.

    ‘Format’ take a custom format ID to change how the downloads of outputted.

    ‘Wrap’ by default wraps the downloads in a unordered list; you can set this option to be blank if you want to wrap it with something else (like a table).

    ‘Before’ and ‘after’ are what each download will be wrapped in (by default this is a list item). If you modify these values you must ensure the code you insert is encoded e.g. replace < with <.

    ‘autop’ can be true or false; false prevents wrapping the outputted content in p tags and is default.

    Valid examples:

    [downloads]

    [downloads query=”limit=5&orderby=hits”]

    [downloads query=”limit=5&orderby=hits” format=”2″]

    [download query="limit=5&orderby=hits" wrap="" before="<p>" after="</p>"]

    Show a special download page

    Use the [download_page] shortcode. See the ‘download page’ section for more info.

    Parsing shortcodes in templates

    Did you know you could output shortcodes in places other than posts? Just wrap your shortcode in the do_shortcode() function. Example:

    do_shortcode(‘[download id=”1″]’);
    get_downloads() template function

    This function returns downloads that match your query; it takes 1 argument containing the query string. The defaults are as follows:

    'limit' => '', 'offset' => 0, 'vip' => 0 'category' => '', 'orderby' => 'id', 'order' => 'ASC'

    As with many of wordpress’ functions, construct your query string using the above attributes linked together with an ampersand (&), e.g. limit=5&orderby=hits&order=desc.

    ‘limit‘ takes an integer and will return that many posts.

    ‘offset‘ takes an integer and will offset the returned posts by that number. e.g. offset of 1 would not return the first result.

    ‘vip‘ can be 1 (true) or 0 (false); if set to true, only downloads you have permission to access will be displayed (non members will not see member only downloads).

    ‘category‘ takes a comma separated list of category id’s and returns downloads in those categories.

    ‘orderby‘ orders the downloads. Valid options for this include id, hits, title, date, filename, and random. NEW: can also be ‘meta’ (but you must also add meta_name to the query).

    ‘meta_name‘ define the meta field to sort by when using orderby=meta. Only downloads with this meta field will show.

    ‘order‘ can be ‘ASC’ for ascending, and ‘DESC’ for descending.

    get_downloads() returns an array object with the following data:

    size
    url
    title
    version
    hits
    image
    desc
    category
    category_id
    id
    date
    memberonly
    Usage Example: (Output a list of top downloads)

    $dl = get_downloads(‘limit=5&orderby=hits&order=desc’);

    if (!empty($dl)) {
        echo '<ul class="downloadList">';
        foreach($dl as $d) {
            $date = date("jS M Y", strtotime($d->date));
            echo '
    <li><a>url.'" title="'.__('Version',"wp-download_monitor").' '.$d->version.' '.__('downloaded',"wp-download_monitor").' '.$d->hits.' '.__('times',"wp-download_monitor").'" >'.$d->title.' ('.$d->hits.')</a></li>
    ';
        }
        echo '';
    }

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

Viewing 1 replies (of 1 total)
  • The topic ‘Where to find v3.3 documentation?’ is closed to new replies.