PluginProbe
YayMail – WooCommerce Email Customizer / 2.1.5
YayMail – WooCommerce Email Customizer v2.1.5
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 / includes / Helper / Helper.php

Helper.php in YayMail – WooCommerce Email Customizer 2.1.5, at includes/Helper/Helper.php

58 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Helper;
4
5 defined( 'ABSPATH' ) || exit;
6 class Helper {
7
8
9 public static function checkNonce() {
10 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( $_POST['nonce'] ) : '';
11 if ( ! wp_verify_nonce( $nonce, 'email-nonce' ) ) {
12 wp_send_json_error( array( 'mess' => 'Nonce is invalid' ) );
13 }
14 }
15
16 public static function sanitize_array( $var ) {
17 if ( is_array( $var ) ) {
18 return array_map( 'self::sanitize_array', $var );
19 } else {
20 return is_scalar( $var ) ? wp_kses_allowed_html( $var ) : $var;
21 }
22 }
23
24 public static function unsanitize_array( $var ) {
25 if ( is_array( $var ) ) {
26 return array_map( 'self::unsanitize_array', $var );
27 } else {
28 return html_entity_decode( $var, ENT_QUOTES, 'UTF-8' );
29 }
30 }
31
32 // Fix bugs for only Customer Invoice (core code of Woocommerce)
33 public static function getCustomerInvoiceSubject( $objEmail ) {
34 if ( $objEmail->object && $objEmail->object->has_status( array( 'completed', 'processing' ) ) ) {
35 $subject = $objEmail->get_option( 'subject_paid', $objEmail->get_default_subject( true ) );
36 return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $objEmail->format_string( $subject ), $objEmail->object, $objEmail );
37 }
38
39 $subject = $objEmail->get_option( 'subject', $objEmail->get_default_subject() );
40 return apply_filters( 'woocommerce_email_subject_customer_invoice', $objEmail->format_string( $subject ), $objEmail->object, $objEmail );
41 }
42
43 // Get Subject for email WC_Email_New_Booking (Woo Bookings plugin)
44 public static function getNewBookingSubject( $objEmail ) {
45 $subject = $objEmail->get_option( 'subject', $objEmail->subject );
46 return apply_filters( 'woocommerce_email_subject_' . $objEmail->id, $objEmail->format_string( $subject ), $objEmail->object );
47 }
48
49 // Check Key Exist
50 public static function checkKeyExist( $array, $key, $valueDefault ) {
51 if ( isset( $array->$key ) ) {
52 return $key;
53 } else {
54 return $valueDefault;
55 }
56 }
57 }
58