wp-shortcake / shortcake

Shortcake makes using WordPress shortcodes a piece of cake.
GNU General Public License v2.0
664 stars 142 forks source link

Allow 'inner_content' below all the shortcode args #403

Open cliffordp opened 9 years ago

cliffordp commented 9 years ago

Whether 'inner_content' => array(), is added before or after the shortcode's attrs, it displays first in the shortcode UI.

Why not let me display it under the attrs?

danielbachhuber commented 9 years ago

Why not let me display it under the attrs?

Seems like a reasonable enhancement.

bishless commented 9 years ago

I'd dig this, too!

Could it be done w/ a 'priority' => '10', addition to each attribute array (10 is just an ex)? Then we could have more control over the attr order in our UI.

khromov commented 9 years ago

Why not let inner_content be a regular field and let the array order in attrs determine the natural ordering? That way you could even (theoretically) use any field type:

array(
  'label'  => esc_html__( 'Content', 'shortcake' ),
  'attr'   => '_inner_content', // "_inner_content" is a reserved attribute name that always refers to the inner content
  'type'         => 'text',
  'description'  => esc_html__( 'Enter the content.', 'shortcake' ),
  ),
danielbachhuber commented 9 years ago

Why not let inner_content be a regular field and let the array order in attrs determine the natural ordering?

Because it has the potential of conflicting with an attribute named inner_content. It's a special case.

I like the priority idea, where every field defaults to 10.

khromov commented 9 years ago

@danielbachhuber It would conflict with the attribute named _inner_content, which is quite an unlikely attribute name and underscores are common convention for "private" variables. (See hidden meta fields, etc)

I think priority just complicates what is an inherit feature in PHP arrays - natural ordering.

danielbachhuber commented 9 years ago

It would conflict with the attribute named _inner_content, which is quite an unlikely attribute name and underscores are common convention for "private" variables. (See hidden meta fields, etc)

Eh, I'm not a huge fan of special cases when we don't need to add them.

I think priority just complicates what is an inherit feature in PHP arrays - natural ordering.

priority is an established paradigm for ordering in WordPress, particularly when adding entries after the original array has been defined (which we support through filters).

khromov commented 9 years ago

Eh, I'm not a huge fan of special cases when we don't need to add them.

But dedicating a "magic" array key like we have today for inner_content is still be a special case, whether it's in the attrs array or not.

It would streamline the experience for devs (all fields are handled the same), reduce code (no special handling for inner_content required) as well as improve flexibility (use any field type for inner_content ) to stick the inner content field into attrs array.

priority is an established paradigm for ordering in WordPress, particularly when adding entries after the original array has been defined (which we support through filters).

Fair point, I think it's the better decision to use priority!

danielbachhuber commented 9 years ago

But dedicating a "magic" array key like we have today for inner_content is still be a special case, whether it's in the attrs array or not.

Not really. Shortcode attributes are technically different than the inner content for a shortcode.

rahulv3a commented 8 years ago

I like the idea of getting more control over the position of 'inner_content'.

Any idea when can we expect this feature? I hope soon.