Forums

[resolved] [Plugin: AdSense Manager] A bug in $ad name resolution (3 posts)

  1. Kaspars
    Member
    Posted 3 years ago #

    Hi, Martin. I thought I'll post it here instead of just sending an email.

    In line 189 of adsense-manager.php is function widget.

    If $n is already set then substr($args['widget_id'],9) will not be applied. Also, if $n is empty, it will try to do the substr.

    Here is my suggestion:

    if ($n == '') { $n='default-ad'; }
    if ($n !== 'default-ad') {
       $n = substr($args['widget_id'], 9);
       $ad = $_adsensem['ads'][$n];
    } else {
       $ad = $_adsensem['ads'][$_adsensem['default-ad']];
    }

    http://wordpress.org/extend/plugins/adsense-manager/

  2. Kaspars
    Member
    Posted 3 years ago #

    Sorry, I just figured out that we also need to check if $args['widget_id'] is not empty and only then use the default-ad.

    if ($n == '' && empty($args['widget_id'])) { $n = 'default-ad'; }
    if ($n !== 'default-ad') {
       $n = substr($args['widget_id'], 9);
       $ad = $_adsensem['ads'][$n];
    } else {
       $ad = $_adsensem['ads'][$_adsensem['default-ad']];
    }
  3. Kaspars
    Member
    Posted 3 years ago #

    Here is the ultimate version, which also includes situation when $args['widget_id'] is empty and $n is a the necessary ad id:

    if ($n == '' && empty($args['widget_id'])) {
    	$n = 'default-ad';
    } elseif (!empty($args['widget_id'])) {
    	$n = substr($args['widget_id'], 9);
    	$ad = $_adsensem['ads'][$n];
    } elseif (!empty($n)) {
    	$ad = $_adsensem['ads'][$n];
    } else {
    	$ad = $_adsensem['ads'][$_adsensem['default-ad']];
    }

Topic Closed

This topic has been closed to new replies.

About this Topic