本文整理汇总了PHP中adrotate_group函数的典型用法代码示例。如果您正苦于以下问题:PHP adrotate_group函数的具体用法?PHP adrotate_group怎么用?PHP adrotate_group使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了adrotate_group函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bhr_site_banner
function bhr_site_banner()
{
if (function_exists('adrotate_group')) {
echo adrotate_group(1);
// Meetups
}
}
示例2: widget
function widget($args, $instance)
{
global $adrotate_config, $post, $blog_id;
extract($args);
if (empty($instance['groupid'])) {
$instance['groupid'] = 0;
}
if (empty($instance['siteid'])) {
$instance['siteid'] = $blog_id;
}
if (empty($instance['title'])) {
$instance['title'] = '';
}
if (empty($instance['categories'])) {
$instance['categories'] = '';
}
if (empty($instance['pages'])) {
$instance['pages'] = '';
}
// Determine post injection
if ($instance['categories'] != '' or $instance['pages'] != '') {
$show = false;
$categories = explode(",", $instance['categories']);
$pages = explode(",", $instance['pages']);
if (is_page($pages) or is_category($categories) or in_category($categories)) {
$show = true;
}
} else {
$show = true;
}
if ($show) {
echo $before_widget;
$title = apply_filters('widget_title', $instance['title']);
if ($title) {
echo $before_title . $title . $after_title;
}
if ($adrotate_config['widgetalign'] == 'Y') {
echo '<ul><li>';
}
if ($adrotate_config['w3caching'] == 'Y') {
echo '<!-- mfunc ' . W3TC_DYNAMIC_SECURITY . ' -->';
echo 'echo adrotate_group(' . $instance['groupid'] . ', 0, 0, ' . $instance['siteid'] . ');';
echo '<!-- /mfunc ' . W3TC_DYNAMIC_SECURITY . ' -->';
} else {
echo adrotate_group($instance['groupid'], 0, 0, $instance['siteid']);
}
if ($adrotate_config['widgetalign'] == 'Y') {
echo '</li></ul>';
}
echo $after_widget;
}
}
示例3: adrotate_shortcode
function adrotate_shortcode($atts, $content = null)
{
global $adrotate_config;
$banner_id = $group_ids = 0;
if (!empty($atts['banner'])) {
$banner_id = trim($atts['banner'], "\r\t ");
}
if (!empty($atts['group'])) {
$group_ids = trim($atts['group'], "\r\t ");
}
if (!empty($atts['fallback'])) {
$fallback = 0;
}
// Not supported in free version
if (!empty($atts['weight'])) {
$weight = 0;
}
// Not supported in free version
if (!empty($atts['site'])) {
$site = 0;
}
// Not supported in free version
$output = '';
if ($adrotate_config['w3caching'] == "Y") {
$output .= '<!-- mfunc ' . W3TC_DYNAMIC_SECURITY . ' -->';
}
if ($banner_id > 0 and $group_ids == 0) {
// Show one Ad
if ($adrotate_config['supercache'] == "Y") {
$output .= '<!--mfunc echo adrotate_ad(' . $banner_id . ', true, 0, 0) -->';
}
$output .= adrotate_ad($banner_id, true, 0, 0);
if ($adrotate_config['supercache'] == "Y") {
$output .= '<!--/mfunc-->';
}
}
if ($banner_id == 0 and $group_ids > 0) {
// Show group
if ($adrotate_config['supercache'] == "Y") {
$output .= '<!--mfunc echo adrotate_group(' . $group_ids . ', 0, 0, 0) -->';
}
$output .= adrotate_group($group_ids, 0, 0, 0);
if ($adrotate_config['supercache'] == "Y") {
$output .= '<!--/mfunc-->';
}
}
if ($adrotate_config['w3caching'] == "Y") {
$output .= '<!-- /mfunc -->';
}
return $output;
}
示例4: widget
function widget($args, $instance)
{
global $adrotate_config, $blog_id;
extract($args);
if (empty($instance['adid'])) {
$instance['adid'] = 0;
}
if (empty($instance['siteid'])) {
$instance['siteid'] = $blog_id;
}
if (empty($instance['title'])) {
$instance['title'] = '';
}
$title = apply_filters('widget_title', $instance['title']);
echo $before_widget;
if ($title) {
echo $before_title . $title . $after_title;
}
if ($adrotate_config['widgetalign'] == 'Y') {
echo '<ul><li>';
}
if ($adrotate_config['w3caching'] == 'Y') {
echo '<!-- mfunc ' . W3TC_DYNAMIC_SECURITY . ' -->';
}
if ($instance['type'] == "single") {
if ($adrotate_config['supercache'] == "Y") {
echo '<!--mfunc echo adrotate_ad(' . $instance['adid'] . ', true, 0, 0, ' . $instance['siteid'] . ') -->';
}
echo adrotate_ad($instance['adid'], true, 0, 0, 0);
if ($adrotate_config['supercache'] == "Y") {
echo '<!--/mfunc-->';
}
}
if ($instance['type'] == "group") {
if ($adrotate_config['supercache'] == "Y") {
echo '<!--mfunc echo adrotate_group(' . $instance['adid'] . ', 0, 0, ' . $instance['siteid'] . ') -->';
}
echo adrotate_group($instance['adid'], 0, 0, 0);
if ($adrotate_config['supercache'] == "Y") {
echo '<!--/mfunc-->';
}
}
if ($adrotate_config['w3caching'] == 'Y') {
echo '<!-- /mfunc -->';
}
if ($adrotate_config['widgetalign'] == 'Y') {
echo '</li></ul>';
}
echo $after_widget;
}
示例5: adrotate_shortcode
function adrotate_shortcode($atts, $content = null)
{
global $adrotate_config;
$banner_id = $group_ids = $fallback = $weight = $site = 0;
if (!empty($atts['banner'])) {
$banner_id = trim($atts['banner'], "\r\t ");
}
if (!empty($atts['group'])) {
$group_ids = trim($atts['group'], "\r\t ");
}
if (!empty($atts['fallback'])) {
$fallback = trim($atts['fallback'], "\r\t ");
}
// Optional for groups (override)
if (!empty($atts['weight'])) {
$weight = trim($atts['weight'], "\r\t ");
}
// Optional for groups (override)
if (!empty($atts['site'])) {
$site = trim($atts['site'], "\r\t ");
}
// Optional for site (override)
$output = '';
if ($adrotate_config['w3caching'] == "Y") {
$output .= '<!-- mfunc ' . W3TC_DYNAMIC_SECURITY . ' -->';
if ($banner_id > 0 and ($group_ids == 0 or $group_ids > 0)) {
// Show one Ad
$output .= 'echo adrotate_ad(' . $banner_id . ', true, 0, ' . $site . ');';
}
if ($banner_id == 0 and $group_ids > 0) {
// Show group
$output .= 'echo adrotate_group(' . $group_ids . ', ' . $fallback . ', ' . $weight . ', ' . $site . ');';
}
$output .= '<!-- /mfunc ' . W3TC_DYNAMIC_SECURITY . ' -->';
} else {
if ($banner_id > 0 and ($group_ids == 0 or $group_ids > 0)) {
// Show one Ad
$output .= adrotate_ad($banner_id, true, 0, $site);
}
if ($banner_id == 0 and $group_ids > 0) {
// Show group
$output .= adrotate_group($group_ids, $fallback, $weight, $site);
}
}
return $output;
}
示例6: adrotate_inject_posts
function adrotate_inject_posts($post_content)
{
global $wpdb, $post, $adrotate_debug;
$group_array = array();
if (is_page()) {
// Inject ads into page
$ids = $wpdb->get_results("SELECT `id`, `page`, `page_loc`, `page_par` FROM `{$wpdb->prefix}adrotate_groups` WHERE `page_loc` > 0 AND `page_loc` < 5;");
foreach ($ids as $id) {
$pages = explode(",", $id->page);
if (!is_array($pages)) {
$pages = array();
}
if (in_array($post->ID, $pages)) {
$group_array[$id->id] = array('location' => $id->page_loc, 'paragraph' => $id->page_par, 'ids' => $pages);
}
}
unset($ids, $pages);
}
if (is_single()) {
// Inject ads into posts in specified category
$ids = $wpdb->get_results("SELECT `id`, `cat`, `cat_loc`, `cat_par` FROM `{$wpdb->prefix}adrotate_groups` WHERE `cat_loc` > 0 AND `cat_loc` < 5;");
$wp_categories = get_terms('category', array('fields' => 'ids'));
foreach ($ids as $id) {
$categories = explode(",", $id->cat);
if (!is_array($categories)) {
$categories = array();
}
foreach ($wp_categories as &$value) {
if (in_array($value, $categories)) {
$group_array[$id->id] = array('location' => $id->cat_loc, 'paragraph' => $id->cat_par, 'ids' => $categories);
}
}
}
unset($ids, $wp_categories, $categories);
}
$group_array = adrotate_shuffle($group_array);
$group_count = count($group_array);
if ($adrotate_debug['general'] == true) {
echo "<p><strong>[DEBUG][adrotate_inject_posts()] group_array</strong><pre>";
echo "Group count: " . $group_count . "</br>";
print_r($group_array);
echo "</pre></p>";
}
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('</p>', $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] .= '</p>';
}
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;
}
示例7: adrotate_inject_posts
function adrotate_inject_posts($post_content)
{
global $wpdb, $post, $adrotate_debug;
$group_array = array();
if (is_page()) {
// Inject ads into page
$ids = $wpdb->get_results("SELECT `id`, `page`, `page_loc`, `page_par` FROM `{$wpdb->prefix}adrotate_groups` WHERE `page_loc` > 0;");
foreach ($ids as $id) {
$pages = explode(",", $id->page);
if (!is_array($pages)) {
$pages = array();
}
if (in_array($post->ID, $pages)) {
$group_array[$id->id] = array('location' => $id->page_loc, 'paragraph' => $id->page_par, 'pages' => $pages, 'categories' => array());
}
}
unset($ids, $pages);
}
if (is_single()) {
// Inject ads into posts in specified category
$ids = $wpdb->get_results("SELECT `id`, `cat`, `cat_loc`, `cat_par` FROM `{$wpdb->prefix}adrotate_groups` WHERE `cat_loc` > 0;");
$wp_categories = get_terms('category', array('fields' => 'ids'));
foreach ($ids as $id) {
$categories = explode(",", $id->cat);
if (!is_array($categories)) {
$categories = array();
}
foreach ($wp_categories as &$value) {
if (in_array($value, $categories)) {
$group_array[$id->id] = array('location' => $id->cat_loc, 'paragraph' => $id->cat_par, 'pages' => array(), 'categories' => $categories);
}
}
}
unset($ids, $wp_categories, $categories);
}
if ($adrotate_debug['general'] == true) {
echo "<p><strong>[DEBUG][adrotate_inject_posts()] group_array</strong><pre>";
print_r($group_array);
echo "</pre></p>";
}
$group_count = count($group_array);
if ($group_count > 0) {
if ($group_count > 1) {
// Try to prevent the same ad from showing when there are multiple ads to show
$paragraph_count = substr_count($post_content, '<p>');
if ($paragraph_count == 0 or $group_count < $paragraph_count) {
$paragraph_count = $group_count;
}
$group_choice = array_rand($group_array, $paragraph_count);
if (!is_array($group_choice)) {
$group_choice = array($group_choice);
}
shuffle($group_choice);
} else {
$group_choice = array_rand($group_array, 1);
$group_choice = array($group_choice, $group_choice);
}
if ($adrotate_debug['general'] == true) {
echo "<p><strong>[DEBUG][adrotate_inject_posts()] group_choice</strong><pre>";
print_r($group_choice);
echo "</pre></p>";
}
$before = $after = 0;
foreach ($group_choice as $key => $group_id) {
if (is_page($group_array[$group_id]['pages']) or in_category($group_array[$group_id]['categories'])) {
// Advert in front of content
if (($group_array[$group_id]['location'] == 1 or $group_array[$group_id]['location'] == 3) and $before == 0) {
$post_content = adrotate_group($group_id) . $post_content;
$before = 1;
}
// Advert behind content
if (($group_array[$group_id]['location'] == 2 or $group_array[$group_id]['location'] == 3) and $after == 0) {
$post_content = $post_content . adrotate_group($group_id);
$after = 1;
}
// Adverts inside the content
if ($group_array[$group_id]['location'] == 4 and $key == 0) {
$paragraphs = explode("</p>", $post_content);
$paragraph_count = count($paragraphs);
$par = 1;
$post_content = '';
// Backward compatibility
if ($group_array[$group_id]['paragraph'] == 20) {
$group_array[$group_id]['paragraph'] == 2;
}
if ($group_array[$group_id]['paragraph'] == 30) {
$group_array[$group_id]['paragraph'] == 3;
}
if ($group_array[$group_id]['paragraph'] == 40) {
$group_array[$group_id]['paragraph'] == 4;
}
// Advanced setting
$middle = $group_array[$group_id]['paragraph'] == 99 ? ceil($paragraph_count / 2) : 1;
foreach ($paragraphs as &$paragraph) {
if ($par == $group_array[$group_id]['paragraph'] or $par == $middle and $group_array[$group_id]['paragraph'] == 99) {
$paragraph .= adrotate_group($group_id);
}
$post_content .= $paragraph . "</p>";
$par++;
unset($paragraph);
//.........这里部分代码省略.........
示例8: dynamic_sidebar
dynamic_sidebar('widgets-sidebar-top');
?>
</div>
<?php
}
?>
<?php
// AdRotate groups 3, 4 and 5
if (function_exists('adrotate_group')) {
?>
<div class="sidebar__widgets adverts--sidebar" id="adverts--sidebar">
<?php
printf('%s', adrotate_group(3));
printf('%s', adrotate_group(4));
printf('%s', adrotate_group(5));
?>
</div>
<?php
}
?>
<?php
if (is_active_sidebar('widgets-sidebar-bottom')) {
?>
<div class="sidebar__widgets">
<?php
dynamic_sidebar('widgets-sidebar-bottom');
?>
</div>
<?php
示例9: adrotate_fallback
function adrotate_fallback($group, $case, $site = 0)
{
$fallback_output = '';
if ($group > 0) {
$fallback_output = adrotate_group($group, 0, 0, $site);
} else {
if ($case == 'expired') {
$fallback_output = adrotate_error('ad_expired');
}
if ($case == 'unqualified') {
$fallback_output = adrotate_error('ad_unqualified');
}
}
return $fallback_output;
}
示例10: adrotate_inject_posts
function adrotate_inject_posts($post_content)
{
global $wpdb, $adrotate_debug;
if (is_single()) {
// Inject ads into posts in specified category
$ids = $wpdb->get_results("SELECT `id`, `cat`, `cat_loc`, `cat_par` FROM `{$wpdb->prefix}adrotate_groups` WHERE `cat_loc` > 0;");
$wp_categories = get_terms('category', array('fields' => 'ids'));
$group_array = array();
foreach ($ids as $id) {
$categories = explode(",", $id->cat);
if (!is_array($categories)) {
$categories = array();
}
foreach ($wp_categories as &$value) {
if (in_array($value, $categories)) {
$group_array[$id->id] = array('location' => $id->cat_loc, 'paragraph' => $id->cat_par, 'categories' => $categories);
}
}
}
if ($adrotate_debug['general'] == true) {
echo "<p><strong>[DEBUG][adrotate_inject_posts()] group_array</strong><pre>";
print_r($group_array);
echo "</pre></p>";
}
unset($ids, $wp_categories, $categories);
$group_count = count($group_array);
if ($group_count > 0) {
if ($group_count > 1) {
// Try to prevent the same ad from showing when there are multiple ads to show
$paragraph_count = substr_count($post_content, '<p>');
if ($paragraph_count == 0 or $group_count < $paragraph_count) {
$paragraph_count = $group_count;
}
$group_choice = array_rand($group_array, $paragraph_count);
if (!is_array($group_choice)) {
$group_choice = array($group_choice);
}
shuffle($group_choice);
} else {
$group_choice = array_rand($group_array, 1);
$group_choice = array($group_choice, $group_choice);
}
if ($adrotate_debug['general'] == true) {
echo "<p><strong>[DEBUG][adrotate_inject_posts()] group_choice</strong><pre>";
print_r($group_choice);
echo "</pre></p>";
}
$before = $after = 0;
foreach ($group_choice as $key => $group_id) {
if (in_category($group_array[$group_id]['categories'])) {
// Advert in front of content
if (($group_array[$group_id]['location'] == 1 or $group_array[$group_id]['location'] == 3) and $before == 0) {
$post_content = adrotate_group($group_id) . $post_content;
$before = 1;
}
// Advert behind content
if (($group_array[$group_id]['location'] == 2 or $group_array[$group_id]['location'] == 3) and $after == 0) {
$post_content = $post_content . adrotate_group($group_id);
$after = 1;
}
// Adverts inside the content
if ($group_array[$group_id]['location'] == 4 and $key == 0) {
preg_match_all("/(?:.*?)<p[^>]*>(?:.*?)<\\/p>(?:<\\/[a-z]*?>)*/is", $post_content, $paragraphs);
// $paragraphs = explode("</p>", $post_content);
$par = 1;
$post_content = '';
foreach ($paragraphs[0] as &$paragraph) {
// foreach($paragraphs as &$paragraph) {
if ($par == $group_array[$group_id]['paragraph'] or $par == 2 and $group_array[$group_id]['paragraph'] == 20 or $par == 3 and $group_array[$group_id]['paragraph'] == 30 or $par == 4 and $group_array[$group_id]['paragraph'] == 40) {
$paragraph .= adrotate_group($group_id);
$par++;
if ($group_array[$group_id]['paragraph'] > 1 and $group_array[$group_id]['paragraph'] < 10) {
$par = 1;
}
} else {
$par++;
}
$post_content .= $paragraph;
unset($paragraph);
}
}
}
}
}
unset($group_choice, $group_count, $group_array, $paragraph, $paragraph_count, $before, $after);
}
return $post_content;
}
示例11: adrotate_group
<section id="wrapp-adv-device">
<div class="container">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<?php
echo adrotate_group(1);
?>
</div>
</div>
</div>
</section>
<?php
$parentId = get_category_by_slug('news');
$args = array('category_custom_field' => 'category_order', 'orderby' => 'category_order', 'order' => 'DESC', 'parent' => $parentId->term_id, 'taxonomy' => 'category', 'hide_empty' => 0);
$categories = get_categories($args);
$cats = array();
foreach ($categories as $cat) {
$ordr = get_field('category_order', 'category_' . $cat->term_id);
$cat->order = $ordr;
$cats[] = $cat;
}
usort($cats, function ($a, $b) {
return $a->order - $b->order;
});
$width = 320;
$height = 320;
if (wpmd_is_tablet()) {
$width = 380;
$height = 380;
}
if (wpmd_is_phone()) {
示例12: date
$year = date('Y', $date);
$month = date('m', $date);
$day = date('d', $date);
$date_str = date('l, F j, Y', $date);
//build date query
$date_query = array(array('year' => $year, 'month' => $month, 'day' => $day));
//get latest resource post with delivery_newsletter checked
$resources = get_posts(array('post_type' => 'resources', 'posts_per_page' => 1, 'orderby' => 'date', 'order' => 'desc', 'meta_query' => array(array('key' => 'delivery_newsletter', 'value' => 1))));
//get latest discussions posts
$discussions = get_posts(array('post_type' => 'discussion', 'posts_per_page' => 3, 'orderby' => 'date', 'order' => 'desc', 'date_query' => $date_query));
//get latest retail news posts
$news = get_posts(array('post_type' => 'post', 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'desc', 'date_query' => $date_query));
//get latest press releases
$press_releases = get_posts(array('post_type' => 'press_releases', 'posts_per_page' => -1, 'orderby' => 'date', 'order' => 'desc', 'date_query' => $date_query));
//get ads from adrotate - parse HTML
$ad_group_html = adrotate_group(6);
$ad_group_html_parsed = str_get_html($ad_group_html);
$ads = array();
foreach ($ad_group_html_parsed->find('a') as $element) {
$ads[] = $element;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="format-detection" content="telephone=no">
<title>RetailWire Daily Delivery Newsletter</title>
示例13: get_sidebar
get_sidebar();
}
?>
</main><?php
// End #main
?>
<?php
if (!is_404()) {
?>
<div class="trim-block noprint">
<div class="stripe stripe__absolute-top"></div>
<div class="adverts--banner" id="adverts--footer">
<?php
if (function_exists('adrotate_group') && !is_404()) {
printf(adrotate_group(2));
}
?>
</div>
</div>
<footer class="footer noprint" id="footer">
<div class="footer__menus" id="footer__menus">
<div class="footer__columns flex--four-col--nav vspace--full">
<div class="footer__site-links-1">
<?php
// Custom footer menu
?>
示例14: adrotate_group
?>
</div>
<div class="four box">
<?php
echo adrotate_group(4);
?>
</div>
</div>
<div class="boxes">
<div class="one box">
<?php
echo adrotate_group(5);
?>
</div>
<div class="three box">
<?php
echo adrotate_group(6);
?>
</div>
<div class="four box">
<?php
echo adrotate_group(7);
?>
</div>
</div>
</div>
</div>
</div>
</section>
<?php
get_footer();
示例15: adrotate_group
<?php
//indexbanner2 = 5
// check for plugin by using plugin name
if (is_plugin_active('adrotate/adrotate.php')) {
if (substr(adrotate_group(5), 0, 5) == "<span" || substr(adrotate_group(5), 0, 2) == "<!") {
//nothing to display
} else {
echo '<div class="indx-sm-c2a">';
echo adrotate_group(5);
echo '</div>';
}
}
?>
<?php
//indexbanner3 = 17
// check for plugin by using plugin name
if (is_plugin_active('adrotate/adrotate.php')) {
if (substr(adrotate_group(17), 0, 5) == "<span" || substr(adrotate_group(17), 0, 2) == "<!") {
//nothing to display
} else {
echo '<div class="indx-sm-c2a">';
echo adrotate_group(17);
echo '</div>';
}
}
?>
</div>
</section>
</div>