WPML.php
38 lines
| 1 | <?php |
| 2 | namespace NTA_WhatsApp\Support; |
| 3 | |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | class WPML { |
| 7 | |
| 8 | protected static $instance = null; |
| 9 | |
| 10 | protected $isActive = false; |
| 11 | |
| 12 | public static function getInstance() { |
| 13 | if ( null === self::$instance ) { |
| 14 | self::$instance = new self(); |
| 15 | self::$instance->doHooks(); |
| 16 | } |
| 17 | return self::$instance; |
| 18 | } |
| 19 | |
| 20 | private function doHooks() { |
| 21 | global $sitepress; |
| 22 | |
| 23 | if ( $sitepress !== null && get_class( $sitepress ) === 'SitePress' ) { |
| 24 | $settings = $sitepress->get_setting( 'custom_posts_sync_option', array() ); |
| 25 | $post_type = 'whatsapp-accounts'; |
| 26 | if ( isset( $settings[ $post_type ] ) && ( $settings[ $post_type ] == 1 || $settings[ $post_type ] == 2 ) ) { |
| 27 | $this->isActive = true; |
| 28 | add_filter( 'njt_wa_get_post_type', array( $this, 'getPostType' ), 10, 1 ); |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | public function getPostType( $args ) { |
| 34 | $args['suppress_filters'] = false; |
| 35 | return $args; |
| 36 | } |
| 37 | } |
| 38 |