Plugin Directory

Changeset 2558574


Ignore:
Timestamp:
07/05/2021 07:43:27 AM (5 years ago)
Author:
ResponsiveVoice
Message:

Add responsivevoice_content_before_cleaning and responsivevoice_content_after_cleaning filter hooks

Location:
responsivevoice-text-to-speech/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • responsivevoice-text-to-speech/trunk/readme.txt

    r2507842 r2558574  
    66Requires at least: 3.6
    77Tested up to: 5.7
    8 Stable tag: 1.6.9
     8Stable tag: 1.7.0
    99License: GPLv2
    1010
     
    8080
    8181== Changelog ==
     82
     83= Version 1.7.0 =
     84* Add `responsivevoice_content_before_cleaning` and `responsivevoice_content_after_cleaning` filter hooks for plugin and theme developers.
    8285
    8386= Version 1.6.9 =
     
    284287== Upgrade Notice ==
    285288
    286 = 1.6.8 =
     289= 1.7.0 =
    287290* Upgrade the plugin for the latest improvements.
  • responsivevoice-text-to-speech/trunk/responsivevoice-text-to-speech.php

    r2507842 r2558574  
    44Plugin URI: responsivevoice.com/wordpress-text-to-speech-plugin/?utm_source=wpadmin&utm_medium=plugin&utm_campaign=wprvttsplugin
    55Description: An easy to use plugin to integrate ResponsiveVoice Text to Speech into your WP blog.
    6 Version: 1.6.9
     6Version: 1.7.0
    77Author: ResponsiveVoice
    88Author URI: http://responsivevoice.com
     
    2828add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'RV_custom_plugin_action_links');
    2929
     30/**
     31 * Adds a "Listen" button to the post that reads its entire contents.
     32 *
     33 * @param array $attributes
     34 *
     35 * @return string
     36 */
    3037function RV_add_listen_button($attributes)
    3138{
     
    3340    $id_listenButton++;
    3441
    35     $postContent = get_the_content();
    36     $postContent = RV_clean_text($postContent);
     42    $content = get_the_content();
     43    $content = apply_filters('responsivevoice_content_before_cleaning', $content);
     44    $content = RV_clean_text($content);
     45    $content = apply_filters('responsivevoice_content_after_cleaning', $content);
     46    /**
     47     * @var string $voice
     48     * @var string $buttontext
     49     */
    3750    extract(shortcode_atts(array(
    3851        'voice'      => 'UK English Female',
     
    5063                    responsiveVoice.cancel();
    5164                }else{
    52                     responsiveVoice.speak("' . $postContent . '", "' . $voice . '"' . $parameters . ');
     65                    responsiveVoice.speak("' . $content . '", "' . $voice . '"' . $parameters . ');
    5366                }
    5467            };
     
    5972}
    6073
     74/**
     75 * Adds a BB-style button to the post that reads the content enclosed within the opening and closing shortcodes.
     76 *
     77 * @param array $attributes
     78 * @param string $includedtext
     79 *
     80 * @return string
     81 */
    6182function RV_add_bblisten($attributes, $includedtext = "")
    6283{
     
    6485    $id_bb++;
    6586
    66     $cleantext = RV_clean_text($includedtext);
     87    $content = apply_filters('responsivevoice_content_before_cleaning', $includedtext);
     88    $content = RV_clean_text($content);
     89    $content = apply_filters('responsivevoice_content_after_cleaning', $content);
     90    /**
     91     * @var string $voice
     92     * @var string $buttontext
     93     * @var string $buttonposition
     94     */
    6795    extract(shortcode_atts(array(
    6896        'voice'          => 'UK English Female',
     
    81109                    responsiveVoice.cancel();
    82110                }else{
    83                     responsiveVoice.speak("' . $cleantext . '", "' . $voice . '"' . $parameters . ');
     111                    responsiveVoice.speak("' . $content . '", "' . $voice . '"' . $parameters . ');
    84112                }
    85113            };
     
    87115    ';
    88116
    89     if ($buttonposition == 'after') {
    90         return $includedtext . $bb;
    91     } else {
    92         return $bb . $includedtext;
    93     }
     117    return $buttonposition === 'after' ? $includedtext . $bb : $bb . $includedtext;
    94118}
    95119
     
    121145    }
    122146
    123     foreach ($attributes AS $attribute => $value) {
     147    foreach ($attributes as $attribute => $value) {
    124148        if (array_search($attribute, $valid_attributes) === false) {
    125149            unset($attributes[$attribute]);
Note: See TracChangeset for help on using the changeset viewer.