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 | * UIX Modal |
||
4 | * |
||
5 | * @package ui |
||
6 | * @author David Cramer |
||
7 | * @license GPL-2.0+ |
||
8 | * @link |
||
9 | * @copyright 2016 David Cramer |
||
10 | */ |
||
11 | namespace uix\ui; |
||
12 | |||
13 | /** |
||
14 | * Same as the Box type, however it renders a button control that loads the modal via a template |
||
15 | * |
||
16 | * @package uix\ui |
||
17 | * @author David Cramer |
||
18 | */ |
||
19 | class modal extends panel { |
||
20 | |||
21 | /** |
||
22 | * The type of object |
||
23 | * |
||
24 | * @since 1.0.0 |
||
25 | * @access public |
||
26 | * @var string |
||
27 | */ |
||
28 | public $type = 'modal'; |
||
29 | |||
30 | /** |
||
31 | * footer object |
||
32 | * |
||
33 | * @since 1.0.0 |
||
34 | * @access public |
||
35 | * @var footer |
||
36 | */ |
||
37 | public $footer; |
||
38 | |||
39 | /** |
||
40 | * modal template |
||
41 | * |
||
42 | * @since 1.0.0 |
||
43 | * @access public |
||
44 | * @var string |
||
45 | */ |
||
46 | public $templates = null; |
||
47 | |||
48 | |||
49 | /** |
||
50 | * Sets the controls data |
||
51 | * |
||
52 | * @since 1.0.0 |
||
53 | * @see \uix\uix |
||
54 | * @access public |
||
55 | */ |
||
56 | 1 | public function is_submitted() { |
|
57 | 1 | $data = uix()->request_vars( 'post' ); |
|
58 | |||
59 | 1 | return isset( $data[ 'uixNonce_' . $this->id() ] ) && wp_verify_nonce( $data[ 'uixNonce_' . $this->id() ], $this->id() ); |
|
60 | } |
||
61 | |||
62 | /** |
||
63 | * Sets the wrappers attributes |
||
64 | * |
||
65 | * @since 1.0.0 |
||
66 | * @access public |
||
67 | */ |
||
68 | 1 | public function set_attributes() { |
|
69 | |||
70 | $this->attributes += array( |
||
71 | 1 | 'data-modal' => $this->id(), |
|
72 | 1 | 'data-content' => '#' . $this->id() . '-tmpl', |
|
73 | 1 | 'data-margin' => 12, |
|
74 | 1 | 'data-element' => 'form', |
|
75 | 1 | 'data-width' => '480', |
|
76 | 1 | 'data-height' => '550', |
|
77 | 1 | 'class' => 'button', |
|
78 | ); |
||
79 | 1 | $this->set_modal_size(); |
|
80 | 1 | $this->set_modal_config(); |
|
81 | 1 | if ( ! empty( $this->struct['description'] ) ) { |
|
82 | 1 | $this->attributes['data-title'] = $this->struct['description']; |
|
83 | 1 | unset( $this->struct['description'] ); |
|
84 | } |
||
85 | 1 | if ( ! empty( $this->struct['attributes'] ) ) { |
|
86 | 1 | $this->attributes = array_merge( $this->attributes, $this->struct['attributes'] ); |
|
87 | } |
||
88 | 1 | } |
|
89 | |||
90 | /** |
||
91 | * Sets the modals defined size |
||
92 | * |
||
93 | * @since 1.0.0 |
||
94 | * @access private |
||
95 | */ |
||
96 | 1 | View Code Duplication | private function set_modal_size() { |
0 ignored issues
–
show
|
|||
97 | |||
98 | 1 | if ( ! empty( $this->struct['width'] ) ) { |
|
99 | 1 | $this->attributes['data-width'] = $this->struct['width']; |
|
100 | } |
||
101 | 1 | if ( ! empty( $this->struct['height'] ) ) { |
|
102 | 1 | $this->attributes['data-height'] = $this->struct['height']; |
|
103 | } |
||
104 | |||
105 | 1 | } |
|
106 | |||
107 | |||
108 | /** |
||
109 | * Sets the wrappers data attributes |
||
110 | * |
||
111 | * @since 1.0.0 |
||
112 | * @access private |
||
113 | */ |
||
114 | 1 | private function set_modal_config() { |
|
115 | |||
116 | 1 | if ( ! empty( $this->struct['config'] ) ) { |
|
117 | 1 | $attributes = array(); |
|
118 | 1 | foreach ( $this->struct['config'] as $att => $value ) { |
|
119 | 1 | $attributes[ 'data-' . $att ] = $value; |
|
120 | } |
||
121 | 1 | $this->attributes['data-config'] = json_encode( $attributes ); |
|
122 | |||
123 | } |
||
124 | 1 | } |
|
125 | |||
126 | /** |
||
127 | * set assets |
||
128 | * |
||
129 | * @since 1.0.0 |
||
130 | * @see \uix\ui\uix |
||
131 | * @access public |
||
132 | */ |
||
133 | 1 | View Code Duplication | public function set_assets() { |
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. ![]() |
|||
134 | |||
135 | 1 | $this->assets['script']['baldrick'] = array( |
|
136 | 1 | 'src' => $this->url . 'assets/js/jquery.baldrick' . UIX_ASSET_DEBUG . '.js', |
|
137 | 'deps' => array( 'jquery' ), |
||
138 | ); |
||
139 | 1 | $this->assets['script']['modals'] = array( |
|
140 | 1 | 'src' => $this->url . 'assets/js/modals' . UIX_ASSET_DEBUG . '.js', |
|
141 | 'deps' => array( 'baldrick' ), |
||
142 | ); |
||
143 | 1 | $this->assets['style']['modals'] = $this->url . 'assets/css/modals' . UIX_ASSET_DEBUG . '.css'; |
|
144 | |||
145 | 1 | parent::set_assets(); |
|
146 | 1 | } |
|
147 | |||
148 | /** |
||
149 | * Render the Control |
||
150 | * |
||
151 | * @since 1.0.0 |
||
152 | * @see \uix\ui\uix |
||
153 | * @access public |
||
154 | * @return string HTML of rendered box |
||
155 | */ |
||
156 | 1 | public function render() { |
|
157 | |||
158 | 1 | $this->set_footers(); |
|
159 | |||
160 | 1 | add_action( 'admin_footer', array( $this, 'output_templates' ) ); |
|
161 | 1 | add_action( 'wp_footer', array( $this, 'output_templates' ) ); |
|
162 | |||
163 | 1 | $output = '<button ' . $this->build_attributes() . '>' . $this->struct['label'] . '</button>'; |
|
164 | |||
165 | 1 | $this->templates .= $this->render_modal_template(); |
|
166 | |||
167 | 1 | return $output; |
|
168 | } |
||
169 | |||
170 | /** |
||
171 | * Set the child footer objects |
||
172 | * |
||
173 | * @since 1.0.0 |
||
174 | * @see \uix\ui\uix |
||
175 | * @access public |
||
176 | */ |
||
177 | 1 | public function set_footers() { |
|
178 | |||
179 | 1 | if ( ! empty( $this->child ) ) { |
|
180 | 1 | foreach ( $this->child as $child_slug => $child ) { |
|
181 | 1 | if ( in_array( $child->type, array( 'footer' ) ) ) { |
|
182 | 1 | $this->footer = $child; |
|
183 | 1 | $this->attributes['data-footer'] = '#' . $this->id() . '-footer-tmpl'; |
|
184 | } |
||
185 | } |
||
186 | } |
||
187 | 1 | } |
|
188 | |||
189 | /** |
||
190 | * Render the template code in script tags |
||
191 | * |
||
192 | * @since 1.0.0 |
||
193 | * @see \uix\ui\uix |
||
194 | * @access public |
||
195 | * @return string HTML of rendered template in script tags |
||
196 | */ |
||
197 | 1 | public function render_modal_template() { |
|
198 | 1 | unset( $this->struct['label'] ); |
|
199 | 1 | $output = '<script data-height="' . esc_attr( $this->attributes['data-height'] ) . '" data-width="' . esc_attr( $this->attributes['data-width'] ) . '" type="text/html" id="' . esc_attr( $this->id() ) . '-tmpl">'; |
|
200 | 1 | $output .= $this->modal_template(); |
|
201 | 1 | $output .= '</script>'; |
|
202 | 1 | $output .= $this->render_footer_template(); |
|
203 | |||
204 | 1 | return $output; |
|
205 | } |
||
206 | |||
207 | /** |
||
208 | * Render the template code |
||
209 | * |
||
210 | * @since 1.0.0 |
||
211 | * @see \uix\ui\uix |
||
212 | * @access public |
||
213 | * @return string HTML of rendered template |
||
214 | */ |
||
215 | 1 | public function modal_template() { |
|
216 | 1 | $this->get_data(); // init data |
|
217 | 1 | $output = wp_nonce_field( $this->id(), 'uixNonce_' . $this->id(), true, false ); |
|
218 | 1 | $output .= parent::render(); |
|
0 ignored issues
–
show
It seems like you call parent on a different method (
render() instead of modal_template() ). Are you sure this is correct? If so, you might want to change this to $this->render() .
This check looks for a call to a parent method whose name is different than the method from which it is called. Consider the following code: class Daddy
{
protected function getFirstName()
{
return "Eidur";
}
protected function getSurName()
{
return "Gudjohnsen";
}
}
class Son
{
public function getFirstName()
{
return parent::getSurname();
}
}
The ![]() |
|||
219 | |||
220 | 1 | return $output; |
|
221 | } |
||
222 | |||
223 | /** |
||
224 | * Render the footer template |
||
225 | * |
||
226 | * @since 1.0.0 |
||
227 | * @see \uix\ui\uix |
||
228 | * @access public |
||
229 | * @return string HTML of rendered box |
||
230 | */ |
||
231 | 1 | public function render_footer_template() { |
|
232 | 1 | $output = null; |
|
233 | 1 | if ( ! empty( $this->footer ) ) { |
|
234 | 1 | $output .= '<script type="text/html" id="' . esc_attr( $this->id() ) . '-footer-tmpl">'; |
|
235 | 1 | $output .= $this->footer->render(); |
|
236 | 1 | $output .= '</script>'; |
|
237 | } |
||
238 | |||
239 | 1 | return $output; |
|
240 | } |
||
241 | |||
242 | /** |
||
243 | * Render templates to page |
||
244 | * |
||
245 | * @since 1.0.0 |
||
246 | * @see \uix\ui\uix |
||
247 | * @access public |
||
248 | */ |
||
249 | public function output_templates() { |
||
250 | echo $this->templates; |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * Enqueues specific tabs assets for the active pages |
||
255 | * |
||
256 | * @since 1.0.0 |
||
257 | * @access protected |
||
258 | */ |
||
259 | protected function set_active_styles() { |
||
260 | |||
261 | $style = 'h3#' . $this->id() . '_uixModalLable { background: ' . $this->base_color() . '; }'; |
||
262 | $style .= '#' . $this->id() . '_uixModal.uix-modal-wrap > .uix-modal-body:after {background: url(' . $this->url . 'assets/svg/loading.php?base_color=' . urlencode( str_replace( '#', '', $this->base_color() ) ) . ') no-repeat center center;}'; |
||
263 | |||
264 | uix_share()->set_active_styles( $style ); |
||
265 | parent::set_active_styles(); |
||
266 | } |
||
267 | |||
268 | } |
||
269 |
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.