Example #1
0
/**
 * Inserts ads into posts
 * 
 * @since  2015-07-28
 * @author Patrick Forget <*****@*****.**>
 */
function oboxads_insert_ads_in_posts($content)
{
    if (is_single()) {
        $bannerCode = oboxadsGetAd('content');
        $bannerCode = str_replace(array("\r", "\n"), "", $bannerCode);
        if (preg_match("/\\[oboxads[^\\]]*\\]/", $content)) {
            $content = preg_replace('/([oboxads[^\\]]*\\])/', $bannerCode . '$1', $content, 1);
        } else {
            $content = preg_replace('/(<p[^>]*>.*<\\/p>)/', $bannerCode . '$1', $content, 1);
        }
        //if
    }
    //if
    return $content;
}
 /**
  * Return the widget/shortcode output
  *
  * @since  1.0.0
  * @param  array  $atts Array of widget/shortcode attributes/args
  * @return string       Widget output
  */
 public static function get_widget($atts)
 {
     $widget = '';
     // Set up default values for attributes
     $atts = shortcode_atts(array('before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '', 'title' => '', 'section' => 'side'), (array) $atts, self::$shortcode);
     // Before widget hook
     $widget .= $atts['before_widget'];
     // Title
     $widget .= $atts['title'] ? $atts['before_title'] . esc_html($atts['title']) . $atts['after_title'] : '';
     $widget .= oboxadsGetAd($atts['section']);
     // After widget hook
     $widget .= $atts['after_widget'];
     return $widget;
 }
/**
 * Oboxmedia Wordpress Plugin Oboxads ShowAd Function
 * @version 1.0.0
 * @package Oboxmedia Wordpress Plugin
 */
function oboxadsShowAd($section)
{
    echo oboxadsGetAd($section);
}