Issues (2873)

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.

components/Advanced-Relationships.php (28 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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 25 and the first side effect is on line 19.

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.

Loading history...
2
/**
3
 * Name: Advanced Relationships
4
 *
5
 * Description: Add advanced relationship objects for relating to including Database Tables, Multisite Networks,
6
 * Multisite Sites, Themes, Page Templates, Sidebars, Post Type Objects, and Taxonomy Objects
7
 *
8
 * Version: 2.3
9
 *
10
 * Category: Advanced
11
 *
12
 * Tableless Mode: No
13
 *
14
 * @package    Pods\Components
15
 * @subpackage Advanced Relationships
16
 */
17
18
if ( class_exists( 'Pods_Advanced_Relationships' ) ) {
19
	return;
20
}
21
22
/**
23
 * Class Pods_Advanced_Relationships
24
 */
25
class Pods_Advanced_Relationships extends PodsComponent {
26
27
	/**
28
	 * {@inheritdoc}
29
	 */
30
	public function init() {
31
32
		add_action( 'pods_form_ui_field_pick_related_objects_other', array( $this, 'add_related_objects' ) );
33
	}
34
35
	/**
36
	 * Add Advanced Related Objects
37
	 *
38
	 * @since 2.3
39
	 */
40
	public function add_related_objects() {
41
42
		PodsField_Pick::$related_objects['table'] = array(
43
			'label' => __( 'Database Tables', 'pods' ),
44
			'group' => __( 'Advanced Objects', 'pods' ),
45
		);
46
47
		if ( is_multisite() ) {
48
			PodsField_Pick::$related_objects['site'] = array(
49
				'label' => __( 'Multisite Sites', 'pods' ),
50
				'group' => __( 'Advanced Objects', 'pods' ),
51
			);
52
53
			PodsField_Pick::$related_objects['network'] = array(
54
				'label' => __( 'Multisite Networks', 'pods' ),
55
				'group' => __( 'Advanced Objects', 'pods' ),
56
			);
57
		}
58
59
		PodsField_Pick::$related_objects['theme'] = array(
60
			'label'         => __( 'Themes', 'pods' ),
61
			'group'         => __( 'Advanced Objects', 'pods' ),
62
			'simple'        => true,
63
			'data_callback' => array( $this, 'data_themes' ),
64
		);
65
66
		PodsField_Pick::$related_objects['page-template'] = array(
67
			'label'         => __( 'Page Templates', 'pods' ),
68
			'group'         => __( 'Advanced Objects', 'pods' ),
69
			'simple'        => true,
70
			'data_callback' => array( $this, 'data_page_templates' ),
71
		);
72
73
		PodsField_Pick::$related_objects['sidebar'] = array(
74
			'label'         => __( 'Sidebars', 'pods' ),
75
			'group'         => __( 'Advanced Objects', 'pods' ),
76
			'simple'        => true,
77
			'data_callback' => array( $this, 'data_sidebars' ),
78
		);
79
80
		PodsField_Pick::$related_objects['post-types'] = array(
81
			'label'         => __( 'Post Type Objects', 'pods' ),
82
			'group'         => __( 'Advanced Objects', 'pods' ),
83
			'simple'        => true,
84
			'data_callback' => array( $this, 'data_post_types' ),
85
		);
86
87
		PodsField_Pick::$related_objects['taxonomies'] = array(
88
			'label'         => __( 'Taxonomy Objects', 'pods' ),
89
			'group'         => __( 'Advanced Objects', 'pods' ),
90
			'simple'        => true,
91
			'data_callback' => array( $this, 'data_taxonomies' ),
92
		);
93
	}
94
95
	/**
96
	 * Data callback for Themes
97
	 *
98
	 * @param string       $name    The name of the field
0 ignored issues
show
Should the type for parameter $name not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
99
	 * @param string|array $value   The value of the field
0 ignored issues
show
Should the type for parameter $value not be string|array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
100
	 * @param array        $options Field options
0 ignored issues
show
Should the type for parameter $options not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
101
	 * @param array        $pod     Pod data
0 ignored issues
show
Should the type for parameter $pod not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
102
	 * @param int          $id      Item ID
0 ignored issues
show
Should the type for parameter $id not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
103
	 *
104
	 * @return array
105
	 *
106
	 * @since 2.3
107
	 */
108
	public function data_themes( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
109
110
		$data = array();
111
112
		$themes = wp_get_themes( array( 'allowed' => true ) );
113
114
		foreach ( $themes as $theme ) {
115
			$data[ $theme->Template ] = $theme->Name;
116
		}
117
118
		return apply_filters( 'pods_form_ui_field_pick_' . __FUNCTION__, $data, $name, $value, $options, $pod, $id );
119
	}
120
121
	/**
122
	 * Data callback for Page Templates
123
	 *
124
	 * @param string       $name    The name of the field
0 ignored issues
show
Should the type for parameter $name not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
125
	 * @param string|array $value   The value of the field
0 ignored issues
show
Should the type for parameter $value not be string|array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
126
	 * @param array        $options Field options
0 ignored issues
show
Should the type for parameter $options not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
127
	 * @param array        $pod     Pod data
0 ignored issues
show
Should the type for parameter $pod not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
128
	 * @param int          $id      Item ID
0 ignored issues
show
Should the type for parameter $id not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
129
	 *
130
	 * @return array
131
	 *
132
	 * @since 2.3
133
	 */
134
	public function data_page_templates( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
135
136
		$data = array();
137
138
		if ( ! function_exists( 'get_page_templates' ) ) {
139
			include_once ABSPATH . 'wp-admin/includes/theme.php';
140
		}
141
142
		$page_templates = apply_filters( 'pods_page_templates', get_page_templates() );
143
144
		if ( ! in_array( 'page.php', $page_templates, true ) && locate_template( array( 'page.php', false ) ) ) {
145
			$page_templates['Page (WP Default)'] = 'page.php';
146
		}
147
148
		if ( ! in_array( 'index.php', $page_templates, true ) && locate_template( array( 'index.php', false ) ) ) {
149
			$page_templates['Index (WP Fallback)'] = 'index.php';
150
		}
151
152
		ksort( $page_templates );
153
154
		$page_templates = array_flip( $page_templates );
155
156
		foreach ( $page_templates as $page_template_file => $page_template ) {
157
			$data[ $page_template_file ] = $page_template;
158
		}
159
160
		return apply_filters( 'pods_form_ui_field_pick_' . __FUNCTION__, $data, $name, $value, $options, $pod, $id );
161
	}
162
163
	/**
164
	 * Data callback for Sidebars
165
	 *
166
	 * @param string       $name    The name of the field
0 ignored issues
show
Should the type for parameter $name not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
167
	 * @param string|array $value   The value of the field
0 ignored issues
show
Should the type for parameter $value not be string|array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
168
	 * @param array        $options Field options
0 ignored issues
show
Should the type for parameter $options not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
169
	 * @param array        $pod     Pod data
0 ignored issues
show
Should the type for parameter $pod not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
170
	 * @param int          $id      Item ID
0 ignored issues
show
Should the type for parameter $id not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
171
	 *
172
	 * @return array
173
	 *
174
	 * @since 2.3
175
	 */
176
	public function data_sidebars( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
177
178
		$data = array();
179
180
		global $wp_registered_sidebars;
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $wp_registered_sidebars exceeds the maximum configured length of 20.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
181
182
		if ( ! empty( $wp_registered_sidebars ) ) {
183
			foreach ( $wp_registered_sidebars as $sidebar ) {
184
				$data[ $sidebar['id'] ] = $sidebar['name'];
185
			}
186
		}
187
188
		return apply_filters( 'pods_form_ui_field_pick_' . __FUNCTION__, $data, $name, $value, $options, $pod, $id );
189
	}
190
191
	/**
192
	 * Data callback for Post Types
193
	 *
194
	 * @param string       $name    The name of the field
0 ignored issues
show
Should the type for parameter $name not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
195
	 * @param string|array $value   The value of the field
0 ignored issues
show
Should the type for parameter $value not be string|array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
196
	 * @param array        $options Field options
0 ignored issues
show
Should the type for parameter $options not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
197
	 * @param array        $pod     Pod data
0 ignored issues
show
Should the type for parameter $pod not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
198
	 * @param int          $id      Item ID
0 ignored issues
show
Should the type for parameter $id not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
199
	 *
200
	 * @return array
201
	 *
202
	 * @since 2.3
203
	 */
204
	public function data_post_types( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
205
206
		$data = array();
207
208
		$post_types = get_post_types( array(), 'objects' );
209
210
		$ignore = array( 'revision', 'nav_menu_item' );
211
212
		foreach ( $post_types as $post_type ) {
213
			if ( in_array( $post_type->name, $ignore, true ) || 0 === strpos( $post_type->name, '_pods_' ) ) {
214
				continue;
215
			}
216
217
			$data[ $post_type->name ] = $post_type->label;
218
		}
219
220
		return apply_filters( 'pods_form_ui_field_pick_' . __FUNCTION__, $data, $name, $value, $options, $pod, $id );
221
	}
222
223
	/**
224
	 * Data callback for Taxonomies
225
	 *
226
	 * @param string       $name    The name of the field
0 ignored issues
show
Should the type for parameter $name not be string|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
227
	 * @param string|array $value   The value of the field
0 ignored issues
show
Should the type for parameter $value not be string|array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
228
	 * @param array        $options Field options
0 ignored issues
show
Should the type for parameter $options not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
229
	 * @param array        $pod     Pod data
0 ignored issues
show
Should the type for parameter $pod not be array|null? Also, consider making the array more specific, something like array<String>, or String[].

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive. In addition it looks for parameters that have the generic type array and suggests a stricter type like array<String>.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
230
	 * @param int          $id      Item ID
0 ignored issues
show
Should the type for parameter $id not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
231
	 *
232
	 * @return array
233
	 *
234
	 * @since 2.3
235
	 */
236
	public function data_taxonomies( $name = null, $value = null, $options = null, $pod = null, $id = null ) {
237
238
		$data = array();
239
240
		$taxonomies = get_taxonomies( array(), 'objects' );
241
242
		$ignore = array( 'nav_menu', 'post_format' );
243
244
		foreach ( $taxonomies as $taxonomy ) {
245
			if ( in_array( $taxonomy->name, $ignore, true ) ) {
246
				continue;
247
			}
248
249
			$data[ $taxonomy->name ] = $taxonomy->label;
250
		}
251
252
		return apply_filters( 'pods_form_ui_field_pick_' . __FUNCTION__, $data, $name, $value, $options, $pod, $id );
253
	}
254
255
}
256