Buttons

The Buttons extension for Download Monitor allows you to create new button templates without having to do any coding!

Installation

  • Unzip and upload the plugin’s folder to your /wp-content/plugins/ directory
  • Activate the extension through the ‘Plugins’ menu in WordPress

For more information on installing and managing plugins see here

Usage

After installing the extension, a new sub-menu item is added to your Downloads menu item called “Buttons“. On this new page, you can add, edit, and delete your new custom button templates.

Creating a new template

A new Buttons template can be added via the Buttons overview page. Click on the new “Buttons” sub-menu item, located under Download in your WordPress admin menu. At the top of this page is a form you can use to create a new template. After creating the template, you will be automatically redirected to the page to edit that template. All templates are created with a default configuration to get you going but all values can be changed in any way you like.


Add a new template by entering the new name (1) and press the “Add Template” button (2).

Editing a template

After adding a new Buttons template, or by clicking on the edit action on one of your existing templates, you are taken to the edit screen. On this screen, you can edit all of the stylings of your button.

After changing any of the styling options, the live preview (3) will automatically update to reflect the change. Please note that the button is not stored until you click the “Save Button” button (2). After you’re done editing your button, you can go back to the overview screen with the “Back to overview” button (1).


On this screen, you can edit all of the stylings of your button. The live preview (3) will display your changes directly as you do them. This way you are sure your buttons look the way you want them to.

Using a Buttons template in a shortcode

After you’ve created the Buttons template and set it up the way you like it, it’s time to use it on your website. You can use your new template in the same way you’d use a normal Download Monitor template. The only difference is that you will have to prefix your template name with dlm-buttons-.

  1. Copy the shortcode of your button

    Go to your WordPress dashboard > Downloads > Buttons > Copy the shortcode displayed next to your template.
  2. Add the ID of your download in the shortcode

    You will need to go to your WP dashboard > Downloads > All Downloads > edit a download> head over to Download Information and check the ID of your download. Copy that ID and add it in the shortcode you copied above.

  3. Display your button

    Go to your WordPress dashboard > Pages > Add New/Edit a page you created > paste there the shortcode > Publish.


    Here we are displaying our new button for our download with ID 1645!

Setting the Buttons template from the default WordPress editor

  1. Go to your dashboard > Pages/Posts and create a new one or use an existing one. To connect the download button with the download file, click on “+“, and add the Download Button block.

  2. You’ll need to customize a few things
    -> Download – you’ll need to select the file you want to connect with the download button;
    -> Template – in our case, we’ll select the custom template;
    -> Custom template – add the shortcode from the button template (in my case: [… template=”dlm-buttons-test”];

Setting a Buttons template as default template for all buttons

If you created a new template you’d like to use for all of your Download Monitor buttons, you can set it as the default template.

Go to your WordPress dashboard > Downloads > Settings > General > General Settings > Default Template > set it to ‘Custom template‘ > a new field called Custom Template will appear. In this new field (Custom Template), enter the name of your Buttons template. Note that this should include the dlm-buttons- prefix.

After you’ve done this, save the page by clicking the Save Changes button. Now all your Download Monitor shortcodes that have no specific template assigned to them will use your new Buttons template.

FAQ

Why is “dlm-buttons-” prepended to my template name?

Because Download Monitor works with template files out of the box, we needed a way to identify the special templates created by the Buttons extension. This is what the "dlm-buttons-" prefix does. You don’t have to add this to the template name when you create a template but you do need to add this when using the template name in your shortcodes.

Is HTML allowed in the button text?

Some HTML tags are allowed in the button text. Tags that are allowed are: <b><strong><i><em><u><small><br>.

You can add new allowed HTML tags to this list with the dlm_buttons_text_allowed_html_tags filter. An example of adding a tag (div) is:

add_filter( 'dlm_buttons_text_allowed_html_tags', function ( $tags ) {
$tags[] = "div";

return $tags;
} );
How are the Buttons templates stored?

The template configuration is stored in your WordPress database in a custom table named wp_dlm_buttons (the wp_ may be different if you’ve changed your database prefix). We store not actual files on your server, the buttons are generated on the fly. Please note that if your database output is cached, our button config will be cached as well.

Was this article helpful?
Start Protecting your WordPress Downloads

Protect and track downloads on WordPress... What are you waiting for?