Issues (4296)

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/class-give-tooltips.php (3 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
/**
4
 * Class for managing tooltips
5
 *
6
 * @package     Give
7
 * @subpackage  Classes/Give_Tooltips
8
 * @copyright   Copyright (c) 2017, WordImpress
9
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
10
 * @since       2.0
11
 */
12
class Give_Tooltips {
13
	/**
14
	 * Set tooltip arguments.
15
	 *
16
	 * @since  2.0
17
	 * @access private
18
	 *
19
	 * @param $args
20
	 *
21
	 * @return array
22
	 */
23
	private function set_toottip_args( $args ) {
24
		$args = wp_parse_args(
25
			$args,
26
			array(
27
				// Tooltip tag.
28
				'tag'         => 'span',
29
				'tag_content' => '',
30
31
				// Set to link of anchor if tooltip tag is anchor.
32
				'link'        => '#',
33
34
				// Text for tooltip
35
				'label'       => '',
36
37
				// Value: top-right, top, top-left, right, left, bottom-right, bottom, bottom-left.
38
				'position'    => 'top',
39
40
				// Value: error, warning, info, success.
41
				'status'      => '',
42
43
				// Value: small, medium, large.
44
				'size'        => '',
45
46
				// Value: true/false.
47
				'show_always' => false,
48
49
				// Value: true/false
50
				'round_edges' => false,
51
52
				// Value: true/false
53
				'animate'     => true,
54
55
				// Attributes.
56
				'attributes'  => array(),
57
58
				// Value: true/false
59
				'auto_width'  => true,
60
			)
61
		);
62
63
		// Auto set width of tooltip.
64
		if (
65
			! empty( $args['auto_width'] ) &&
66
			! empty( $args['label'] ) &&
67
			empty( $args['size'] )
68
		) {
69
			if ( 15 < str_word_count( $args['label'] ) ) {
70
				$args['size'] = 'large';
71
			} elseif ( 7 < str_word_count( $args['label'] ) ) {
72
				$args['size'] = 'medium';
73
			}
74
		}
75
76
		return $args;
77
	}
78
79
80
	/**
81
	 * Render tooltip
82
	 *
83
	 * @since  2.0
84
	 * @access public
85
	 *
86
	 * @param $args
87
	 *
88
	 * @return string
89
	 */
90
	public function render( $args ) {
91
		$args = $this->set_toottip_args( $args );
92
93
		$tooltip_pos = array(
94
			'top'          => 'hint--top',
95
			'top-right'    => 'hint--top-right',
96
			'top-left'     => 'hint--top-left',
97
			'right'        => 'hint--right',
98
			'left'         => 'hint--left',
99
			'bottom'       => 'hint--bottom',
100
			'bottom-right' => 'hint--bottom-right',
101
			'bottom-left'  => 'hint--bottom-left',
102
		);
103
104
		$tooltip_status = array(
105
			'error'   => 'hint--error',
106
			'warning' => 'hint--warning',
107
			'info'    => 'hint--info',
108
			'success' => 'hint--success',
109
		);
110
111
		$tooltip_size = array(
112
			'small'  => 'hint--small',
113
			'medium' => 'hint--medium',
114
			'large'  => 'hint--large',
115
		);
116
117
		// Set label.
118
		$args['attributes']['aria-label'] = $args['label'];
119
120
		// Set classes.
121
		$args['attributes']['class'] = ! empty( $args['attributes']['class'] ) ? $args['attributes']['class'] : '';
122
		$args['attributes']['class'] .= " {$tooltip_pos[ $args['position'] ]}";
123
		$args['attributes']['class'] .= ! empty( $args['status'] ) ? " {$tooltip_status[ $args['status'] ]}" : '';
124
		$args['attributes']['class'] .= ! empty( $args['size'] ) ? " {$tooltip_size[ $args['size'] ]}" : '';
125
		$args['attributes']['class'] .= $args['show_always'] ? ' hint--always' : '';
126
		$args['attributes']['class'] .= $args['round_edges'] ? ' hint--rounded' : '';
127
		$args['attributes']['class'] .= $args['animate'] ? ' hint--bounce' : ' hint--no-animate';
128
		$args['attributes']['class'] = trim( $args['attributes']['class'] );
129
130
		// Set link attribute in tooltip has anchor tag.
131
		if ( 'a' === $args['tag'] && ! empty( $args['link'] ) ) {
132
			$args['attributes']['href'] = esc_url( $args['link'] );
133
		}
134
135
		return sprintf( '<%1$s %2$s rel="tooltip">%3$s</%1$s>', $args['tag'], give_get_attribute_str( $args['attributes'] ), $args['tag_content'] );
136
	}
137
138
139
	/**
140
	 * Render tooltip with anchor tag
141
	 *
142
	 * @since  2.0
143
	 * @access public
144
	 *
145
	 * @param array $args
146
	 *
147
	 * @return string
148
	 */
149
	function render_link( $args ) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
150
		$args['tag']    = 'a';
151
		$tooltip_markup = $this->render( $args );
152
153
		return $tooltip_markup;
154
	}
155
156
	/**
157
	 * Render tooltip with span tag
158
	 *
159
	 * @since  2.0
160
	 * @access public
161
	 *
162
	 * @param array|string $args
163
	 *
164
	 * @return string
165
	 */
166
	function render_span( $args ) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
167
		// Set tooltip args from string.
168
		if ( is_string( $args ) ) {
169
			$args = array( 'label' => $args );
170
		}
171
172
		$args['tag']    = 'span';
173
		$tooltip_markup = $this->render( $args );
174
175
		return $tooltip_markup;
176
	}
177
178
	/**
179
	 * Render tooltip with span tag and question mark icon
180
	 *
181
	 * @since  2.0
182
	 * @access public
183
	 *
184
	 * @param array|string $args
185
	 *
186
	 * @return string
187
	 */
188
	function render_help( $args ) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
189
		// Set tooltip args from string.
190
		if ( is_string( $args ) ) {
191
			$args = array( 'label' => $args );
192
		}
193
194
		$args['tag_content']         = '<i class="give-icon give-icon-question"></i>';
195
		$args['attributes']['class'] = 'give-tooltip';
196
		$tooltip_markup              = $this->render_span( $args );
197
198
		return $tooltip_markup;
199
	}
200
}