No parameters in shortcode results in error
-
Hello ,
when shortcodes are used and no parameters passed e.g.
[woocs]
an error is thrown :"WARNING: wp-content/plugins/woocommerce-currency-switcher/index.php:1384 - extract() expects parameter 1 to be array, string given require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/var/www/themes_archive/Bishop/bishop/page.php'), get_header, locate_template, load_template, require_once('/var/www/themes_archive/Bishop/bishop/header.php'), get_template_part, locate_template, load_template, require('/var/www/themes_archive/Bishop/bishop/theme_includes/site-currency.php'), do_shortcode, preg_replace_callback, do_shortcode_tag, call_user_func, WOOCS->woocs_shortcode, WOOCS->render_html, extract"
Fixed by checking if $args are empty declare it as array.
//[woocs] public function woocs_shortcode($args) { if(empty($args)) $args = array(); return $this->render_html(WOOCS_PATH . 'views/shortcodes/woocs.php', $args); }
Better if you would use the shortcode_atts() to declare defaults.
https://www.ads-software.com/plugins/woocommerce-currency-switcher/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘No parameters in shortcode results in error’ is closed to new replies.