WordPress.org

Ready to get started?Download WordPress

Forums

Simple Ads Manager
Ads getting blocked as pop ups (7 posts)

  1. siddkb1986
    Member
    Posted 1 year ago #

    The ads that are generated using the drawad() are getting blocked as pop ups on most browsers. Even though I have many links with target="_blank" on my page these are the only ones that are getting blocked as pop ups. Could you please tell me what I can do to prevent this from happening?
    Here's the generated code on the page :
    <div class="homepage_ad spot2"><a id="a29_2" class="sam_ad" href="http://www.gyaanexchange.com/catalogue/arts-in-motion/" target="_blank"><img src="http://www.gyaanexchange.com/wp-content/plugins/sam-images/artsinmotion.jpg" alt="Find classes on performing arts"></a></div>

    You can view the page here:

    Would really appreciate your help on this. Thanks a ton!

    http://wordpress.org/extend/plugins/simple-ads-manager/

  2. minimus
    Member
    Plugin Author

    Posted 1 year ago #

    Set "Display Ad Source in" on Settings Page to "New Window"

  3. siddkb1986
    Member
    Posted 1 year ago #

    Thanks minimus, it was on New Window so I switched it to current tab and its working perfectly fine now! Thanks again!

  4. B_Dark
    Member
    Posted 1 year ago #

    @minimus

    I use the plugin in a multisite. I have chosen "New Window", at the begining it looked like it worded with "New Window" and then it kept working with pop-up again. Why is this happening?
    Also, I think that is better to have an option in every banner how we want to show it.

  5. appcuarium
    Member
    Posted 1 year ago #

    Actually the issue is very easy to fix. It's a small programming error related to the click tracking snippet.

    Modify sam-layout.js located in /js folder so it looks like this:

    (function($) {
      $(function() {
        $("body").on('click','.sam_ad', function() {
          	var $me = $(this),
          		adId = $me.attr('id');
    
          $.ajax({
            type: "POST",
            url: samAjax.ajaxurl,
            data: {
              action: "sam_click",
              sam_ad_id: adId,
              _ajax_nonce: samAjax._ajax_nonce
            },
            async: true
          });
        });
      });
    })(jQuery);

    The clicks get counted and the target behavior is the expected.

    Regards.
    S.

  6. owcv
    Member
    Posted 1 year ago #

    But that isn't update-safe :-(

  7. appcuarium
    Member
    Posted 1 year ago #

    Well, maybe the plugin developer will include the patch in his next release. Update safe patches should be considered with care as they can prevent the updated plugin to act on its own.

    Anyway, you could unbind the click event and then bind it to the .sam_ad class in an external js file, let's say your custom scripts.

    The final code will look like this:

    ( function( $ ) {
      $( function() {
        $( 'body' ).off( 'click', '.sam_ad' ).on(' click', '.sam_ad', function() {
          	var $me = $( this ),
          		adId = $me.attr( 'id' );
          $.ajax({
            type: "POST",
            url: samAjax.ajaxurl,
            data: {
              action: "sam_click",
              sam_ad_id: adId,
              _ajax_nonce: samAjax._ajax_nonce
            },
            async: true
          });
        });
      });
    })( jQuery );

    What this will do is override the click event in the plugin with the custom function.

    Hope it helps :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic