0 ) foreach ($matches as $val) {
$code = '[download id="'.$val[1].'" format="'.$val[2].'"]';
$data = str_replace( $val[0] , $code , $data );
} // End foreach
// Handle Non-formatted downloads
preg_match_all("/\[download#([0-9]+)/", $data, $matches, PREG_SET_ORDER);
$patts = array();
$subs = array();
if ( sizeof( $matches ) > 0 ) foreach ($matches as $val) {
$patts[] = "[download#" . $val[1] . "]";
$subs[] = '[download id="'.$val[1].'"]';
// No hit counter
$format = '{title}';
$patts[] = "[download#" . $val[1] . "#nohits]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// URL only
$format = '{url}';
$patts[] = "[download#" . $val[1] . "#url]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Description only
$format = '{description}';
$patts[] = "[download#" . $val[1] . "#description]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Description (autop) only
$format = '{description-autop}';
$patts[] = "[download#" . $val[1] . "#description_autop]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Hits only
$format = '{hits}';;
$patts[] = "[download#" . $val[1] . "#hits]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Image link
$format = '';
$patts[] = "[download#" . $val[1] . "#image]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// Regular download link WITH filesize
$format = '{title} ({hits}) - {size}';
$patts[] = "[download#" . $val[1] . "#size]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
// No hit counter + filesize
$format = '{title} ({size})';
$patts[] = "[download#" . $val[1] . "#size#nohits]";
$subs[] = '[download id="'.$val[1].'" format="'.htmlspecialchars($format).'"]';
} // End foreach
$data = str_replace($patts, $subs, $data);
} // End if [download# found
global $wpdb, $wp_dlm_db, $wp_dlm_db_meta, $wp_dlm_db_taxonomies, $downloadurl, $downloadtype;
// Handle CATEGORIES
if (substr_count($data,"[download_cat#")) {
$patts = array();
$subs = array();
preg_match_all("/\[download_cat#([0-9]+)#format=([0-9]+)\]/", $data, $result, PREG_SET_ORDER);
if ($result) foreach ($result as $val) {
$format = wp_dlm_get_custom_format($val[2]);
if ($format) {
$format = str_replace('\\"',"'",$format);
$args = array(
'orderby' => 'title',
'category' => $val[1],
'digforcats' => 'true'
);
$downloads = get_downloads($args);
// GENERATE LIST
$links = '
'.__('No Downloads Found',"wp-download_monitor").'
'; $retval .= "