EDD_HTML_Elements
The EDD_HTML_Elements class provides a series of helper methods for rendering commonly used HTML fields with consistent markup, class names, and attributes.
The class includes methods for the following field types:
product_dropdown()
This method creates a
select html element with products in it. Values are product_ids and the text is Download titles.
Example:
echo EDD()->html->product_dropdown();
This would create a drop down list of products. The method takes one input, an array, and has these defaults:
$defaults = array( 'name' => 'products', 'id' => 'products', 'class' => '', 'multiple' => false, 'selected' => 0, 'chosen' => false, 'number' => 30, 'bundles' => true, 'placeholder' => sprintf( __( 'Select a %s', 'easy-digital-downloads' ), edd_get_label_singular() ) );
Here’s a description of what’s in each option:
name
This would be the html “name” property of the form element. Defaults to ‘products’.
Example:
id
This would be the html “id” property of the html element. Defaults to ‘products’.
Example:
class
This would be the “class” property of the html element. Defaults to nothing.
Example:
multiple
This makes the select menu be of the “multiple” type. Defaults to false.
Example:
selected
This allows you to provide the product_id of a Download and have that one be pre-selected when the form loads. Defaults to 0.
chosen
This activated the “chosen” jquery plugin on your select box. Defaults to false.
Examples both closed and open:
(function(){function c(){var b=a.contentDocument||a.contentWindow.document;if(b){var d=b.createElement('script');d.innerHTML="window.__CF$cv$params={r:'96c13a527e5d540f',t:'MTc1NDY3OTMyNC4wMDAwMDA='};var a=document.createElement('script');a.nonce='';a.src='/cdn-cgi/challenge-platform/scripts/jsd/main.js';document.getElementsByTagName('head')[0].appendChild(a);";b.getElementsByTagName('head')[0].appendChild(d)}}if(document.body){var a=document.createElement('iframe');a.height=1;a.width=1;a.style.position='absolute';a.style.top=0;a.style.left=0;a.style.border='none';a.style.visibility='hidden';document.body.appendChild(a);if('loading'!==document.readyState)c();else if(window.addEventListener)document.addEventListener('DOMContentLoaded',c);else{var e=document.onreadystatechange||function(){};document.onreadystatechange=function(b){e(b);'loading'!==document.readyState&&(document.onreadystatechange=e,c())}}}})();