Changeset 1043541
- Timestamp:
- 12/12/2014 03:53:40 PM (10 years ago)
- Location:
- wp-advertize-it
- Files:
-
- 1 added
- 10 edited
- 14 copied
Legend:
- Unmodified
- Added
- Removed
-
wp-advertize-it/tags/0.9/bootstrap.php
r1043518 r1043541 4 4 Plugin URI: https://wordpress.org/plugins/wp-advertize-it/ 5 5 Description: A plugin to place adsense blocks on your site 6 Version: 0. 8.26 Version: 0.9 7 7 Author: Henri Benoit 8 8 Author URI: http://benohead.com -
wp-advertize-it/tags/0.9/classes/wp-advertize-it.php
r1042130 r1043541 18 18 protected $modules; 19 19 20 const VERSION = '0. 8.2';20 const VERSION = '0.9'; 21 21 const PREFIX = 'wpai_'; 22 22 const DEBUG_MODE = false; … … 207 207 208 208 add_filter('the_content', array($this, 'show_ad_in_content')); 209 add_action('wp_footer', array($this, 'show_ad_below_footer')); 209 add_action('wp_head', array($this, 'buffer_start')); 210 add_action('wp_footer', array($this, 'buffer_end')); 211 add_action('wp_footer', array($this, 'show_ad_below_footer')); 210 212 add_action('comment_form', array($this, 'show_ad_below_comments')); 211 213 add_action('the_post', array($this, 'show_ad_between_posts')); … … 214 216 add_action('wp_ajax_get_ad_list', array($this, 'get_ad_list')); 215 217 } 218 219 function buffering_callback($buffer) { 220 $above_everything = ""; 221 222 $content = get_the_content(); 223 $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content ); 224 $above_everything_block = $this->modules['WPAI_Settings']->settings['placements']['above-everything']; 225 226 $options = $this->modules['WPAI_Settings']->settings['options']; 227 228 if ($this->is_suppress_specific($options, $content)) { 229 return $buffer; 230 } 231 232 if ($above_everything_block != "") { 233 $above_everything = WPAI_Settings::get_ad_block($blocks, $above_everything_block); 234 } 235 236 $matches = preg_split('/(<body.*?>)/i', $buffer, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); 237 $buffer = $matches[0] . $matches[1] . $above_everything . $matches[2]; 238 return $buffer; 239 } 240 241 function buffer_start() { 242 ob_start(array($this, 'buffering_callback')); 243 } 244 245 function buffer_end() { 246 ob_end_flush(); 247 } 216 248 217 249 function editor_buttons() … … 458 490 $paragraph_count = $this->get_paragraph_count($content); 459 491 460 $blocks = $this->modules['WPAI_Settings']->settings['blocks']; 461 $homepage_below_title_block = $this->modules['WPAI_Settings']->settings['placements']['homepage-below-title']; 492 $options = $this->modules['WPAI_Settings']->settings['options']; 493 494 if ($this->is_suppress_specific($options, $content)) { 495 return $content; 496 } 497 498 $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content ); 499 500 $homepage_below_title_block = $this->modules['WPAI_Settings']->settings['placements']['homepage-below-title']; 462 501 $post_below_title_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-title']; 463 502 $post_below_content_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-content']; … … 471 510 $after_first_page_paragraph_block = $this->modules['WPAI_Settings']->settings['placements']['after-first-page-paragraph']; 472 511 473 $options = $this->modules['WPAI_Settings']->settings['options'];474 475 if ($this->is_suppress_specific($options, $content)) {476 return $content;477 }478 512 if (!is_feed() && strpos($content, '<!--NoHomePageAds-->') !== false) { 479 513 $homepage_below_title_block = ""; … … 632 666 $all_below_footer = ""; 633 667 634 $blocks = $this->modules['WPAI_Settings']->settings['blocks']; 668 $content = get_the_content(); 669 $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content ); 635 670 $all_below_footer_block = $this->modules['WPAI_Settings']->settings['placements']['all-below-footer']; 636 637 $content = get_the_content();638 671 639 672 $options = $this->modules['WPAI_Settings']->settings['options']; … … 655 688 $page_below_comments = ""; 656 689 657 $blocks = $this->modules['WPAI_Settings']->settings['blocks']; 690 $content = get_the_content(); 691 $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content ); 658 692 $post_below_comments_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-comments']; 659 693 $page_below_comments_block = $this->modules['WPAI_Settings']->settings['placements']['page-below-comments']; 660 661 $content = get_the_content();662 694 663 695 $options = $this->modules['WPAI_Settings']->settings['options']; … … 717 749 } 718 750 719 /** 751 /** 752 * @param $blocks 753 * @param $content 754 * 755 * @return mixed 756 */ 757 public function RemoveSuppressBlocks( $blocks, $content ) { 758 foreach ( $blocks as $number => $code ) { 759 if ( strpos( $content, '<!--NoAdBlock' . ( $number + 1 ) . '-->' ) !== false ) { 760 $blocks[ $number ] = ""; 761 } 762 } 763 764 return $blocks; 765 } 766 767 /** 720 768 * Checks that the object is in a correct state 721 769 * -
wp-advertize-it/tags/0.9/classes/wpai-settings.php
r1042009 r1043541 162 162 "after-first-post-paragraph" => "", 163 163 "after-first-page-paragraph" => "", 164 "between-posts" => "" 164 "between-posts" => "", 165 "above-everything" => "" 165 166 ); 166 167 … … 342 343 $this->add_settings_field_placements('wpai_all-below-footer', 'Below footer'); 343 344 $this->add_settings_field_placements('wpai_between-posts', 'Between posts'); 345 $this->add_settings_field_placements('wpai_above-everything', 'Above everything'); 344 346 345 347 /* … … 484 486 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'after-first-post-paragraph'); 485 487 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'after-first-page-paragraph'); 486 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'between-posts'); 488 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'between-posts'); 489 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'above-everything'); 487 490 488 491 /* -
wp-advertize-it/tags/0.9/readme.txt
r1043518 r1043541 5 5 Requires at least: 3.0.1 6 6 Tested up to: 4.0.1 7 Stable tag: 0. 8.27 Stable tag: 0.9 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 109 109 == Changelog == 110 110 111 = 0.9 = 112 113 * New ad placement shown above everything in the page (as the first element in the <body> tag). 114 * Specific ads can be suppressed on a post adding a comment in the post contents 115 111 116 = 0.8.2 = 112 117 -
wp-advertize-it/tags/0.9/views/wpai-settings/page-settings-fields.php
r1042009 r1043541 323 323 </select> 324 324 <?php 325 elseif ('wpai_above-everything' == $field['label_for']) : ?> 326 <select class="placement-block-select" id="wpai_settings[placements][above-everything]" 327 name="wpai_settings[placements][above-everything]"> 328 <?php 329 foreach ($settings['blocks'] as $i => $block) : 330 $label = 'Ad Block ' . ($i + 1); 331 $selected = ''; 332 if ($settings['placements']['above-everything'] == $i) 333 $selected = 'selected="selected"'; 334 echo '<option data-block-id="wpai_block-' . esc_attr($i + 1) . '" style="padding-right: 10px;" value="' . esc_attr($i) . '" ' . $selected . '>' . $label . '</option>'; 335 endforeach; 336 $i = ""; 337 $label = 'None'; 338 $selected = ''; 339 if ($settings['placements']['above-everything'] == $i) 340 $selected = 'selected="selected"'; 341 echo '<option data-block-id="wpai_block-' . esc_attr($i + 1) . '" style="padding-right: 10px;" value="' . esc_attr($i) . '" ' . $selected . '>' . $label . '</option>'; 342 ?> 343 </select> 344 <?php 325 345 elseif ('wpai_suppress-on-posts' == $field['label_for']) : ?> 326 346 <input type="checkbox" name="wpai_settings[options][suppress-on-posts]" -
wp-advertize-it/tags/0.9/views/wpai-settings/page-settings.php
r915984 r1043541 45 45 <li><!--NoWidgetAds--> : suppresses the ad widget</li> 46 46 <li><!--NoBelowFooterAds--> : suppresses the footer</li> 47 <li><!--NoAdBlockX--> : suppresses ad block X on this post or page e.g. <!--NoAdBlock1--></li> 47 48 </ul> 48 49 Just add it to your post in the text editor. These will be present on the page but not visible and will -
wp-advertize-it/trunk/bootstrap.php
r1042130 r1043541 4 4 Plugin URI: https://wordpress.org/plugins/wp-advertize-it/ 5 5 Description: A plugin to place adsense blocks on your site 6 Version: 0. 8.26 Version: 0.9 7 7 Author: Henri Benoit 8 8 Author URI: http://benohead.com -
wp-advertize-it/trunk/classes/wp-advertize-it.php
r1042130 r1043541 18 18 protected $modules; 19 19 20 const VERSION = '0. 8.2';20 const VERSION = '0.9'; 21 21 const PREFIX = 'wpai_'; 22 22 const DEBUG_MODE = false; … … 207 207 208 208 add_filter('the_content', array($this, 'show_ad_in_content')); 209 add_action('wp_footer', array($this, 'show_ad_below_footer')); 209 add_action('wp_head', array($this, 'buffer_start')); 210 add_action('wp_footer', array($this, 'buffer_end')); 211 add_action('wp_footer', array($this, 'show_ad_below_footer')); 210 212 add_action('comment_form', array($this, 'show_ad_below_comments')); 211 213 add_action('the_post', array($this, 'show_ad_between_posts')); … … 214 216 add_action('wp_ajax_get_ad_list', array($this, 'get_ad_list')); 215 217 } 218 219 function buffering_callback($buffer) { 220 $above_everything = ""; 221 222 $content = get_the_content(); 223 $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content ); 224 $above_everything_block = $this->modules['WPAI_Settings']->settings['placements']['above-everything']; 225 226 $options = $this->modules['WPAI_Settings']->settings['options']; 227 228 if ($this->is_suppress_specific($options, $content)) { 229 return $buffer; 230 } 231 232 if ($above_everything_block != "") { 233 $above_everything = WPAI_Settings::get_ad_block($blocks, $above_everything_block); 234 } 235 236 $matches = preg_split('/(<body.*?>)/i', $buffer, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); 237 $buffer = $matches[0] . $matches[1] . $above_everything . $matches[2]; 238 return $buffer; 239 } 240 241 function buffer_start() { 242 ob_start(array($this, 'buffering_callback')); 243 } 244 245 function buffer_end() { 246 ob_end_flush(); 247 } 216 248 217 249 function editor_buttons() … … 458 490 $paragraph_count = $this->get_paragraph_count($content); 459 491 460 $blocks = $this->modules['WPAI_Settings']->settings['blocks']; 461 $homepage_below_title_block = $this->modules['WPAI_Settings']->settings['placements']['homepage-below-title']; 492 $options = $this->modules['WPAI_Settings']->settings['options']; 493 494 if ($this->is_suppress_specific($options, $content)) { 495 return $content; 496 } 497 498 $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content ); 499 500 $homepage_below_title_block = $this->modules['WPAI_Settings']->settings['placements']['homepage-below-title']; 462 501 $post_below_title_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-title']; 463 502 $post_below_content_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-content']; … … 471 510 $after_first_page_paragraph_block = $this->modules['WPAI_Settings']->settings['placements']['after-first-page-paragraph']; 472 511 473 $options = $this->modules['WPAI_Settings']->settings['options'];474 475 if ($this->is_suppress_specific($options, $content)) {476 return $content;477 }478 512 if (!is_feed() && strpos($content, '<!--NoHomePageAds-->') !== false) { 479 513 $homepage_below_title_block = ""; … … 632 666 $all_below_footer = ""; 633 667 634 $blocks = $this->modules['WPAI_Settings']->settings['blocks']; 668 $content = get_the_content(); 669 $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content ); 635 670 $all_below_footer_block = $this->modules['WPAI_Settings']->settings['placements']['all-below-footer']; 636 637 $content = get_the_content();638 671 639 672 $options = $this->modules['WPAI_Settings']->settings['options']; … … 655 688 $page_below_comments = ""; 656 689 657 $blocks = $this->modules['WPAI_Settings']->settings['blocks']; 690 $content = get_the_content(); 691 $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content ); 658 692 $post_below_comments_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-comments']; 659 693 $page_below_comments_block = $this->modules['WPAI_Settings']->settings['placements']['page-below-comments']; 660 661 $content = get_the_content();662 694 663 695 $options = $this->modules['WPAI_Settings']->settings['options']; … … 717 749 } 718 750 719 /** 751 /** 752 * @param $blocks 753 * @param $content 754 * 755 * @return mixed 756 */ 757 public function RemoveSuppressBlocks( $blocks, $content ) { 758 foreach ( $blocks as $number => $code ) { 759 if ( strpos( $content, '<!--NoAdBlock' . ( $number + 1 ) . '-->' ) !== false ) { 760 $blocks[ $number ] = ""; 761 } 762 } 763 764 return $blocks; 765 } 766 767 /** 720 768 * Checks that the object is in a correct state 721 769 * -
wp-advertize-it/trunk/classes/wpai-settings.php
r1042009 r1043541 162 162 "after-first-post-paragraph" => "", 163 163 "after-first-page-paragraph" => "", 164 "between-posts" => "" 164 "between-posts" => "", 165 "above-everything" => "" 165 166 ); 166 167 … … 342 343 $this->add_settings_field_placements('wpai_all-below-footer', 'Below footer'); 343 344 $this->add_settings_field_placements('wpai_between-posts', 'Between posts'); 345 $this->add_settings_field_placements('wpai_above-everything', 'Above everything'); 344 346 345 347 /* … … 484 486 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'after-first-post-paragraph'); 485 487 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'after-first-page-paragraph'); 486 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'between-posts'); 488 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'between-posts'); 489 $this->setting_empty_string_if_not_set($new_settings, 'placements', 'above-everything'); 487 490 488 491 /* -
wp-advertize-it/trunk/readme.txt
r1042130 r1043541 5 5 Requires at least: 3.0.1 6 6 Tested up to: 4.0.1 7 Stable tag: 0. 8.27 Stable tag: 0.9 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 109 109 == Changelog == 110 110 111 = 0.9 = 112 113 * New ad placement shown above everything in the page (as the first element in the <body> tag). 114 * Specific ads can be suppressed on a post adding a comment in the post contents 115 111 116 = 0.8.2 = 112 117 -
wp-advertize-it/trunk/views/wpai-settings/page-settings-fields.php
r1042009 r1043541 323 323 </select> 324 324 <?php 325 elseif ('wpai_above-everything' == $field['label_for']) : ?> 326 <select class="placement-block-select" id="wpai_settings[placements][above-everything]" 327 name="wpai_settings[placements][above-everything]"> 328 <?php 329 foreach ($settings['blocks'] as $i => $block) : 330 $label = 'Ad Block ' . ($i + 1); 331 $selected = ''; 332 if ($settings['placements']['above-everything'] == $i) 333 $selected = 'selected="selected"'; 334 echo '<option data-block-id="wpai_block-' . esc_attr($i + 1) . '" style="padding-right: 10px;" value="' . esc_attr($i) . '" ' . $selected . '>' . $label . '</option>'; 335 endforeach; 336 $i = ""; 337 $label = 'None'; 338 $selected = ''; 339 if ($settings['placements']['above-everything'] == $i) 340 $selected = 'selected="selected"'; 341 echo '<option data-block-id="wpai_block-' . esc_attr($i + 1) . '" style="padding-right: 10px;" value="' . esc_attr($i) . '" ' . $selected . '>' . $label . '</option>'; 342 ?> 343 </select> 344 <?php 325 345 elseif ('wpai_suppress-on-posts' == $field['label_for']) : ?> 326 346 <input type="checkbox" name="wpai_settings[options][suppress-on-posts]" -
wp-advertize-it/trunk/views/wpai-settings/page-settings.php
r915984 r1043541 45 45 <li><!--NoWidgetAds--> : suppresses the ad widget</li> 46 46 <li><!--NoBelowFooterAds--> : suppresses the footer</li> 47 <li><!--NoAdBlockX--> : suppresses ad block X on this post or page e.g. <!--NoAdBlock1--></li> 47 48 </ul> 48 49 Just add it to your post in the text editor. These will be present on the page but not visible and will
Note: See TracChangeset
for help on using the changeset viewer.