Changeset 3496011
- Timestamp:
- 03/31/2026 09:18:04 PM (4 days ago)
- Location:
- text-to-speech-tts/trunk
- Files:
-
- 3 edited
-
includes/class-mementor-tts-public.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
-
text-to-speech-tts.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
text-to-speech-tts/trunk/includes/class-mementor-tts-public.php
r3495969 r3496011 104 104 // add_filter('the_content', array($this, 'protect_player_html'), 1); 105 105 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. 107 109 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'; 109 111 }); 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); 110 126 111 127 // Clear dynamic CSS cache when player settings are updated … … 646 662 return; 647 663 } 648 664 649 665 // Mark that we've attempted generation for this post 650 666 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 } 651 675 652 676 // Get post content … … 752 776 753 777 $result = $processor->generate_audio($text, $post_id); 754 778 755 779 if ($result && is_string($result)) { 756 780 $this->log_debug('Audio generated successfully: ' . $result); 757 781 } 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); 759 784 } 760 785 } … … 1329 1354 $audio_url = $this->get_audio_url($post_id); 1330 1355 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 1341 1370 // Render player 1342 1371 $player_html = '<div class="mementor-tts-player-container">'; 1343 1372 $player_html .= $this->render_player($audio_url, 'post-' . $post_id); 1344 1373 $player_html .= '</div>'; 1345 1374 1346 1375 // Add player after content 1347 1376 return $content . $player_html; -
text-to-speech-tts/trunk/readme.txt
r3495969 r3496011 6 6 Tested up to: 6.9 7 7 Requires PHP: 7.2 8 Stable tag: 3.1. 48 Stable tag: 3.1.5 9 9 License: GPLv3 or later 10 10 License URI: [https://www.gnu.org/licenses/gpl-3.0.txt](https://www.gnu.org/licenses/gpl-3.0.txt) … … 236 236 237 237 == 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) 238 245 239 246 = 3.1.4 - 2026-03-31 = -
text-to-speech-tts/trunk/text-to-speech-tts.php
r3495969 r3496011 9 9 * Plugin URI: https://mementor.no/en/wordpress-plugins/text-to-speech/ 10 10 * 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. 411 * Version: 3.1.5 12 12 * Author: Mementor AS 13 13 * Author URI: https://mementor.no/en/ … … 26 26 27 27 // Define plugin constants 28 define('MEMENTOR_TTS_VERSION', '3.1. 4');28 define('MEMENTOR_TTS_VERSION', '3.1.5'); 29 29 define('MEMENTOR_TTS_PLUGIN_DIR', plugin_dir_path(__FILE__)); 30 30 define('MEMENTOR_TTS_PLUGIN_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset
for help on using the changeset viewer.