Automattic /
jetpack
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 | * Most of the heavy lifting done in iCalendarReader class |
||
| 5 | */ |
||
| 6 | class Upcoming_Events_Shortcode { |
||
| 7 | |||
| 8 | public static function init() { |
||
| 9 | add_shortcode( 'upcomingevents', array( __CLASS__, 'shortcode' ) ); |
||
| 10 | } |
||
| 11 | |||
| 12 | public static function shortcode( $atts = array() ) { |
||
| 13 | jetpack_require_lib( 'icalendar-reader' ); |
||
| 14 | $atts = shortcode_atts( array( 'url' => '', 'number' => 0 ), $atts, 'upcomingevents' ); |
||
| 15 | $args = array( |
||
| 16 | 'context' => 'shortcode', |
||
| 17 | 'number' => absint( $atts['number'] ), |
||
| 18 | ); |
||
| 19 | $events = icalendar_render_events( $atts['url'], $args ); |
||
| 20 | |||
| 21 | if ( ! $events ) { |
||
|
0 ignored issues
–
show
|
|||
| 22 | $events = sprintf( '<p>%s</p>', __( 'No upcoming events', 'jetpack' ) ); |
||
| 23 | } |
||
| 24 | |||
| 25 | return $events; |
||
| 26 | } |
||
| 27 | } |
||
| 28 | |||
| 29 | add_action( 'plugins_loaded', array( 'Upcoming_Events_Shortcode', 'init' ), 101 ); |
||
| 30 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: