Issues (942)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

includes/emails/class-wc-email-cancelled-order.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Class WC_Email_Cancelled_Order file.
4
 *
5
 * @package WooCommerce\Emails
6
 */
7
8 1
if ( ! defined( 'ABSPATH' ) ) {
9
	exit;
10
}
11
12 1
if ( ! class_exists( 'WC_Email_Cancelled_Order', false ) ) :
13
14
	/**
15
	 * Cancelled Order Email.
16
	 *
17
	 * An email sent to the admin when an order is cancelled.
18
	 *
19
	 * @class       WC_Email_Cancelled_Order
20
	 * @version     2.2.7
21
	 * @package     WooCommerce/Classes/Emails
22
	 * @extends     WC_Email
23
	 */
24
	class WC_Email_Cancelled_Order extends WC_Email {
25
26
		/**
27
		 * Constructor.
28
		 */
29 1 View Code Duplication
		public function __construct() {
30 1
			$this->id             = 'cancelled_order';
31 1
			$this->title          = __( 'Cancelled order', 'woocommerce' );
32 1
			$this->description    = __( 'Cancelled order emails are sent to chosen recipient(s) when orders have been marked cancelled (if they were previously processing or on-hold).', 'woocommerce' );
33 1
			$this->template_html  = 'emails/admin-cancelled-order.php';
34 1
			$this->template_plain = 'emails/plain/admin-cancelled-order.php';
35 1
			$this->placeholders   = array(
36
				'{order_date}'              => '',
37
				'{order_number}'            => '',
38
				'{order_billing_full_name}' => '',
39
			);
40
41
			// Triggers for this email.
42 1
			add_action( 'woocommerce_order_status_processing_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 );
43 1
			add_action( 'woocommerce_order_status_on-hold_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 );
44
45
			// Call parent constructor.
46 1
			parent::__construct();
47
48
			// Other settings.
49 1
			$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
50
		}
51
52
		/**
53
		 * Get email subject.
54
		 *
55
		 * @since  3.1.0
56
		 * @return string
57
		 */
58 1
		public function get_default_subject() {
59 1
			return __( '[{site_title}]: Order #{order_number} has been cancelled', 'woocommerce' );
60
		}
61
62
		/**
63
		 * Get email heading.
64
		 *
65
		 * @since  3.1.0
66
		 * @return string
67
		 */
68 1
		public function get_default_heading() {
69 1
			return __( 'Order Cancelled: #{order_number}', 'woocommerce' );
70
		}
71
72
		/**
73
		 * Trigger the sending of this email.
74
		 *
75
		 * @param int            $order_id The order ID.
76
		 * @param WC_Order|false $order Order object.
77
		 */
78 View Code Duplication
		public function trigger( $order_id, $order = false ) {
79
			$this->setup_locale();
80
81
			if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
82
				$order = wc_get_order( $order_id );
83
			}
84
85
			if ( is_a( $order, 'WC_Order' ) ) {
86
				$this->object                                    = $order;
87
				$this->placeholders['{order_date}']              = wc_format_datetime( $this->object->get_date_created() );
88
				$this->placeholders['{order_number}']            = $this->object->get_order_number();
89
				$this->placeholders['{order_billing_full_name}'] = $this->object->get_formatted_billing_full_name();
90
			}
91
92
			if ( $this->is_enabled() && $this->get_recipient() ) {
93
				$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
94
			}
95
96
			$this->restore_locale();
97
		}
98
99
		/**
100
		 * Get content html.
101
		 *
102
		 * @return string
103
		 */
104
		public function get_content_html() {
105
			return wc_get_template_html(
106
				$this->template_html,
107
				array(
108
					'order'              => $this->object,
109
					'email_heading'      => $this->get_heading(),
110
					'additional_content' => $this->get_additional_content(),
111
					'sent_to_admin'      => true,
112
					'plain_text'         => false,
113
					'email'              => $this,
114
				)
115
			);
116
		}
117
118
		/**
119
		 * Get content plain.
120
		 *
121
		 * @return string
122
		 */
123
		public function get_content_plain() {
124
			return wc_get_template_html(
125
				$this->template_plain,
126
				array(
127
					'order'              => $this->object,
128
					'email_heading'      => $this->get_heading(),
129
					'additional_content' => $this->get_additional_content(),
130
					'sent_to_admin'      => true,
131
					'plain_text'         => true,
132
					'email'              => $this,
133
				)
134
			);
135
		}
136
137
		/**
138
		 * Default content to show below main email content.
139
		 *
140
		 * @since 3.7.0
141
		 * @return string
142
		 */
143 1
		public function get_default_additional_content() {
144 1
			return __( 'Thanks for reading.', 'woocommerce' );
145
		}
146
147
		/**
148
		 * Initialise settings form fields.
149
		 */
150 1 View Code Duplication
		public function init_form_fields() {
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
151
			/* translators: %s: list of placeholders */
152 1
			$placeholder_text  = sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '<code>' . esc_html( implode( '</code>, <code>', array_keys( $this->placeholders ) ) ) . '</code>' );
153 1
			$this->form_fields = array(
154
				'enabled'            => array(
155 1
					'title'   => __( 'Enable/Disable', 'woocommerce' ),
156 1
					'type'    => 'checkbox',
157 1
					'label'   => __( 'Enable this email notification', 'woocommerce' ),
158 1
					'default' => 'yes',
159
				),
160
				'recipient'          => array(
161 1
					'title'       => __( 'Recipient(s)', 'woocommerce' ),
162 1
					'type'        => 'text',
163
					/* translators: %s: admin email */
164 1
					'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'woocommerce' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
165 1
					'placeholder' => '',
166 1
					'default'     => '',
167
					'desc_tip'    => true,
168
				),
169
				'subject'            => array(
170 1
					'title'       => __( 'Subject', 'woocommerce' ),
171 1
					'type'        => 'text',
172
					'desc_tip'    => true,
173 1
					'description' => $placeholder_text,
174 1
					'placeholder' => $this->get_default_subject(),
175 1
					'default'     => '',
176
				),
177
				'heading'            => array(
178 1
					'title'       => __( 'Email heading', 'woocommerce' ),
179 1
					'type'        => 'text',
180
					'desc_tip'    => true,
181 1
					'description' => $placeholder_text,
182 1
					'placeholder' => $this->get_default_heading(),
183 1
					'default'     => '',
184
				),
185
				'additional_content' => array(
186 1
					'title'       => __( 'Additional content', 'woocommerce' ),
187 1
					'description' => __( 'Text to appear below the main email content.', 'woocommerce' ) . ' ' . $placeholder_text,
188 1
					'css'         => 'width:400px; height: 75px;',
189 1
					'placeholder' => __( 'N/A', 'woocommerce' ),
190 1
					'type'        => 'textarea',
191 1
					'default'     => $this->get_default_additional_content(),
192
					'desc_tip'    => true,
193
				),
194
				'email_type'         => array(
195 1
					'title'       => __( 'Email type', 'woocommerce' ),
196 1
					'type'        => 'select',
197 1
					'description' => __( 'Choose which format of email to send.', 'woocommerce' ),
198 1
					'default'     => 'html',
199 1
					'class'       => 'email_type wc-enhanced-select',
200 1
					'options'     => $this->get_email_type_options(),
201
					'desc_tip'    => true,
202
				),
203
			);
204
		}
205
	}
206
207
endif;
208
209
return new WC_Email_Cancelled_Order();
210