Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Adsense plugin crashes

Dear All,

I had installed Vanilla Forums latest version 2.2 on my cloud shared server. All other plugins are working just normal, except Google adsense. I am getting following error. Secondly, there is no error, in the error logs. don't know what to do.

Had anyone tried adsense on latest version 2.2 ?

Comments

  • anybody find solution to this? Not working on 2.3

  • R_JR_J Ex-Fanboy Munich Admin

    Please try editing the default.php file in the plugin. In lines 18, 25 and 90 you find public function ... (&$Sender). Try removing the & sign before the $Sender variable.

    In most cases this is enough to make an old plugin work again. It would be great if you could provide feedback if that has worked for you!

  • There seems to be a problem with the naming as well.

    If you change the folder name to AdSense2 and change the adsense to adsense2 in this part the plugin works (after removing the ampersands as well):

    $PluginInfo['AdSense2'] = array(
       'Name' => 'AdSense2',
       'Description' => 'Adds Google AdSense code to the first comment of each thread. You must have an AdSense publisher ID for this plugin to work.',
       'Version' => '1.6',
       'Author' => 'ithcy',
       'AuthorEmail' => 'vanilla@rel2.com',
       'AuthorUrl' => 'http://rel2.com',
       'SettingsUrl' => '/dashboard/settings/adsense',
       'SettingsPermission' => 'Garden.Settings.Manage'
    );
    class AdSense2Plugin extends Gdn_Plugin
    

    I'm not sure what causes that to happen.

    I'm also not sure why it matters to remove the ampersand? In some plugins (like this one) it matters, in some it doesn't.
    Is it not possible to pass some data structures by reference and does php then give an error or something?

  • R_JR_J Ex-Fanboy Munich Admin

    @Caylus said:
    Is it not possible to pass some data structures by reference and does php then give an error or something?

    http://php.net/manual/en/language.references.pass.php

    There is no reference sign on a function call - only on function definitions. Function definitions alone are enough to correctly pass the argument by reference. As of PHP 5.3.0, you will get a warning saying that "call-time pass-by-reference" is deprecated when you use & in foo(&$a);. And as of PHP 5.4.0, call-time pass-by-reference was removed, so using it will raise a fatal error.

  • ok thankyou i will try this asap and report back

  • Help needed. Setting page is shown now but no ads are displaying in vanilla 2.3
    . I guess plugin is unable to fetch adsense ads now. Maybe needs more code change. please view my configuration in attached snapshot.

    settings page is showing after i apply above suggestion of removing & . i also changed name to adsense2 upto line 11 as shown and named plugin folder as adsense2. Settings page again shows well.

    i created a 720*90 ad. Created custom channel and entered there numbers. I filled adsense id by adding ca- and only pure number too. I am using auro2 theme but Changed to default theme to test, still same results .

    Do i need to unable or disable some other plugin.

    Sir my users are mainly from mobile and i don't get even CTR of 1 percent because vanilla do not show ads in posts. So one ad in the end of first post will be a boon. Thankyou

  • R_JR_J Ex-Fanboy Munich Admin

    Try to add 'MobileFriendly' => true, to the plugin like that:

    <?php if (!defined('APPLICATION')) die();
    
    $PluginInfo['AdSense'] = array(
       'Name' => 'AdSense',
       'Description' => 'Adds Google AdSense code to the first comment of each thread. You must have an AdSense publisher ID for this plugin to work.',
       'MobileFriendly' => true,
    
    ...
    
  • @R_J said:
    Try to add 'MobileFriendly' => true, to the plugin like that:

    sir ads are not visible on desktop .

  • It seems like there is an error in line 37, coupled with line 43.

    If I understand it correctly DiscussionController_afterCommentBody_Handler only fires after comments in the discussion, not the OP itself. Which means that the check in line 43 (if ($Type == 'comment') {return;}) will always happen, since the type will always be "comment".

    There's two things you can try, either change DiscussionController_afterCommentBody_Handler to DiscussionController_afterDiscussionBody_Handler on line 37, or you can delete the check in line 43.

    Both should work. I sadly can't test it because I don't have an adsense account. My apologies if this doesn't fix anything.

  • Thankyou Caylus your solution worked perfect.

    I am attaching edited code in word document format so that others can just copy and use it in default php. Just change folder name from adsense to adsense2 and use the code.

    After this, To customize the ad options and ad sizes, I Just changed the name and sizes in settings php file located inside view folder . Like i added square format by editing third ad format in following way.

    $AdFormatText = array
    (
    'Image/Text Ad, Leaderboard (728x90)',
    'Image/Text Ad, Banner (468x60)',
    'Image/Text Ad, Square (200x200)',
    'Link Unit, up to 5 links (728x15)',
    'Link Unit, up to 4 links (728x15)',
    'Link Unit, up to 5 links (468x15)',
    'Link Unit, up to 4 links (468x15)'
    );
    $AdFormatValue = array
    (
    '728x90_as',
    '468x60_as',
    '200x200_as',
    '728x15_0ads_al_s',
    '728x15_0ads_al',
    '468x15_0ads_al_s',
    '468x15_0ads_al',
    );

  • Thanks for testing! Glad it worked! I'll try getting in touch with the original author.

  • Hi so this is working well for you?

  • @CCarters said:
    Hi so this is working well for you?

    yes absolutely fine after the changes as discussed in this post

Sign In or Register to comment.