You are here

function hook_shortcode_info in Shortcode 7.2

Declare Shortcodes.

@hook hook_shortcode_info()

Return value

array An associative array of shortcodes, whose keys are internal shortcode names, which should be unique.. Each value is an associative array describing the shortcode, with the following elements (all are optional except as noted):

  • title: (required) An administrative summary of what the shortcode does.
  • description: Additional administrative information about the shortcode's behavior, if needed for clarification.
  • settings callback: The name of a function that returns configuration form elements for the shortcode. TODO
  • default settings: An associative array containing default settings for the shortcode, to be applied when the shortcode has not been configured yet.
  • process callback: (required) The name the function that performs the actual shortcodeing.
  • tips callback: The name of a function that returns end-user-facing usage guidelines for the shortcode.
  • todo: wysiwyg or attributes? WYSIWYG callback: The name of a function that returns a FAPI array with configuration input for the shortcode.
2 functions implement hook_shortcode_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

shortcode_basic_tags_shortcode_info in shortcode_basic_tags/shortcode_basic_tags.module
Implements hook_shortcode_info().
shortcode_embed_content_shortcode_info in shortcode_embed_content/shortcode_embed_content.module
Implements hook_shortcode_info()
1 invocation of hook_shortcode_info()
shortcode_list_all in ./shortcode.module
Builds a list of all ShortCodes (for filter).

File

./shortcode.api.php, line 34
Shortcode API documentation.

Code

function hook_shortcode_info() {

  // Example of quote Shortcode.
  $shortcodes['quote'] = array(
    'title' => t('Quote'),
    'description' => t('Replace a given text formatted like a quote.'),
    'process callback' => 'shortcode_basic_tags_shortcode_quote',
    // todo: write about this.
    // 'settings callback' => '_shortcode_settings_form',
    'tips callback' => 'shortcode_basic_tags_shortcode_quote_tip',
    'attributes callback' => '_shortcode_settings_form',
    'default settings' => array(),
  );
  return $shortcodes;
}