PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.2.8
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.2.8
3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.2.0 1.2.1 All 156 releases
notificationx / includes / Extensions / Google / YouTube.php

YouTube.php in NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar 3.2.8, at includes/Extensions/Google/YouTube.php

293 lines 14.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * YouTube Extension
4 *
5 * @package NotificationX\Extensions
6 */
7
8 namespace NotificationX\Extensions\Google;
9
10 use NotificationX\Core\Helper;
11 use NotificationX\GetInstance;
12 use NotificationX\Extensions\Extension;
13
14 /**
15 * YouTube Extension
16 * @method static YouTube get_instance($args = null)
17 */
18 class YouTube extends Extension {
19 /**
20 * Instance of YouTube
21 *
22 * @var YouTube
23 */
24 use GetInstance;
25
26 public $priority = 5;
27 public $id = 'youtube';
28 // public $img = NOTIFICATIONX_ADMIN_URL . 'images/extensions/sources/google-rating.png';
29 public $doc_link = 'https://notificationx.com/docs/youtube-video-activities-popups/';
30 public $types = 'video';
31 public $module = 'modules_google_youtube';
32 public $module_priority = 25;
33 public $default_theme = 'youtube_channel-1';
34 public $is_pro = true;
35 public $link_type = 'yt_channel_link';
36 public $api_base = 'https://youtube.googleapis.com/youtube/v3/';
37 public $img = NOTIFICATIONX_ADMIN_URL . 'images/extensions/sources/youtube.png';
38 public $cron_schedule = 'nx_youtube_interval';
39 public $channel_themes = ['youtube_channel-1', 'youtube_channel-2'];
40 public $video_themes = ['youtube_video-1', 'youtube_video-2', 'youtube_video-3', 'youtube_video-4'];
41
42 /**
43 * Initially Invoked when initialized.
44 */
45 public function __construct(){
46 // add_action('admin_init', array($this, 'init_google_client'));
47 parent::__construct();
48 }
49
50 public function init_extension()
51 {
52 $this->title = __('YouTube', 'notificationx');
53 $this->module_title = __('YouTube', 'notificationx');
54 $this->themes = [
55 'channel-1' => [
56 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/youtube/channel-theme-1.png',
57 'template' => [
58 // 'first_param' => 'tag_rated',
59 // 'custom_first_param' => __('Someone', 'notificationx'),
60 'second_param' => __('Follow ', 'notificationx'),
61 'third_param' => 'tag_yt_channel_title',
62 'custom_third_param' => __('Anonymous Title', 'notificationx'),
63 'yt_third_label' => __('YouTube Channel', 'notificationx'),
64 'fourth_param' => 'tag_yt_views',
65 'custom_fourth_param' => '3.4M+',
66 'yt_fourth_label' => __('Views', 'notificationx'),
67 'fifth_param' => 'tag_yt_videos',
68 'custom_fifth_param' => '564',
69 'yt_fifth_label' => __('Videos', 'notificationx'),
70 ],
71 'defaults' => [
72 // 'youtube_type' => 'channel',
73 'image_shape' => 'rounded',
74 'link_type' => 'yt_channel_link',
75 'show_notification_image' => 'yt_thumbnail',
76 'link_button_text' => __('Subscribe Now','notificationx'),
77 'link_button' => true,
78 ],
79 ],
80 'channel-2' => [
81 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/youtube/channel-theme-2.png',
82 'template' => [
83 // 'first_param' => 'tag_rated',
84 // 'custom_first_param' => __('Someone', 'notificationx'),
85 'second_param' => __('Follow ', 'notificationx'),
86 'third_param' => 'tag_yt_channel_title',
87 'custom_third_param' => __('Anonymous Title', 'notificationx'),
88 'yt_third_label' => __('YouTube Channel', 'notificationx'),
89 'fourth_param' => 'tag_yt_views',
90 'custom_fourth_param' => '3.4M+',
91 'fifth_param' => 'tag_yt_videos',
92 'custom_fifth_param' => '564',
93 ],
94 'defaults' => [
95 // 'youtube_type' => 'channel',
96 'image_shape' => 'circle',
97 'link_type' => 'yt_channel_link',
98 'show_notification_image' => 'yt_thumbnail',
99 'link_button_text' => __('Subscribe Now','notificationx'),
100 'link_button' => true,
101 ],
102 ],
103 'video-1' => [
104 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/youtube/video-theme-1.png',
105 'template' => [
106 'second_param' => __('Check our latest video ', 'notificationx'),
107 'third_param' => 'tag_yt_views',
108 'custom_third_param' => '3.4M+',
109 'fourth_param' => 'tag_yt_likes',
110 'custom_fourth_param' => '2.5K',
111 'fifth_param' => 'tag_yt_comments',
112 'custom_fifth_param' => '1K',
113 ],
114 'defaults' => [
115 // 'youtube_type' => 'video',
116 'image_shape' => 'circle',
117 'link_type' => 'yt_video_link',
118 'show_notification_image' => 'yt_thumbnail',
119 'link_button_text' => __('Watch Now','notificationx'),
120 ],
121 ],
122 'video-2' => [
123 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/youtube/video-theme-2.png',
124 'template' => [
125 'second_param' => __('Check our latest video ', 'notificationx'),
126 'third_param' => 'tag_yt_views',
127 'custom_third_param' => '3.4M+',
128 'yt_third_label' => __('Views', 'notificationx'),
129 'fourth_param' => 'tag_yt_likes',
130 'custom_fourth_param' => '2.5K',
131 'yt_fourth_label' => __('Likes', 'notificationx'),
132 'fifth_param' => 'tag_yt_comments',
133 'yt_fifth_label' => __('Comments', 'notificationx'),
134 'custom_fifth_param' => '1K',
135 ],
136 'defaults' => [
137 // 'youtube_type' => 'video',
138 'image_shape' => 'rounded',
139 'link_type' => 'yt_video_link',
140 'show_notification_image' => 'yt_thumbnail',
141 'link_button_text' => __('Watch Now','notificationx'),
142 ],
143 ],
144 'video-3' => [
145 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/youtube/video-theme-3.png',
146 'template' => [
147 'second_param' => __('Check our latest video ', 'notificationx'),
148 'third_param' => 'tag_yt_views',
149 'custom_third_param' => '3.4M+',
150 'fourth_param' => 'tag_yt_likes',
151 'custom_fourth_param' => '2.5K',
152 'fifth_param' => 'tag_yt_comments',
153 'custom_fifth_param' => '1K',
154 ],
155 'defaults' => [
156 // 'youtube_type' => 'video',
157 'image_shape' => 'circle',
158 'link_type' => 'yt_video_link',
159 'show_notification_image' => 'yt_thumbnail',
160 'link_button_text' => __('Watch Now','notificationx'),
161 'link_button' => true,
162 ],
163 ],
164 'video-4' => [
165 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/youtube/video-theme-4.png',
166 'template' => [
167 'second_param' => __('Check our latest video ', 'notificationx'),
168 'third_param' => 'tag_yt_views',
169 'custom_third_param' => '3.4M+',
170 'yt_third_label' => __('Views', 'notificationx'),
171 'fourth_param' => 'tag_yt_likes',
172 'custom_fourth_param' => '2.5K',
173 'yt_fourth_label' => __('Links', 'notificationx'),
174 'fifth_param' => 'tag_yt_comments',
175 'yt_fifth_label' => __('Comments', 'notificationx'),
176 'custom_fifth_param' => '1K',
177 ],
178 'defaults' => [
179 // 'youtube_type' => 'video',
180 'image_shape' => 'rounded',
181 'link_type' => 'yt_video_link',
182 'show_notification_image' => 'yt_thumbnail',
183 'link_button_text' => __('Watch Now','notificationx'),
184 'link_button' => true,
185 ],
186 ],
187 ];
188 $this->res_themes = [
189 'res-channel-1' => [
190 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_youtube/channel-res-theme-1.png',
191 'is_pro' => true,
192 ],
193 'res-channel-2' => [
194 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_youtube/channel-res-theme-2.png',
195 'is_pro' => true,
196 ],
197 'res-video-1' => [
198 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_youtube/channel-res-theme-3.png',
199 'is_pro' => true,
200 ],
201 'res-video-2' => [
202 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_youtube/channel-res-theme-4.png',
203 'is_pro' => true,
204 ],
205 'res-video-3' => [
206 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_youtube/channel-res-theme-5.png',
207 'is_pro' => true,
208 ],
209 'res-video-4' => [
210 'source' => NOTIFICATIONX_ADMIN_URL . 'images/extensions/themes/res_youtube/channel-res-theme-6.png',
211 'is_pro' => true,
212 ],
213 ];
214 $this->templates = [
215 "{$this->id}_channel" => [
216 'third_param' => [
217 'tag_yt_channel_title' => __('Channel Title', 'notificationx'),
218 ],
219 'fourth_param' => [
220 'tag_yt_views' => __('Total Views', 'notificationx'),
221 'tag_none' => __('None', 'notificationx'),
222 ],
223 'fifth_param' => [
224 'tag_yt_videos' => __('Total Videos', 'notificationx'),
225 'tag_none' => __('None', 'notificationx'),
226 ],
227 '_themes' => [
228 "{$this->id}_channel-1",
229 "{$this->id}_channel-2",
230 ],
231 ],
232 "{$this->id}_video" => [
233 'third_param' => [
234 'tag_yt_views' => __('Total Views', 'notificationx'),
235 'tag_none' => __('None', 'notificationx'),
236 ],
237 'fourth_param' => [
238 'tag_yt_likes' => __('Total Likes', 'notificationx'),
239 'tag_none' => __('None', 'notificationx'),
240 ],
241 'fifth_param' => [
242 'tag_yt_comments' => __('Total Comments', 'notificationx'),
243 'tag_none' => __('None', 'notificationx'),
244 ],
245 '_themes' => [
246 "{$this->id}_video-1",
247 "{$this->id}_video-2",
248 "{$this->id}_video-3",
249 "{$this->id}_video-4",
250 ],
251 ],
252 ];
253 $this->popup = [
254 "denyButtonText" => __("<a href='https://notificationx.com/docs/youtube-video-activities-popups/
255 ' target='_blank'>More Info</a>", "notificationx"),
256 "confirmButtonText" => __("<a href='https://notificationx.com/#pricing' target='_blank'>Upgrade to PRO</a>", "notificationx"),
257 "html"=> __('
258 <span>Google reviews provide helpful information and make your business stand out.</span>
259 ', 'notificationx')
260 ];
261 }
262
263 /**
264 * @param array $data
265 * @param array $saved_data
266 * @param stdClass $settings
267 * @return array
268 */
269 public function fallback_data($data, $saved_data, $settings) {
270 $data['title'] = $saved_data['yt_channel_title'];
271 // channel
272 $data['yt_views'] = Helper::nice_number($saved_data['_yt_views']);
273 $data['yt_subscribers'] = Helper::nice_number($saved_data['_yt_subscribers']);
274 $data['yt_videos'] = Helper::nice_number($saved_data['_yt_videos']);
275 // single video
276 $data['yt_likes'] = Helper::nice_number($saved_data['_yt_likes']);
277 $data['yt_comments'] = Helper::nice_number($saved_data['_yt_comments']);
278 $data['yt_favorites'] = Helper::nice_number($saved_data['_yt_favorites']);
279 return $data;
280 }
281
282 public function doc(){
283 $url = admin_url('admin.php?page=nx-settings&tab=tab-api-integrations#google_youtube_settings_section');
284 return sprintf(__('<p>To create YouTube notification popups, make sure that you have configured your <a target="_blank" href="%1$s">YouTube API</a> key, Check out our step-by-step documentation for further assistance. <a target="_blank" href="%2$s">documentation</a>.</p>
285
286 <p>👉NotificationX <a target="_blank" href="%3$s">Integration with Youtube</a>.</p>', 'notificationx'),
287 $url,
288 'https://notificationx.com/docs/collect-youtube-api-key/',
289 'https://notificationx.com/docs/youtube-video-activities-popups/'
290 );
291 }
292 }
293