Plugin Directory

Changeset 3190691


Ignore:
Timestamp:
11/17/2024 03:46:54 PM (17 months ago)
Author:
yingling017
Message:

Update to version 2.0.17 from GitHub

Location:
reading-time-wp
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • reading-time-wp/tags/2.0.17/readme.txt

    r3068141 r3190691  
    44Tags: reading time, estimated time, word count, time, posts, page, reading
    55Requires at least: 3.0.1
    6 Tested up to: 6.5.2
    7 Stable tag: 2.0.16
     6Tested up to: 6.7
     7Stable tag: 2.0.17
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515WP Reading Time let's you easily add an estimated reading time to your WordPress posts. Activating the plugin will automatically add the reading time to the beginning of your post's content. This can be deactivated in the Reading Time settings which can be accessed from your Dashboard's Settings menu. You can also edit the label and postfix from this menu.
    1616
    17 If you'd prefer more control over where you add your reading time you can use the the [rt_reading_time] shortcode to insert the time into a post. This shortcode also excepts values for label and postfix. These are optional. Ex. [rt_reading_time label="Reading Time:" postfix="minutes"].
     17If you'd prefer more control over where you add your reading time you can use the the [rt_reading_time] shortcode to insert the time into a post. This shortcode also excepts values for label and postfix. These are optional. Ex. [rt_reading_time label="Reading Time:" postfix="minutes" postfix_singular="minute"].
    1818
    1919== Installation ==
     
    7575
    7676== Changelog ==
     77
     78= 2.0.17 =
     79* Moved reading time output to function
     80* Added filter for reading time output `rtwp_filter_reading_time_output` passes 4 arguments: `$output`, `$label`, `$reading_time`, `$postfix`
     81* WordPress 6.7 support
    7782
    7883= 2.0.16 =
  • reading-time-wp/tags/2.0.17/rt-reading-time.php

    r3068141 r3190691  
    88 * Plugin URI: https://jasonyingling.me/reading-time-wp/
    99 * Description: Add an estimated reading time to your posts.
    10  * Version: 2.0.16
     10 * Version: 2.0.17
    1111 * Author: Jason Yingling
    1212 * Author URI: https://jasonyingling.me
     
    242242        $rt_post = $atts['post_id'] && ( get_post_status( $atts['post_id'] ) ) ? $atts['post_id'] : get_the_ID();
    243243
    244         $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
    245 
    246         $calculated_postfix = $this->rt_add_postfix( $this->reading_time, $atts['postfix_singular'], $atts['postfix'] );
    247 
    248         return '<span class="span-reading-time rt-reading-time"><span class="rt-label rt-prefix">' . wp_kses( $atts['label'], $this->rtwp_kses ) . '</span> <span class="rt-time"> ' . esc_html( $this->reading_time ) . '</span> <span class="rt-label rt-postfix">' . wp_kses( $calculated_postfix, $this->rtwp_kses ) . '</span></span>';
     244         // Store the result of $this->rt_calculate_reading_time in a variable
     245        $reading_time = $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
     246
     247        $calculated_postfix = $this->rt_add_postfix( $reading_time, $atts['postfix_singular'], $atts['postfix'] );
     248
     249        $output = $this->rt_generate_reading_time_output( $atts['label'], $reading_time, $calculated_postfix );
     250
     251        return $output;
     252    }
     253
     254    /**
     255     * Generate the reading time output.
     256     *
     257     * @param string $label The label for the reading time.
     258     * @param string $reading_time The calculated reading time.
     259     * @param string $postfix The postfix for the reading time.
     260     * @return string The generated reading time output.
     261     */
     262    public function rt_generate_reading_time_output( $label, $reading_time, $postfix, $style = '' ) {
     263        if ( $style !== '' ) {
     264            $style = ' style="display: ' . esc_attr( $style ) . ';"';
     265        }
     266        $output = '<span class="span-reading-time rt-reading-time"' . $style . '><span class="rt-label rt-prefix">' . wp_kses( $label, $this->rtwp_kses ) . '</span> <span class="rt-time"> ' . esc_html( $reading_time ) . '</span> <span class="rt-label rt-postfix">' . wp_kses( $postfix, $this->rtwp_kses ) . '</span></span>';
     267        return apply_filters( 'rtwp_filter_reading_time_output', $output, $label, $reading_time, $postfix );
    249268    }
    250269
     
    305324        $rt_post          = get_the_ID();
    306325
    307         $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
     326         // Store the result of $this->rt_calculate_reading_time in a variable
     327        $reading_time = $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
    308328
    309329        $label            = $rt_reading_time_options['label'];
     
    315335        }
    316336
    317         $calculated_postfix = $this->rt_add_postfix( $this->reading_time, $postfix_singular, $postfix );
    318 
    319         $content  = '<span class="rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">' . wp_kses( $label, $this->rtwp_kses ) . '</span> <span class="rt-time">' . esc_html( $this->reading_time ) . '</span> <span class="rt-label rt-postfix">' . wp_kses( $calculated_postfix, $this->rtwp_kses ) . '</span></span>';
     337        $calculated_postfix = $this->rt_add_postfix( $reading_time, $postfix_singular, $postfix );
     338
     339        $content  = $this->rt_generate_reading_time_output( $label, $reading_time, $calculated_postfix, 'block' );
    320340        $content .= $original_content;
    321341        return $content;
     
    351371        $rt_post          = get_the_ID();
    352372
    353         $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
     373         // Store the result of $this->rt_calculate_reading_time in a variable
     374        $reading_time = $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
    354375
    355376        $label            = $rt_reading_time_options['label'];
     
    359380        $calculated_postfix = $this->rt_add_postfix( $this->reading_time, $postfix_singular, $postfix );
    360381
    361         $content  = '<span class="rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">' . wp_kses( $label, $this->rtwp_kses ) . '</span> <span class="rt-time">' . esc_html( $this->reading_time ) . '</span> <span class="rt-label rt-postfix">' . wp_kses( $calculated_postfix, $this->rtwp_kses ) . '</span></span> ';
     382        $content  = $this->rt_generate_reading_time_output( $label, $reading_time, $calculated_postfix, 'block' );
    362383        $content .= $original_content;
    363384        return $content;
  • reading-time-wp/trunk/readme.txt

    r3068141 r3190691  
    44Tags: reading time, estimated time, word count, time, posts, page, reading
    55Requires at least: 3.0.1
    6 Tested up to: 6.5.2
    7 Stable tag: 2.0.16
     6Tested up to: 6.7
     7Stable tag: 2.0.17
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515WP Reading Time let's you easily add an estimated reading time to your WordPress posts. Activating the plugin will automatically add the reading time to the beginning of your post's content. This can be deactivated in the Reading Time settings which can be accessed from your Dashboard's Settings menu. You can also edit the label and postfix from this menu.
    1616
    17 If you'd prefer more control over where you add your reading time you can use the the [rt_reading_time] shortcode to insert the time into a post. This shortcode also excepts values for label and postfix. These are optional. Ex. [rt_reading_time label="Reading Time:" postfix="minutes"].
     17If you'd prefer more control over where you add your reading time you can use the the [rt_reading_time] shortcode to insert the time into a post. This shortcode also excepts values for label and postfix. These are optional. Ex. [rt_reading_time label="Reading Time:" postfix="minutes" postfix_singular="minute"].
    1818
    1919== Installation ==
     
    7575
    7676== Changelog ==
     77
     78= 2.0.17 =
     79* Moved reading time output to function
     80* Added filter for reading time output `rtwp_filter_reading_time_output` passes 4 arguments: `$output`, `$label`, `$reading_time`, `$postfix`
     81* WordPress 6.7 support
    7782
    7883= 2.0.16 =
  • reading-time-wp/trunk/rt-reading-time.php

    r3068141 r3190691  
    88 * Plugin URI: https://jasonyingling.me/reading-time-wp/
    99 * Description: Add an estimated reading time to your posts.
    10  * Version: 2.0.16
     10 * Version: 2.0.17
    1111 * Author: Jason Yingling
    1212 * Author URI: https://jasonyingling.me
     
    242242        $rt_post = $atts['post_id'] && ( get_post_status( $atts['post_id'] ) ) ? $atts['post_id'] : get_the_ID();
    243243
    244         $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
    245 
    246         $calculated_postfix = $this->rt_add_postfix( $this->reading_time, $atts['postfix_singular'], $atts['postfix'] );
    247 
    248         return '<span class="span-reading-time rt-reading-time"><span class="rt-label rt-prefix">' . wp_kses( $atts['label'], $this->rtwp_kses ) . '</span> <span class="rt-time"> ' . esc_html( $this->reading_time ) . '</span> <span class="rt-label rt-postfix">' . wp_kses( $calculated_postfix, $this->rtwp_kses ) . '</span></span>';
     244         // Store the result of $this->rt_calculate_reading_time in a variable
     245        $reading_time = $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
     246
     247        $calculated_postfix = $this->rt_add_postfix( $reading_time, $atts['postfix_singular'], $atts['postfix'] );
     248
     249        $output = $this->rt_generate_reading_time_output( $atts['label'], $reading_time, $calculated_postfix );
     250
     251        return $output;
     252    }
     253
     254    /**
     255     * Generate the reading time output.
     256     *
     257     * @param string $label The label for the reading time.
     258     * @param string $reading_time The calculated reading time.
     259     * @param string $postfix The postfix for the reading time.
     260     * @return string The generated reading time output.
     261     */
     262    public function rt_generate_reading_time_output( $label, $reading_time, $postfix, $style = '' ) {
     263        if ( $style !== '' ) {
     264            $style = ' style="display: ' . esc_attr( $style ) . ';"';
     265        }
     266        $output = '<span class="span-reading-time rt-reading-time"' . $style . '><span class="rt-label rt-prefix">' . wp_kses( $label, $this->rtwp_kses ) . '</span> <span class="rt-time"> ' . esc_html( $reading_time ) . '</span> <span class="rt-label rt-postfix">' . wp_kses( $postfix, $this->rtwp_kses ) . '</span></span>';
     267        return apply_filters( 'rtwp_filter_reading_time_output', $output, $label, $reading_time, $postfix );
    249268    }
    250269
     
    305324        $rt_post          = get_the_ID();
    306325
    307         $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
     326         // Store the result of $this->rt_calculate_reading_time in a variable
     327        $reading_time = $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
    308328
    309329        $label            = $rt_reading_time_options['label'];
     
    315335        }
    316336
    317         $calculated_postfix = $this->rt_add_postfix( $this->reading_time, $postfix_singular, $postfix );
    318 
    319         $content  = '<span class="rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">' . wp_kses( $label, $this->rtwp_kses ) . '</span> <span class="rt-time">' . esc_html( $this->reading_time ) . '</span> <span class="rt-label rt-postfix">' . wp_kses( $calculated_postfix, $this->rtwp_kses ) . '</span></span>';
     337        $calculated_postfix = $this->rt_add_postfix( $reading_time, $postfix_singular, $postfix );
     338
     339        $content  = $this->rt_generate_reading_time_output( $label, $reading_time, $calculated_postfix, 'block' );
    320340        $content .= $original_content;
    321341        return $content;
     
    351371        $rt_post          = get_the_ID();
    352372
    353         $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
     373         // Store the result of $this->rt_calculate_reading_time in a variable
     374        $reading_time = $this->rt_calculate_reading_time( $rt_post, $rt_reading_time_options );
    354375
    355376        $label            = $rt_reading_time_options['label'];
     
    359380        $calculated_postfix = $this->rt_add_postfix( $this->reading_time, $postfix_singular, $postfix );
    360381
    361         $content  = '<span class="rt-reading-time" style="display: block;"><span class="rt-label rt-prefix">' . wp_kses( $label, $this->rtwp_kses ) . '</span> <span class="rt-time">' . esc_html( $this->reading_time ) . '</span> <span class="rt-label rt-postfix">' . wp_kses( $calculated_postfix, $this->rtwp_kses ) . '</span></span> ';
     382        $content  = $this->rt_generate_reading_time_output( $label, $reading_time, $calculated_postfix, 'block' );
    362383        $content .= $original_content;
    363384        return $content;
Note: See TracChangeset for help on using the changeset viewer.