The MU forums have moved to

Adsense plugin issue (6 posts)

  1. corourke
    Posted 17 years ago #

    I just tried to install drmike's adsense plugin from the wpmudev site and it keeps displaying the code of the widget rather than running. Every page on the admin screen reflects that code. When I downloaded it I changed the extension to php (the zip is adsense.php.txt) and thenput into mu-plugins.
    I'm running wpmu 1.0 on a php 5 setup using subdomains.

  2. kprimdal
    Posted 17 years ago #


    I have tryed the same with some off drmikes hack, so i just copied to code inserted it in my php editor and then saved it in the same file, and then i worked. I don't know why, but it works

  3. corourke
    Posted 17 years ago #

    Well that partially worked. Now I'm getting these two errors:
    Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/.belfry/corourke/ on line 110

    Warning: Invalid argument supplied for foreach() in /home/.belfry/corourke/ on line 128

    Any ideas on that? I checked through the code and everything seems like it's validly written.

  4. corourke
    Posted 17 years ago #

    Nevermind. The error results from using php5.

    I found the solution (problem occurs in the regular wordpress version) on Mike Mullins site (wrote original widget)

    Replace this:
    $options = array_merge(widget_adsense_options(), get_option(’widget_adsense’));


    $wadsense = get_option(’widget_adsense’);
    $options = array_merge(widget_adsense_options(), array($wadsense));

  5. Cruz
    Posted 17 years ago #

    In my case, the login page won't load after installation. Other problem than PHP?

  6. Bike
    Posted 16 years ago #

    Has anybody a working example of this?
    I found out that there are two instances of the code need to be replaced for PHP5. At least when I only replace the first, there are more errors. When only replacing the second instance, no errors, but it doesn't work, same as replacing both.

    Main problem seems to be that the blogger's settings are not saved. A publisher ID can be entered and the rest can be changed. After saving changes, it is still there when clicking again on the adsense widget. But when doing anything else (for example going to Themes tab and then back to widgets), the user code has disappeared. Other widgets, like the text one, do keep their info.

    Any thoughts? Thanks
    ps: WPMU 1.2.3

    Some extra info from the widget code:

    			// Save changes
    			update_option('widget_adsense', $options);

    I am not sure how other widgets do this, but I cannot see how this line can save anything anywhere? What is missing?

    and some more info:
    this is the last part of the code that should register/save?

    		foreach($options as $key => $value): ?>
    			<p style="text-align:left"><label for="adsense-<?=$key?>"><?=$key?>: <input style="width: 200px;" id="adsense-<?=$key?>" name="adsense-<?=$key?>" type="text" value="<?=htmlspecialchars($value, ENT_QUOTES)?>" /></label></p>
    		<? endforeach;
    		echo '<input type="hidden" id="adsense-submit" name="adsense-submit" value="1" />';
    	// This registers our widget so it appears with the other available
    	// widgets and can be dragged and dropped into any active sidebars.
    	register_sidebar_widget('Google AdSense', 'widget_adsense');
    	// This registers our optional widget control form. Because of this
    	// our widget will have a button that reveals a 300x100 pixel form.
    	register_widget_control('Google AdSense', 'widget_adsense_control', 220, 50 * count(widget_adsense_options()));

About this Topic