Issues (80)

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.

inc/woocommerce.php (6 issues)

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
 * Add WooCommerce support
4
 *
5
 * @package spurs
6
 */
7
8
// Exit if accessed directly.
9
defined( 'ABSPATH' ) || exit;
10
11
add_action( 'after_setup_theme', 'spurs_woocommerce_support' );
12
if ( ! function_exists( 'spurs_woocommerce_support' ) ) {
13
	/**
14
	 * Declares WooCommerce theme support.
15
	 */
16
	function spurs_woocommerce_support() {
17
		add_theme_support( 'woocommerce' );
18
19
		// Add New Woocommerce 3.0.0 Product Gallery support
20
		add_theme_support( 'wc-product-gallery-lightbox' );
21
		add_theme_support( 'wc-product-gallery-zoom' );
22
		add_theme_support( 'wc-product-gallery-slider' );
23
24
		// hook in and customizer form fields.
25
		add_filter( 'woocommerce_form_field_args', 'spurs_wc_form_field_args', 10, 3 );
26
	}
27
}
28
29
30
/**
31
 * First unhook the WooCommerce wrappers
32
 */
33
remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10 );
34
remove_action( 'woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10 );
35
36
/**
37
 * Then hook in your own functions to display the wrappers your theme requires
38
 */
39
add_action( 'woocommerce_before_main_content', 'spurs_woocommerce_wrapper_start', 10 );
40
add_action( 'woocommerce_after_main_content', 'spurs_woocommerce_wrapper_end', 10 );
41
if ( ! function_exists( 'spurs_woocommerce_wrapper_start' ) ) {
42
	function spurs_woocommerce_wrapper_start() {
43
		$container = get_theme_mod( 'spurs_container_type' );
44
		echo '<div class="wrapper" id="woocommerce-wrapper">';
45
		echo '<div class="' . esc_attr( $container ) . '" id="content" tabindex="-1">';
46
		echo '<div class="row">';
47
		get_template_part( 'global-templates/left-sidebar-check' );
48
		echo '<main class="site-main" id="main">';
49
	}
50
}
51
if ( ! function_exists( 'spurs_woocommerce_wrapper_end' ) ) {
52
	function spurs_woocommerce_wrapper_end() {
53
		echo '</main>';
54
		echo '</div>';
55
		get_template_part( 'global-templates/right-sidebar-check' );
56
		echo '</div><!-- .row -->';
57
		echo '</div><!-- Container end -->';
58
		echo '</div><!-- Wrapper end -->';
59
	}
60
}
61
62
63
/**
64
 * Filter hook function monkey patching form classes
65
 * Author: Adriano Monecchi http://stackoverflow.com/a/36724593/307826
66
 *
67
 * @param string $args Form attributes.
68
 * @param string $key Not in use.
69
 * @param null $value Not in use.
70
 *
71
 * @return mixed
72
 */
73
if ( ! function_exists( 'spurs_wc_form_field_args' ) ) {
74
	function spurs_wc_form_field_args( $args, $key, $value = null ) {
75
		// Start field type switch case.
76
		switch ( $args['type'] ) {
77
			/* Targets all select input type elements, except the country and state select input types */
78 View Code Duplication
			case 'select' :
0 ignored issues
show
This code seems to be duplicated across 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...
79
				// Add a class to the field's html element wrapper - woocommerce
80
				// input types (fields) are often wrapped within a <p></p> tag.
81
				$args['class'][] = 'form-group';
82
				// Add a class to the form input itself.
83
				$args['input_class']       = array( 'form-control', 'input-lg' );
84
				$args['label_class']       = array( 'control-label' );
85
				$args['custom_attributes'] = array(
86
					'data-plugin'      => 'select2',
87
					'data-allow-clear' => 'true',
88
					'aria-hidden'      => 'true',
89
					// Add custom data attributes to the form input itself.
90
				);
91
				break;
92
			// By default WooCommerce will populate a select with the country names - $args
93
			// defined for this specific input type targets only the country select element.
94
			case 'country' :
95
				$args['class'][]     = 'form-group single-country';
96
				$args['label_class'] = array( 'control-label' );
97
				break;
98
			// By default WooCommerce will populate a select with state names - $args defined
99
			// for this specific input type targets only the country select element.
100 View Code Duplication
			case 'state' :
0 ignored issues
show
This code seems to be duplicated across 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...
101
				// Add class to the field's html element wrapper.
102
				$args['class'][] = 'form-group';
103
				// add class to the form input itself.
104
				$args['input_class']       = array( '', 'input-lg' );
105
				$args['label_class']       = array( 'control-label' );
106
				$args['custom_attributes'] = array(
107
					'data-plugin'      => 'select2',
108
					'data-allow-clear' => 'true',
109
					'aria-hidden'      => 'true',
110
				);
111
				break;
112
			case 'password' :
113
			case 'text' :
114
			case 'email' :
115
			case 'tel' :
116
			case 'number' :
117
				$args['class'][]     = 'form-group';
118
				$args['input_class'] = array( 'form-control', 'input-lg' );
119
				$args['label_class'] = array( 'control-label' );
120
				break;
121 View Code Duplication
			case 'textarea' :
0 ignored issues
show
This code seems to be duplicated across 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...
122
				$args['input_class'] = array( 'form-control', 'input-lg' );
123
				$args['label_class'] = array( 'control-label' );
124
				break;
125 View Code Duplication
			case 'checkbox' :
0 ignored issues
show
This code seems to be duplicated across 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...
126
				$args['label_class'] = array( 'custom-control custom-checkbox' );
127
				$args['input_class'] = array( 'custom-control-input', 'input-lg' );
128
				break;
129 View Code Duplication
			case 'radio' :
0 ignored issues
show
This code seems to be duplicated across 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...
130
				$args['label_class'] = array( 'custom-control custom-radio' );
131
				$args['input_class'] = array( 'custom-control-input', 'input-lg' );
132
				break;
133 View Code Duplication
			default :
0 ignored issues
show
This code seems to be duplicated across 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...
134
				$args['class'][]     = 'form-group';
135
				$args['input_class'] = array( 'form-control', 'input-lg' );
136
				$args['label_class'] = array( 'control-label' );
137
				break;
138
		} // end switch ($args).
139
140
		return $args;
141
	}
142
}
143
if ( ! is_admin() && ! function_exists( 'wc_review_ratings_enabled' ) ) {
144
	/**
145
	 * Check if reviews are enabled.
146
	 *
147
	 * Function introduced in WooCommerce 3.6.0., include it for backward compatibility.
148
	 *
149
	 * @return bool
150
	 */
151
	function wc_reviews_enabled() {
152
		return 'yes' === get_option( 'woocommerce_enable_reviews' );
153
	}
154
155
	/**
156
	 * Check if reviews ratings are enabled.
157
	 *
158
	 * Function introduced in WooCommerce 3.6.0., include it for backward compatibility.
159
	 *
160
	 * @return bool
161
	 */
162
	function wc_review_ratings_enabled() {
163
		return wc_reviews_enabled() && 'yes' === get_option( 'woocommerce_enable_review_rating' );
164
	}
165
}
166
167
/**
168
 * Change loop add-to-cart button class to Bootstrap
169
 */
170
add_filter( 'woocommerce_loop_add_to_cart_args', 'spurs_woocommerce_add_to_cart_args', 10, 2 );
171
172
if ( ! function_exists( 'spurs_woocommerce_add_to_cart_args' ) ) {
173
	function spurs_woocommerce_add_to_cart_args( $args, $product ) {
174
		$args['class'] = str_replace( 'button', 'btn btn-outline-primary', 'button' );
175
176
		return $args;
177
	}
178
}
179