• Resolved SamHodges

    (@samhodges)


    Hi Guys,

    I’ve been using wordpress now for a couple of years as a leech basically just consuming content, and i recently came up with an idea for a plugin related to my workplace… I am now trying to reproduce and advert widget basically which pulls in widgets generated by a 3rd party.

    I have created a stement thatis supposed to throw out the JS if a statement is true, but i cant seem to make the JS render in my widget, the same code works in the HTML javascript adder widget but not mine… any ideas?

    if( $type == 'skyscraper'){
    			$widget = '<div id="FusePress"><div id="widget-26-W0bc2803a495" style="overflow: visible;"></div><script language="javascript" type="text/javascript" src="http://www.click-trail.co.uk/feed-distribution/lastminute/dp/uk/widgets/ws1/6.php?pid=4654843&fpwid=W0bc2803a495"></script></div>';
    		}

    Thanks,

    Sam

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter SamHodges

    (@samhodges)

    Dont suppose anyone has a solution r.e. this? Im guessing it must be a relativley easy problem but i cant seem to find the answer anywhere…

    Sam

    Thread Starter SamHodges

    (@samhodges)

    Thanks, i actually came up witht hat answer myself after a little more digging. I get the concept but im guessing my execution is an orderof magnitue out… Because the if statement has several other else’s attached i have to load the url of the JS dynamically so i defined a function to decide what to load after it has decided which type to call. After that i pass that in then try and echo out the JS after, im guessing this is not the correct way of doing things?

    function load_url(){
    			wp_enqueue_script( load_url, $widget_url);
    		}	
    
    if( $type == 'skyscraper'){
    			$widget_url = 'http://www.click-trail.co.uk/feed-distribution/lastminute/dp/uk/widgets/ws1/6.php?pid=4654843&fpwid=W0bc2803a495';
    			add_action('wp_enque_scripts', 'load_url');
    			$widget = '<div id="widget-26-W0bc2803a495" style="overflow: visible;"></div><script language="javascript" type="text/javascript" src="http://www.click-trail.co.uk/feed-distribution/lastminute/dp/uk/widgets/ws1/6.php?pid=4654843&fpwid=W0bc2803a495"></script>';
    
    		}
    
    echo $widget;

    Sorry im very special..

    Thread Starter SamHodges

    (@samhodges)

    Very special indeed, that function does solve it!

    Incredibly rookie case sensativity mistake!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘JavaScript not rendering in custom widget’ is closed to new replies.