PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.7
YayMail – WooCommerce Email Customizer v4.4.7
4.4.7 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 All 58 releases
yaymail / src / Shortcodes / VerifyEmailShortcodes.php

VerifyEmailShortcodes.php in YayMail – WooCommerce Email Customizer 4.4.7, at src/Shortcodes/VerifyEmailShortcodes.php

70 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Shortcodes;
4
5 use YayMail\Utils\SingletonTrait;
6 use YayMail\Abstracts\BaseShortcode;
7
8 /**
9 * Shortcodes for WC core "Confirm email address" email (WC 11.0).
10 * Values come from the WC template args: user_display_name, user_email, verify_url.
11 *
12 * @since 4.4.7
13 * @method: static VerifyEmailShortcodes get_instance()
14 */
15 class VerifyEmailShortcodes extends BaseShortcode {
16 use SingletonTrait;
17
18 protected function __construct() {
19 $this->available_email_ids = [ 'customer_verify_email' ];
20 parent::__construct();
21 }
22
23 public function get_shortcodes() {
24 $shortcodes = [];
25 $shortcodes[] = [
26 'name' => 'yaymail_verify_email_url',
27 'description' => __( 'Confirm Email Address URL', 'yaymail' ),
28 'group' => 'verify_email',
29 'callback' => [ $this, 'yaymail_verify_email_url' ],
30 ];
31 $shortcodes[] = [
32 'name' => 'yaymail_verify_email_user_display_name',
33 'description' => __( 'Customer Display Name', 'yaymail' ),
34 'group' => 'verify_email',
35 'callback' => [ $this, 'yaymail_verify_email_user_display_name' ],
36 ];
37 $shortcodes[] = [
38 'name' => 'yaymail_verify_email_user_email',
39 'description' => __( 'Email Address Being Confirmed', 'yaymail' ),
40 'group' => 'verify_email',
41 'callback' => [ $this, 'yaymail_verify_email_user_email' ],
42 ];
43 return $shortcodes;
44 }
45
46 public function yaymail_verify_email_url( $data ) {
47 $render_data = isset( $data['render_data'] ) ? $data['render_data'] : [];
48 return ! empty( $render_data['verify_url'] ) ? esc_url( $render_data['verify_url'] ) : esc_url( home_url() );
49 }
50
51 public function yaymail_verify_email_user_display_name( $data ) {
52 $render_data = isset( $data['render_data'] ) ? $data['render_data'] : [];
53 if ( ! empty( $render_data['user_display_name'] ) ) {
54 return esc_html( $render_data['user_display_name'] );
55 }
56 // Editor preview: use the current admin.
57 $user = wp_get_current_user();
58 return esc_html( ! empty( $user->first_name ) ? $user->first_name : ( $user->user_login ? $user->user_login : 'John' ) );
59 }
60
61 public function yaymail_verify_email_user_email( $data ) {
62 $render_data = isset( $data['render_data'] ) ? $data['render_data'] : [];
63 if ( ! empty( $render_data['user_email'] ) ) {
64 return esc_html( $render_data['user_email'] );
65 }
66 $user = wp_get_current_user();
67 return esc_html( $user->user_email ? $user->user_email : '[email protected]' );
68 }
69 }
70