Plugin Directory

Changeset 1556460

Timestamp:
12/16/2016 11:50:31 PM (8 years ago)
Author:
goldenapples
Message:

Use the WP.org-flavored markdown

Try to get code blocks working correctly in the readme by using the correct
idiosynratic markdown flavor.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • speed-bumps/trunk/readme.txt

    r1556451 r1556460  
    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(
     30`register_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 ```
    41 register_speed_bump( 'speed_bump_sample', array(
     39
     40register_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 ```
    50 echo insert_speed_bumps( $content_to_be_inserted_into );
    51 ```
     48`echo insert_speed_bumps( $content_to_be_inserted_into );
     49`
    5250
    5351== Frequently Asked Questions ==
     
    7068Simple, 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!
    7169
    72 ```
    73 register_speed_bump( 'rickroll', array(
     70`register_speed_bump( 'rickroll', array(
    7471    'string_to_inject' => function() { return '<iframe width="420" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allowfullscreen></iframe>'; },
    7572    'minimum_content_length' => false,
     
    7875));
    7976add_filter( 'the_content', 'insert_speed_bumps', 1 );
    80 ```
     77`
    8178
    8279But, 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:
    8380
    84 ```
    85 add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
     81`add_filter( 'speed_bumps_rickroll_constraints', 'give_you_up', 10, 4 );
    8682
    8783function give_you_up( $can_insert, $context, $args, $already_inserted ) {
     
    9187    return $can_insert;
    9288}
    93 ```
     89`
    9490
    9591You could also disable it altogether with this filter (although why you would disable so soon after addition, only Rick Astley himself could answer):
    9692
    97 ```
    98 add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
    99 ```
     93`add_filter( 'speed_bumps_rickroll_constraints', '__return_false' );
     94`
    10095
    10196= How to remove default rules? =
     
    10398Each 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:
    10499
    105 ```
     100`
    106101remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::content_is_long_enough_to_insert' );
    107102remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Text\Minimum_Text::meets_minimum_distance_from_start' );
     
    110105remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Content\Injection::meets_minimum_distance_from_other_inserts' );
    111106remove_filter( 'speed_bumps_{id}_constraints', '\Speed_Bumps\Constraints\Elements\Element_Constraints::meets_minimum_distance_from_elements' );
    112 ```
     107`
    113108
    114109== Changelog ==
Note: See TracChangeset for help on using the changeset viewer.