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 |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * Homes.com Commute Time Widget (http://www.homes.com/widget/commute-time/) |
||
4 | * |
||
5 | * @package RE-PRO |
||
6 | */ |
||
7 | |||
8 | /* Exit if accessed directly. */ |
||
9 | if ( ! defined( 'ABSPATH' ) ) { exit; } |
||
10 | |||
11 | /** |
||
12 | * HomesCommuteTimeWidget class. |
||
13 | * |
||
14 | * @extends WP_Widget |
||
15 | */ |
||
16 | class HomesCommuteTimeWidget extends WP_Widget { |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
17 | |||
18 | /** |
||
19 | * __construct function. |
||
20 | * |
||
21 | * @access public |
||
22 | * @return void |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Adding a
@return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.
Adding a Please refer to the PHP core documentation on constructors. ![]() |
|||
23 | */ |
||
24 | public function __construct() { |
||
25 | |||
26 | parent::__construct( |
||
27 | 'homes_commute_time', |
||
28 | __( 'Homes Commute Time', 're-pro' ), |
||
29 | array( |
||
30 | 'description' => __( 'Display a form that checks the commute time from Homes.com', 're-pro' ), |
||
31 | 'classname' => 're-pro re-pro-widget homes-widget homes-commute-time', |
||
32 | 'customize_selective_refresh' => true, |
||
33 | ) |
||
34 | ); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * Widget function. |
||
39 | * |
||
40 | * @access public |
||
41 | * @param mixed $args Arguments. |
||
42 | * @param mixed $instance Instance. |
||
43 | */ |
||
44 | public function widget( $args, $instance ) { |
||
45 | |||
46 | $iframe_id = ! empty( $args['widget_id'] ) ? $args['widget_id'] : ''; |
||
47 | $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; |
||
48 | $addr = ! empty( $instance['addr'] ) ? $instance['addr'] : ''; |
||
49 | $color = ! empty( $instance['color'] ) ? $instance['color'] : ''; |
||
50 | |||
51 | echo $args['before_widget']; |
||
52 | |||
53 | echo $args['before_title'] . esc_attr( $title ) . $args['after_title']; |
||
54 | |||
55 | $homes_widgets = new HomesWidgets(); |
||
56 | |||
57 | $homes_widgets->get_commute_time_widget( $iframe_id, $addr, $color ); |
||
58 | |||
59 | echo $args['after_widget']; |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Form function. |
||
64 | * |
||
65 | * @access public |
||
66 | * @param mixed $instance Instance. |
||
67 | * @return void |
||
68 | */ |
||
69 | public function form( $instance ) { |
||
70 | |||
71 | // Set default values. |
||
72 | $instance = wp_parse_args( (array) $instance, array( |
||
73 | 'title' => '', |
||
74 | 'addr' => '', |
||
75 | 'color' => '0054a0', |
||
76 | ) ); |
||
77 | |||
78 | // Retrieve an existing value from the database. |
||
79 | $title = ! empty( $instance['title'] ) ? $instance['title'] : ''; |
||
80 | $addr = ! empty( $instance['addr'] ) ? $instance['addr'] : ''; |
||
81 | $color = ! empty( $instance['color'] ) ? $instance['color'] : ''; |
||
82 | |||
83 | // Title. |
||
84 | echo '<p>'; |
||
85 | echo ' <label for="' . $this->get_field_id( 'title' ) . '" class="title-label">' . __( 'Tile:', 're-pro' ) . '</label>'; |
||
86 | echo ' <input id="' . $this->get_field_id( 'title' ) . '" name="' . $this->get_field_name( 'title' ) . '" value="' . $title . '" class="widefat">'; |
||
87 | echo '</p>'; |
||
88 | |||
89 | // Street Address. |
||
90 | echo '<p>'; |
||
91 | echo ' <label for="' . $this->get_field_id( 'addr' ) . '" class="title-label">' . __( 'Default Start Address:', 're-pro' ) . '</label>'; |
||
92 | echo ' <input id="' . $this->get_field_id( 'addr' ) . '" name="' . $this->get_field_name( 'addr' ) . '" value="' . $addr . '" class="widefat">'; |
||
93 | echo '</p>'; |
||
94 | |||
95 | // Button Color |
||
96 | echo '<p>'; |
||
97 | echo ' <label for="' . $this->get_field_id( 'color' ) . '" class="title-label">' . __( 'Button Color:', 're-pro' ) . '</label>'; |
||
98 | echo ' <input id="' . $this->get_field_id( 'color' ) . '" name="' . $this->get_field_name( 'color' ) . '" value="' . $color . '" class="widefat">'; |
||
99 | echo '</p>'; |
||
100 | |||
101 | } |
||
102 | |||
103 | /** |
||
104 | * Update Widget Instance. |
||
105 | * |
||
106 | * @access public |
||
107 | * @param mixed $new_instance New Instance. |
||
108 | * @param mixed $old_instance Old Instance. |
||
109 | * @return $instance |
||
0 ignored issues
–
show
The doc-type
$instance could not be parsed: Unknown type name "$instance" 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. ![]() |
|||
110 | */ |
||
111 | View Code Duplication | public function update( $new_instance, $old_instance ) { |
|
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. ![]() |
|||
112 | |||
113 | $instance = $old_instance; |
||
114 | |||
115 | $instance['title'] = ! empty( $new_instance['title'] ) ? strip_tags( $new_instance['title'] ) : ''; |
||
116 | $instance['addr'] = ! empty( $new_instance['addr'] ) ? strip_tags( $new_instance['addr'] ) : ''; |
||
117 | $instance['color'] = ! empty( $new_instance['color'] ) ? strip_tags( $new_instance['color'] ) : ''; |
||
118 | |||
119 | return $instance; |
||
120 | } |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * Register Homes.com Cummute Time Widget. |
||
125 | * |
||
126 | * @access public |
||
127 | * @return void |
||
128 | */ |
||
129 | function repro_homes_com_commute_widget() { |
||
130 | if ( ! is_ssl() ) { |
||
131 | register_widget( 'HomesCommuteTimeWidget' ); |
||
132 | } |
||
133 | } |
||
134 | add_action( 'widgets_init', 'repro_homes_com_commute_widget' ); |
||
135 |
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.