FrontendHooksFactory.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\DisplayAsTranslated; |
| 4 | |
| 5 | use function WPML\Container\make; |
| 6 | |
| 7 | class FrontendHooksFactory implements \IWPML_Frontend_Action_Loader { |
| 8 | |
| 9 | public function create() { |
| 10 | global $sitepress; |
| 11 | |
| 12 | $hooks = []; |
| 13 | $isSecondaryLang = $sitepress->get_current_language() !== $sitepress->get_default_language(); |
| 14 | |
| 15 | if ( $isSecondaryLang ) { |
| 16 | |
| 17 | if ( $sitepress->is_display_as_translated_taxonomy( 'product_cat' ) ) { |
| 18 | $hooks[] = make( ProductCatHooks::class ); |
| 19 | } |
| 20 | } |
| 21 | |
| 22 | if ( $sitepress->is_display_as_translated_post_type( 'product' ) ) { |
| 23 | $hooks[] = make( ProductHooks::class ); |
| 24 | } |
| 25 | |
| 26 | return $hooks; |
| 27 | } |
| 28 | } |
| 29 |