diff --git a/adgear-ad-manager.php b/adgear-ad-manager.php
index fa11d5c..40aabb5 100644
--- a/adgear-ad-manager.php
+++ b/adgear-ad-manager.php
@@ -72,6 +72,9 @@ function adgear_ad() {
if ( adgear_is_dynamic_site() ) {
$format = func_get_arg(0);
$path = func_get_arg(1);
+ echo "
";
+ var_dump($path);
+ echo "
";
// Switch on $format
$embed_code = get_option( 'adgear_site_universal_embed_code' );
@@ -139,11 +142,14 @@ function adgear_ad_spots() {
function adgear_ad_handler($atts) {
extract(shortcode_atts(array(
- "id" => "",
- "format" => "",
- "path" => "",
- "slugify" => "",
- "single" => "",
+ "id" => "",
+ "format" => "",
+ "path" => "",
+ "slugify" => "",
+ "single" => "",
+ "path_pre" => "",
+ "path_middle" => "",
+ "path_post" => "",
), $atts));
// If this tag should render only on single posts page, and we're not on a single post, abort
@@ -152,55 +158,66 @@ function adgear_ad_handler($atts) {
// If this tag should render only on listing pages, and we're on a single post, abort
if ($single == 'no' && is_single()) return "";
-// echo "";
-// var_dump(array(
-// "id" => $id,
-// "format" => $format,
-// "path" => $path,
-// "slugify" => $slugify,
-// "single" => $single,
-// "site_is_dynamic" => adgear_is_dynamic_site(),
-// ));
-// echo "
";
+ echo "";
+ var_dump(array(
+ "id" => $id,
+ "format" => $format,
+ "path" => $path,
+ "path_pre" => $path_pre,
+ "path_middle" => $path_middle,
+ "path_post" => $path_post,
+ "slugify" => $slugify,
+ "single" => $single,
+ "site_is_dynamic" => adgear_is_dynamic_site(),
+ ));
+ echo "
";
if ( !adgear_is_dynamic_site() && $id ) {
return adgear_ad( $id );
} else if ( adgear_is_dynamic_site() && $format && $path ) {
- $pathname = array();
+ $pathname = explode( ',', $path_pre);
switch( $path ) {
case "by_categories":
global $post;
$postcats = get_the_category($post->ID);
+ $cats = array();
if ( $postcats ) {
foreach( $postcats as $cat ) {
- $pathname[] = $cat->cat_name;
+ $cats[] = $cat->cat_name;
}
}
- sort( $pathname );
+ sort( $cats );
+ $pathname = array_merge( $pathname, $cats );
break;
case "by_tags":
global $post;
$posttags = get_the_tags($post->ID);
+ $tags = array();
if ( $posttags ) {
foreach( $posttags as $tag ) {
- $pathname[] = $tag->name;
+ $tags[] = $tag->name;
}
}
- sort( $pathname );
+ sort( $tags );
+ $pathname = array_merge( $pathname, $tags );
break;
default:
- $pathname = explode( ',', $path );
+ $pathname = array_merge( $pathname, explode( ',', $path ) );
break;
}
+ $pathname = array_merge( $pathname, explode( ',', $path_middle ) );
+
if ( $slugify == "1" || $slugify == "yes" ) {
$post = get_post( get_the_ID() );
$pathname[] = $post->post_name;
}
+ $pathname = array_merge( $pathname, explode( ',', $path_post ) );
+
return adgear_ad( $format, $pathname);
} else if ( adgear_is_dynamic_site() && $format ) {
return adgear_ad( $format, array() );
@@ -259,6 +276,27 @@ function adgear_path_type_selector_ui($args) {
+
+
+
+
+
+
@@ -351,7 +389,7 @@ function update($new_instance, $old_instance) {
$instance = $old_instance;
if ( adgear_is_dynamic_site() ) {
- $keys = array( 'format_id', 'path_type', 'path', 'slugify', 'single' );
+ $keys = array( 'format_id', 'path_type', 'path_pre', 'path', 'path_middle', 'slugify', 'path_post', 'single' );
} else {
$keys = array( 'adspot_id', 'single' );
}
@@ -375,36 +413,57 @@ function form($instance) {
echo '';
if ( adgear_is_dynamic_site() ) {
- $format_id = strip_tags($instance['format_id']);
- $path_type = strip_tags($instance['path_type']);
- $path = strip_tags($instance['path']);
- $slugify = strip_tags($instance['slugify']);
+ $format_id = strip_tags($instance['format_id']);
+ $path_type = strip_tags($instance['path_type']);
+ $path = strip_tags($instance['path']);
+ $slugify = strip_tags($instance['slugify']);
+
+ /* Backwards compatibility: don't show ugly error messages when the keys don't exist */
+ if ( array_key_exists( 'path_pre', $instance ) ) {
+ $path_pre = strip_tags($instance['path_pre']);
+ $path_middle = strip_tags($instance['path_middle']);
+ $path_post = strip_tags($instance['path_post']);
+ } else {
+ $path_pre = $path_middle = $path_post = "";
+ }
?>
- Format:
+
$this->get_field_id('format_id'), 'name' => $this->get_field_name('format_id'), 'selected' => $format_id, 'include_blank' => true )); ?>
- Path type:
+
+ $this->get_field_id('path_pre'), 'name' => $this->get_field_name('path_pre'), 'value' => $path_pre ) ); ?>
+
+
+
$this->get_field_id('path_type'), 'name' => $this->get_field_name('path_type'), 'selected' => $path_type, 'path_id' => $this->get_field_id('path'), 'path_name' => $this->get_field_name('path'), 'path_selected' => $path )); ?>
- Use post's slug in path:
+
+ $this->get_field_id('path_middle'), 'name' => $this->get_field_name('path_middle'), 'value' => $path_middle ) ); ?>
+
+
+
$this->get_field_id('slugify'), 'name' => $this->get_field_name('slugify'), 'selected' => $slugify )); ?>
+
+
+ $this->get_field_id('path_post'), 'name' => $this->get_field_name('path_post'), 'value' => $path_post ) ); ?>
+
- Ad Spot:
+
$this->get_field_id('adspot_id'), 'name' => $this->get_field_name('adspot_id'), 'selected' => $adspot_id )); ?>
- When to show this ad:
+
$this->get_field_id('single'), 'name' => $this->get_field_name('single'), 'selected' => $single)) ?>
diff --git a/adgear-ad-manager/adgear-meta.js b/adgear-ad-manager/adgear-meta.js
index de6cfa9..436613f 100644
--- a/adgear-ad-manager/adgear-meta.js
+++ b/adgear-ad-manager/adgear-meta.js
@@ -30,6 +30,9 @@ function adgearDynamicSiteChange($, root) {
var slugify = root.find(".adgear_slugify_selector").val();
var path = root.find(".adgear_path").val();
var format_id = root.find(".adgear_format_selector").val();
+ var pathPre = root.find(".adgear_path_pre").val();
+ var pathMiddle = root.find(".adgear_path_middle").val();
+ var pathPost = root.find(".adgear_path_post").val();
var pathType = root.find(".adgear_path_type_selector").val();
var single = root.find(".adgear_single_selector").val();
var format = root.find(".adgear_format_selector").get()[0];
@@ -63,7 +66,21 @@ function adgearDynamicSiteChange($, root) {
if (sendCode) sendCode.css({opacity: 0.5}).get()[0].disabled = true;
} else {
- value = "[adgear_ad format=" + format_id + " name=\"" + formatName + "\" single=" + single + " slugify=" + slugify + " path=" + pathParam + "]";
+ var tagCode = {format : format_id,
+ name : formatName,
+ single : single,
+ slugify : slugify,
+ path : pathParam,
+ pre : pathPre,
+ middle : pathMiddle,
+ post : pathPost};
+
+ value = "[adgear_ad";
+ for(var key in tagCode) {
+ value += " " + key + '="' + tagCode[key] + '"';
+ }
+ value += "]";
+
css = {"color": "black", "font-style": "normal"};
if (sendCode) sendCode.css({opacity: 1.0}).get()[0].disabled = false;
@@ -81,7 +98,7 @@ function adgearDynamicSiteChange($, root) {
adgearStaticSiteChange($, $(ev.target).parents('.adgear-meta'));
});
- $(".adgear-meta .adgear_path_type_selector, .adgear-meta .adgear_slugify_selector, .adgear-meta .adgear_format_selector, .adgear-meta .adgear_path, .adgear-meta .adgear_single_selector").live("change", function(ev) {
+ $(".adgear-meta .adgear_path_type_selector, .adgear-meta .adgear_slugify_selector, .adgear-meta .adgear_format_selector, .adgear-meta .adgear_path, .adgear-meta .adgear_single_selector, .adgear-meta .adgear_path_pre, .adgear-meta .adgear_path_middle, .adgear-meta .adgear_path_post").live("change", function(ev) {
if (!dynamic) return;
adgearDynamicSiteChange($, $(ev.target).parents('.adgear-meta'));
});
diff --git a/adgear-ad-manager/admin.php b/adgear-ad-manager/admin.php
index f5ae697..0c40a93 100644
--- a/adgear-ad-manager/admin.php
+++ b/adgear-ad-manager/admin.php
@@ -196,18 +196,36 @@ function adgear_meta_box_form() {
'adgear_format_id', 'name' => 'adgear[format_id]', 'selected' => '', 'include_blank' => true )); ?>
+
+
+
+ 'adgear_path_pre', 'name' => 'adgear[path_pre]', 'value' => '' ) ); ?>
+
+
'adgear_type', 'name' => 'adgear[type]', 'selected' => 'categories', 'path_id' => 'adgear_path', 'path_name' => 'adgear[path]', 'path_selected' => '' ) ); ?>
+
+
+
+ 'adgear_path_middle', 'name' => 'adgear[path_middle]', 'value' => '' ) ); ?>
+
+
'adgear_slugify', 'name' => 'adgear[slugify]', 'selected' => 'yes') ); ?>
+
+
+
+ 'adgear_path_post', 'name' => 'adgear[path_post]', 'value' => '' ) ); ?>
+
+
@@ -225,7 +243,7 @@ function adgear_meta_box_form() {
-
+