WordPress.org

Plugin Directory

Changeset 1722794


Ignore:
Timestamp:
08/31/17 16:05:31 (3 weeks ago)
Author:
morganestes
Message:

Adds randomization of comment fixes

Location:
mansplainer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mansplainer/trunk/mansplainer.php

    r1722069 r1722794  
    4646 * 
    4747 * @since 1.0.0 
     48 * @since 1.1.0 Pick random comments to "fix", with filter for all comments. 
    4849 * 
    4950 * @param string           $comment_text Text of the current comment. 
     
    5354 */ 
    5455function fix_the_comments( $comment_text, $comment, $args ) { 
     56 
     57    /** 
     58     * Enable fixing all the comments or random ones. 
     59     * 
     60     * @since 1.1.0 
     61     * 
     62     * @param bool $not_all_comments Whether to fix all the comments, or random ones. Default true (random). 
     63     */ 
     64    $not_all_comments = apply_filters( 'mansplainer_not_all_comments', true ); 
     65 
     66    if ( $not_all_comments && boolval( random_int( 0, 1 ) ) ) { 
     67        return $comment_text; 
     68    } 
    5569 
    5670    /** 
     
    6882        __( 'I don\'t want to sealion, but', 'mansplainer' ), 
    6983        __( 'But have you considered...', 'mansplainer' ), 
     84        __( 'I can\'t believe I have to say this, but', 'mansplainer' ), 
     85        __( 'I\'m sure you\'ll agree that', 'mansplainer' ), 
     86        __( '💩', 'mansplainer' ), 
    7087    ] ); 
    7188 
    72     $how_many_splains = count( $splains ); 
    73     $pick_a_splain    = random_int( 0, $how_many_splains - 1 ); 
    74     $new_splain       = sprintf( '%1$s %2$s', 
     89    $pick_a_splain = random_int( 0, count( $splains ) - 1 ); 
     90    $new_splain    = sprintf( '%1$s %2$s', 
    7591        esc_html( trim( $splains[ $pick_a_splain ] ) ), 
    7692        $comment_text 
     
    7995    return $new_splain; 
    8096} 
    81  
  • mansplainer/trunk/readme.txt

    r1722106 r1722794  
    1919But what if you (accidentally, I'm sure) fail to indicate that you're the savior when you comment? Let Mansplain fix that for you. 
    2020 
    21 Mansplain helps keep your comment section technically correct (which we know is the *best* kind of correct) by prefixing comments 
    22 with an appropriately helpful phrase to let everyone know that _this_ comment can be relied on to be accurate, helpful, and properly 'splained. :) 
     21Mansplain helps keep your comment section technically correct (which we know is the *best* kind of correct) by prefixing comments with an appropriately helpful phrase to let everyone know that _this_ comment can be relied on to be accurate, helpful, and properly 'splained. :) 
    2322 
    2423== Installation == 
     
    4241== Changelog == 
    4342 
     43= 1.1.0 = 
     44* Changed to targeting random comments instead of all of them. 
     45* Introduced `mansplainer_not_all_comments` filter to enable original behavior of "fixing" all comments. 
     46* Added some new splains. 
     47 
    4448= 1.0.0 = 
    4549* Initial release, in case you didn't already know that. 
     50 
     51== Upgrade Notice == 
     52 
     53= 1.1.0 = 
     54This release changes the behavior slightly by adding splains to random comments instead of every one. 
     55 
     56To enable the splains on all the comments, add `add_filter( 'mansplainer_not_all_comments', '__return_false' );` to your theme's functions.php file or to another plugin. 
    4657 
    4758== Disclaimer == 
Note: See TracChangeset for help on using the changeset viewer.