BeforeHooks.php
1 week ago
class-wcml-setup-handlers.php
1 week ago
class-wcml-setup-ui.php
1 week ago
class-wcml-setup.php
1 week ago
BeforeHooks.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\Setup; |
| 4 | |
| 5 | use WPML\FP\Fns; |
| 6 | |
| 7 | class BeforeHooks implements \IWPML_Backend_Action, \IWPML_Frontend_Action, \IWPML_DIC_Action { |
| 8 | |
| 9 | private $woocommerce_wpml; |
| 10 | |
| 11 | public function __construct( \woocommerce_wpml $woocommerce_wpml ) { |
| 12 | $this->woocommerce_wpml = $woocommerce_wpml; |
| 13 | } |
| 14 | |
| 15 | public function add_hooks() { |
| 16 | $pendingWizard = ! $this->woocommerce_wpml->get_setting( 'set_up_wizard_run' ); |
| 17 | if ( $pendingWizard ) { |
| 18 | add_filter( 'get_translatable_documents_all', [ __CLASS__, 'blockProductTranslation' ] ); |
| 19 | |
| 20 | if ( $this->isStringTranslationActive() ) { |
| 21 | add_filter( 'wpml_wizard_display_wcml_messages', Fns::always( true ) ); |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | public static function blockProductTranslation( $translatablePostTypes ) { |
| 27 | unset( $translatablePostTypes['product'], $translatablePostTypes['product_variation'] ); |
| 28 | return $translatablePostTypes; |
| 29 | } |
| 30 | |
| 31 | private function isStringTranslationActive(): bool { |
| 32 | return defined( 'WPML_ST_VERSION' ); |
| 33 | } |
| 34 | } |
| 35 |