Responsive Google AdSense

Just add this Responsive Google AdSense snippet code to your website page to make your Google ads responsive to any devices if Google’s native responsive code does not work for you.


 
 
 
    /* Calculate the width of available ad space */
    ad = document.getElementById('google-ads-1');
 
    if (ad.getBoundingClientRect().width) {
        adWidth = ad.getBoundingClientRect().width; // for modern browsers 
    } else {
        adWidth = ad.offsetWidth; // for old IE 
    }
 
    /* Replace ca-pub-XXX with your AdSense Publisher ID */ 
    google_ad_client = "ca-pub-XXX";
 
    /* Replace 1234567890 with the AdSense Ad Slot ID */ 
    google_ad_slot = "1234567890";
  
    /* Do not change anything after this line */
    if ( adWidth >= 728 )
      google_ad_size = ["728", "90"];  /* Leaderboard 728x90 */
    else if ( adWidth >= 468 )
      google_ad_size = ["468", "60"];  /* Banner (468 x 60) */
    else if ( adWidth >= 336 )
      google_ad_size = ["336", "280"]; /* Large Rectangle (336 x 280) */
    else if ( adWidth >= 300 )
      google_ad_size = ["300", "250"]; /* Medium Rectangle (300 x 250) */
    else if ( adWidth >= 250 )
      google_ad_size = ["250", "250"]; /* Square (250 x 250) */
    else if ( adWidth >= 200 )
      google_ad_size = ["200", "200"]; /* Small Square (200 x 200) */
    else if ( adWidth >= 180 )
      google_ad_size = ["180", "150"]; /* Small Rectangle (180 x 150) */
    else
      google_ad_size = ["125", "125"]; /* Button (125 x 125) */
 
    document.write (
     ''
    );
  
    (adsbygoogle = window.adsbygoogle || []).push({});
 

 
//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

 
Source: Snippet by Digital Inspiration

Fatal error: Allowed memory size of …

These couple of days I’ve been in progress of developing and maintaining a website based on WordPress which is hosted in CrazyDomains. Unfortunately I got a problem regarding memory allowance like “Fatal error: Allowed memory size of…” that some people said it was a common error problem if it is hosted in CrazyDomains. And I think that’s right, I’ve tried to follow some solutions, like:

  1. If you have access to your PHP.ini file, change the line in PHP.ini If your line shows 32M try 64M: memory_limit = 128M ; Maximum amount of memory a script may consume (128MB)
  2. If you don’t have access to PHP.ini try adding this to an .htaccess file: php_value memory_limit
  3. Try adding this line to your wp-config.php file: Increasing memory allocated to PHP define(‘WP_MEMORY_LIMIT’, ‘128M’);
  4. Talk to your host.

Unfortunately, It doesn’t work for me as the web is hosted in CrazyDomains.

[contentblock id=1 img=adsense.png]

Finally I stepped into WordPress.org forums and found the solution. To sum up, I …

  1. made a php.ini file in wp-admin directory, and…
  2. added memory_limit = 256M; into it.

Eventually it works well, alhamdulillah 🙂

source: http://wordpress.org/support/topic/fatal-error-allowed-memory-size-of-33554432-bytes-exhausted-14