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 | public static function getInstance() |
| 11 | { |
| 12 | if (null == self::$instance) { |
| 13 | self::$instance = new self; |
| 14 | self::$instance->doHooks(); |
| 15 | } |
| 16 | return self::$instance; |
| 17 | } |
| 18 | |
| 19 | private function doHooks(){ |
| 20 | global $sitepress; |
| 21 | |
| 22 | if ($sitepress !== null && get_class($sitepress) === 'SitePress') { |
| 23 | $settings = $sitepress->get_setting('custom_posts_sync_option', array()); |
| 24 | $post_type = 'whatsapp-accounts'; |
| 25 | if (isset($settings[$post_type]) && ($settings[$post_type] == 1 || $settings[$post_type] == 2)) { |
| 26 | $this->isActive = true; |
| 27 | add_filter('njt_wa_get_post_type', array($this, 'getPostType'), 10, 1); |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | public function getPostType($args) |
| 33 | { |
| 34 | $args['suppress_filters'] = false; |
| 35 | return $args; |
| 36 | } |
| 37 | } |
| 38 |