-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail-text-customizer-for-woocommerce.php
executable file
·111 lines (80 loc) · 2.84 KB
/
email-text-customizer-for-woocommerce.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/*
* Plugin Name: Email Text Customizer for WooCommerce
* Plugin URI: https://wordpress.org/plugins/email-text-customizer-for-woocommerce
* Description: Allows you to customize the text of all WooCommerce emails without having to delve into template code.
* Author: EnigmaWeb
* Author URI: https://www.enigmaweb.com.au
* Version: 1.0.2
* Text Domain: woo-email-text-customizer
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
} // Exit if accessed directly
/**
* Class WETC
*/
class WETC {
/**
* Do the magic
*/
public function __construct() {
/** WC Email Classes Modifier */
add_filter( 'woocommerce_email_classes', array( $this, 'WCEmailClassesModifier' ) );
/** Copy WC Email Modified Templates on Activation */
register_activation_hook( __FILE__, array( $this, 'WCEmailTemplateCopier' ) );
}
/**
* Copy WC Email Modified Templates
*/
public function WCEmailTemplateCopier() {
// Source & Destination path
$src = plugin_dir_path( __FILE__ ) . 'assets/emails/';
$dst = get_stylesheet_directory() . '/woocommerce/emails/';
// If Woo emails templates dir is not exists
if ( ! file_exists( $dst ) ) {
// Create directories
mkdir( get_stylesheet_directory() . '/woocommerce/' );
mkdir( get_stylesheet_directory() . '/woocommerce/emails/' );
}
// If Woo emails templates dir exists
if ( is_dir( $src ) ) {
if ( $dir = opendir( $src ) ) {
while ( ( $file = readdir( $dir ) ) !== false ) {
if ( $file != '.' && $file != '..' ) {
if ( file_exists( $dst . $file ) ) {
unlink( $dst . $file );
}
// Copy WC email templates files
copy( $src . $file, $dst . $file );
}
}
closedir( $dir );
}
}
}
/**
* WC Default Email Classes Modifier
*
* @param array $email_classes
*
* @return mixed
*/
public function WCEmailClassesModifier( $email_classes ) {
require ('assets/wetc-wc-email-classes-modifier.php');
$email_classes['WC_Email_New_Order'] = new WETCNewOrder();
$email_classes['WC_Email_Cancelled_Order'] = new WETCCancelledOrder();
$email_classes['WC_Email_Failed_Order'] = new WETCFailedOrder();
$email_classes['WC_Email_Customer_On_Hold_Order'] = new WETCOrderOnHold();
$email_classes['WC_Email_Customer_Processing_Order'] = new WETCProcessingOrder();
$email_classes['WC_Email_Customer_Completed_Order'] = new WETCCompletedOrder();
$email_classes['WC_Email_Customer_Refunded_Order'] = new WETCRefundedOrder();
$email_classes['WC_Email_Customer_Invoice'] = new WETCInvoice();
$email_classes['WC_Email_Customer_Note'] = new WETCNote();
$email_classes['WC_Email_Customer_Reset_Password'] = new WETCResetPassword();
$email_classes['WC_Email_Customer_New_Account'] = new WETCNewAccount();
return $email_classes;
}
}
/** Main Plugin Instance */
$WETC = new WETC;