{"id":9536928,"date":"2017-09-27T20:54:10","date_gmt":"2017-09-27T20:54:10","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/shortcode-issues-11\/"},"modified":"2017-09-27T20:54:10","modified_gmt":"2017-09-27T20:54:10","slug":"shortcode-issues-11","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/shortcode-issues-11\/","title":{"rendered":"Shortcode Issues"},"content":{"rendered":"<p>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 &#8216;keep refreshing&#8217; error message.  I believe I figured out the reason for this issue, after doing some digging.<\/p>\n<p>On lines 175 and 182, the same line of code reads:<br \/>\n<code>$results = icit_fetch_open_weather( $appid, $city, $country, $display );<\/code><\/p>\n<p>But, according to the function in the helper class, the last parameter should be <code>$breakdown<\/code>, and not <code>$display<\/code>.<\/p>\n<p>Line 9 of <code>\/includes\/helpers.php<\/code> reads:<br \/>\n<code>function icit_fetch_open_weather( $appid, $city = &#039;liverpool&#039;, $country = &#039;uk&#039;, $extended = false ) {<\/code><\/p>\n<p>And, I&#8217;m pretty sure, <code>$extended<\/code> is supposed to be <code>$breakdown<\/code>, since it was never passing a simple boolean false, but &#8216;none&#8217; which should be only for the CSS.<\/p>\n<p>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 &#8211; 110 read test individual shortcode atts to see if they read false and then set them appropriately to &#8216;false&#8217;.<\/p>\n<p>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&#8217;t re-set the attribute.<\/p>\n<pre><code>foreach( $this-&gt;defaults as $key =&gt; $default ) {\n\tif ( is_bool( $default ) &amp;&amp; !is_null( filter_var( $attributes[$key], FILTER_VALIDATE_BOOLEAN ) ) )\n\t\t$attributes[$key] = filter_var( $attributes[$key], FILTER_VALIDATE_BOOLEAN );\n}<\/code><\/pre>\n<p>This worked for me, and extended the boolean variables in the shortcode.<\/p>\n","protected":false},"template":"","class_list":["post-9536928","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9536928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/9536928\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=9536928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}