| @@ -6,9 +6,9 @@ | ||
| 6 | 6 | * Author: wpLingua Translation Service |
| 7 | 7 | * Author URI: https://wplingua.com/ |
| 8 | 8 | * Text Domain: wplingua |
| 9 | 9 | * Domain Path: /languages/ |
| 10 | - * Version: 2.14.0 | |
| 10 | + * Version: 3.0.0 | |
| 11 | 11 | * Requires PHP: 7.4 |
| 12 | 12 | * License: GPL v2 or later |
| 13 | 13 | * License URI: https://www.gnu.org/licenses/gpl-2.0.html |
| 14 | 14 | */ |
| @@ -23,9 +23,9 @@ | ||
| 23 | 23 | // Define wpLingua constants |
| 24 | 24 | define( 'WPLNG_API_URL', 'https://api.wplingua.com' ); |
| 25 | 25 | define( 'WPLNG_API_VERSION', '3.0' ); |
| 26 | 26 | define( 'WPLNG_API_SSLVERIFY', true ); |
| 27 | -define( 'WPLNG_PLUGIN_VERSION', '2.14.0' ); | |
| 27 | +define( 'WPLNG_PLUGIN_VERSION', '3.0.0' ); | |
| 28 | 28 | define( 'WPLNG_PLUGIN_FILE', plugin_basename( __FILE__ ) ); |
| 29 | 29 | define( 'WPLNG_PLUGIN_DIR', __DIR__ ); |
| 30 | 30 | define( 'WPLNG_CACHE_DIR', WP_CONTENT_DIR . '/wplingua-cache' ); |
| 31 | 31 | define( 'WPLNG_PHP_MIN_VERSION', '7.4' ); |
| @@ -38,8 +38,9 @@ | ||
| 38 | 38 | defined( 'WPLNG_DEBUG_JSON' ) || define( 'WPLNG_DEBUG_JSON', false ); |
| 39 | 39 | defined( 'WPLNG_DEBUG_AJAX' ) || define( 'WPLNG_DEBUG_AJAX', false ); |
| 40 | 40 | defined( 'WPLNG_DEBUG_REST' ) || define( 'WPLNG_DEBUG_REST', false ); |
| 41 | 41 | defined( 'WPLNG_DEBUG_BEAT' ) || define( 'WPLNG_DEBUG_BEAT', false ); |
| 42 | +defined( 'WPLNG_DEBUG_MAIL' ) || define( 'WPLNG_DEBUG_MAIL', false ); | |
| 42 | 43 | defined( 'WPLNG_DEBUG_XML' ) || define( 'WPLNG_DEBUG_XML', false ); |
| 43 | 44 | |
| 44 | 45 | |
| 45 | 46 | // Load all needed PHP files |
| @@ -105,11 +106,13 @@ | ||
| 105 | 106 | // Update version number in DB |
| 106 | 107 | update_option( 'wplng_version', WPLNG_PLUGIN_VERSION, true ); |
| 107 | 108 | |
| 108 | 109 | // Clear all wpLingua cache |
| 109 | - wplng_clear_translations_cache(); | |
| 110 | - wplng_clear_slugs_cache(); | |
| 110 | + delete_option( 'wplng_cached_translations' ); | |
| 111 | + delete_option( 'wplng_cached_slugs' ); | |
| 112 | + delete_option( 'wplng_api_key_data' ); | |
| 111 | 113 | wplng_clear_folder_cache(); |
| 114 | + wplng_clear_website_cache(); | |
| 112 | 115 | |
| 113 | 116 | // Clear old cache method (version <= 2.12.3) |
| 114 | 117 | delete_transient( 'wplng_cached_translations' ); |
| 115 | 118 | delete_transient( 'wplng_cached_slugs' ); |
| @@ -129,10 +132,10 @@ | ||
| 129 | 132 | add_action( 'admin_notices', 'wplng_admin_notice_incompatible_plain_permalink', 1 ); |
| 130 | 133 | |
| 131 | 134 | // Return if incompatibility is detected |
| 132 | 135 | if ( ! empty( wplng_get_incompatible_plugins() ) |
| 133 | - || ( is_multisite() | |
| 134 | - && ! apply_filters( 'wplng_bypass_multisite_incompatibility', false ) | |
| 136 | + || ( is_multisite() | |
| 137 | + && ! apply_filters( 'wplng_bypass_multisite_incompatibility', false ) | |
| 135 | 138 | ) |
| 136 | 139 | || ( version_compare( PHP_VERSION, WPLNG_PHP_MIN_VERSION ) < 0 ) |
| 137 | 140 | || ! wplng_htaccess_is_valid() |
| 138 | 141 | || empty( get_option( 'permalink_structure' ) ) |
| @@ -174,8 +177,11 @@ | ||
| 174 | 177 | */ |
| 175 | 178 | |
| 176 | 179 | // Add menu in back office |
| 177 | 180 | add_action( 'admin_menu', 'wplng_create_menu' ); |
| 181 | + add_filter( 'parent_file', 'wplng_option_page_parent_file' ); | |
| 182 | + add_filter( 'submenu_file', 'wplng_option_page_submenu_file' ); | |
| 183 | + add_action( 'admin_head', 'wplng_option_page_hide_submenu' ); | |
| 178 | 184 | |
| 179 | 185 | // Add admin Bar menu |
| 180 | 186 | add_action( 'admin_bar_menu', 'wplng_admin_bar_menu', 81 ); |
| 181 | 187 | add_action( 'admin_bar_menu', 'wplng_admin_bar_edit', 81 ); |
| @@ -190,12 +196,17 @@ | ||
| 190 | 196 | add_action( 'admin_enqueue_scripts', 'wplng_option_page_switcher_assets' ); |
| 191 | 197 | add_action( 'admin_enqueue_scripts', 'wplng_option_page_exclusions_assets' ); |
| 192 | 198 | add_action( 'admin_enqueue_scripts', 'wplng_option_page_dictionary_assets' ); |
| 193 | 199 | add_action( 'admin_enqueue_scripts', 'wplng_option_page_link_media_assets' ); |
| 200 | + add_action( 'admin_enqueue_scripts', 'wplng_option_page_mail_assets' ); | |
| 194 | 201 | |
| 195 | 202 | // Update flags URL |
| 196 | 203 | add_action( 'update_option_wplng_flags_style', 'wplng_options_switcher_update_flags_style', 10, 2 ); |
| 197 | 204 | |
| 205 | + // Update translations on dictionary changes | |
| 206 | + add_action( 'update_option_wplng_dictionary_entries', 'wplng_on_dictionary_entries_updated', 10, 2 ); | |
| 207 | + add_action( 'wp_ajax_wplng_dictionary_update_translations', 'wplng_ajax_dictionary_update_translations' ); | |
| 208 | + | |
| 198 | 209 | // Reset API data on API key changing |
| 199 | 210 | add_action( 'update_option_wplng_api_key', 'wplng_on_update_option_wplng_api_key', 10, 2 ); |
| 200 | 211 | |
| 201 | 212 | // Add edit link on page and post list |
| @@ -201,8 +212,11 @@ | ||
| 201 | 212 | // Add edit link on page and post list |
| 202 | 213 | add_filter( 'page_row_actions', 'wplng_row_edit_translation_link', 10, 2 ); |
| 203 | 214 | add_filter( 'post_row_actions', 'wplng_row_edit_translation_link', 10, 2 ); |
| 204 | 215 | |
| 216 | + // Notice for PRO users | |
| 217 | + add_action( 'admin_notices', 'wplng_admin_notice_pro', 1 ); | |
| 218 | + | |
| 205 | 219 | /** |
| 206 | 220 | * wplng_translation : CPT, taxo, meta |
| 207 | 221 | */ |
| 208 | 222 | |
| @@ -341,8 +355,11 @@ | ||
| 341 | 355 | add_action( 'init', 'wplng_ob_start', 1 ); |
| 342 | 356 | |
| 343 | 357 | // Redirect page if is called with an untranslate slug |
| 344 | 358 | add_action( 'template_redirect', 'wplng_redirect_translated_slug' ); |
| 359 | + | |
| 360 | + // Translate WooCommerce cart URL | |
| 361 | + add_filter( 'woocommerce_get_cart_url', 'wplng_url_translate' ); | |
| 345 | 362 | |
| 346 | 363 | /** |
| 347 | 364 | * Generate JSON translation on the fly for wp-i18n.js |
| 348 | 365 | */ |