get_row($wpdb->prepare("SELECT `id`, `title`, `bannercode`, `tracker`, `image` FROM `{$wpdb->prefix}adrotate` WHERE `id` = %d AND (`type` = 'active' OR `type` = '2days' OR `type` = '7days');", $banner_id)); if($banner) { if($adrotate_debug['general'] == true) { echo "
[DEBUG][adrotate_ad()] Selected Ad ID
"; print_r($banner->id); echo ""; } $selected = array($banner->id => 0); $selected = adrotate_filter_schedule($selected, $banner); } else { $selected = false; } if($selected) { $image = str_replace('%folder%', $adrotate_config['banner_folder'], $banner->image); if($individual == true) $output .= ''; if($adrotate_config['stats'] == 1) { adrotate_count_impression($banner->id, 0, 0); } } else { $output .= adrotate_error('ad_expired', array($banner_id)); } unset($banner); } else { $output .= adrotate_error('ad_no_id'); } return $output; } /*------------------------------------------------------------- Name: adrotate_group Purpose: Fetch ads in specified group(s) and show a random ad Since: 3.0 -------------------------------------------------------------*/ function adrotate_group($group_ids, $fallback = 0, $weight = 0, $site = 0) { global $wpdb, $adrotate_config, $adrotate_debug; $output = $group_select = ''; if($group_ids) { $now = adrotate_now(); $group_array = (!is_array($group_ids)) ? explode(",", $group_ids) : $group_ids; foreach($group_array as $key => $value) { $group_select .= " `{$wpdb->prefix}adrotate_linkmeta`.`group` = {$value} OR"; } $group_select = rtrim($group_select, " OR"); $group = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}adrotate_groups` WHERE `name` != '' AND `id` = %d;", $group_array[0])); if($adrotate_debug['general'] == true) { echo "
[DEBUG][adrotate_group] Selected group
"; print_r($group); echo ""; } if($group) { // Get all ads in all selected groups $ads = $wpdb->get_results( "SELECT `{$wpdb->prefix}adrotate`.`id`, `{$wpdb->prefix}adrotate`.`title`, `{$wpdb->prefix}adrotate`.`bannercode`, `{$wpdb->prefix}adrotate`.`image`, `{$wpdb->prefix}adrotate`.`tracker`, `{$wpdb->prefix}adrotate_linkmeta`.`group` FROM `{$wpdb->prefix}adrotate`, `{$wpdb->prefix}adrotate_linkmeta` WHERE ({$group_select}) AND `{$wpdb->prefix}adrotate_linkmeta`.`user` = 0 AND `{$wpdb->prefix}adrotate`.`id` = `{$wpdb->prefix}adrotate_linkmeta`.`ad` AND (`{$wpdb->prefix}adrotate`.`type` = 'active' OR `{$wpdb->prefix}adrotate`.`type` = '2days' OR `{$wpdb->prefix}adrotate`.`type` = '7days') GROUP BY `{$wpdb->prefix}adrotate`.`id` ORDER BY `{$wpdb->prefix}adrotate`.`id`;"); if($ads) { if($adrotate_debug['general'] == true) { echo "
[DEBUG][adrotate_group()] All ads in group
"; print_r($ads); echo ""; } foreach($ads as $ad) { $selected[$ad->id] = $ad; $selected = adrotate_filter_schedule($selected, $ad); } unset($ads); if($adrotate_debug['general'] == true) { echo "
[DEBUG][adrotate_group] Reduced array based on schedule restrictions
"; print_r($selected); echo ""; } $array_count = count($selected); if($array_count > 0) { $before = $after = ''; $before = str_replace('%id%', $group_array[0], stripslashes(html_entity_decode($group->wrapper_before, ENT_QUOTES))); $after = str_replace('%id%', $group_array[0], stripslashes(html_entity_decode($group->wrapper_after, ENT_QUOTES))); $output .= '
[DEBUG][adrotate_inject_posts()] group_array
"; echo "Group count: ".$group_count.""; print_r($group_array); echo ""; } if($group_count > 0) { $before = $after = $inside = 0; foreach($group_array as $group_id => $group) { if(is_page($group['ids']) OR is_category($group['ids']) OR in_category($group['ids'])) { // Advert in front of content if(($group['location'] == 1 OR $group['location'] == 3) AND $before == 0) { $post_content = adrotate_group($group_id).$post_content; unset($group_array[$group_id]); $before = 1; } // Advert behind the content if(($group['location'] == 2 OR $group['location'] == 3) AND $after == 0) { $post_content = $post_content.adrotate_group($group_id); unset($group_array[$group_id]); $after = 1; } // Adverts inside the content if($group['location'] == 4) { $paragraphs = explode('', $post_content); $paragraph_count = count($paragraphs); $count_p = ($group['paragraph'] == 99) ? ceil($paragraph_count / 2) : $group['paragraph']; foreach($paragraphs as $index => $paragraph) { if(trim($paragraph)) { $paragraphs[$index] .= ''; } if($count_p == $index + 1 AND $inside == 0) { $paragraphs[$index] .= adrotate_group($group_id); unset($group_array[$group_id]); $inside = 1; } } $inside = 0; // Reset for the next paragraph $post_content = implode('', $paragraphs); unset($paragraphs, $paragraph_count); } } } unset($group_array, $before, $after, $inside); } return $post_content; } /*------------------------------------------------------------- Name: adrotate_preview Purpose: Show preview of selected ad (Dashboard) Since: 3.0 -------------------------------------------------------------*/ function adrotate_preview($banner_id) { global $wpdb, $adrotate_debug; if($banner_id) { $now = adrotate_now(); $banner = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}adrotate` WHERE `id` = %d;", $banner_id)); if($adrotate_debug['general'] == true) { echo "
[DEBUG][adrotate_preview()] Ad information
"; print_r($banner); echo ""; } if($banner) { $image = str_replace('%folder%', '/banners/', $banner->image); $output = adrotate_ad_output($banner->id, 0, $banner->title, $banner->bannercode, $banner->tracker, $image); } else { $output = adrotate_error('ad_expired'); } } else { $output = adrotate_error('ad_no_id'); } return $output; } /*------------------------------------------------------------- Name: adrotate_ad_output Purpose: Prepare the output for viewing Since: 3.0 -------------------------------------------------------------*/ function adrotate_ad_output($id, $group = 0, $name, $bannercode, $tracker, $image) { global $blog_id, $adrotate_debug, $adrotate_config; $banner_output = $bannercode; $banner_output = stripslashes(htmlspecialchars_decode($banner_output, ENT_QUOTES)); if($adrotate_config['stats'] > 0 AND $tracker == "Y") { if(empty($blog_id) or $blog_id == '') { $blog_id = 0; } if($adrotate_config['stats'] == 1) { // Internal tracker preg_match_all('/](?:.*?)>/i', $banner_output, $matches, PREG_SET_ORDER); if(isset($matches[0])) { $banner_output = str_ireplace(']+class=\"(.+?)\"[^>]*>/i', $value, $regs)) { $result = $regs[1]." gofollow"; $banner_output = str_ireplace('class="'.$regs[1].'"', 'class="'.$result.'"', $banner_output); } else { $banner_output = str_ireplace(' 0) wp_enqueue_script('jshowoff-adrotate', plugins_url('/library/jquery.adrotate.dyngroup.js', __FILE__), false, null, $in_footer); // Make clicktracking and impression tracking a possibility if($adrotate_config['stats'] == 1) { wp_enqueue_script('clicktrack-adrotate', plugins_url('/library/jquery.adrotate.clicktracker.js', __FILE__), false, null, $in_footer); wp_localize_script('jshowoff-adrotate', 'impression_object', array('ajax_url' => admin_url( 'admin-ajax.php'))); wp_localize_script('clicktrack-adrotate', 'click_object', array('ajax_url' => admin_url('admin-ajax.php'))); } if(!$in_footer) { add_action('wp_head', 'adrotate_custom_javascript'); } else { add_action('wp_footer', 'adrotate_custom_javascript', 100); } } /*------------------------------------------------------------- Name: adrotate_custom_javascript Purpose: Add required JavaScript to site Since: 3.10.5 -------------------------------------------------------------*/ function adrotate_custom_javascript() { global $wpdb, $adrotate_config; $groups = $wpdb->get_results("SELECT `id`, `adspeed` FROM `{$wpdb->prefix}adrotate_groups` WHERE `name` != '' AND `modus` = 1 ORDER BY `id` ASC;"); if($groups) { $output = "\n"; $output .= "\n"; $output .= "\n\n"; unset($groups); echo $output; } } /*------------------------------------------------------------- Name: adrotate_custom_css Purpose: Add required CSS to site head Since: 3.8 -------------------------------------------------------------*/ function adrotate_custom_css() { global $wpdb, $adrotate_config; $output = "\n\n"; $groups = $wpdb->get_results("SELECT `id`, `modus`, `gridrows`, `gridcolumns`, `adwidth`, `adheight`, `admargin`, `align` FROM `{$wpdb->prefix}adrotate_groups` WHERE `name` != '' ORDER BY `id` ASC;"); if($groups) { $output_css = "\t.g { margin:0px; padding:0px; overflow:hidden; line-height:1; zoom:1; }\n"; $output_css .= "\t.g img { height:auto; }\n"; $output_css .= "\t.g-col { position:relative; float:left; }\n"; $output_css .= "\t.g-col:first-child { margin-left: 0; }\n"; $output_css .= "\t.g-col:last-child { margin-right: 0; }\n"; foreach($groups as $group) { if($group->align == 0) { // None $group_align = ''; } else if($group->align == 1) { // Left $group_align = ' float:left; clear:left;'; } else if($group->align == 2) { // Right $group_align = ' float:right; clear:right;'; } else if($group->align == 3) { // Center $group_align = ' margin: 0 auto;'; } if($group->modus == 0 AND ($group->admargin > 0 OR $group->align > 0)) { // Single ad group if($group->align < 3) { $output_css .= "\t.g-".$group->id." { margin:".$group->admargin."px;".$group_align." }\n"; } else { $output_css .= "\t.g-".$group->id." { ".$group_align." }\n"; } } if($group->modus == 1) { // Dynamic group if($group->adwidth != 'auto') { $width = "width:100%; max-width:".$group->adwidth."px;"; } else { $width = "width:auto;"; } if($group->adheight != 'auto') { $height = "height:100%; max-height:".$group->adheight."px;"; } else { $height = "height:auto;"; } if($group->align < 3) { $output_css .= "\t.g-".$group->id." { margin:".$group->admargin."px;".$width." ".$height.$group_align." }\n"; } else { $output_css .= "\t.g-".$group->id." { ".$width." ".$height.$group_align." }\n"; } unset($width_sum, $width, $height_sum, $height); } if($group->modus == 2) { // Block group if($group->adwidth != 'auto') { $width_sum = $group->gridcolumns * ($group->admargin + $group->adwidth + $group->admargin); $grid_width = "min-width:".$group->admargin."px; max-width:".$width_sum."px;"; } else { $grid_width = "width:auto;"; } $output_css .= "\t.g-".$group->id." { ".$grid_width.$group_align." }\n"; $output_css .= "\t.b-".$group->id." { margin:".$group->admargin."px; }\n"; unset($width_sum, $grid_width, $height_sum, $grid_height); } } $output_css .= "\t@media only screen and (max-width: 480px) {\n"; $output_css .= "\t\t.g-col, .g-dyn, .g-single { width:100%; margin-left:0; margin-right:0; }\n"; $output_css .= "\t}\n"; unset($groups); } if(isset($output_css) OR $adrotate_config['widgetpadding'] == "Y") { $output .= "\n"; $output .= "\n"; $output .= "\n\n"; } echo $output; } /*------------------------------------------------------------- Name: adrotate_nonce_error Purpose: Display a formatted error if Nonce fails Since: 3.7.4.2 -------------------------------------------------------------*/ function adrotate_nonce_error() { echo '
'.__('WordPress was unable to verify the authenticity of the url you have clicked. Verify if the url used is valid or log in via your browser.', 'adrotate').'
'; echo ''.__('If you have received the url you want to visit via email, you are being tricked!', 'adrotate').'
'; echo ''.__('Contact support if the issue persists:', 'adrotate').' AJdG Solutions Support.
'; } /*------------------------------------------------------------- Name: adrotate_error Purpose: Show errors for problems in using AdRotate, should they occur Since: 3.0 -------------------------------------------------------------*/ function adrotate_error($action, $arg = null) { global $adrotate_debug; switch($action) { // Ads case "ad_expired" : if($adrotate_debug['general'] == true) { $result = ''.__('Error, Ad is not available at this time due to schedule/geolocation restrictions or does not exist!', 'adrotate').''; } else { $result = ''; } return $result; break; case "ad_unqualified" : if($adrotate_debug['general'] == true) { $result = ''.__('Either there are no banners, they are disabled or none qualified for this location!', 'adrotate').''; } else { $result = ''; } return $result; break; case "ad_no_id" : $result = ''.__('Error, no Ad ID set! Check your syntax!', 'adrotate').''; return $result; break; // Groups case "group_no_id" : $result = ''.__('Error, no group ID set! Check your syntax!', 'adrotate').''; return $result; break; case "group_not_found" : $result = ''.__('Error, group does not exist! Check your syntax!', 'adrotate').' (ID: '.$arg[0].')'; return $result; break; // Database case "db_error" : $result = ''.__('There was an error locating the database tables for AdRotate. Please deactivate and re-activate AdRotate from the plugin page!!', 'adrotate').'.')
.')
.')
.')
.')
'.__('Thank you for choosing AdRotate. Everything related to AdRotate is in this menu. If you need help getting started take a look at the', 'adrotate').' '.__('manuals', 'adrotate').' '.__('and', 'adrotate').' '.__('forums', 'adrotate').'. These links are also available in the help tab in the top right.
'; $pointer_content .= 'AdRotate Professional - Learn more »
If you like AdRotate, consider upgrading to AdRotate Pro and benefit from many extra features to make your campaigns more profitable!
Ad blockers
Disable your ad blocker in your browser so your adverts and dashboard show up correctly. AdRotate Pro has a disguise feature for adverts to help you avoid ad blockers.
AdRotate is growing to be one of the most popular WordPress plugins for Advertising and is a household name for many companies around the world. AdRotate wouldn\'t be possible without your support and my life wouldn\'t be what it is today without your help.
- Arnan
'. 'Facebook: Facebook. Business: ajdg.solutions Personal: arnan.me.
' ) ); } /*------------------------------------------------------------- Name: adrotate_action_links Purpose: Plugin page link Since: 4.11 -------------------------------------------------------------*/ function adrotate_action_links($links) { $custom_actions = array(); $custom_actions['adrotate-pro'] = sprintf('%s', 'https://ajdg.solutions/cart/?add-to-cart=1124&utm_campaign=adrotate&utm_medium=action_links&utm_source=adrotate', 'Get Pro'); $custom_actions['adrotate-help'] = sprintf('%s', 'https://ajdg.solutions/forums/?utm_campaign=adrotate&utm_medium=action_links&utm_source=adrotate', 'Support'); $custom_actions['adrotate-arnan'] = sprintf('%s', 'http://www.arnan.me/?utm_campaign=adrotate&utm_medium=action_links&utm_source=adrotate', 'arnan.me'); return array_merge($custom_actions, $links); } /*------------------------------------------------------------- Name: adrotate_credits Purpose: Promotional stuff shown throughout the plugin Since: 3.7 -------------------------------------------------------------*/ function adrotate_credits() { echo '| '.__('Help AdRotate Grow', 'adrotate').' | '; echo ''.__('AdRotate Professional', 'adrotate').' | '; echo '|
|---|---|---|
![]() | ';
echo ''.__("Many users only think to review AdRotate when something goes wrong while thousands of people happily use AdRotate.", 'adrotate').' '. __("If you find AdRotate useful please leave your", 'adrotate').' '.__('rating','adrotate').' '.__('and','adrotate').' '.__('review','adrotate').' '.__('on WordPress.org to help AdRotate grow in a positive way', 'adrotate').'! | '; echo ' '.__('Get more advanced features like Geo Targeting, scheduling and much more with AdRotate Pro.', 'adrotate').''.__('Includes premium support and free updates!', 'adrotate').' So why wait? '.__('Get started today', 'adrotate').' » | ';
echo '