← All changes
|
inc/compatibility/multilingual/providers/wpml-provider.php
+27
-0
2.11.1
→
2.12.8
View file →
| @@ -14,8 +14,10 @@ | ||
| 14 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | 15 | exit; // Exit if accessed directly. |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- This adapter exists solely to call WPML's own hooks (wpml_*); their names must match WPML exactly to integrate. | |
| 19 | + | |
| 18 | 20 | /** |
| 19 | 21 | * WPML_Provider. |
| 20 | 22 | * |
| 21 | 23 | * Implements {@see Provider} on top of WPML's filter/action API. |
| @@ -305,8 +307,33 @@ | ||
| 305 | 307 | return $value; |
| 306 | 308 | } |
| 307 | 309 | $translated = apply_filters( 'wpml_translate_string', $value, $name, $package ); |
| 308 | 310 | return is_string( $translated ) ? $translated : $value; |
| 311 | + } | |
| 312 | + | |
| 313 | + /** | |
| 314 | + * {@inheritDoc} | |
| 315 | + * | |
| 316 | + * Removes the package and its translations from WPML via the | |
| 317 | + * `wpml_delete_package` action, keyed by the package name + kind. | |
| 318 | + * | |
| 319 | + * @param array<string,string> $package Package descriptor. | |
| 320 | + * @since 2.12.3 | |
| 321 | + * @return void | |
| 322 | + */ | |
| 323 | + public function delete_package( array $package ): void { | |
| 324 | + if ( ! $this->supports_packages() ) { | |
| 325 | + return; | |
| 326 | + } | |
| 327 | + | |
| 328 | + $name = $package['name'] ?? ''; | |
| 329 | + $kind = $package['kind'] ?? ''; | |
| 330 | + | |
| 331 | + if ( '' === $name || '' === $kind ) { | |
| 332 | + return; | |
| 333 | + } | |
| 334 | + | |
| 335 | + do_action( 'wpml_delete_package', $name, $kind ); | |
| 309 | 336 | } |
| 310 | 337 | |
| 311 | 338 | /** |
| 312 | 339 | * Build the active-language list from the most reliable WPML surface available. |