This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * Class for our custom shipping email |
||
4 | * |
||
5 | * @package PrintCenter\Email |
||
6 | * @since 1.0.0 |
||
7 | */ |
||
8 | |||
9 | |||
10 | // Exit if accessed directly |
||
11 | if( ! defined( 'ABSPATH' ) ) { |
||
12 | exit; |
||
13 | } |
||
14 | |||
15 | |||
16 | /** |
||
17 | * Custom shipping email |
||
18 | * |
||
19 | * @since 1.0.0 |
||
20 | */ |
||
21 | class WC_Order_Shipped_Email extends WC_Email { |
||
22 | |||
23 | |||
24 | /** |
||
25 | * Get things started |
||
26 | * |
||
27 | * @access public |
||
28 | * @since 1.0.0 |
||
29 | */ |
||
30 | public function __construct() { |
||
31 | $this->id = 'wc_order_shipped'; |
||
32 | $this->title = __( 'Order Shipped', 'printcenter' ); |
||
33 | $this->description = __( 'Order Shipped Notification emails are sent when a tracking number is received from the SSI API.', 'printcenter' ); |
||
34 | |||
35 | $this->heading = __( 'Your order has shipped', 'printcenter' ); |
||
36 | $this->subject = __( 'Your {site_title} order from {order_date} has shipped', 'printcenter' ); |
||
37 | |||
38 | $this->template_base = PRINTCENTER_DIR . 'templates/'; |
||
39 | $this->template_html = 'emails/order-shipped.php'; |
||
40 | $this->template_plain = 'emails/plain/order-shipped.php'; |
||
41 | |||
42 | //add_action( 'printcenter_send_shipping_email', array( $this, 'trigger' ) ); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
62% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
43 | |||
44 | parent::__construct(); |
||
45 | } |
||
46 | |||
47 | |||
48 | /** |
||
49 | * Setup the email |
||
50 | * |
||
51 | * @access public |
||
52 | * @since 1.0.0 |
||
53 | * @return void |
||
54 | */ |
||
55 | public function trigger( $order_id ) { |
||
56 | if( ! $order_id ) { |
||
57 | return; |
||
58 | } |
||
59 | |||
60 | $this->object = wc_get_order( $order_id ); |
||
61 | $this->recipient = $this->object->billing_email; |
||
62 | |||
63 | $this->find[] = '{order_date}'; |
||
64 | $this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) ); |
||
65 | |||
66 | $this->find[] = '{order_number}'; |
||
67 | $this->replace[] = $this->object->get_order_number(); |
||
68 | |||
69 | if( ! $this->is_enabled() || ! $this->get_recipient() ) { |
||
70 | return; |
||
71 | } |
||
72 | |||
73 | $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); |
||
74 | } |
||
75 | |||
76 | |||
77 | /** |
||
78 | * Get HTML content |
||
79 | * |
||
80 | * @access public |
||
81 | * @since 1.0.0 |
||
82 | * @return string |
||
83 | */ |
||
84 | public function get_content_html() { |
||
85 | ob_start(); |
||
86 | wc_get_template( $this->template_html, array( |
||
87 | 'order' => $this->object, |
||
88 | 'email_heading' => $this->get_heading(), |
||
89 | 'sent_to_admin' => false, |
||
90 | 'plain_text' => false |
||
91 | ), $this->template_base, $this->template_base ); |
||
92 | return ob_get_clean(); |
||
93 | } |
||
94 | |||
95 | |||
96 | /** |
||
97 | * Get plain content |
||
98 | * |
||
99 | * @access public |
||
100 | * @since 1.0.0 |
||
101 | * @return string |
||
102 | */ |
||
103 | public function get_content_plain() { |
||
104 | ob_start(); |
||
105 | wc_get_template( $this->template_plain, array( |
||
106 | 'order' => $this->object, |
||
107 | 'email_heading' => $this->get_heading(), |
||
108 | 'sent_to_admin' => false, |
||
109 | 'plain_text' => true |
||
110 | ), $this->template_base, $this->template_base ); |
||
111 | return ob_get_clean(); |
||
112 | } |
||
113 | |||
114 | |||
115 | /** |
||
116 | * Email settings |
||
117 | * |
||
118 | * @access public |
||
119 | * @since 1.0.0 |
||
120 | * @return void |
||
121 | */ |
||
122 | public function init_form_fields() { |
||
123 | $this->form_fields = array( |
||
124 | 'enabled' => array( |
||
125 | 'title' => 'Enable/Disable', |
||
126 | 'type' => 'checkbox', |
||
127 | 'label' => 'Enable this email notification', |
||
128 | 'default' => 'yes' |
||
129 | ), |
||
130 | 'subject' => array( |
||
131 | 'title' => 'Subject', |
||
132 | 'type' => 'text', |
||
133 | 'description' => sprintf( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', $this->subject ), |
||
134 | 'placeholder' => '', |
||
135 | 'default' => '' |
||
136 | ), |
||
137 | 'heading' => array( |
||
138 | 'title' => 'Email Heading', |
||
139 | 'type' => 'text', |
||
140 | 'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.' ), $this->heading ), |
||
141 | 'placeholder' => '', |
||
142 | 'default' => '' |
||
143 | ), |
||
144 | 'email_type' => array( |
||
145 | 'title' => 'Email type', |
||
146 | 'type' => 'select', |
||
147 | 'description' => 'Choose which format of email to send.', |
||
148 | 'default' => 'html', |
||
149 | 'class' => 'email_type wc_enhanced_select', |
||
150 | 'options' => $this->get_email_type_options() |
||
151 | ) |
||
152 | ); |
||
153 | } |
||
154 | } |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.