Spacing field defaults setting and units problem
This is my configuration for a spacing field:
array(
"title" => _x( "Main area padding", "backend", "coach-theme" ),
"desc" => _x( "Select the top and bottom padding for the main area.", "backend", "coach-theme" ),
"id" => "opt_mainareapadding",
"type" => "spacing",
"mode" => "padding",
"units" => array('em', 'px'),
"units_extended" => true,
"top" => true,
"bottom" => true,
"left" => false,
"right" => false,
"default" => array(
'padding-top' => '1em',
'padding-bottom' => '1em',
),
),
- If I reset the section or after installation the default values will be set to 1px and 1px.
- I can select 10 different units (maybe because "units_extended => true), but if I set "units_extended" => false, I can still select between 5 values, not only the 2 from the "units" array.
- The only way I can get the default value set properly to 1em, 1em is to configure "units => 'em', but in this case I cannot select any unit, even if "units_extended" => true.
In your default array, add this: 'units' => 'em'. As for the issue regarding extended units, I'll have to get back to you on that. It does seems wonky, it defaults to the five standard instead of the two specified. Probably a glitch in the logic, but I'll check into it.
Oh, by the way, after adding the units default, you'll have to reset the section to get the default to show. :)
Just pushed 3.1.5.9, which should take care of the select box properly listing your units. Just FYI, if you set units in your code, it overrides units_extended, so even with it set to true, it will only list the units you specify. This is (should have been originally) by design.
Hi Kevin, thank you very much. It works great. I added the units in the default array and deleted the units_extended. It now shows the behavior I want.