Conditions | 4 |
Paths | 8 |
Total Lines | 123 |
Code Lines | 87 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
131 | function cmb2_render_callback_for_brightcove_video( $field, $escaped_value, $object_id, $object_type, $field_type_object ) { |
||
132 | |||
133 | $field_id = $field->id(); |
||
134 | |||
135 | $bc_video_values = [ |
||
136 | 'video_id' => $escaped_value['bc_video_id'] ?? '', |
||
137 | 'player_id' => $escaped_value['bc_player_id'] ?? '', |
||
138 | 'account_id' => $escaped_value['bc_account_id'] ?? '', |
||
139 | 'video_duration' => $escaped_value['bc_video_duration'] ?? '', |
||
140 | ]; |
||
141 | |||
142 | $bc_video_args = [ |
||
143 | 'embed' => 'iframe', |
||
144 | 'width' => '100%', |
||
145 | 'height' => 'auto', |
||
146 | 'padding_top' => '10', // Adding min 10 padding since by-default it's adding 56.25% padding even with 0 padding. |
||
147 | ]; |
||
148 | |||
149 | $bc_video_args = wp_parse_args( $bc_video_values, $bc_video_args ); |
||
150 | |||
151 | $allowed_html = wp_kses_allowed_html( 'post' ); |
||
152 | $allowed_html['iframe'] = [ |
||
153 | 'src' => true, |
||
154 | 'webkitallowfullscreen' => true, |
||
155 | 'allowfullscreen' => true, |
||
156 | 'mozallowfullscreen' => true, |
||
157 | 'style' => true, |
||
158 | ]; |
||
159 | $allowed_html['input'] = [ |
||
160 | 'type' => true, |
||
161 | 'class' => true, |
||
162 | 'name' => true, |
||
163 | 'id' => true, |
||
164 | 'value' => true, |
||
165 | 'data-hash' => true, |
||
166 | ]; |
||
167 | |||
168 | // Remove jetpack shortcode module filters which is converting this shortcode to anchor tag when jetpack is enabled. |
||
169 | // ref: https://github.com/Automattic/jetpack/blob/cb04cfc4479515f12945256555bbab1192711c57/modules/shortcodes/class.filter-embedded-html-objects.php#L11-L12. |
||
170 | if ( class_exists( 'Filter_Embedded_HTML_Objects' ) ) { |
||
171 | remove_filter( 'pre_kses', [ 'Filter_Embedded_HTML_Objects', 'filter' ], 11 ); |
||
172 | remove_filter( 'pre_kses', [ 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ], 100 ); |
||
173 | } |
||
174 | |||
175 | ?> |
||
176 | <div class="cmb2-brightcove-video-metabox"> |
||
177 | <button type="button" class="button brightcove-add-media-btn"> |
||
178 | <?php |
||
179 | $button_title = __( 'Select Brightcove Video', 'cmb2-brightcove-video-field' ); |
||
180 | printf( |
||
181 | '<img class="bc-button-icon" src="%s" alt="%s" />%s', |
||
182 | esc_url( BRIGHTCOVE_URL . 'images/menu-icon.svg' ), |
||
183 | esc_attr( $button_title ), |
||
184 | esc_html( $button_title ) |
||
185 | ); |
||
186 | ?> |
||
187 | </button> |
||
188 | <div class="brightcove-video-preview"> |
||
189 | <?php |
||
190 | if( ! empty( $bc_video_args['video_id'] ) ) { |
||
191 | echo wp_kses( BC_Video_Shortcode::bc_video( $bc_video_args ), $allowed_html ); |
||
192 | echo '<a href="#" class="bc-remove-video">Remove brightcove video</a>'; |
||
193 | } |
||
194 | ?> |
||
195 | </div> |
||
196 | <?php |
||
197 | |||
198 | echo wp_kses( |
||
199 | $field_type_object->input( |
||
200 | [ |
||
201 | 'type' => 'hidden', |
||
202 | 'id' => esc_attr( $field_id . '_bc_video_id' ), |
||
203 | 'class' => 'bc_video_id', |
||
204 | 'name' => esc_attr( $field_id . '[bc_video_id]' ), |
||
205 | 'value' => esc_attr( $bc_video_values['video_id'] ) ?? '', |
||
206 | ] |
||
207 | ), |
||
208 | $allowed_html |
||
209 | ); |
||
210 | echo wp_kses( |
||
211 | $field_type_object->input( |
||
212 | [ |
||
213 | 'type' => 'hidden', |
||
214 | 'id' => esc_attr( $field_id . '_bc_video_duration' ), |
||
215 | 'class' => 'bc_video_duration', |
||
216 | 'name' => esc_attr( $field_id . '[bc_video_duration]' ), |
||
217 | 'value' => esc_attr( $bc_video_values['video_duration'] ) ?? '', |
||
218 | ] |
||
219 | ), |
||
220 | $allowed_html |
||
221 | ); |
||
222 | echo wp_kses( |
||
223 | $field_type_object->input( |
||
224 | [ |
||
225 | 'type' => 'hidden', |
||
226 | 'id' => esc_attr( $field_id . '_bc_player_id' ), |
||
227 | 'class' => 'bc_player_id', |
||
228 | 'name' => esc_attr( $field_id . '[bc_player_id]' ), |
||
229 | 'value' => esc_attr( $bc_video_values['player_id'] ) ?? '', |
||
230 | ] |
||
231 | ), |
||
232 | $allowed_html |
||
233 | ); |
||
234 | echo wp_kses( |
||
235 | $field_type_object->input( |
||
236 | [ |
||
237 | 'type' => 'hidden', |
||
238 | 'id' => esc_attr( $field_id . '_bc_account_id' ), |
||
239 | 'class' => 'bc_account_id', |
||
240 | 'name' => esc_attr( $field_id . '[bc_account_id]' ), |
||
241 | 'value' => esc_attr( $bc_video_values['account_id'] ) ?? '', |
||
242 | ] |
||
243 | ), |
||
244 | $allowed_html |
||
245 | ); |
||
246 | ?> |
||
247 | </div> |
||
248 | <?php |
||
249 | |||
250 | // Enable jetpack embed filter. |
||
251 | if ( class_exists( 'Filter_Embedded_HTML_Objects' ) ) { |
||
252 | add_filter( 'pre_kses', [ 'Filter_Embedded_HTML_Objects', 'filter' ], 11 ); |
||
253 | add_filter( 'pre_kses', [ 'Filter_Embedded_HTML_Objects', 'maybe_create_links' ], 100 ); |
||
254 | } |
||
274 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths