Tagged: shortcode, shortcode generator
Add to Shortcode Generator
-
AuthorReplies
-
November 12, 2015 at 8:00 pm #24075
Jason Bobich
KeymasterHi,
No, it’s not something I’ve really intended anyone to add to. It’s honestly sort of a complex thing. In theory though you could probably add a basic shortcode to it…. ha, no promises though.
Filter in a tab for it:
And then filter in the shortcode and options to the big array of shortcodes:
The key of the array item you add to the larger array you’re filtering will be the shortcode like:
$options['foo'] = array( // your basic array of options like other places in the // framework, option types are more limited though );
If you want your shortcode to enclose content like
[foo]some content...[/foo]
, then within the shortcode’s options, create a textarea option with IDsc_content
and I think the shortcode generator takes care of the rest.-
This reply was modified 7 years, 4 months ago by
Jason Bobich.
November 12, 2015 at 10:53 pm #24082mizzinc
ParticipantThat was super helpful! I added the icon box with a few adjustments.
The only bug: when opening the generator the icon box (new item) is set to active and looking at the source code it appears the Button is as well. Any thoughts?
Button Icon Box Product
– Michael
November 12, 2015 at 11:34 pm #24083Jason Bobich
KeymasterWhat’s the code you’ve written for adding to the generator?
November 12, 2015 at 11:36 pm #24084mizzinc
Participantfunction my_shortcodes_groups( $groups ) { $groups['icon_box_product']['id'] = 'product_box'; $groups['icon_box_product']['name'] = __( 'Icon Box Product', 'theme-blvd-shortcodes' ); $groups['icon_box_product']['sub'] = array(); return $groups; } add_filter( 'themeblvd_shortcodes_groups', 'my_shortcodes_groups' );
function my_shortcodes_options( $options ) { // Image $options['product_box']['image']['id'] = 'image'; $options['product_box']['image']['name'] = __( 'Image URL', 'theme-blvd-shortcodes'); $options['product_box']['image']['desc'] = __( 'Copy/Paste the image/icon to be used. Ex: http://yoursite.com/image.jpg', 'theme-blvd-shortcodes'); $options['product_box']['image']['type'] = 'text'; // Size $options['product_box']['size']['id'] = 'size'; $options['product_box']['size']['name'] = __( 'Icon Size', 'theme-blvd-shortcodes'); $options['product_box']['size']['desc'] = __( 'Enter a size for the icon - 16px to 128px', 'theme-blvd-shortcodes'); $options['product_box']['size']['type'] = 'text'; // Location $options['product_box']['location']['id'] = 'location'; $options['product_box']['location']['name'] = __( 'Icon Placement', 'theme-blvd-layout-builder' ); $options['product_box']['location']['desc'] = __( 'Select how the icon should be displayed within the block.', 'theme-blvd-shortcodes'); $options['product_box']['location']['std'] = 'above'; $options['product_box']['location']['type'] = 'select'; $options['product_box']['location']['options']['above'] = __('Icon is above title and content.', 'theme-blvd-shortcodes'); $options['product_box']['location']['options']['side'] = __('Icon is to the left of title and content.', 'theme-blvd-shortcodes'); $options['product_box']['location']['options']['side-alt'] = __('Icon is to the right of title and content.', 'theme-blvd-shortcodes'); // Title $options['product_box']['title']['id'] = 'title'; $options['product_box']['title']['name'] = __( 'Title', 'theme-blvd-shortcodes'); $options['product_box']['title']['desc'] = __( 'Add the title', 'theme-blvd-shortcodes'); $options['product_box']['title']['type'] = 'text'; // Text $options['product_box']['text']['id'] = 'sc_content'; $options['product_box']['text']['name'] = __( 'Content (optional)', 'theme-blvd-shortcodes'); $options['product_box']['text']['desc'] = __( 'Add content that will appear when mouse hovers over the product.', 'theme-blvd-shortcodes'); $options['product_box']['text']['std'] = 'Content here...'; $options['product_box']['text']['type'] = 'textarea'; // Link URL $options['product_box']['link_url']['id'] = 'link_url'; $options['product_box']['link_url']['name'] = __( 'Link URL', 'theme-blvd-shortcodes'); $options['product_box']['link_url']['desc'] = __( 'Enter the full URL where you want this link to go to.', 'theme-blvd-shortcodes'); $options['product_box']['link_url']['type'] = 'text'; // Background Colour $options['product_box']['bg_color']['id'] = 'bg_color'; $options['product_box']['bg_color']['name'] = __( 'Product', 'theme-blvd-shortcodes'); $options['product_box']['bg_color']['desc'] = __( 'Please select the product which will automatically apply the background gradient colour', 'theme-blvd-shortcodes'); $options['product_box']['location']['std'] = 'hydrocolloids'; $options['product_box']['bg_color']['type'] = 'select'; $options['product_box']['bg_color']['options']['hydrocolloids'] = __('Hydrocolloids', 'theme-blvd-shortcodes'); $options['product_box']['bg_color']['options']['colours'] = __('Colours', 'theme-blvd-shortcodes'); $options['product_box']['bg_color']['options']['emulsifiers'] = __('Emulsifiers', 'theme-blvd-shortcodes'); $options['product_box']['bg_color']['options']['flavourings'] = __('Flavourings', 'theme-blvd-shortcodes'); $options['product_box']['bg_color']['options']['fortificants'] = __('Fortificants', 'theme-blvd-shortcodes'); $options['product_box']['bg_color']['options']['andmore'] = __('And more....', 'theme-blvd-shortcodes'); $options['product_box']['bg_color']['options']['andmore'] = __('None', 'theme-blvd-shortcodes'); return $options; } add_filter( 'themeblvd_shortcodes_options', 'my_shortcodes_options' );
November 13, 2015 at 9:53 pm #24095Jason Bobich
KeymasterWhen you filter
themeblvd_shortcodes_groups
you’re making the key of the array item you’re addingicon_box_product
— but instead the keys of these arrays need to be integers that are incremented.So, do it like this:
function my_shortcodes_groups( $groups ) { $groups[] = array( 'id' => 'product_box', 'name' => __( 'Icon Box Product', 'theme-blvd-shortcodes' ), 'sub' => array() ); return $groups; } add_filter( 'themeblvd_shortcodes_groups', 'my_shortcodes_groups' );
November 13, 2015 at 10:19 pm #24099mizzinc
ParticipantI’ll just go find that coding 101 book I had. Ha! Thank you.
-
This reply was modified 7 years, 4 months ago by
-
AuthorReplies
- You must be logged in to reply to this topic.