Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

Unable to Update New Shortcode Options

Open NwpDeveloper opened this issue 10 years ago • 2 comments

Just wanted to double check this is the correct behavior.

If I change the key or how an option is nested, ANY shortcode already laid out in page builder doesn't work.

Example: I have a basic shortcode called title.

'title' => array(
    'type' =>'text',
    'attr'  => array('class' => 'fw-full-control'),
    'value' => 'Title',
),

I drag a shortcode and save it with text "Hello World". If I later decide to change the option like putting it in a popup and update the $atts in view.php; then the shortcode already laid out on pagebuilder will return default val "Title" instead of "Hello World."

This is because when the shortcode is initially saved the data in post_meta and posts has ["title"="Hello World"]. However, since we changed the option and view to $atts['title popup']['title] it doesn't exist in the db.

This is bad because if you decide to change a shortcode's option after it's already laid out in a page the entire page loses it's options and nothing is rendered.

Is there a cleaner way of maintaining changes other than making a switch to check if old option vars isset?

NwpDeveloper avatar Feb 06 '16 21:02 NwpDeveloper

Would recursively looping $atts until the specified option $key is found be too slow? That's another way to handle this.

NwpDeveloper avatar Feb 06 '16 22:02 NwpDeveloper

This is the correct behavior.

If you are talking only about popup, there is a solution for you, use popup container (it's not in docs) https://github.com/ThemeFuse/Unyson/issues/615

'hello' => array(
    'type' => 'popup',
    'options' => array(
        'title' => array(
            'type' => 'text',
            'attr'  => array('class' => 'fw-full-control'),
            'value' => 'Title',
        ),
    ),
),

that way you will maintain $atts['title]

ghost avatar Feb 08 '16 08:02 ghost