function sdm_create_download_shortcode($atts) { extract(shortcode_atts(array('id' => 'id', 'fancy' => '0', 'button_text' => '', 'new_window' => ''), $atts)); if (empty($id)) { return '<p style="color: red;">' . __('Error! Please enter an ID value with this shortcode.', 'simple-download-monitor') . '</p>'; } // Check to see if the download link cpt is password protected $get_cpt_object = get_post($id); $cpt_is_password = !empty($get_cpt_object->post_password) ? 'yes' : 'no'; // yes = download is password protected; // Get CPT title $item_title = get_the_title($id); $isset_item_title = isset($item_title) && !empty($item_title) ? $item_title : ''; // See if user color option is selected $main_opts = get_option('sdm_downloads_options'); $color_opt = $main_opts['download_button_color']; $def_color = isset($color_opt) ? str_replace(' ', '', strtolower($color_opt)) : __('green', 'simple-download-monitor'); //*** Generate the download now button code *** $window_target = ''; if (!empty($new_window)) { $window_target = 'target="_blank"'; } if (empty($button_text)) { //Use the default text for the button $button_text_string = __('Download Now!', 'simple-download-monitor'); } else { //Use the custom text $button_text_string = $button_text; } $homepage = get_bloginfo('url'); $download_url = $homepage . '/?smd_process_download=1&download_id=' . $id; $download_button_code = '<a href="' . $download_url . '" class="sdm_download ' . $def_color . '" title="' . $isset_item_title . '" ' . $window_target . '>' . $button_text_string . '</a>'; if ($cpt_is_password !== 'no') { //This is a password protected download so replace the download now button with password requirement $download_button_code = sdm_get_password_entry_form($id); } //End of download now button code generation $output = ''; if ($fancy == '0') { $output = '<div class="sdm_download_link">' . $download_button_code . '</div>'; } else { if ($fancy == '1') { include_once 'includes/templates/fancy1/sdm-fancy-1.php'; $output .= sdm_generate_fancy1_display_output($atts); $output .= '<div class="sdm_clear_float"></div>'; } else { if ($fancy == '2') { include_once 'includes/templates/fancy2/sdm-fancy-2.php'; $output .= '<link type="text/css" rel="stylesheet" href="' . WP_SIMPLE_DL_MONITOR_URL . '/includes/templates/fancy2/sdm-fancy-2-styles.css?ver=' . WP_SIMPLE_DL_MONITOR_VERSION . '" />'; $output .= sdm_generate_fancy2_display_output($atts); $output .= '<div class="sdm_clear_float"></div>'; } else { //Default output is the standard download now button (fancy 0) $output = '<div class="sdm_download_link">' . $download_button_code . '</div>'; } } } return apply_filters('sdm_download_shortcode_output', $output, $atts); }
function sdm_generate_fancy1_category_display_output($get_posts, $args) { $output = ""; //TODO - when the CSS file is moved to the fancy1 folder, change it here //$output .= '<link type="text/css" rel="stylesheet" href="' . WP_SIMPLE_DL_MONITOR_URL . '/includes/templates/fancy1/sdm-fancy-1-styles.css?ver=' . WP_SIMPLE_DL_MONITOR_VERSION . '" />'; isset($args['button_text']) ? $button_text = $args['button_text'] : ($button_text = ''); isset($args['new_window']) ? $new_window = $args['new_window'] : ($new_window = ''); foreach ($get_posts as $item) { $id = $item->ID; //Get the post ID //Create a args array $args = array('id' => $id, 'fancy' => '1', 'button_text' => $button_text, 'new_window' => $new_window); $output .= sdm_generate_fancy1_display_output($args); } $output .= '<div class="sdm_clear_float"></div>'; return $output; }