PluginProbe ʕ •ᴥ•ʔ
Brevo – Email, SMS, Web Push, Chat, and more. / 3.2.0
Brevo – Email, SMS, Web Push, Chat, and more. v3.2.0
2.9.13 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8 2.9.9 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.9 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.28 3.1.29 3.1.3 3.1.30 3.1.31 3.1.32 3.1.33 3.1.34 3.1.35 3.1.36 3.1.37 3.1.38 3.1.39 3.1.4 3.1.40 3.1.41 3.1.42 3.1.43 3.1.44 3.1.45 3.1.46 3.1.47 3.1.48 3.1.49 3.1.5 3.1.50 3.1.51 3.1.52 3.1.53 3.1.54 3.1.55 3.1.56 3.1.57 3.1.58 3.1.59 3.1.6 3.1.60 3.1.61 3.1.62 3.1.63 3.1.64 3.1.65 3.1.66 3.1.67 3.1.68 3.1.69 3.1.7 3.1.70 3.1.71 3.1.72 3.1.73 3.1.74 3.1.75 3.1.76 3.1.77 3.1.78 3.1.79 3.1.8 3.1.80 3.1.81 3.1.82 3.1.83 3.1.84 3.1.85 3.1.86 3.1.87 3.1.88 3.1.89 3.1.9 3.1.90 3.1.91 3.1.92 3.1.93 3.1.94 3.1.95 3.1.96 3.1.97 3.1.98 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 trunk 1.0 1.5 2.0.8 2.9.10 2.9.11 2.9.12
mailin / inc / push-public.php
mailin / inc Last commit date
templates 1 year ago SendinblueAccount.php 1 year ago SendinblueApiClient.php 1 year ago function.wp_mail.php 8 years ago http-build-url.php 1 year ago index.php 8 years ago mailin.php 3 years ago push-admin.php 1 year ago push-amp.php 1 year ago push-api.php 1 year ago push-httpclient.php 1 year ago push-public.php 1 year ago push-settings.php 1 year ago push-utils.php 1 year ago push-woocommerce.php 1 year ago sendinblue.php 3 years ago sib-api-manager.php 1 year ago sib-form-preview.php 2 years ago sib-sms-code.php 3 years ago table-forms.php 1 year ago
push-public.php
120 lines
1 <?php
2 if (!defined( 'ABSPATH' )) { http_response_code(403); exit(); }
3
4 if ( ! class_exists( 'SIB_Push_Public' ) ) {
5 class SIB_Push_Public {
6 const INSTALLATION_ID_COOKIE_NAME = 'sbjs_installation_id';
7 static function init() {
8
9 // For AMP
10 add_filter( 'the_content', array(__CLASS__, 'the_content'), 10);
11
12 // Cookie
13 try {
14 if (SIB_Push_Utils::get_woocommerce()
15 && SIB_Push_WooCommerce::cart_reminder_enabled()) {
16 add_action('wp_head', array(__CLASS__, 'sib_push_cookie'), 10);
17 }
18 } catch ( SIB_Push_MissingCredentialsException $e ) {
19 // Ignore
20 } catch ( Exception $e ) {
21 SIB_Push_Utils::log_error($e);
22 }
23
24
25 // AMP support through official plugin (https://amp-wp.org/):
26 // https://wordpress.org/plugins/amp/
27 // Display the snippet and top button
28 add_action('amp_post_template_body_open', array(__CLASS__, 'amp_post_template_body_open'));
29
30 // AMP support through alternative plugin (AMP for WP, https://ampforwp.com/):
31 // https://wordpress.org/plugins/accelerated-mobile-pages/
32 // Display the snippet and top button
33 add_filter('ampforwp_after_header', array(__CLASS__, 'ampforwp_after_header'), 10, 3);
34
35 // AMP support, common to both plugins
36 // Add the official support for web push in AMP
37 add_filter('amp_post_template_head', array(__CLASS__, 'amp_post_template_head'), 10, 3);
38 // Add the css
39 add_action('amp_post_template_css', array(__CLASS__, 'amp_post_template_css'));
40 // Display the bottom button
41 add_action('amp_post_template_footer', array(__CLASS__, 'amp_post_template_footer'));
42 }
43
44 public static function amp_post_template_head() {
45 if (SIB_Push_Settings::getSettings()->getDisableAmpTopSubscribeButton()
46 && SIB_Push_Settings::getSettings()->getDisableAmpBottomSubscribeButton()) {
47 return;
48 }
49 ?><script type='text/javascript' src='https://cdn.ampproject.org/v0/amp-web-push-0.1.js' async custom-element="amp-web-push"></script><?php
50 }
51 public static function amp_post_template_body_open() {
52 if (!SIB_Push_Settings::getSettings()->getDisableAmpTopSubscribeButton()
53 || !SIB_Push_Settings::getSettings()->getDisableAmpBottomSubscribeButton()) {
54 echo SIB_Push_Amp::snippet();
55 }
56 if (!SIB_Push_Settings::getSettings()->getDisableAmpTopSubscribeButton()) {
57 echo SIB_Push_Amp::widget();
58 }
59 }
60 public static function amp_post_template_footer() {
61 if (SIB_Push_Settings::getSettings()->getDisableAmpBottomSubscribeButton()) {
62 return;
63 }
64 echo SIB_Push_Amp::widget();
65 }
66 public static function amp_post_template_css() {
67 $plugin_dir_path = plugin_dir_path(__FILE__);
68 $real_path = realpath($plugin_dir_path . '/../css');
69 include ($real_path . '/push-amp.css');
70 }
71 public static function ampforwp_after_header() {
72 if (!SIB_Push_Settings::getSettings()->getDisableAmpTopSubscribeButton()
73 || !SIB_Push_Settings::getSettings()->getDisableAmpBottomSubscribeButton()) {
74 echo SIB_Push_Amp::snippet();
75 }
76 if (!SIB_Push_Settings::getSettings()->getDisableAmpTopSubscribeButton()) {
77 echo SIB_Push_Amp::widget();
78 }
79 }
80 public static function the_content($content) {
81 // Support for transitional mode of the official AMP plugin
82 // Only single post, attachment, page, custom post types
83 if (
84 is_main_query()
85 && in_the_loop()
86 && is_singular() // post, attachment, page, custom post types
87 ) {
88 if (SIB_Push_Utils::is_amp_request()) {
89 $disableTop = SIB_Push_Settings::getSettings()->getDisableAmpTopSubscribeButton();
90 $disableBottom = SIB_Push_Settings::getSettings()->getDisableAmpBottomSubscribeButton();
91 if ($disableBottom && $disableTop) return $content;
92 $file_content = SIB_Push_Amp::widget();
93 return ($disableTop ? '' : $file_content) . $content . ($disableBottom ? '' : $file_content);
94 }
95 }
96
97 return $content;
98 }
99
100 public static function sib_push_cookie() {
101 if (!SIB_Push_Utils::is_push_active()) return;
102 ?>
103 <script>
104 (function() {
105 window.addEventListener('WonderPushEvent', function(event) {
106 if (event.detail.name === 'session') {
107 window.WonderPush.push(function() {
108 window.WonderPush.getInstallationId()
109 .then(function(installationId) {
110 document.cookie = '<?php echo self::INSTALLATION_ID_COOKIE_NAME ?>=' + encodeURIComponent(installationId || '') + '; expires=' + new Date(new Date().getTime() + 86400000).toGMTString() + '; path=/';
111 });
112 });
113 }
114 });
115 })();
116 </script>
117 <?php
118 }
119 }
120 }