Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Scott DeLuzio

    (@scottdeluzio)

    The short answer is yes, this is possible.

    The longer answer is that I initially created this with AdSense ads in mind. Google AdSense policies limit you to three ads on each page. Of course there are other ad networks that could use this plugin just the same, which may not have those restrictions. You could also try to test various ad sizes and eventually need more than three ad shortcodes while still falling within the policy of displaying three per page.

    After about an hour of “what-if’s” when I was developing the plugin, I eventually decided to stick with three shortcodes for simplicity’s sake. Perhaps in a future version of this plugin I’ll make it more dynamic so there isn’t a cap on the number of shortcodes available.

    In the meantime, if you want to manually add more shortcodes to this plugin, you can edit the adsense-inpost-ads.php file, and find all references to “adsense unit c”, copy and paste those lines and change the “c” to a “d” (or whatever identifier you want to use). So…

    • Line 45: copy add_option('oizuled-adsense-unit-c', ''); and paste add_option('oizuled-adsense-unit-d', ''); in a new line directly below it.
    • Line 51: copy delete_option('oizuled-adsense-unit-c'); and paste delete_option('oizuled-adsense-unit-d'); in a new line directly below it.
    • Line 60: copy register_setting( 'oizuled-adsense-option-group', 'oizuled-adsense-unit-c'); and paste register_setting( 'oizuled-adsense-option-group', 'oizuled-adsense-unit-d'); in a new line directly below it.
    • Line 85-91: copy
      function oizuled_adsense_c() {
      if(!isset($oizuledadsense_c)) {
      	$oizuledadsense_c = get_option('oizuled-adsense-unit-c');
      }
      	return $oizuledadsense_c;
      }
      add_shortcode('AdSense-C', 'oizuled_adsense_c');

      and paste

      function oizuled_adsense_d() {
      if(!isset($oizuledadsense_d)) {
      	$oizuledadsense_d = get_option('oizuled-adsense-unit-d');
      }
      	return $oizuledadsense_d;
      }
      add_shortcode('AdSense-D', 'oizuled_adsense_d');

      in a new line directly below it (but before the ending ?>)

    Then in options.php, you will need to copy lines 17-20

    <tr valign="top">
    					<th scope="row">Enter the AdSense code provided to you from your <a href="https://www.google.com/adsense" target="_blank">Google AdSense account</a>.</th>
    					<td><textarea rows="5" cols="36" name="oizuled-adsense-unit-c"><?php echo get_option('oizuled-adsense-unit-c'); ?></textarea><br />Use <strong>[AdSense-C]</strong> to display this ad.</td>
    				</tr>

    and paste

    <tr valign="top">
    					<th scope="row">Enter the AdSense code provided to you from your <a href="https://www.google.com/adsense" target="_blank">Google AdSense account</a>.</th>
    					<td><textarea rows="5" cols="36" name="oizuled-adsense-unit-d"><?php echo get_option('oizuled-adsense-unit-d'); ?></textarea><br />Use <strong>[AdSense-D]</strong> to display this ad.</td>
    				</tr>

    in a line directly below it.

    Repeat each of those steps for as many new shortcodes as you need.

    One caution – if you do this and the plugin gets updated in the future, all of your changes will be lost going forward. It will be important to keep a backup of your changes so you don’t accidentally lose any changes by applying an update.

    Thread Starter blueredblue

    (@blueredblue)

    Thankyou for the extremely detailed response to my question. I see why you chose three initially. My intent was to use them on multiple pages, and I was after each shortcode linking to a different adsense ad unit so I can track what’s achieving what. You have given me the tools to do that, so I very much appreciate the effort.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘More than three?’ is closed to new replies.