Plugin Directory

Changeset 1556450

Timestamp:
12/16/2016 10:56:18 PM (8 years ago)
Author:
goldenapples
Message:

Tagging and relasing version 0.2.0

Location:
speed-bumps
Files:
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • speed-bumps/tags/0.2.0/Gruntfile.js

    r1204895 r1556450  
    4545        phpcs: {
    4646            application: {
    47                 src: ['inc/**/*.php', 'tests/**/*.php']
     47                src:
    4848            },
    4949            options: {
    50                 bin: 'vendor/bin/phpcs',
    51                 standard: 'WordPress-VIP'
     50                bin: ,
     51                standard:
    5252            }
    5353        }
  • speed-bumps/tags/0.2.0/README.md

    r1204895 r1556450  
    11# Speed Bumps #
    2 **Contributors:** fusioneng, goldenapples, noppanit 
     2**Contributors:** fusioneng, goldenapples, noppanit 
    33**Tags:** content, advertising, recirculation 
    4 **Requires at least:** 3.0.1 
    5 **Stable tag:** 0.1.0 
    6 **Tested up to:** 4.3 
     4**Requires at least:**  
     5**Stable tag:** 0..0 
     6**Tested up to:** 4. 
    77**License:** GPLv2 or later 
    88**License URI:** http://www.gnu.org/licenses/gpl-2.0.html 
     
    114114## Changelog ##
    115115
    116 ### 0.1.0 (July 22, 2015) ###
     116### 0.2.0 (December 15, 2016) ###
     117
     118* Compatability: Remove direct $wp_filter access for WP 4.7 compatability.
     119* Compatability: Fix issues throwing warnings in PHP7.
     120* Feature: Add "last ditch fallback" option for speed bump registration.
     121* Feature: Add filter around speed bump insertion content.
     122* Performance: Unregister speed bumps when global constraints prevent them being inserted.
     123* Performance: Unregister speed bumps after inserting them the maximum number of times.
     124* Performance: Allow speed bump constraint filters to short-circuit other filters at an insertion point, or to skip all remaining insertion points in a document.
     125
     126### 0.1.0 (July 23, 2015) ###
    117127
    118128* Initial release.
    119 * [Full release notes](http://fus.in/1MidK1N)
     129* [Full release notes](http://fus)
  • speed-bumps/tags/0.2.0/inc/constraints/content/class-injection.php

    r1204895 r1556450  
    44use Speed_Bumps\Utils\Comparison;
    55use Speed_Bumps\Utils\Text;
     6
    67
    78/**
     
    3738
    3839        if ( count( $this_speed_bump_insertions ) >= $args['maximum_inserts'] ) {
    39             $can_insert = false;
     40            $can_insert = ;
    4041        }
    4142
  • speed-bumps/tags/0.2.0/inc/constraints/elements/class-shortcode.php

    r1204895 r1556450  
    22namespace Speed_Bumps\Constraints\Elements;
    33
    4 class Shortcode extends Constraint_Abstract{
     4class Shortcode extends Constraint_Abstract{
    55    public function paragraph_not_contains_element( $paragraph ) {
    66        if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $paragraph, $matches, PREG_SET_ORDER ) ) {
  • speed-bumps/tags/0.2.0/inc/constraints/text/class-minimum-text.php

    r1204895 r1556450  
    22namespace Speed_Bumps\Constraints\Text;
    33
     4
    45use Speed_Bumps\Utils\Text;
    5 use Speed_Bumps\Utils\Comparison;
     6use Speed_Bumps;
    67
    78/**
     
    4041                if ( isset( $args['minimum_content_length'][ $unit ] ) &&
    4142                    Comparison::content_less_than( $unit, $args['minimum_content_length'][ $unit ], $content ) ) {
    42                     $can_insert = false;
     43                    $can_insert = ;
    4344                }
    4445            }
     
    4748        if ( intval( $args['minimum_content_length'] ) ) {
    4849            if ( Comparison::content_less_than( 'characters', intval( $args['minimum_content_length'] ), $content ) ) {
    49                 $can_insert = false;
     50                $can_insert = ;
    5051            }
    5152        }
     53
     54
     55
     56
     57
    5258
    5359        return $can_insert;
  • speed-bumps/tags/0.2.0/languages/speed-bumps.pot

    r1204895 r1556450  
    1 # Copyright (C) 2015 Fusion Engineering
     1# Copyright (C) 201 Fusion Engineering
    22# This file is distributed under the same license as the Speed-bumps package.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Speed-bumps 0.1.0\n"
    6 "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/speed-bumps\n"
    7 "POT-Creation-Date: 2015-07-22 18:59:50+00:00\n"
     5"Project-Id-Version: Speed-bumps 0..0\n"
     6"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/speed-bumps\n"
     7"POT-Creation-Date: 201+00:00\n"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=utf-8\n"
    1010"Content-Transfer-Encoding: 8bit\n"
    11 "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
     11"PO-Revision-Date: 201-MO-DA HO:MI+ZONE\n"
    1212"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    1313"Language-Team: LANGUAGE <LL@li.org>\n"
    14 "X-Generator: grunt-wp-i18n 0.5.2\n"
     14"X-Generator: grunt-wp-i18n 0.5.\n"
    1515"X-Poedit-KeywordsList: "
    1616"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
  • speed-bumps/tags/0.2.0/readme.txt

    r1204895 r1556450  
    33Tags: content, advertising, recirculation
    44Requires at least: 4.2
    5 Stable tag: 0.1.0
    6 Tested up to: 4.3
     5Stable tag: 0..0
     6Tested up to: 4.
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    114114== Changelog ==
    115115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
    116126= 0.1.0 (July 23, 2015) =
    117127
  • speed-bumps/tags/0.2.0/speed-bumps.php

    r1204895 r1556450  
    22/*
    33Plugin Name: Speed-bumps
    4 Version: 0.1.0
     4Version: 0..0
    55Description: A Plugin to insert a piece of content intelligently.
    66Author: Fusion Engineering
     
    6666     * - and the file containing the class itself will be named `class-{classname}.php`
    6767     */
    68     function spl_autoload($class) {
     68    function spl_autoload() {
    6969
    7070        // project-specific namespace
     
    8888        if ( file_exists( $file ) ) {
    8989            //Require the file
    90             require($file);
     90            require();
    9191        }
    9292    }
     
    109109     */
    110110    public function insert_speed_bumps( $the_content ) {
     111
     112
    111113        $output = array();
    112114        $already_inserted = array();
     
    126128            foreach ( $this->get_speed_bumps() as $id => $args ) {
    127129
    128                 if ( apply_filters( 'speed_bumps_'. $id . '_constraints', true, $context, $args, $already_inserted ) ) {
     130                $speed_bump_filter = sprintf( self::$filter_id, $id );
     131
     132                /**
     133                 * Filter whether a speed bump can be inserted at a given location
     134                 *
     135                 * This filter is dynamically named "speed_bump_{id}_constraints", and is the main logic of
     136                 * this plugin. Returning false from this filter means that the speed bump will not be
     137                 * inserted.
     138                 *
     139                 * @param bool  $can_insert        Whether the speed bump can be inserted here
     140                 * @param array $args              Speed bump rules
     141                 * @param array $context           Current insertion point context
     142                 * @param array $already_inserted  Other speed bumps which have been inserted
     143                 */
     144                if ( apply_filters( $speed_bump_filter, true, $context, $args, $already_inserted ) ) {
    129145
    130146                    $content_to_be_inserted = call_user_func( $args['string_to_inject'], $context, $already_inserted );
    131147
    132                     $output[] = $content_to_be_inserted;
     148                    /**
     149                     * Filter the output of a speed bump.
     150                     *
     151                     * @param string $content_to_be_inserted Output of speed bump
     152                     * @param array  $args                   Speed bump rules
     153                     * @param array  $context                Current insertion point context
     154                     * @param array  $already_inserted       Other speed bumps which have been inserted
     155                     */
     156                    $output[] = apply_filters( 'speed_bumps_content_inserted', $content_to_be_inserted, $args, $context, $already_inserted );
     157
     158                    $already_inserted[] = array(
     159                        'index' => $index,
     160                        'speed_bump_id' => $id,
     161                        'inserted_content' => $content_to_be_inserted,
     162                    );
     163                }
     164
     165                /**
     166                 * Fires after all constraints on a speed bump are completed for an insertion point
     167                 *
     168                 * @param string $speed_bump_filter The speed bump's filter name
     169                 * @param array  $context           Current insertion point context
     170                 */
     171                do_action( 'speed_bumps_constraints_completed', $speed_bump_filter );
     172
     173            } // @codingStandardsIgnoreLine End foreach() loop through filters at insertion point
     174
     175        } // @codingStandardsIgnoreLine End foreach() loop through paragraphs.
     176
     177        // Apply "last ditch" insertion rules for any speed bumps that implement them
     178        $context['last_ditch'] = true;
     179
     180        foreach ( $this->get_speed_bumps() as $id => $args ) {
     181
     182            if ( ! empty( $args['last_ditch_fallback'] ) ) {
     183
     184                if ( is_callable( $args['last_ditch_fallback'] ) ) {
     185                    $can_insert = call_user_func( $args['last_ditch_fallback'], $context, $already_inserted );
     186                } else {
     187                    $inserted = array_filter( $already_inserted, function( $insert ) use ( $id ) { return $insert['speed_bump_id'] === $id; } );
     188                    $can_insert = ( count( $inserted ) < $args['minimum_inserts'] );
     189                }
     190
     191                if ( $can_insert ) {
     192                    $content_to_be_inserted = call_user_func( $args['string_to_inject'], $context, $already_inserted );
     193
     194                    $output[] = apply_filters( 'speed_bumps_content_inserted', $content_to_be_inserted, $args, $context, $already_inserted );
     195
    133196                    $already_inserted[] = array(
    134197                        'index' => $index,
     
    140203        }
    141204
     205
    142206        return implode( PHP_EOL . PHP_EOL, $output );
    143207    }
     
    163227            // Maximum number of times this can be inserted in a post
    164228            'maximum_inserts' => 1,
     229
     230
     231
     232
     233
     234
     235
    165236
    166237            // Rules which govern the content as a whole
     
    232303    }
    233304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
    234316    public function get_speed_bump( $id ) {
    235317        return self::$speed_bumps[ $id ];
     
    245327        foreach ( $this->get_speed_bumps() as $id => $args ) {
    246328            $this->clear_speed_bump( $id );
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
    247452        }
    248453    }
  • speed-bumps/trunk/Gruntfile.js

    r1204895 r1556450  
    4545        phpcs: {
    4646            application: {
    47                 src: ['inc/**/*.php', 'tests/**/*.php']
     47                src:
    4848            },
    4949            options: {
    50                 bin: 'vendor/bin/phpcs',
    51                 standard: 'WordPress-VIP'
     50                bin: ,
     51                standard:
    5252            }
    5353        }
  • speed-bumps/trunk/README.md

    r1204895 r1556450  
    11# Speed Bumps #
    2 **Contributors:** fusioneng, goldenapples, noppanit 
     2**Contributors:** fusioneng, goldenapples, noppanit 
    33**Tags:** content, advertising, recirculation 
    4 **Requires at least:** 3.0.1 
    5 **Stable tag:** 0.1.0 
    6 **Tested up to:** 4.3 
     4**Requires at least:**  
     5**Stable tag:** 0..0 
     6**Tested up to:** 4. 
    77**License:** GPLv2 or later 
    88**License URI:** http://www.gnu.org/licenses/gpl-2.0.html 
     
    114114## Changelog ##
    115115
    116 ### 0.1.0 (July 22, 2015) ###
     116### 0.2.0 (December 15, 2016) ###
     117
     118* Compatability: Remove direct $wp_filter access for WP 4.7 compatability.
     119* Compatability: Fix issues throwing warnings in PHP7.
     120* Feature: Add "last ditch fallback" option for speed bump registration.
     121* Feature: Add filter around speed bump insertion content.
     122* Performance: Unregister speed bumps when global constraints prevent them being inserted.
     123* Performance: Unregister speed bumps after inserting them the maximum number of times.
     124* Performance: Allow speed bump constraint filters to short-circuit other filters at an insertion point, or to skip all remaining insertion points in a document.
     125
     126### 0.1.0 (July 23, 2015) ###
    117127
    118128* Initial release.
    119 * [Full release notes](http://fus.in/1MidK1N)
     129* [Full release notes](http://fus)
  • speed-bumps/trunk/inc/constraints/content/class-injection.php

    r1204895 r1556450  
    44use Speed_Bumps\Utils\Comparison;
    55use Speed_Bumps\Utils\Text;
     6
    67
    78/**
     
    3738
    3839        if ( count( $this_speed_bump_insertions ) >= $args['maximum_inserts'] ) {
    39             $can_insert = false;
     40            $can_insert = ;
    4041        }
    4142
  • speed-bumps/trunk/inc/constraints/elements/class-shortcode.php

    r1204895 r1556450  
    22namespace Speed_Bumps\Constraints\Elements;
    33
    4 class Shortcode extends Constraint_Abstract{
     4class Shortcode extends Constraint_Abstract{
    55    public function paragraph_not_contains_element( $paragraph ) {
    66        if ( preg_match_all( '/' . get_shortcode_regex() . '/s', $paragraph, $matches, PREG_SET_ORDER ) ) {
  • speed-bumps/trunk/inc/constraints/text/class-minimum-text.php

    r1204895 r1556450  
    22namespace Speed_Bumps\Constraints\Text;
    33
     4
    45use Speed_Bumps\Utils\Text;
    5 use Speed_Bumps\Utils\Comparison;
     6use Speed_Bumps;
    67
    78/**
     
    4041                if ( isset( $args['minimum_content_length'][ $unit ] ) &&
    4142                    Comparison::content_less_than( $unit, $args['minimum_content_length'][ $unit ], $content ) ) {
    42                     $can_insert = false;
     43                    $can_insert = ;
    4344                }
    4445            }
     
    4748        if ( intval( $args['minimum_content_length'] ) ) {
    4849            if ( Comparison::content_less_than( 'characters', intval( $args['minimum_content_length'] ), $content ) ) {
    49                 $can_insert = false;
     50                $can_insert = ;
    5051            }
    5152        }
     53
     54
     55
     56
     57
    5258
    5359        return $can_insert;
  • speed-bumps/trunk/languages/speed-bumps.pot

    r1204895 r1556450  
    1 # Copyright (C) 2015 Fusion Engineering
     1# Copyright (C) 201 Fusion Engineering
    22# This file is distributed under the same license as the Speed-bumps package.
    33msgid ""
    44msgstr ""
    5 "Project-Id-Version: Speed-bumps 0.1.0\n"
    6 "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/speed-bumps\n"
    7 "POT-Creation-Date: 2015-07-22 18:59:50+00:00\n"
     5"Project-Id-Version: Speed-bumps 0..0\n"
     6"Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/speed-bumps\n"
     7"POT-Creation-Date: 201+00:00\n"
    88"MIME-Version: 1.0\n"
    99"Content-Type: text/plain; charset=utf-8\n"
    1010"Content-Transfer-Encoding: 8bit\n"
    11 "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
     11"PO-Revision-Date: 201-MO-DA HO:MI+ZONE\n"
    1212"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    1313"Language-Team: LANGUAGE <LL@li.org>\n"
    14 "X-Generator: grunt-wp-i18n 0.5.2\n"
     14"X-Generator: grunt-wp-i18n 0.5.\n"
    1515"X-Poedit-KeywordsList: "
    1616"__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_"
  • speed-bumps/trunk/readme.txt

    r1204895 r1556450  
    33Tags: content, advertising, recirculation
    44Requires at least: 4.2
    5 Stable tag: 0.1.0
    6 Tested up to: 4.3
     5Stable tag: 0..0
     6Tested up to: 4.
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    114114== Changelog ==
    115115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
    116126= 0.1.0 (July 23, 2015) =
    117127
  • speed-bumps/trunk/speed-bumps.php

    r1204895 r1556450  
    22/*
    33Plugin Name: Speed-bumps
    4 Version: 0.1.0
     4Version: 0..0
    55Description: A Plugin to insert a piece of content intelligently.
    66Author: Fusion Engineering
     
    6666     * - and the file containing the class itself will be named `class-{classname}.php`
    6767     */
    68     function spl_autoload($class) {
     68    function spl_autoload() {
    6969
    7070        // project-specific namespace
     
    8888        if ( file_exists( $file ) ) {
    8989            //Require the file
    90             require($file);
     90            require();
    9191        }
    9292    }
     
    109109     */
    110110    public function insert_speed_bumps( $the_content ) {
     111
     112
    111113        $output = array();
    112114        $already_inserted = array();
     
    126128            foreach ( $this->get_speed_bumps() as $id => $args ) {
    127129
    128                 if ( apply_filters( 'speed_bumps_'. $id . '_constraints', true, $context, $args, $already_inserted ) ) {
     130                $speed_bump_filter = sprintf( self::$filter_id, $id );
     131
     132                /**
     133                 * Filter whether a speed bump can be inserted at a given location
     134                 *
     135                 * This filter is dynamically named "speed_bump_{id}_constraints", and is the main logic of
     136                 * this plugin. Returning false from this filter means that the speed bump will not be
     137                 * inserted.
     138                 *
     139                 * @param bool  $can_insert        Whether the speed bump can be inserted here
     140                 * @param array $args              Speed bump rules
     141                 * @param array $context           Current insertion point context
     142                 * @param array $already_inserted  Other speed bumps which have been inserted
     143                 */
     144                if ( apply_filters( $speed_bump_filter, true, $context, $args, $already_inserted ) ) {
    129145
    130146                    $content_to_be_inserted = call_user_func( $args['string_to_inject'], $context, $already_inserted );
    131147
    132                     $output[] = $content_to_be_inserted;
     148                    /**
     149                     * Filter the output of a speed bump.
     150                     *
     151                     * @param string $content_to_be_inserted Output of speed bump
     152                     * @param array  $args                   Speed bump rules
     153                     * @param array  $context                Current insertion point context
     154                     * @param array  $already_inserted       Other speed bumps which have been inserted
     155                     */
     156                    $output[] = apply_filters( 'speed_bumps_content_inserted', $content_to_be_inserted, $args, $context, $already_inserted );
     157
     158                    $already_inserted[] = array(
     159                        'index' => $index,
     160                        'speed_bump_id' => $id,
     161                        'inserted_content' => $content_to_be_inserted,
     162                    );
     163                }
     164
     165                /**
     166                 * Fires after all constraints on a speed bump are completed for an insertion point
     167                 *
     168                 * @param string $speed_bump_filter The speed bump's filter name
     169                 * @param array  $context           Current insertion point context
     170                 */
     171                do_action( 'speed_bumps_constraints_completed', $speed_bump_filter );
     172
     173            } // @codingStandardsIgnoreLine End foreach() loop through filters at insertion point
     174
     175        } // @codingStandardsIgnoreLine End foreach() loop through paragraphs.
     176
     177        // Apply "last ditch" insertion rules for any speed bumps that implement them
     178        $context['last_ditch'] = true;
     179
     180        foreach ( $this->get_speed_bumps() as $id => $args ) {
     181
     182            if ( ! empty( $args['last_ditch_fallback'] ) ) {
     183
     184                if ( is_callable( $args['last_ditch_fallback'] ) ) {
     185                    $can_insert = call_user_func( $args['last_ditch_fallback'], $context, $already_inserted );
     186                } else {
     187                    $inserted = array_filter( $already_inserted, function( $insert ) use ( $id ) { return $insert['speed_bump_id'] === $id; } );
     188                    $can_insert = ( count( $inserted ) < $args['minimum_inserts'] );
     189                }
     190
     191                if ( $can_insert ) {
     192                    $content_to_be_inserted = call_user_func( $args['string_to_inject'], $context, $already_inserted );
     193
     194                    $output[] = apply_filters( 'speed_bumps_content_inserted', $content_to_be_inserted, $args, $context, $already_inserted );
     195
    133196                    $already_inserted[] = array(
    134197                        'index' => $index,
     
    140203        }
    141204
     205
    142206        return implode( PHP_EOL . PHP_EOL, $output );
    143207    }
     
    163227            // Maximum number of times this can be inserted in a post
    164228            'maximum_inserts' => 1,
     229
     230
     231
     232
     233
     234
     235
    165236
    166237            // Rules which govern the content as a whole
     
    232303    }
    233304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
    234316    public function get_speed_bump( $id ) {
    235317        return self::$speed_bumps[ $id ];
     
    245327        foreach ( $this->get_speed_bumps() as $id => $args ) {
    246328            $this->clear_speed_bump( $id );
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
    247452        }
    248453    }
Note: See TracChangeset for help on using the changeset viewer.