Plugin Directory

Changeset 1556474

Timestamp:
12/17/2016 12:00:10 AM (8 years ago)
Author:
goldenapples
Message:

Tweak markdown format a bit more for plugin repo

Location:
speed-bumps
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • speed-bumps/tags/0.2.0/README.md

    r1556451 r1556474  
    2828The simplest way to have Speed Bumps process all of your content and insert speed bumps into content everywhere is simply adding the filter following registration:
    2929
    30 ```
    31 register_speed_bump( 'speed_bump_sample', array(
    32     'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
    33 ));
    34 add_filter( 'the_content', 'insert_speed_bumps', 1 );
    35 ```
     30    register_speed_bump( 'speed_bump_sample', array(
     31        'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
     32    ));
     33    add_filter( 'the_content', 'insert_speed_bumps', 1 );
     34
    3635
    3736This registration results in the `string_to_inject` value being injected at the first opportunity based on the default rules (e.g. on posts longer than 1200 characters, following the third paragraph OR following the paragraph which contains the 75th word, whichever comes later).
    3837
    3938Let's say you wanted the speed bump higher in the content. You could modify the `from_start` parameter to declare that the speed bump can be inserted after the first paragraph (yes, like good engineers, we prefer zero-based indexing).
    40 ```
    41 register_speed_bump( 'speed_bump_sample', array(
    42     'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
    43     'from_start' => 0,
    44 ));
    45 ```
     39
     40register_speed_bump( 'speed_bump_sample', array(
     41    'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
     42    'from_start' => 0,
     43));
     44
    4645
    4746You can also selectively insert speed bumps into a string of content by calling Speed Bumps directly:
    4847
    49 ```
    50 echo insert_speed_bumps( $content_to_be_inserted_into );
    51 ```
     48
     49echo insert_speed_bumps( $content_to_be_inserted_into );
     50
    5251
    5352## Frequently Asked Questions ##
     
    7069**Simple, stupid example:** You have a speed bump called "rickroll" which inserts a beautiful musical video throughout your content. You _really_ need this viral bump (publisher's words, not yours) so you disable minimum content length and the rules regarding acceptable speed bump distance from start/end of the post. Greedy! 
    7170
    72 ```
    73 register_speed_bump( 'rickroll', array(
    74     'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
    75     'minimum_content_length' => false,
    76     'from_start' => false,
    77     'from_end' => false,
    78 ));
    79 add_filter( 'the_content', 'insert_speed_bumps', 1 );
    80 ```
     71    register_speed_bump( 'rickroll', array(
     72        'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
     73        'minimum_content_length' => false,
     74        'from_start' => false,
     75        'from_end' => false,
     76    ));
     77    add_filter( 'the_content', 'insert_speed_bumps', 1 );
     78
    8179
    8280But, maybe that's a little too extreme. You want to show it in certain situations, say, only when the previous paragraph contains the phrase 'give {something} up'. Here's how you would achieve that:
    8381
    84 ```
    85 add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
     82    add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
     83   
     84    function give_you_up( $can_insert, $context, $args, $already_inserted ) {
     85        if ( ! preg_match( '/give [^ ]+ up/i', $context['prev_paragraph'] ) ) {
     86            $can_insert = false;
     87        }
     88        return $can_insert;
     89    }
    8690
    87 function give_you_up( $can_insert, $context, $args, $already_inserted ) {
    88     if ( ! preg_match( '/give [^ ]+ up/i', $context['prev_paragraph'] ) ) {
    89         $can_insert = false;
    90     }
    91     return $can_insert;
    92 }
    93 ```
    9491
    9592You could also disable it altogether with this filter (although why you would disable so soon after addition, only Rick Astley himself could answer):
    9693
    97 ```
    98 add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
    99 ```
     94
     95add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
     96
    10097
    10198### How to remove default rules? ###
     
    103100Each rule is hooked to that speed bump's "constraints" filter. To remove a rule, simply remove the filter which defines that rule, like these lines which remove the default rules for your speed bump:
    104101
    105 ```
    106 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::content_is_long_enough_to_insert' );
    107 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_start' );
    108 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_end' );
    109 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::less_than_maximum_number_of_inserts' );
    110 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::meets_minimum_distance_from_other_inserts' );
    111 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Elements\Element_Constraints::meets_minimum_distance_from_elements' );
    112 ```
     102
     103remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::content_is_long_enough_to_insert' );
     104remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_start' );
     105remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_end' );
     106remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::less_than_maximum_number_of_inserts' );
     107remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::meets_minimum_distance_from_other_inserts' );
     108remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Elements\Element_Constraints::meets_minimum_distance_from_elements' );
     109
    113110
    114111## Changelog ##
  • speed-bumps/tags/0.2.0/readme.txt

    r1556451 r1556474  
    2727
    2828The simplest way to have Speed Bumps process all of your content and insert speed bumps into content everywhere is simply adding the filter following registration:
    29 
    30 ```
     29`
    3130register_speed_bump( 'speed_bump_sample', array(
    3231    'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
    3332));
    3433add_filter( 'the_content', 'insert_speed_bumps', 1 );
    35 ```
     34`
    3635
    3736This registration results in the `string_to_inject` value being injected at the first opportunity based on the default rules (e.g. on posts longer than 1200 characters, following the third paragraph OR following the paragraph which contains the 75th word, whichever comes later).
    3837
    3938Let's say you wanted the speed bump higher in the content. You could modify the `from_start` parameter to declare that the speed bump can be inserted after the first paragraph (yes, like good engineers, we prefer zero-based indexing).
    40 ```
     39`
    4140register_speed_bump( 'speed_bump_sample', array(
    4241    'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
    4342    'from_start' => 0,
    4443));
    45 ```
     44`
    4645
    4746You can also selectively insert speed bumps into a string of content by calling Speed Bumps directly:
    4847
    49 ```
     48`
    5049echo insert_speed_bumps( $content_to_be_inserted_into );
    51 ```
     50`
    5251
    5352== Frequently Asked Questions ==
     
    6968
    7069Simple, stupid example: You have a speed bump called "rickroll" which inserts a beautiful musical video throughout your content. You _really_ need this viral bump (publisher's words, not yours) so you disable minimum content length and the rules regarding acceptable speed bump distance from start/end of the post. Greedy!
    71 
    72 ```
     70`
    7371register_speed_bump( 'rickroll', array(
    7472    'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
     
    7876));
    7977add_filter( 'the_content', 'insert_speed_bumps', 1 );
    80 ```
     78`
    8179
    8280But, maybe that's a little too extreme. You want to show it in certain situations, say, only when the previous paragraph contains the phrase 'give {something} up'. Here's how you would achieve that:
    83 
    84 ```
     81`
    8582add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
    8683
     
    9188    return $can_insert;
    9289}
    93 ```
     90`
    9491
    9592You could also disable it altogether with this filter (although why you would disable so soon after addition, only Rick Astley himself could answer):
    9693
    97 ```
     94`
    9895add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
    99 ```
     96`
    10097
    10198= How to remove default rules? =
     
    103100Each rule is hooked to that speed bump's "constraints" filter. To remove a rule, simply remove the filter which defines that rule, like these lines which remove the default rules for your speed bump:
    104101
    105 ```
     102`
    106103remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::content_is_long_enough_to_insert' );
    107104remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_start' );
     
    110107remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::meets_minimum_distance_from_other_inserts' );
    111108remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Elements\Element_Constraints::meets_minimum_distance_from_elements' );
    112 ```
     109`
    113110
    114111== Changelog ==
  • speed-bumps/trunk/README.md

    r1556451 r1556474  
    2828The simplest way to have Speed Bumps process all of your content and insert speed bumps into content everywhere is simply adding the filter following registration:
    2929
    30 ```
    31 register_speed_bump( 'speed_bump_sample', array(
    32     'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
    33 ));
    34 add_filter( 'the_content', 'insert_speed_bumps', 1 );
    35 ```
     30    register_speed_bump( 'speed_bump_sample', array(
     31        'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
     32    ));
     33    add_filter( 'the_content', 'insert_speed_bumps', 1 );
     34
    3635
    3736This registration results in the `string_to_inject` value being injected at the first opportunity based on the default rules (e.g. on posts longer than 1200 characters, following the third paragraph OR following the paragraph which contains the 75th word, whichever comes later).
    3837
    3938Let's say you wanted the speed bump higher in the content. You could modify the `from_start` parameter to declare that the speed bump can be inserted after the first paragraph (yes, like good engineers, we prefer zero-based indexing).
    40 ```
    41 register_speed_bump( 'speed_bump_sample', array(
    42     'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
    43     'from_start' => 0,
    44 ));
    45 ```
     39
     40register_speed_bump( 'speed_bump_sample', array(
     41    'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
     42    'from_start' => 0,
     43));
     44
    4645
    4746You can also selectively insert speed bumps into a string of content by calling Speed Bumps directly:
    4847
    49 ```
    50 echo insert_speed_bumps( $content_to_be_inserted_into );
    51 ```
     48
     49echo insert_speed_bumps( $content_to_be_inserted_into );
     50
    5251
    5352## Frequently Asked Questions ##
     
    7069**Simple, stupid example:** You have a speed bump called "rickroll" which inserts a beautiful musical video throughout your content. You _really_ need this viral bump (publisher's words, not yours) so you disable minimum content length and the rules regarding acceptable speed bump distance from start/end of the post. Greedy! 
    7170
    72 ```
    73 register_speed_bump( 'rickroll', array(
    74     'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
    75     'minimum_content_length' => false,
    76     'from_start' => false,
    77     'from_end' => false,
    78 ));
    79 add_filter( 'the_content', 'insert_speed_bumps', 1 );
    80 ```
     71    register_speed_bump( 'rickroll', array(
     72        'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
     73        'minimum_content_length' => false,
     74        'from_start' => false,
     75        'from_end' => false,
     76    ));
     77    add_filter( 'the_content', 'insert_speed_bumps', 1 );
     78
    8179
    8280But, maybe that's a little too extreme. You want to show it in certain situations, say, only when the previous paragraph contains the phrase 'give {something} up'. Here's how you would achieve that:
    8381
    84 ```
    85 add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
     82    add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
     83   
     84    function give_you_up( $can_insert, $context, $args, $already_inserted ) {
     85        if ( ! preg_match( '/give [^ ]+ up/i', $context['prev_paragraph'] ) ) {
     86            $can_insert = false;
     87        }
     88        return $can_insert;
     89    }
    8690
    87 function give_you_up( $can_insert, $context, $args, $already_inserted ) {
    88     if ( ! preg_match( '/give [^ ]+ up/i', $context['prev_paragraph'] ) ) {
    89         $can_insert = false;
    90     }
    91     return $can_insert;
    92 }
    93 ```
    9491
    9592You could also disable it altogether with this filter (although why you would disable so soon after addition, only Rick Astley himself could answer):
    9693
    97 ```
    98 add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
    99 ```
     94
     95add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
     96
    10097
    10198### How to remove default rules? ###
     
    103100Each rule is hooked to that speed bump's "constraints" filter. To remove a rule, simply remove the filter which defines that rule, like these lines which remove the default rules for your speed bump:
    104101
    105 ```
    106 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::content_is_long_enough_to_insert' );
    107 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_start' );
    108 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_end' );
    109 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::less_than_maximum_number_of_inserts' );
    110 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::meets_minimum_distance_from_other_inserts' );
    111 remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Elements\Element_Constraints::meets_minimum_distance_from_elements' );
    112 ```
     102
     103remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::content_is_long_enough_to_insert' );
     104remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_start' );
     105remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_end' );
     106remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::less_than_maximum_number_of_inserts' );
     107remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::meets_minimum_distance_from_other_inserts' );
     108remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Elements\Element_Constraints::meets_minimum_distance_from_elements' );
     109
    113110
    114111## Changelog ##
  • speed-bumps/trunk/readme.txt

    r1556460 r1556474  
    2727
    2828The simplest way to have Speed Bumps process all of your content and insert speed bumps into content everywhere is simply adding the filter following registration:
    29 
    30 `register_speed_bump( 'speed_bump_sample', array(
     29`
     30register_speed_bump( 'speed_bump_sample', array(
    3131    'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
    3232));
     
    3737
    3838Let's say you wanted the speed bump higher in the content. You could modify the `from_start` parameter to declare that the speed bump can be inserted after the first paragraph (yes, like good engineers, we prefer zero-based indexing).
    39 
    40 `register_speed_bump( 'speed_bump_sample', array(
     39`
     40register_speed_bump( 'speed_bump_sample', array(
    4141    'string_to_inject' => function() { return '<div id="speed-bump-sample"></div>'; },
    4242    'from_start' => 0,
     
    4646You can also selectively insert speed bumps into a string of content by calling Speed Bumps directly:
    4747
    48 `echo insert_speed_bumps( $content_to_be_inserted_into );
     48`
     49echo insert_speed_bumps( $content_to_be_inserted_into );
    4950`
    5051
     
    6768
    6869Simple, stupid example: You have a speed bump called "rickroll" which inserts a beautiful musical video throughout your content. You _really_ need this viral bump (publisher's words, not yours) so you disable minimum content length and the rules regarding acceptable speed bump distance from start/end of the post. Greedy!
    69 
    70 `register_speed_bump( 'rickroll', array(
     70`
     71register_speed_bump( 'rickroll', array(
    7172    'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
    7273    'minimum_content_length' => false,
     
    7879
    7980But, maybe that's a little too extreme. You want to show it in certain situations, say, only when the previous paragraph contains the phrase 'give {something} up'. Here's how you would achieve that:
    80 
    81 `add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
     81`
     82add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
    8283
    8384function give_you_up( $can_insert, $context, $args, $already_inserted ) {
     
    9192You could also disable it altogether with this filter (although why you would disable so soon after addition, only Rick Astley himself could answer):
    9293
    93 `add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
     94`
     95add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
    9496`
    9597
Note: See TracChangeset for help on using the changeset viewer.