WordPress.org

Ready to get started?Download WordPress

Forums

Download Monitor
[resolved] Issue with wp_dlm_parse_downloads() (4 posts)

  1. Eos Rose
    Member
    Posted 1 year ago #

    I have created the following function, which allows me to take a download ID saved in a custom field and specify how I want it formatted. In general, it works. However, I now need to snag this code and run it though the JournalPress plugin to be crossposted. I've successfully persuaded JournalPress to crosspost some complex functions that I've defined in my functions.php file, but it snags when it reaches the function for the download link.

    My WordPress Download Monitor function looks like this:

    if(!function_exists('dw13')){
    	function dw13(){
    		global $post;
    		if(get_post_meta($post->ID, 'mp3_id', true)) {
    			if (is_single() || is_page()) {
    				if (intval(get_post_meta($post->ID, 'mp3_id', true)) > 0) {
    					$mp3_display = wp_dlm_parse_downloads('[download id='.get_post_meta($post->ID, 'mp3_id', true).' format="6"]', 2) . "\n";
    					return apply_filters('the_content', $mp3_display);
    				}
    			}
    		}
    	}
    }

    It displays just fine in my single.php template, but it defies crossposting. If anyone has any ideas regarding why this isn't working, please share them. I've been staring at this code for so long that I'm not sure I'm even seeing it anymore.

    http://wordpress.org/extend/plugins/download-monitor/

  2. Eos Rose
    Member
    Posted 1 year ago #

    I removed the "\n" from the end of one line. That didn't do anything, though I'm sure removing that was a good idea.

    I also removed if (is_single() || is_page()) { } and now I'm left with:

    if(!function_exists('dw13')){
    	function dw13(){
    		global $post;
    		if(get_post_meta($post->ID, 'mp3_id', true)) {
    			if (intval(get_post_meta($post->ID, 'mp3_id', true)) > 0) {
    				$mp3_display = wp_dlm_parse_downloads('[download id='.get_post_meta($post->ID, 'mp3_id', true).' format="6"]', 2);
    				return apply_filters('the_content', $mp3_display);
    			}
    		}
    	}
    }

    Still not working. My post won't even save anymore, I just get a white screen of death, lol.

  3. Eos Rose
    Member
    Posted 1 year ago #

    I tried do_shortcode the results were odd. I'm still getting the desired results on single.php (that is, the link is printing as commanded) and my crossposting plugin doesn't choke, but all that's crossposted is [download id="681" format="6"] rather than the download link. I feel like maybe I'm getting closer...

    if(!function_exists('dw13')){
    	function dw13(){
    		global $post;
    		if(get_post_meta($post->ID, 'mp3_id', true)) {
    			if (intval(get_post_meta($post->ID, 'mp3_id', true)) > 0) {
    				$mp3_display = get_post_meta($post->ID, 'mp3_id', true);
    				return do_shortcode('[download id="'.$mp3_display.'" format="6"]');
    			}
    		}
    	}
    }
  4. Eos Rose
    Member
    Posted 1 year ago #

    So it seems like JournalPress somehow strips out all shortcodes. I don't use any other shortcodes, so I can't verify this. It could be Download Monitor specific, but at this point I doubt it.

    What I need is a way to call up the information from the database using the download ID without using any sort of shortcode. Anyone know how to do this?

    I require the download link, filesize, and two custom meta fields.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic