Plugin Directory

Changeset 3496011


Ignore:
Timestamp:
03/31/2026 09:18:04 PM (4 days ago)
Author:
mvirik
Message:

Release 3.1.5

Location:
text-to-speech-tts/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • text-to-speech-tts/trunk/includes/class-mementor-tts-public.php

    r3495969 r3496011  
    104104        // add_filter('the_content', array($this, 'protect_player_html'), 1);
    105105       
    106         // Add a filter for auto-generation feature (enabled when user has a paid plan)
     106        // Auto-generation on page visit is gated by the "Auto-generate on publish" setting.
     107        // Without this check, every paid-plan page visit for a post without audio would
     108        // trigger synchronous generation — burning credits the user never opted into.
    107109        add_filter('mementor_tts_auto_generation_enabled', function() {
    108             return tts_has_paid_plan();
     110            return tts_has_paid_plan() && get_option('mementor_tts_auto_generate_on_publish', '0') === '1';
    109111        });
     112
     113        // Log credit usage after auto-generation (AJAX handler has its own logging)
     114        add_action('mementor_tts_after_generate_audio', function($credits, $post_id, $voice_id) {
     115            if (wp_doing_ajax()) {
     116                return; // AJAX handler logs separately with more detailed metadata
     117            }
     118            $speech_builder = Mementor_TTS_Speech_Builder::get_instance();
     119            $speech_builder->log_generation($post_id, $credits, array(
     120                'text_length' => $credits,
     121                'voice_id'    => $voice_id,
     122                'model_id'    => get_option('mementor_tts_model', 'eleven_flash_v2_5'),
     123                'api_type'    => 'auto',
     124            ));
     125        }, 10, 3);
    110126
    111127        // Clear dynamic CSS cache when player settings are updated
     
    646662            return;
    647663        }
    648        
     664
    649665        // Mark that we've attempted generation for this post
    650666        self::$audio_generation_attempted[$post_id] = true;
     667
     668        // Check if a previous generation attempt failed recently (6-hour cooldown)
     669        // This prevents retrying on every page load for posts with problematic content
     670        $fail_key = 'mementor_tts_gen_fail_' . $post_id;
     671        if (get_transient($fail_key)) {
     672            $this->log_debug('Skipping auto-generation for post ' . $post_id . ' — recent failure cooldown active');
     673            return;
     674        }
    651675
    652676        // Get post content
     
    752776       
    753777        $result = $processor->generate_audio($text, $post_id);
    754        
     778
    755779        if ($result && is_string($result)) {
    756780            $this->log_debug('Audio generated successfully: ' . $result);
    757781        } else {
    758             $this->log_debug('Failed to generate audio');
     782            $this->log_debug('Failed to generate audio for post ' . $post_id . ' — setting 6-hour cooldown');
     783            set_transient($fail_key, time(), 6 * HOUR_IN_SECONDS);
    759784        }
    760785    }
     
    13291354        $audio_url = $this->get_audio_url($post_id);
    13301355        if (!$audio_url) {
    1331             // Generate audio if it doesn't exist
    1332             $this->generate_audio_for_post($post_id);
    1333             $audio_url = $this->get_audio_url($post_id);
    1334         }
    1335        
    1336         // If we still don't have an audio URL, return the content unchanged
    1337         if (!$audio_url) {
    1338             return $content;
    1339         }
    1340        
     1356            // Check if this is a PRO version or if auto-generation is enabled
     1357            $is_pro = tts_has_paid_plan();
     1358            $auto_generation_enabled = apply_filters('mementor_tts_auto_generation_enabled', false);
     1359
     1360            // Only generate audio automatically if this is a PRO feature
     1361            if ($is_pro && $auto_generation_enabled) {
     1362                $this->generate_audio_for_post($post_id);
     1363                $audio_url = $this->get_audio_url($post_id);
     1364            }
     1365            if (!$audio_url) {
     1366                return $content;
     1367            }
     1368        }
     1369
    13411370        // Render player
    13421371        $player_html = '<div class="mementor-tts-player-container">';
    13431372        $player_html .= $this->render_player($audio_url, 'post-' . $post_id);
    13441373        $player_html .= '</div>';
    1345        
     1374
    13461375        // Add player after content
    13471376        return $content . $player_html;
  • text-to-speech-tts/trunk/readme.txt

    r3495969 r3496011  
    66Tested up to: 6.9
    77Requires PHP: 7.2
    8 Stable tag: 3.1.4
     8Stable tag: 3.1.5
    99License: GPLv3 or later
    1010License URI: [https://www.gnu.org/licenses/gpl-3.0.txt](https://www.gnu.org/licenses/gpl-3.0.txt)
     
    236236
    237237== Changelog ==
     238
     239= 3.1.5 - 2026-03-31 =
     240
     241* Fixed: Audio was being auto-generated on every page visit for paid plan users, regardless of settings
     242* Fixed: Auto-generation on page visit now correctly respects the "Auto-generate on publish" setting
     243* Fixed: Credit usage from auto-generation was not logged in the "Credit Usage by Post" table
     244* Fixed: Failed auto-generation attempts no longer retry on every page load (6-hour cooldown)
    238245
    239246= 3.1.4 - 2026-03-31 =
  • text-to-speech-tts/trunk/text-to-speech-tts.php

    r3495969 r3496011  
    99 * Plugin URI:        https://mementor.no/en/wordpress-plugins/text-to-speech/
    1010 * Description:       The easiest Text-to-Speech plugin for WordPress. Add natural voices, boost accessibility, and engage visitors with an instant audio player.
    11  * Version:           3.1.4
     11 * Version:           3.1.5
    1212 * Author:            Mementor AS
    1313 * Author URI:        https://mementor.no/en/
     
    2626
    2727// Define plugin constants
    28 define('MEMENTOR_TTS_VERSION', '3.1.4');
     28define('MEMENTOR_TTS_VERSION', '3.1.5');
    2929define('MEMENTOR_TTS_PLUGIN_DIR', plugin_dir_path(__FILE__));
    3030define('MEMENTOR_TTS_PLUGIN_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset for help on using the changeset viewer.