Any way to use php in simple ads?

Is there any way to use php in simple ads? I don't mind doing a little hacking, if necessary.

Thanks

  • Predrag Dubajic

    Hey @Tedster,

    Hope you're well today.

    If you go to your plugin folder and open simple-ads.php you can the part that prints out the code on line 111 to 122:

    function simple_ads_get_ad_code($ad_type) {
    	if ( $ad_type == 'before' ) {
    		$ad_code = stripslashes( get_site_option('advertising_before_code') );
    	}
    	if ( $ad_type == 'after' ) {
    		$ad_code = stripslashes( get_site_option('advertising_after_code') );
    	}
    	if ( $ad_code == 'empty' ) {
    		$ad_code = '';
    	}
    	return $ad_code;
    }

    Can you give me some more info on what is you want to do so I can help you more?

    Best regards,
    Philip

  • Tedster

    Hi Philip,

    I'm currently using some basic html and javascript in Simple Ads, which works fine. However, I update the html quite frequently and I would like to make it a bit more dynamic. Here is the code I'm using at this time...

    <div id="ebaybox"><br />
      <div id="flowerdivcontainer"><br />
      </div></p>
    <p>  <div id="flowertabs" class="modernbricksmenu2"><br />
      <ul class="flowertabs"><br />
      <li class="flowertabs"><a href="/ebay-block/camera.php" rel="flowerdivcontainer">Cameras</a><br />
      <li class="flowertabs"><a href="/ebay-block/computer.php" rel="flowerdivcontainer">Computers</a><br />
      <li class="flowertabs"><a href="/ebay-block/fashion.php" rel="flowerdivcontainer">Fashion</a><br />
      <li class="flowertabs"><a href="/ebay-block/guitar.php" rel="flowerdivcontainer">Guitars</a><br />
      <li class="flowertabs"><a href="/ebay-block/hobbies.php" rel="flowerdivcontainer">Hobbies</a><br />
      <li class="flowertabs"><a href="/ebay-block/jewelry.php" rel="flowerdivcontainer">Jewelry</a><br />
      <li class="flowertabs"><a href="/ebay-block/movies.php" rel="flowerdivcontainer">Movies</a><br />
      <li class="flowertabs"><a href="/ebay-block/phones.php" rel="flowerdivcontainer">Phones</a><br />
      <li class="flowertabs"><a href="/ebay-block/tools.php" rel="flowerdivcontainer">Tools</a><br />
      <li class="flowertabs"><a href="/ebay-block/toys.php" rel="flowerdivcontainer">Toys</a><br />
      <li class="flowertabs"><a href="/ebay-block/tvs.php" rel="flowerdivcontainer">TVs</a><br />
      <li class="flowertabs"><a href="/ebay-block/video-games.php" rel="flowerdivcontainer">Video Games</a><br />
      <li class="flowertabs"><a href="/ebay-block/watches.php" rel="flowerdivcontainer">Watches</a><br />
      <li class="flowertabs ajaxtabsmore"><a href="/ebay-block/more.php" rel="flowerdivcontainer">More!</a><br />
      <li class="flowertabs ajaxtabsinfo"><a href="/ebay-block/info.php" rel="flowerdivcontainer">(Info)</a></p>
    <p>  </div><br />
      <br style="clear: left" /><br />
    </div><br />
    
    <script type="text/javascript">
    
    var myflowers=new ddajaxtabs("flowertabs", "flowerdivcontainer")
    myflowers.setpersist(true)
    myflowers.setselectedClassTarget("link") //"link" or "linkparent"
    myflowers.init()
    
    </script>

    It would make my life a lot easier if I could store the code in a file and reference the file from Simple Ads. That way I can simply update the file without having to copy/paste the updated code into Simple Ads every time. Another benefit of referencing a file is that I can use an array for the variables, such as ("camera.php", "Cameras"), and run a foreach loop to generate the list items.

    I guess mostly I would like a way to reference the file from Simple Ads, rather than pasting the code directly into it. I'm just assuming a php include( '/my/file.php' ); function would be the best way to do it, but I'm also open to suggestions.

  • Tedster

    Thanks Philip,
    Including the page directly into the code works fine... as long as I remember for any updates! :smiley:

    An interesting thing, when I put the include in the "Before" content it appeared after the content, and vice-versa. I did the following to get my code to appear after the content...

    function simple_ads_get_ad_code($ad_type) {
    	if ( $ad_type == 'before' ) {
    		$ad_code = include( '/home/####/public_html/ebay-block/block-001.php' );
    	}
    	if ( $ad_type == 'after' ) {
    		$ad_code = stripslashes( get_site_option('advertising_after_code') );
    	}
    	if ( $ad_code == 'empty' ) {
    		$ad_code = '';
    	}
    	return $ad_code;
    }

    Not that it matters, as long as it works.

    Anyway, as you can see I had to link directly to my /home/ directory. I tried get_site_uri() and all the other ways I could think of, but they all included the sub-directory of my multisite sites. What would be the proper way to link to my home directory?

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.