Plugin Directory

Changeset 1043541


Ignore:
Timestamp:
12/12/2014 03:53:40 PM (10 years ago)
Author:
benohead
Message:

tagging version 0.9

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  
    44Plugin URI:  https://wordpress.org/plugins/wp-advertize-it/
    55Description: A plugin to place adsense blocks on your site
    6 Version:     0.8.2
     6Version:     0.9
    77Author:      Henri Benoit
    88Author URI:  http://benohead.com
  • wp-advertize-it/tags/0.9/classes/wp-advertize-it.php

    r1042130 r1043541  
    1818        protected $modules;
    1919
    20         const VERSION = '0.8.2';
     20        const VERSION = '0.9';
    2121        const PREFIX = 'wpai_';
    2222        const DEBUG_MODE = false;
     
    207207
    208208            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'));
    210212            add_action('comment_form', array($this, 'show_ad_below_comments'));
    211213            add_action('the_post', array($this, 'show_ad_between_posts'));
     
    214216            add_action('wp_ajax_get_ad_list', array($this, 'get_ad_list'));
    215217        }
     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        }
    216248
    217249        function editor_buttons()
     
    458490            $paragraph_count = $this->get_paragraph_count($content);
    459491
    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'];
    462501            $post_below_title_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-title'];
    463502            $post_below_content_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-content'];
     
    471510            $after_first_page_paragraph_block = $this->modules['WPAI_Settings']->settings['placements']['after-first-page-paragraph'];
    472511
    473             $options = $this->modules['WPAI_Settings']->settings['options'];
    474 
    475             if ($this->is_suppress_specific($options, $content)) {
    476                 return $content;
    477             }
    478512            if (!is_feed() && strpos($content, '<!--NoHomePageAds-->') !== false) {
    479513                $homepage_below_title_block = "";
     
    632666            $all_below_footer = "";
    633667
    634             $blocks = $this->modules['WPAI_Settings']->settings['blocks'];
     668            $content = get_the_content();
     669            $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content );
    635670            $all_below_footer_block = $this->modules['WPAI_Settings']->settings['placements']['all-below-footer'];
    636 
    637             $content = get_the_content();
    638671
    639672            $options = $this->modules['WPAI_Settings']->settings['options'];
     
    655688            $page_below_comments = "";
    656689
    657             $blocks = $this->modules['WPAI_Settings']->settings['blocks'];
     690            $content = get_the_content();
     691            $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content );
    658692            $post_below_comments_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-comments'];
    659693            $page_below_comments_block = $this->modules['WPAI_Settings']->settings['placements']['page-below-comments'];
    660 
    661             $content = get_the_content();
    662694
    663695            $options = $this->modules['WPAI_Settings']->settings['options'];
     
    717749        }
    718750
    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        /**
    720768         * Checks that the object is in a correct state
    721769         *
  • wp-advertize-it/tags/0.9/classes/wpai-settings.php

    r1042009 r1043541  
    162162                "after-first-post-paragraph" => "",
    163163                "after-first-page-paragraph" => "",
    164                 "between-posts" => ""
     164                "between-posts" => "",
     165                "above-everything" => ""
    165166            );
    166167
     
    342343            $this->add_settings_field_placements('wpai_all-below-footer', 'Below footer');
    343344            $this->add_settings_field_placements('wpai_between-posts', 'Between posts');
     345            $this->add_settings_field_placements('wpai_above-everything', 'Above everything');
    344346
    345347            /*
     
    484486            $this->setting_empty_string_if_not_set($new_settings, 'placements', 'after-first-post-paragraph');
    485487            $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');
    487490
    488491            /*
  • wp-advertize-it/tags/0.9/readme.txt

    r1043518 r1043541  
    55Requires at least: 3.0.1
    66Tested up to: 4.0.1
    7 Stable tag: 0.8.2
     7Stable tag: 0.9
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    109109== Changelog ==
    110110
     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
    111116= 0.8.2 =
    112117
  • wp-advertize-it/tags/0.9/views/wpai-settings/page-settings-fields.php

    r1042009 r1043541  
    323323    </select>
    324324<?php
     325elseif ('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
    325345elseif ('wpai_suppress-on-posts' == $field['label_for']) : ?>
    326346    <input type="checkbox" name="wpai_settings[options][suppress-on-posts]"
  • wp-advertize-it/tags/0.9/views/wpai-settings/page-settings.php

    r915984 r1043541  
    4545            <li>&lt;!--NoWidgetAds--&gt; : suppresses the ad widget</li>
    4646            <li>&lt;!--NoBelowFooterAds--&gt; : suppresses the footer</li>
     47            <li>&lt;!--NoAdBlockX--&gt; : suppresses ad block X on this post or page e.g. &lt;!--NoAdBlock1--&gt;</li>
    4748        </ul>
    4849        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  
    44Plugin URI:  https://wordpress.org/plugins/wp-advertize-it/
    55Description: A plugin to place adsense blocks on your site
    6 Version:     0.8.2
     6Version:     0.9
    77Author:      Henri Benoit
    88Author URI:  http://benohead.com
  • wp-advertize-it/trunk/classes/wp-advertize-it.php

    r1042130 r1043541  
    1818        protected $modules;
    1919
    20         const VERSION = '0.8.2';
     20        const VERSION = '0.9';
    2121        const PREFIX = 'wpai_';
    2222        const DEBUG_MODE = false;
     
    207207
    208208            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'));
    210212            add_action('comment_form', array($this, 'show_ad_below_comments'));
    211213            add_action('the_post', array($this, 'show_ad_between_posts'));
     
    214216            add_action('wp_ajax_get_ad_list', array($this, 'get_ad_list'));
    215217        }
     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        }
    216248
    217249        function editor_buttons()
     
    458490            $paragraph_count = $this->get_paragraph_count($content);
    459491
    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'];
    462501            $post_below_title_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-title'];
    463502            $post_below_content_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-content'];
     
    471510            $after_first_page_paragraph_block = $this->modules['WPAI_Settings']->settings['placements']['after-first-page-paragraph'];
    472511
    473             $options = $this->modules['WPAI_Settings']->settings['options'];
    474 
    475             if ($this->is_suppress_specific($options, $content)) {
    476                 return $content;
    477             }
    478512            if (!is_feed() && strpos($content, '<!--NoHomePageAds-->') !== false) {
    479513                $homepage_below_title_block = "";
     
    632666            $all_below_footer = "";
    633667
    634             $blocks = $this->modules['WPAI_Settings']->settings['blocks'];
     668            $content = get_the_content();
     669            $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content );
    635670            $all_below_footer_block = $this->modules['WPAI_Settings']->settings['placements']['all-below-footer'];
    636 
    637             $content = get_the_content();
    638671
    639672            $options = $this->modules['WPAI_Settings']->settings['options'];
     
    655688            $page_below_comments = "";
    656689
    657             $blocks = $this->modules['WPAI_Settings']->settings['blocks'];
     690            $content = get_the_content();
     691            $blocks = $this->RemoveSuppressBlocks( $this->modules['WPAI_Settings']->settings['blocks'], $content );
    658692            $post_below_comments_block = $this->modules['WPAI_Settings']->settings['placements']['post-below-comments'];
    659693            $page_below_comments_block = $this->modules['WPAI_Settings']->settings['placements']['page-below-comments'];
    660 
    661             $content = get_the_content();
    662694
    663695            $options = $this->modules['WPAI_Settings']->settings['options'];
     
    717749        }
    718750
    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        /**
    720768         * Checks that the object is in a correct state
    721769         *
  • wp-advertize-it/trunk/classes/wpai-settings.php

    r1042009 r1043541  
    162162                "after-first-post-paragraph" => "",
    163163                "after-first-page-paragraph" => "",
    164                 "between-posts" => ""
     164                "between-posts" => "",
     165                "above-everything" => ""
    165166            );
    166167
     
    342343            $this->add_settings_field_placements('wpai_all-below-footer', 'Below footer');
    343344            $this->add_settings_field_placements('wpai_between-posts', 'Between posts');
     345            $this->add_settings_field_placements('wpai_above-everything', 'Above everything');
    344346
    345347            /*
     
    484486            $this->setting_empty_string_if_not_set($new_settings, 'placements', 'after-first-post-paragraph');
    485487            $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');
    487490
    488491            /*
  • wp-advertize-it/trunk/readme.txt

    r1042130 r1043541  
    55Requires at least: 3.0.1
    66Tested up to: 4.0.1
    7 Stable tag: 0.8.2
     7Stable tag: 0.9
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    109109== Changelog ==
    110110
     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
    111116= 0.8.2 =
    112117
  • wp-advertize-it/trunk/views/wpai-settings/page-settings-fields.php

    r1042009 r1043541  
    323323    </select>
    324324<?php
     325elseif ('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
    325345elseif ('wpai_suppress-on-posts' == $field['label_for']) : ?>
    326346    <input type="checkbox" name="wpai_settings[options][suppress-on-posts]"
  • wp-advertize-it/trunk/views/wpai-settings/page-settings.php

    r915984 r1043541  
    4545            <li>&lt;!--NoWidgetAds--&gt; : suppresses the ad widget</li>
    4646            <li>&lt;!--NoBelowFooterAds--&gt; : suppresses the footer</li>
     47            <li>&lt;!--NoAdBlockX--&gt; : suppresses ad block X on this post or page e.g. &lt;!--NoAdBlock1--&gt;</li>
    4748        </ul>
    4849        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.