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 |
||
2 | |||
3 | /* |
||
4 | * ACF URL Field Class |
||
5 | * |
||
6 | * All the logic for this field type |
||
7 | * |
||
8 | * @class acf_field_url |
||
9 | * @extends acf_field |
||
10 | * @package ACF |
||
11 | * @subpackage Fields |
||
12 | */ |
||
13 | |||
14 | if( ! class_exists('acf_field_url') ) : |
||
15 | |||
16 | class acf_field_url extends acf_field { |
||
17 | |||
18 | |||
19 | /* |
||
20 | * __construct |
||
21 | * |
||
22 | * This function will setup the field type data |
||
23 | * |
||
24 | * @type function |
||
25 | * @date 5/03/2014 |
||
26 | * @since 5.0.0 |
||
27 | * |
||
28 | * @param n/a |
||
29 | * @return n/a |
||
30 | */ |
||
0 ignored issues
–
show
|
|||
31 | |||
32 | View Code Duplication | function __construct() { |
|
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. ![]() |
|||
33 | |||
34 | // vars |
||
35 | $this->name = 'url'; |
||
36 | $this->label = __("Url",'acf'); |
||
0 ignored issues
–
show
The property
label does not exist. Did you maybe forget to declare it?
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code: class MyClass { }
$x = new MyClass();
$x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: class MyClass {
public $foo;
}
$x = new MyClass();
$x->foo = true;
![]() |
|||
37 | $this->defaults = array( |
||
38 | 'default_value' => '', |
||
39 | 'placeholder' => '', |
||
40 | ); |
||
41 | |||
42 | |||
43 | // do not delete! |
||
44 | parent::__construct(); |
||
45 | } |
||
46 | |||
47 | |||
48 | /* |
||
49 | * render_field() |
||
50 | * |
||
51 | * Create the HTML interface for your field |
||
52 | * |
||
53 | * @param $field - an array holding all the field's data |
||
54 | * |
||
55 | * @type action |
||
56 | * @since 3.6 |
||
57 | * @date 23/01/13 |
||
58 | */ |
||
59 | |||
60 | function render_field( $field ) { |
||
0 ignored issues
–
show
|
|||
61 | |||
62 | // vars |
||
63 | $o = array( 'type', 'id', 'class', 'name', 'value', 'placeholder' ); |
||
64 | $e = ''; |
||
65 | |||
66 | |||
67 | // populate atts |
||
68 | $atts = array(); |
||
69 | foreach( $o as $k ) { |
||
70 | |||
71 | $atts[ $k ] = $field[ $k ]; |
||
72 | |||
73 | } |
||
74 | |||
75 | |||
76 | // special atts |
||
77 | View Code Duplication | foreach( array( 'readonly', 'disabled' ) as $k ) { |
|
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. ![]() |
|||
78 | |||
79 | if( !empty($field[ $k ]) ) { |
||
80 | |||
81 | $atts[ $k ] = $k; |
||
82 | |||
83 | } |
||
84 | |||
85 | } |
||
86 | |||
87 | |||
88 | // render |
||
89 | $e .= '<div class="acf-input-wrap acf-url">'; |
||
90 | $e .= '<i class="acf-icon -globe small"></i><input ' . acf_esc_attr( $atts ) . ' />'; |
||
91 | $e .= '</div>'; |
||
92 | |||
93 | |||
94 | // return |
||
95 | echo $e; |
||
96 | |||
97 | } |
||
98 | |||
99 | |||
100 | /* |
||
101 | * render_field_settings() |
||
102 | * |
||
103 | * Create extra options for your field. This is rendered when editing a field. |
||
104 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field |
||
105 | * |
||
106 | * @type action |
||
107 | * @since 3.6 |
||
108 | * @date 23/01/13 |
||
109 | * |
||
110 | * @param $field - an array holding all the field's data |
||
111 | */ |
||
112 | |||
113 | View Code Duplication | function render_field_settings( $field ) { |
|
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. ![]() |
|||
114 | |||
115 | // default_value |
||
116 | acf_render_field_setting( $field, array( |
||
117 | 'label' => __('Default Value','acf'), |
||
118 | 'instructions' => __('Appears when creating a new post','acf'), |
||
119 | 'type' => 'text', |
||
120 | 'name' => 'default_value', |
||
121 | )); |
||
122 | |||
123 | |||
124 | // placeholder |
||
125 | acf_render_field_setting( $field, array( |
||
126 | 'label' => __('Placeholder Text','acf'), |
||
127 | 'instructions' => __('Appears within the input','acf'), |
||
128 | 'type' => 'text', |
||
129 | 'name' => 'placeholder', |
||
130 | )); |
||
131 | |||
132 | } |
||
133 | |||
134 | |||
135 | /* |
||
136 | * validate_value |
||
137 | * |
||
138 | * description |
||
139 | * |
||
140 | * @type function |
||
141 | * @date 11/02/2014 |
||
142 | * @since 5.0.0 |
||
143 | * |
||
144 | * @param $post_id (int) |
||
145 | * @return $post_id (int) |
||
146 | */ |
||
0 ignored issues
–
show
The doc-type
$post_id could not be parsed: Unknown type name "$post_id" at position 0. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. ![]() |
|||
147 | |||
148 | function validate_value( $valid, $value, $field, $input ){ |
||
0 ignored issues
–
show
|
|||
149 | |||
150 | // bail early if empty |
||
151 | if( empty($value) ) { |
||
152 | |||
153 | return $valid; |
||
154 | |||
155 | } |
||
156 | |||
157 | |||
158 | if( strpos($value, '://') !== false ) { |
||
159 | |||
160 | // url |
||
161 | |||
162 | } elseif( strpos($value, '//') === 0 ) { |
||
163 | |||
164 | // protocol relative url |
||
165 | |||
166 | } else { |
||
167 | |||
168 | $valid = __('Value must be a valid URL', 'acf'); |
||
169 | |||
170 | } |
||
171 | |||
172 | |||
173 | // return |
||
174 | return $valid; |
||
175 | |||
176 | } |
||
177 | |||
178 | } |
||
179 | |||
180 | new acf_field_url(); |
||
181 | |||
182 | endif; |
||
183 | |||
184 | ?> |
||
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. ![]() |
|||
185 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.