PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.1
YayMail – WooCommerce Email Customizer v4.4.1
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
yaymail / src / Integrations / F4ShippingPhoneAndEmailForWooCommerce / F4ShippingPhoneAndEmailForWooCommerce.php

F4ShippingPhoneAndEmailForWooCommerce.php in YayMail – WooCommerce Email Customizer 4.4.1, at src/Integrations/F4ShippingPhoneAndEmailForWooCommerce/F4ShippingPhoneAndEmailForWooCommerce.php

55 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Integrations\F4ShippingPhoneAndEmailForWooCommerce;
4
5 use YayMail\Utils\SingletonTrait;
6
7 /**
8 * F4 Shipping Phone and E-Mail for WooCommerce
9 * Link: https://en-ca.wordpress.org/plugins/f4-woocommerce-shipping-phone-and-e-mail/
10 *
11 * F4ShippingPhoneAndEmailForWooCommerce
12 * * @method static F4ShippingPhoneAndEmailForWooCommerce get_instance()
13 */
14 class F4ShippingPhoneAndEmailForWooCommerce {
15 use SingletonTrait;
16
17 private function __construct() {
18 if ( self::is_3rd_party_installed() ) {
19 $this->initialize_hooks();
20 }
21 }
22
23 public static function is_3rd_party_installed() {
24 return class_exists( 'F4\WCSPE\Core\Hooks' );
25 }
26
27 private function initialize_hooks() {
28 add_filter( 'yaymail_shipping_address_content', [ $this, 'add_shipping_phone_and_email_to_shipping_address' ], 10, 2 );
29 }
30
31 public function add_shipping_phone_and_email_to_shipping_address( $shipping_address, $order ) {
32
33 $shipping_phone = $order->get_shipping_phone();
34 $shipping_email = $order->get_meta( '_shipping_email' );
35
36 if ( ! empty( $shipping_phone ) ) {
37 if ( strpos( $shipping_address, '<a href="tel:' . esc_attr( $shipping_phone ) . '">' ) === false ) {
38 $html_shipping_phone = '<a class="yaymail-shipping-phone" href="tel:' . esc_attr( $shipping_phone ) . '">' . esc_html( $shipping_phone ) . '</a>';
39 $shipping_address = str_replace( $shipping_phone, $html_shipping_phone, $shipping_address );
40 }
41 }
42
43 if ( ! empty( $shipping_email ) ) {
44 if ( strpos( $shipping_address, '<a href="mailto:' . esc_attr( $shipping_email ) . '">' ) === false ) {
45 $html_shipping_email = '<a class="yaymail-shipping-email" href="mailto:' . esc_attr( $shipping_email ) . '">' . esc_html( $shipping_email ) . '</a>';
46 $shipping_address = str_replace( $shipping_email, $html_shipping_email, $shipping_address );
47 }
48 }
49
50 $shipping_address = trim( $shipping_address );
51
52 return $shipping_address;
53 }
54 }
55