blog adsense

is there a way to place adsense iframe script ads in blog posts? 

  • It's impossible because htmlaweb will filter any script/iframe into output. But if you want to run your site less secure then you can use this hook:

    elgg_register_plugin_hook_handler('config', 'htmlawed', 'htmlawed_unfiltered');
    
    function htmlawed_unfiltered($hook, $type, $result, $params){
        $config = array('iframe' => 1, 'script' => 1);
        return htmLawed($text, $config);
    }

     

  • We assumed this was a security issue. What does your code edit do and where does it go? We can limit blog creation only to admins, if we could only open up the security in the blogs to place adsense inside that would stabilize the security. 

  • What does your code edit do and where does it go?

    In start.php of your own plugin.

    This hook put between init():

    elgg_register_plugin_hook_handler('config', 'htmlawed', 'htmlawed_unfiltered');
  • You wouldn't want to store your AdSense code in thee database, because the moment you decide to change your AdSense ID, you would have to iterate through all the posts to update them. A more efficient way is to extend the object view, check if it's a log and output your AdSense code

  • this is what our google adsense codes that were trying to place in blogs look like.

     

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script&gt;

    <ins class="adsbygoogle"

         style="display:block; text-align:center;"

         data-ad-layout="in-article"

         data-ad-format="fluid"

         data-ad-client="numbergoshere"

         data-ad-slot="numbergoshere"></ins>

    <script>

         (adsbygoogle = window.adsbygoogle || []).push({});

    </script>

     

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script&gt;

    <ins class="adsbygoogle"

         style="display:block"

         data-ad-format="fluid"

         data-ad-layout-key="-dz-4l+39+40+ag"

         data-ad-client="numbergoshere"

         data-ad-slot="numbergoshere"></ins>

    <script>

         (adsbygoogle = window.adsbygoogle || []).push({});

    </script>

     

    <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script&gt;

    <!-- ad name -->

    <ins class="adsbygoogle"

         style="display:inline-block;width:160px;height:60px"

         data-ad-client="numbergoshere"

         data-ad-slot="numbergoshere"></ins>

    <script>

    (adsbygoogle = window.adsbygoogle || []).push({});

    </script>

     

    Theres three different scripts we could use. Where it says "numbergoshere" & "censored" it means thats where your adsense id gos & for security purposes are blurred.

  • Is there something we could just tweak real fast? We are on a time restraint & cant create a mod. We tryed 3 adsense plugins & only 1 worked but they display ads outside of the blog in the footer & sidebar.

  • wordpress has a ad inserter plugin: https://wordpress.org/plugins/ad-inserter/ but would it work with elgg?

  • ismayil,  your hypeembed plugin is broken it says missing dependecies, we would of like to have tried it as a solution though. 

  • Yes, of course, being on a time constraint is an excuse to make others do your work for you. You don't even bother to check what dependencies are missing, so why should I be wasting my time.

  • Your right about one thing, we need someone to do this but not only for us also the community. Bloggers need to moneteize their sites, not a excuse but a fact. No more waisting time please, only post solutions to the issue.

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking