share-factory.php
117 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Social\Lib\Provider; |
| 4 | |
| 5 | use WP_Social\Lib\Provider\Share\Digg_Sharer; |
| 6 | use WP_Social\Lib\Provider\Share\Email_Sharer; |
| 7 | use WP_Social\Lib\Provider\Share\Facebook_Messenger_Sharer; |
| 8 | use WP_Social\Lib\Provider\Share\Facebook_Sharer; |
| 9 | use WP_Social\Lib\Provider\Share\Kik_Sharer; |
| 10 | use WP_Social\Lib\Provider\Share\Linkedin_Sharer; |
| 11 | use WP_Social\Lib\Provider\Share\No_Provider_Share; |
| 12 | use WP_Social\Lib\Provider\Share\Pinterest_Sharer; |
| 13 | use WP_Social\Lib\Provider\Share\Reddit_Sharer; |
| 14 | use WP_Social\Lib\Provider\Share\Skype_Sharer; |
| 15 | use WP_Social\Lib\Provider\Share\Stumbleupon_Sharer; |
| 16 | use WP_Social\Lib\Provider\Share\Telegram_Sharer; |
| 17 | use WP_Social\Lib\Provider\Share\Trello_Sharer; |
| 18 | use WP_Social\Lib\Provider\Share\Twitter_Sharer; |
| 19 | use WP_Social\Lib\Provider\Share\Viber_Sharer; |
| 20 | use WP_Social\Lib\Provider\Share\Whatsapp_Sharer; |
| 21 | use WP_Social\Lib\Provider\Share\Lineapp_Sharer; |
| 22 | |
| 23 | defined('ABSPATH') || exit; |
| 24 | |
| 25 | class Share_Factory { |
| 26 | |
| 27 | private $provider_type; |
| 28 | private $post_id; |
| 29 | |
| 30 | public $factory; |
| 31 | |
| 32 | |
| 33 | public function __construct($post_id) { |
| 34 | |
| 35 | $this->post_id = intval($post_id); |
| 36 | } |
| 37 | |
| 38 | |
| 39 | public function make($type) { |
| 40 | |
| 41 | $this->provider_type = $type; |
| 42 | |
| 43 | switch($type) { |
| 44 | |
| 45 | case 'facebook' : |
| 46 | $this->factory = new Facebook_Sharer($this->post_id, $type); |
| 47 | break; |
| 48 | |
| 49 | case 'twitter' : |
| 50 | $this->factory = new Twitter_Sharer($this->post_id, $type); |
| 51 | break; |
| 52 | |
| 53 | case 'pinterest' : |
| 54 | $this->factory = new Pinterest_Sharer($this->post_id, $type); |
| 55 | break; |
| 56 | |
| 57 | case 'linkedin' : |
| 58 | $this->factory = new Linkedin_Sharer($this->post_id, $type); |
| 59 | break; |
| 60 | |
| 61 | case 'facebook-messenger' : |
| 62 | $this->factory = new Facebook_Messenger_Sharer($this->post_id, $type); |
| 63 | break; |
| 64 | |
| 65 | case 'kik' : |
| 66 | $this->factory = new Kik_Sharer($this->post_id, $type); |
| 67 | break; |
| 68 | |
| 69 | case 'skype' : |
| 70 | $this->factory = new Skype_Sharer($this->post_id, $type); |
| 71 | break; |
| 72 | |
| 73 | case 'trello' : |
| 74 | $this->factory = new Trello_Sharer($this->post_id, $type); |
| 75 | break; |
| 76 | |
| 77 | case 'viber' : |
| 78 | $this->factory = new Viber_Sharer($this->post_id, $type); |
| 79 | break; |
| 80 | |
| 81 | case 'whatsapp' : |
| 82 | $this->factory = new Whatsapp_Sharer($this->post_id, $type); |
| 83 | break; |
| 84 | |
| 85 | case 'telegram' : |
| 86 | $this->factory = new Telegram_Sharer($this->post_id, $type); |
| 87 | break; |
| 88 | |
| 89 | case 'email' : |
| 90 | $this->factory = new Email_Sharer($this->post_id, $type); |
| 91 | break; |
| 92 | |
| 93 | case 'reddit' : |
| 94 | $this->factory = new Reddit_Sharer($this->post_id, $type); |
| 95 | break; |
| 96 | |
| 97 | case 'digg' : |
| 98 | $this->factory = new Digg_Sharer($this->post_id, $type); |
| 99 | break; |
| 100 | |
| 101 | case 'stumbleupon' : |
| 102 | $this->factory = new Stumbleupon_Sharer($this->post_id, $type); |
| 103 | break; |
| 104 | |
| 105 | case 'lineapp' : |
| 106 | $this->factory = new Lineapp_Sharer($this->post_id, $type); |
| 107 | break; |
| 108 | |
| 109 | default: |
| 110 | $this->factory = new No_Provider_Share(); |
| 111 | |
| 112 | } |
| 113 | |
| 114 | return $this->factory; |
| 115 | } |
| 116 | |
| 117 | } |