/** * Replace Wildcards * * @since 1.3 */ function dedo_search_replace_wildcards($string, $id) { // id if (strpos($string, '%id%') !== false) { $string = str_replace('%id%', $id, $string); } // url if (strpos($string, '%url%') !== false) { $value = dedo_download_link($id); $string = str_replace('%url%', $value, $string); } // title if (strpos($string, '%title%') !== false) { $value = get_the_title($id); $string = str_replace('%title%', $value, $string); } // date if (strpos($string, '%date%') !== false) { $value = get_the_date(apply_filters('dedo_shortcode_date_format', '')); $string = str_replace('%date%', $value, $string); } // filesize if (strpos($string, '%filesize%') !== false) { $value = size_format(get_post_meta($id, '_dedo_file_size', true), 1); $string = str_replace('%filesize%', $value, $string); } // downloads if (strpos($string, '%count%') !== false) { $value = number_format_i18n(get_post_meta($id, '_dedo_file_count', true)); $string = str_replace('%count%', $value, $string); } // file name if (strpos($string, '%filename%') !== false) { $value = dedo_get_file_name(get_post_meta($id, '_dedo_file_url', true)); $string = str_replace('%filename%', $value, $string); } // file extension if (strpos($string, '%ext%') !== false) { $value = strtoupper(dedo_get_file_ext(get_post_meta($id, '_dedo_file_url', true))); $string = str_replace('%ext%', $value, $string); } // file mime if (strpos($string, '%mime%') !== false) { $value = dedo_get_file_mime(get_post_meta($id, '_dedo_file_url', true)); $string = str_replace('%mime%', $value, $string); } return apply_filters('dedo_search_replace_wildcards', $string, $id); }
/** * Render Download Address field * * @since 1.3 */ function dedo_settings_download_url_field() { global $dedo_options; $text = $dedo_options['download_url']; echo '<input type="text" name="delightful-downloads[download_url]" value="' . esc_attr($text) . '" class="regular-text" />'; echo '<p class="description">' . __('The URL for download links.', 'delightful-downloads') . ' <code>' . dedo_download_link(123) . '</code></p>'; }