PluginProbe ʕ •ᴥ•ʔ
OttoKit: All-in-One Automation Platform / 1.1.32
OttoKit: All-in-One Automation Platform v1.1.32
1.1.32 1.1.31 1.1.30 1.1.29 1.1.28 1.1.27 1.1.9 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.47 1.0.48 1.0.49 1.0.50 1.0.51 1.0.52 1.0.53 1.0.54 1.0.55 1.0.56 1.0.57 1.0.58 1.0.59 1.0.60 1.0.61 1.0.62 1.0.63 1.0.64 1.0.65 1.0.66 1.0.67 1.0.68 1.0.69 1.0.7 1.0.70 1.0.71 1.0.72 1.0.73 1.0.74 1.0.75 1.0.76 1.0.77 1.0.78 1.0.79 1.0.8 1.0.80 1.0.81 1.0.82 1.0.83 1.0.84 1.0.85 1.0.86 1.0.87 1.0.88 1.0.89 1.0.9 1.0.90 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.20 1.1.21 1.1.22 1.1.23 1.1.24 1.1.25 1.1.26 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
suretriggers / src / Integrations / eventon / eventon.php
suretriggers / src / Integrations / eventon Last commit date
actions 2 months ago triggers 2 months ago eventon.php 2 months ago
eventon.php
168 lines
1 <?php
2 /**
3 * EventOn integrations file
4 *
5 * @since 1.0.0
6 * @package SureTrigger
7 */
8
9 namespace SureTriggers\Integrations\EventOn;
10
11 use SureTriggers\Controllers\IntegrationsController;
12 use SureTriggers\Integrations\Integrations;
13 use SureTriggers\Traits\SingletonLoader;
14
15 /**
16 * Class EventOn
17 *
18 * @package SureTriggers\Integrations\EventOn
19 */
20 class EventOn extends Integrations {
21
22 use SingletonLoader;
23
24 /**
25 * ID
26 *
27 * @var string
28 */
29 protected $id = 'EventOn';
30
31 /**
32 * SureTrigger constructor.
33 */
34 public function __construct() {
35 $this->name = __( 'EventOn', 'suretriggers' );
36 $this->description = __( 'Event calendar plugin for WordPress.', 'suretriggers' );
37 $this->icon_url = SURE_TRIGGERS_URL . 'assets/icons/eventon.svg';
38
39 parent::__construct();
40 }
41
42 /**
43 * Get event context data.
44 *
45 * @param int $event_id Event Post ID.
46 *
47 * @return array
48 */
49 public static function get_event_context( $event_id ) {
50 $event_post = get_post( $event_id );
51 if ( ! $event_post || 'ajde_events' !== $event_post->post_type ) {
52 return [];
53 }
54
55 $context = [
56 'event_id' => $event_id,
57 'event_title' => $event_post->post_title,
58 'event_description' => $event_post->post_content,
59 'event_status' => $event_post->post_status,
60 'event_url' => get_permalink( $event_id ),
61 'featured_image' => get_the_post_thumbnail_url( $event_id, 'full' ),
62 ];
63
64 // Event subtitle.
65 $subtitle = get_post_meta( $event_id, 'evcal_subtitle', true );
66 $context['event_subtitle'] = is_string( $subtitle ) ? $subtitle : '';
67
68 // Unix start/end timestamps.
69 $unix_start = get_post_meta( $event_id, 'evcal_srow', true );
70 $unix_end = get_post_meta( $event_id, 'evcal_erow', true );
71
72 $context['event_start_unix'] = is_numeric( $unix_start ) ? (int) $unix_start : 0;
73 $context['event_end_unix'] = is_numeric( $unix_end ) ? (int) $unix_end : 0;
74
75 if ( is_numeric( $unix_start ) && (int) $unix_start > 0 ) {
76 $context['event_start_date'] = gmdate( 'Y-m-d', (int) $unix_start );
77 $context['event_start_time'] = gmdate( 'H:i:s', (int) $unix_start );
78 } else {
79 $context['event_start_date'] = '';
80 $context['event_start_time'] = '';
81 }
82
83 if ( is_numeric( $unix_end ) && (int) $unix_end > 0 ) {
84 $context['event_end_date'] = gmdate( 'Y-m-d', (int) $unix_end );
85 $context['event_end_time'] = gmdate( 'H:i:s', (int) $unix_end );
86 } else {
87 $context['event_end_date'] = '';
88 $context['event_end_time'] = '';
89 }
90
91 // All day flag.
92 $all_day = get_post_meta( $event_id, 'evcal_allday', true );
93 $context['event_all_day'] = ( 'yes' === $all_day ) ? 'yes' : 'no';
94
95 // Featured / internal status.
96 $featured = get_post_meta( $event_id, '_featured', true );
97 $context['event_featured'] = ( 'yes' === $featured ) ? 'yes' : 'no';
98
99 $internal_status = get_post_meta( $event_id, '_status', true );
100 $context['event_internal_status'] = is_string( $internal_status ) ? $internal_status : '';
101
102 // Timezone.
103 $timezone = get_post_meta( $event_id, 'evo_event_timezone', true );
104 $context['event_timezone'] = is_string( $timezone ) ? $timezone : '';
105
106 // External / learn more links.
107 $exlink = get_post_meta( $event_id, 'evcal_exlink', true );
108 $context['event_exlink'] = is_string( $exlink ) ? $exlink : '';
109
110 $lmlink = get_post_meta( $event_id, 'evcal_lmlink', true );
111 $context['event_lmlink'] = is_string( $lmlink ) ? $lmlink : '';
112
113 // Event color.
114 $color = get_post_meta( $event_id, 'evcal_event_color', true );
115 $context['event_color'] = is_string( $color ) ? $color : '';
116
117 // Virtual event.
118 $virtual_url = get_post_meta( $event_id, '_vir_url', true );
119 $context['event_virtual_url'] = is_string( $virtual_url ) ? $virtual_url : '';
120
121 // Location taxonomy.
122 $location_terms = wp_get_post_terms( $event_id, 'event_location' );
123 if ( is_array( $location_terms ) && ! empty( $location_terms ) ) {
124 $first = $location_terms[0];
125 $context['location_id'] = $first->term_id;
126 $context['location_name'] = $first->name;
127 $context['location_slug'] = $first->slug;
128 }
129
130 // Organizer taxonomy.
131 $organizer_terms = wp_get_post_terms( $event_id, 'event_organizer' );
132 if ( is_array( $organizer_terms ) && ! empty( $organizer_terms ) ) {
133 $first = $organizer_terms[0];
134 $context['organizer_id'] = $first->term_id;
135 $context['organizer_name'] = $first->name;
136 $context['organizer_slug'] = $first->slug;
137 }
138
139 // Event type taxonomy (primary).
140 if ( taxonomy_exists( 'event_type' ) ) {
141 $type_terms = wp_get_post_terms( $event_id, 'event_type' );
142 if ( is_array( $type_terms ) && ! empty( $type_terms ) ) {
143 $type_names = [];
144 foreach ( $type_terms as $term ) {
145 $type_names[] = $term->name;
146 }
147 $context['event_type_names'] = implode( ', ', $type_names );
148 }
149 }
150
151 $author_id = (int) $event_post->post_author;
152 $context['event_author_id'] = $author_id;
153
154 return $context;
155 }
156
157 /**
158 * Is Plugin depended on plugin is installed or not.
159 *
160 * @return bool
161 */
162 public function is_plugin_installed() {
163 return class_exists( 'EventON' );
164 }
165 }
166
167 IntegrationsController::register( EventOn::class );
168