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 / ReviewRequestShortcodes.php

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

49 lines 1.4 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\Helpers;
6 use YayMail\Utils\SingletonTrait;
7 use YayMail\Abstracts\BaseShortcode;
8
9 /**
10 * Shortcodes for WC core review request email (`customer_review_request` feature).
11 *
12 * @since 4.4.7
13 * @method: static ReviewRequestShortcodes get_instance()
14 */
15 class ReviewRequestShortcodes extends BaseShortcode {
16 use SingletonTrait;
17
18 protected function __construct() {
19 $this->available_email_ids = [ 'customer_review_request' ];
20 parent::__construct();
21 }
22
23 public function get_shortcodes() {
24 $shortcodes = [];
25 $shortcodes[] = [
26 'name' => 'yaymail_review_order_url',
27 'description' => __( 'Review Order URL', 'yaymail' ),
28 'group' => 'review_request',
29 'callback' => [ $this, 'yaymail_review_order_url' ],
30 ];
31 return $shortcodes;
32 }
33
34 public function yaymail_review_order_url( $data ) {
35 $render_data = isset( $data['render_data'] ) ? $data['render_data'] : [];
36
37 if ( ! empty( $render_data['review_order_url'] ) ) {
38 return esc_url( $render_data['review_order_url'] );
39 }
40
41 $order = Helpers::get_order_from_shortcode_data( $render_data );
42 if ( ! empty( $order ) && function_exists( 'wc_get_review_order_url' ) ) {
43 return esc_url( wc_get_review_order_url( $order ) );
44 }
45
46 return esc_url( home_url() );
47 }
48 }
49