Shortcode Issues
-
I think there are a couple of issues with the shortcode part of the plugin. I attempted to swap out the widget for just a simple shortcode, and a few things broke in the transition. Notably, I could not get it to load, kept returning the ‘keep refreshing’ error message. I believe I figured out the reason for this issue, after doing some digging.
On lines 175 and 182, the same line of code reads:
$results = icit_fetch_open_weather( $appid, $city, $country, $display );
But, according to the function in the helper class, the last parameter should be
$breakdown
, and not$display
.Line 9 of
/includes/helpers.php
reads:
function icit_fetch_open_weather( $appid, $city = 'liverpool', $country = 'uk', $extended = false ) {
And, I’m pretty sure,
$extended
is supposed to be$breakdown
, since it was never passing a simple boolean false, but ‘none’ which should be only for the CSS.On a different note, I simplified, and extended the parameters able to be passed in the shortcode by changing a few lines of code in icit-weather-widget.php. Lines 103 – 110 read test individual shortcode atts to see if they read false and then set them appropriately to ‘false’.
I simplified the code to run a foreach loop on the defaults, tested if they were boolean by default, and if so, applied a filter_var on the current attribute to verify it is indeed boolean, and, if not, doesn’t re-set the attribute.
foreach( $this->defaults as $key => $default ) { if ( is_bool( $default ) && !is_null( filter_var( $attributes[$key], FILTER_VALIDATE_BOOLEAN ) ) ) $attributes[$key] = filter_var( $attributes[$key], FILTER_VALIDATE_BOOLEAN ); }
This worked for me, and extended the boolean variables in the shortcode.
- The topic ‘Shortcode Issues’ is closed to new replies.