class-event-grouped.php
4 years ago
class-event-single.php
1 year ago
class-event.php
4 years ago
class-events-automatic.php
4 years ago
class-events-custom.php
1 year ago
class-events-edd.php
1 year ago
class-events-fdp.php
4 years ago
class-events-woo.php
1 year ago
interface-events.php
1 year ago
class-events-fdp.php
96 lines
| 1 | <?php |
| 2 | namespace PixelYourSite; |
| 3 | |
| 4 | class EventsFdp extends EventsFactory |
| 5 | { |
| 6 | private $events = array( |
| 7 | 'fdp_view_content', |
| 8 | 'fdp_view_category', |
| 9 | 'fdp_add_to_cart', |
| 10 | 'fdp_purchase', |
| 11 | ); |
| 12 | |
| 13 | |
| 14 | private static $_instance; |
| 15 | |
| 16 | public static function instance() |
| 17 | { |
| 18 | |
| 19 | if (is_null(self::$_instance)) { |
| 20 | self::$_instance = new self(); |
| 21 | } |
| 22 | |
| 23 | return self::$_instance; |
| 24 | |
| 25 | } |
| 26 | |
| 27 | static function getSlug() { |
| 28 | return "fdp"; |
| 29 | } |
| 30 | |
| 31 | private function __construct() |
| 32 | { |
| 33 | add_filter("pys_event_factory",[$this,"register"]); |
| 34 | } |
| 35 | |
| 36 | function register($list) { |
| 37 | $list[] = $this; |
| 38 | return $list; |
| 39 | } |
| 40 | function getEvents() { |
| 41 | return $this->events; |
| 42 | } |
| 43 | |
| 44 | function getCount() |
| 45 | { |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | function isEnabled() |
| 50 | { |
| 51 | return Facebook()->enabled() && PYS()->getOption( 'fdp_enabled' ); |
| 52 | } |
| 53 | |
| 54 | function getOptions() |
| 55 | { |
| 56 | return array(); |
| 57 | } |
| 58 | |
| 59 | function isReadyForFire($event) |
| 60 | { |
| 61 | switch ($event) { |
| 62 | case 'fdp_purchase': |
| 63 | case 'fdp_add_to_cart': |
| 64 | case 'fdp_view_content': { |
| 65 | return is_single() && get_post_type() == 'post'; |
| 66 | } |
| 67 | case 'fdp_view_category': { |
| 68 | return is_category(); |
| 69 | } |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | function getEvent($event) |
| 74 | { |
| 75 | switch ($event) { |
| 76 | case 'fdp_view_category': |
| 77 | case 'fdp_view_content': { |
| 78 | return new SingleEvent($event,EventTypes::$STATIC,'fdp'); |
| 79 | } |
| 80 | case 'fdp_add_to_cart': |
| 81 | case 'fdp_purchase': { |
| 82 | return new SingleEvent($event,EventTypes::$TRIGGER,'fdp'); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * @return EventsFdp |
| 90 | */ |
| 91 | function EventsFdp() { |
| 92 | return EventsFdp::instance(); |
| 93 | } |
| 94 | |
| 95 | EventsFdp(); |
| 96 |