Changeset 3773505
- Timestamp:
- 10/29/2026 04:23:35 PM (73 minutes ago)
- Location:
- text-to-audio/trunk
- Files:
-
- 4 edited
-
includes/TTA_Helper.php (modified) (29 diffs)
-
includes/helpers.php (modified) (9 diffs)
-
readme.txt (modified) (3 diffs)
-
text-to-audio.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
text-to-audio/trunk/includes/TTA_Helper.php
r3761034 r3773505 131 131 } 132 132 133 /** 134 * Check whether a post has any of the excluded tags or categories. 135 * 136 * @param WP_Term[]|false $post_terms Terms attached to the post. 137 * @param string[] $excluded_terms Excluded term slugs from the settings. 138 * @param string $term_type 'tag' or 'category', passed to the filter. 139 * @return bool True when at least one term is excluded. 140 */ 133 141 public static function is_exluded_by_terms($post_terms, $excluded_terms, $term_type = 'tag') 134 142 { … … 153 161 } 154 162 163 /** 164 * Decide whether the player should be shown for a post. 165 * 166 * Checks the single-view context, excluded posts, tags, categories, post types 167 * and post statuses from the settings. Filter: `tta_should_load_button`. 168 * 169 * @param WP_Post|int|string $current_post Post object or ID; defaults to the global post. 170 * @param string $called_from Caller name, passed to the filter. 171 * @param string|null $reason Out-parameter: why the player was not shown. 172 * @return bool True when the player should be shown. 173 */ 155 174 public static function should_load_button($current_post = '', $called_from = 'default', &$reason = null) 156 175 { … … 396 415 } 397 416 417 /** 418 * Get the status of the global post. 419 * 420 * @return string Post status, or an empty string when there is no post. 421 */ 398 422 public static function tts_post_status() 399 423 { … … 533 557 } 534 558 559 /** 560 * Collect settings for active translation plugins the player supports (GTranslate, WPML and others). 561 * 562 * @return array Data keyed by plugin file, only for active plugins. 563 */ 535 564 public static function get_compatible_plugins_data() 536 565 { … … 649 678 } 650 679 680 /** 681 * Get the listening language saved in the settings. 682 * 683 * @param array $plugin_all_settings All plugin settings. 684 * @return string Language code, filtered by `tts_site_language`. 685 */ 651 686 public static function tts_site_language($plugin_all_settings) 652 687 { … … 703 738 } 704 739 740 /** 741 * Build the key an MP3 file URL is stored under for a language and voice. 742 * 743 * @param string $language Language code. 744 * @param string $voice Voice name; added to the key for players above 3. 745 * @return string The file URL key. 746 */ 705 747 public static function tts_get_file_url_key($language, $voice = '') 706 748 { … … 722 764 } 723 765 766 /** 767 * Get the listening voice saved in the settings (players 4 to 6 only). 768 * 769 * @param array $plugin_all_settings All plugin settings. 770 * @return string Voice name with spaces and brackets replaced by underscores. 771 */ 724 772 public static function tts_get_voice($plugin_all_settings) 725 773 { … … 736 784 } 737 785 786 /** 787 * Build the MP3 file name for a post, language and voice. 788 * 789 * @param string $title Title to use; falls back to the post title, then the post ID. 790 * @param string $selectedLang Language code. 791 * @param string $voice Voice name (players 4 to 6). 792 * @param int|string $post_id Post ID; defaults to the post's ID. 793 * @param WP_Post|string $post Post object; defaults to the global post. 794 * @return string File name without extension, filtered by `tts_file_name`. 795 */ 738 796 public static function tts_file_name($title, $selectedLang, $voice = '', $post_id = '', $post = '') 739 797 { … … 1186 1244 } 1187 1245 1246 /** 1247 * Check whether the uploads folder can be written to. 1248 * 1249 * @return bool True when the folder is writable. 1250 */ 1188 1251 public static function is_audio_folder_writable() 1189 1252 { … … 1198 1261 } 1199 1262 1263 /** 1264 * Get the active player ID. Wrapper for the global get_player_id(). 1265 * 1266 * @return int Player ID. 1267 */ 1200 1268 public static function get_player_id() 1201 1269 { … … 1228 1296 } 1229 1297 1298 /** 1299 * Save the default settings when they have not been saved yet. 1300 * 1301 * @return void 1302 */ 1230 1303 public static function set_default_settings() 1231 1304 { … … 1236 1309 } 1237 1310 1311 /** 1312 * Check whether an MP3 file is missing, so it must be made again. 1313 * 1314 * @param string $url File URL. 1315 * @param string $date Post date folder (Y/m/d). 1316 * @param string $file_name Expected file name. 1317 * @return bool True when the file is missing or does not match. 1318 */ 1238 1319 public static function is_file_url_not_exists_and_is_file_empty($url, $date, $file_name) 1239 1320 { … … 1564 1645 } 1565 1646 1647 /** 1648 * Clean text before it is read aloud. 1649 * 1650 * Removes symbols that cannot be spoken, repeated punctuation, spacer dots and 1651 * extra white space. 1652 * 1653 * @param string $inputString Text to clean. 1654 * @return string Cleaned text. 1655 */ 1566 1656 public static function clean_string($inputString) 1567 1657 { … … 1624 1714 1625 1715 1716 /** 1717 * Get the language and voice the player uses for a post. 1718 * 1719 * @param string $language Language from the settings. 1720 * @param string $voice Voice from the settings. 1721 * @param array $plugin_all_settings All plugin settings. 1722 * @param WP_Post $post Current post. 1723 * @return array { language: string, voice: string }, filtered by `tts_player_language_and_player_voice`. 1724 */ 1626 1725 public static function get_player_language_and_player_voice($language, $voice, $plugin_all_settings, $post) 1627 1726 { … … 1640 1739 } 1641 1740 1741 /** 1742 * Check whether the current admin screen is the post editor. 1743 * 1744 * @return bool True on post.php or post-new.php. 1745 */ 1642 1746 public static function is_edit_page() 1643 1747 { … … 1654 1758 } 1655 1759 1760 /** 1761 * Check whether the current admin screen is the AtlasVoice dashboard. 1762 * 1763 * @return bool|null True on the dashboard, false on other admin screens, null outside the admin. 1764 */ 1656 1765 public static function is_text_to_audio_page() 1657 1766 { … … 1762 1871 } 1763 1872 1873 /** 1874 * Check whether Advanced Custom Fields (free or Pro) is active. 1875 * 1876 * @return bool True when ACF is active. 1877 */ 1764 1878 public static function is_acf_active() 1765 1879 { … … 1784 1898 } 1785 1899 1900 /** 1901 * Get the post statuses shown in the admin, cached. 1902 * 1903 * @return array Status labels keyed by status name. 1904 */ 1786 1905 public static function all_post_status() 1787 1906 { … … 1866 1985 } 1867 1986 1987 /** 1988 * Get the public post types, cached. 1989 * 1990 * @return array Post type labels keyed by name, filtered by `tts_get_post_types`. 1991 */ 1868 1992 public static function get_post_types() 1869 1993 { … … 2016 2140 2017 2141 2142 /** 2143 * Get a post's date as the Y/m/d folder used for its MP3 files. 2144 * 2145 * @param WP_Post $post Post object. 2146 * @return string Date in Y/m/d format. 2147 */ 2018 2148 public static function get_post_date($post) 2019 2149 { … … 2024 2154 } 2025 2155 2156 /** 2157 * Check whether the listening language or voice differs from the saved settings. 2158 * 2159 * @param array|object $current_data Listening settings about to be saved. 2160 * @return bool True when a value changed or is missing. 2161 */ 2026 2162 public static function is_listening_lang_or_voice_changed($current_data) 2027 2163 { … … 2061 2197 } 2062 2198 2199 /** 2200 * Check whether the chosen player differs from the saved one. 2201 * 2202 * @param array|object $current_data Customize settings about to be saved. 2203 * @return bool True when the player changed. 2204 */ 2063 2205 public static function is_player_number_changed($current_data) 2064 2206 { … … 2077 2219 } 2078 2220 2221 /** 2222 * Delete a meta key from every post. 2223 * 2224 * @param string $meta_key Meta key to delete. 2225 * @return int|bool Number of rows deleted, or false on error. 2226 */ 2079 2227 public static function delete_post_meta($meta_key = 'tts_is_mp3_file_url_exists') 2080 2228 { … … 2096 2244 } 2097 2245 2246 /** 2247 * Strip HTML, scripts and styles from content and clean it for reading aloud. 2248 * 2249 * @param string $content Raw content. 2250 * @return string Plain text. 2251 */ 2098 2252 public static function clean_content($content) { 2099 2253 … … 2111 2265 } 2112 2266 2267 /** 2268 * Remove a post from the duplicate-post list and clear its saved MP3 URLs. 2269 * 2270 * @param int $post_id Post ID. 2271 * @return void 2272 */ 2113 2273 public static function delete_duplicate_post_ids_if_have( $post_id ){ 2114 2274 $duplicate_post_ids = get_option('tts_duplicate_post_ids', array()); … … 2127 2287 } 2128 2288 2289 /** 2290 * Remove script, style and stylesheet tags from content. 2291 * 2292 * @param string $content HTML content. 2293 * @return string Content without scripts and styles. 2294 */ 2129 2295 public static function remove_js_and_css_from_content($content) { 2130 2296 // Remove <script>...</script> … … 2143 2309 } 2144 2310 2311 /** 2312 * Check whether a post's content contains an AtlasVoice shortcode. 2313 * 2314 * @param WP_Post|object $post Post object. 2315 * @return bool True when [tta_listen_btn] or [atlasvoice] is used. 2316 */ 2145 2317 public static function tts_has_shortcode($post) { 2146 2318 // TTS-261: has_shortcode() runs str_contains() on the content — a non-string … … 2150 2322 } 2151 2323 2324 /** 2325 * Detect the visitor's browser from the user agent. 2326 * 2327 * @return string firefox, chrome, safari, edge, opera or unknown. 2328 */ 2152 2329 public static function detect_browser() { 2153 2330 $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) … … 2171 2348 } 2172 2349 2350 /** 2351 * Get the visitor's IP address, checking proxy and Cloudflare headers first. 2352 * 2353 * @return string IP address, or UNKNOWN. 2354 */ 2173 2355 public static function get_user_ip_address() { 2174 2356 $ip_keys = [ -
text-to-audio/trunk/includes/helpers.php
r3761034 r3773505 219 219 } 220 220 221 /** 222 * Build the player markup for a shortcode, block or the_content. 223 * 224 * @param array $atts Shortcode or block attributes. 225 * @param bool $is_block True when called from the block. 226 * @param string $tag_content Content wrapped by the shortcode. 227 * @return string|null Player HTML, an HTML note for editors, or null in the admin. 228 */ 221 229 function tta_get_button_content($atts, $is_block = false, $tag_content = '') 222 230 { … … 560 568 } 561 569 570 /** 571 * Print the player's data for one post as a JSON payload. 572 * 573 * @param array $params Player values (post, title, content, date, player_number and others). 574 * @param array $plugin_all_settings All plugin settings. 575 * @return void 576 */ 562 577 function get_enqueued_js_object($params, $plugin_all_settings) 563 578 { … … 599 614 'settings' => isset( $plugin_all_settings['settings'] ) ? $plugin_all_settings['settings'] : new \stdClass(), 600 615 'extra' => array( 616 // TTS-359: TTS.settings is filled by the first player only, so a page 617 // with players for several posts needs each player's own post ID here. 618 'post_id' => (int) $post->ID, 601 619 'title' => (string) $title, 602 620 'file_name' => (string) $file_name, … … 682 700 683 701 702 /** 703 * Check whether two texts share at least 80% of their words (Jaccard similarity). 704 * 705 * @param string $text1 First text. 706 * @param string $text2 Second text. 707 * @return bool True when the texts match by 80% or more. 708 */ 684 709 function tts_text_match_80_percent($text1, $text2) 685 710 { … … 931 956 932 957 958 /** 959 * Get the registered shortcodes used in content. 960 * 961 * @param string $content Content to search. 962 * @return string[] Shortcode tag names. 963 */ 933 964 function get_used_shortcodes($content) 934 965 { … … 947 978 } 948 979 980 /** 981 * Get the WordPress locale names, keyed by locale code. 982 * 983 * @return array Locale names keyed by locale code. 984 */ 949 985 function tta_get_default_languages() 950 986 { … … 1081 1117 1082 1118 // Define rtl 1119 /** 1120 * Check whether the site locale is written right to left. 1121 * 1122 * @return bool True for Arabic, Hebrew and Urdu locales. 1123 */ 1083 1124 function tta_is_rtl() 1084 1125 { … … 1153 1194 1154 1195 1196 /** 1197 * Save the default button texts on first use and return them. 1198 * 1199 * @param string $content_read_time Reading time, passed to the filter. 1200 * @return array Button texts, filtered by `tts_initial_button_texts`. 1201 */ 1155 1202 function set_initial_button_texts($content_read_time) 1156 1203 { … … 1188 1235 1189 1236 1237 /** 1238 * Get the active player ID from the settings. 1239 * 1240 * Falls back to player 1 when the saved player is not available, for example 1241 * after Pro was deactivated. Filter: `tts_get_player_id`. 1242 * 1243 * @return int Player ID. 1244 */ 1190 1245 function get_player_id() 1191 1246 { -
text-to-audio/trunk/readme.txt
r3761034 r3773505 6 6 Tested up to: 7.1 7 7 Requires PHP: 7.4 8 Stable tag: 2.3.2 28 Stable tag: 2.3.23 9 9 License: GPLv3 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.txt … … 396 396 397 397 398 = 2.3.23 ( 29 Oct 2026 ) = 399 Fixed : On a page with audio players for more than one post, each player now tells AtlasVoice Pro which post it belongs to. 400 Changed : Behind-the-scenes tidy-up of the code documentation. 401 398 402 = 2.3.22 ( 23 Oct 2026 ) = 399 403 Fixed : On iPhone the player keeps reading the whole post instead of stopping after the first paragraph. … … 569 573 == Upgrade Notice == 570 574 575 = 2.3.23 = 576 Helps pages with audio players for more than one post when AtlasVoice Pro is active, plus a behind-the-scenes tidy-up. Safe to update. 577 571 578 = 2.3.22 = 572 579 Fixes the player on iPhone and Android phones (stopping after the first paragraph, staying silent, or an empty button) and makes Staging and Go live easier to see. Recommended for all sites. -
text-to-audio/trunk/text-to-audio.php
r3761034 r3773505 16 16 * Plugin URI: https://atlasaidev.com/ 17 17 * Description: The most user-friendly Text-to-Speech Accessibility plugin. Just install and automatically add a Text to Audio player to your WordPress site! 18 * Version: 2.3.2 218 * Version: 2.3.23 19 19 * Author: AtlasAiDev 20 20 * Author URI: http://atlasaidev.com/ … … 173 173 { 174 174 if (!defined('TEXT_TO_AUDIO_VERSION')) { 175 define('TEXT_TO_AUDIO_VERSION', apply_filters('tts_version', '2.3.2 2'));175 define('TEXT_TO_AUDIO_VERSION', apply_filters('tts_version', '2.3.23')); 176 176 } 177 177
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)