Splitting Shortcode Attributes not working

I want to adjust a comparison based on attributes I define in my shortcode. As example I use the following short code:

[comparison phonePrefix=”0581″,phoneFlatOption=”true”,
accessModeDsl=”true”, accessModeCable=”false”, accessModeLte=”false”,
accessModeSat=”false”]

Now here is my shortcode function:

function comparison($atts){

$atts = shortcode_atts(
array(
‘phonePrefix’ => ‘030’,
‘customerType’ => ‘existingCustomer’,
‘remainingContractDuration’ => ‘6’,
‘phoneFlatOption’ => ‘true’,
‘minSpeed’ => ‘50000’,
‘accessModeDsl’ => ‘true’,
‘onlyProductsWithoutTrafficLimitation’ => ‘true’,
‘accessModeCable’ => ‘true’,
‘accessModeLte’ => ‘true’,
‘accessModeSat’ => ‘true’,
‘contractDuration’ => ‘-1’,
‘mergeDefaults’ => ‘false’,
), $atts, ‘dslVergleich’);
}

As I understood the shortcode_atts() function it should now replace the default value of ‘phonePrefix’ with 0581. But after I use the function there is still the default value of 030.

This is a var_dump before i used shortcode_atts():

array(5) { [0]=> string(42) “phonePrefix=”0581″,phoneFlatOption=”true”,”
[1]=> string(21) “accessModeDsl=”true”,” [2]=> string(24)
“accessModeCable=”false”,” [3]=> string(22) “accessModeLte=”false”,”
[“accessmodesat”]=> string(5) “false” }

And this is after i used shortcode_atts():

array(12) { [“phonePrefix”]=> string(3) “030” [“customerType”]=> string(16)
“existingCustomer” [“remainingContractDuration”]=> string(1) “6”
[“phoneFlatOption”]=> string(4) “true” [“minSpeed”]=> string(5) “50000”
[“accessModeDsl”]=> string(4) “true”
[“onlyProductsWithoutTrafficLimitation”]=> string(4) “true”
[“accessModeCable”]=> string(4) “true” [“accessModeLte”]=> string(4) “true”
[“accessModeSat”]=> string(4) “true” [“contractDuration”]=> string(2) “-1”
[“mergeDefaults”]=> string(5) “false” }

Thanks for the help!

Greetings

Read more here:: Splitting Shortcode Attributes not working

Leave a Reply

Your email address will not be published. Required fields are marked *