- This topic has 3 replies, 2 voices, and was last updated 3 years, 7 months ago by Skandha.
-
AuthorPosts
-
September 1, 2020 at 3:10 pm #257814PaulParticipant
Hi,
I’m using the Code Snipetts plugin – https://wordpress.org/plugins/code-snippets/ – and followed the instructions in the support forum – https://wordpress.org/support/topic/passing-a-function-argument-through-the-shortcode/ – re parameter passing with the following code snipett.add_shortcode( ‘introduction’, function($atts){
$locn = $atts[“locn”];
$output = “”;
$output .= ‘<h1>Assessment Planner – ‘.$locn.'</h1>’;
$output .= ‘<table id=”chance”><tr><td style=”width: 12%”>% Chance:</td><td><span id=”legendContainer” class=”legend” style=”border-style: solid; border-color: threedface; width: 100%”> </span></td></tr></table>’;return $output;
});http://localhost/risk/wp-admin/edit.php?post_type=pageand get the following error report
Warning: Illegal string offset ‘locn’ in H:\sites.web\risk\wp-content\plugins\code-snippets\php\snippet-ops.php(446) : eval()’d code on line 3
Call Stack
# Time Memory Function Location
1 0.0002 410016 {main}( ) …\index.php:0
2 0.0005 410288 require( ‘H:\sites.web\risk\wp-blog-header.php’ ) …\index.php:17
3 0.1488 5806184 require_once( ‘H:\sites.web\risk\wp-includes\template-loader.php’ ) …\wp-blog-header.php:19
4 0.1573 5894984 include( ‘H:\sites.web\risk\wp-content\themes\catch-kathmandu-pro\page.php’ ) …\template-loader.php:106
5 0.2095 6080256 get_template_part( ) …\page.php:22
6 0.2096 6086408 locate_template( ) …\general-template.php:204
7 0.2576 6086520 load_template( ) …\template.php:676
8 0.2577 6086856 require( ‘H:\sites.web\risk\wp-content\themes\catch-kathmandu-pro\content-page.php’ ) …\template.php:732
9 0.2599 6153896 the_content( ) …\content-page.php:25
10 0.2601 6153920 apply_filters( ) …\post-template.php:253
11 0.2601 6154320 WP_Hook->apply_filters( ) …\plugin.php:206
12 0.2609 6157080 do_shortcode( ) …\class-wp-hook.php:287
13 0.2609 6159408 preg_replace_callback ( ) …\shortcodes.php:218
14 0.2609 6160024 do_shortcode_tag( ) …\shortcodes.php:218
15 0.2610 6160024 {closure:H:\sites.web\risk\wp-content\plugins\code-snippets\php\snippet-ops.php(446) : eval()’d code:1-9}( ) …\shortcodes.php:343The shortccode on the page is
[introduction locn=”UNITED KINGDOM”]
It works fine without reference to $atts[“locn”] in line 3 and $locn in line 5
The error report mentions teh Kathmandu theme, is there a conflict?
Thanks
Paul
September 2, 2020 at 1:39 am #257868SkandhaParticipant@paul-mac: Hello Paul,
Can you please post in your site URL so that I can look into the issue?Kind Regards,
SkandhaSeptember 2, 2020 at 2:52 am #257887PaulParticipantThe page is not live, it is still being developed on my local machine. But never mind I’ve been in contact with the plugin developer and he pointed me in the right directions.
I needed to add the following bit of code to the snipett:
add_shortcode( ‘introduction’, function ( $atts ) {
$atts = shortcode_atts( array(
‘locn’ => ”,
), $atts );Thanks for getting back to me though.
Paul
September 2, 2020 at 3:55 am #257893 -
AuthorPosts
- The topic ‘Error with Code Snipetts plugin’ is closed to new replies.