shortcode.api.php
3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* @file
* Shortcode API documentation.
*/
/**
* hook_shortcode_info()
* Declare shortcodes
*
* @return
* 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 shortcode
* 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
*
*/
function hook_shortcode_info() {
// Quote shortcode example
$shortcodes['quote'] = array(
'title' => t('Quote'),
'description' => t('Replace a given text formatted like a quote.'),
'process callback' => 'shortcode_basic_tags_shortcode_quote',
//'settings callback' => '_shortcode_settings_form', TODO
'tips callback' => 'shortcode_basic_tags_shortcode_quote_tip',
'attributes callback' => '_shortcode_settings_form',
'default settings' => array(),
);
return $shortcodes;
}
/**
* hook_shortcode_info_alter()
* Alter existing shortcodes
*
* @param $shortcodes
* An associative array of shortcodes
*
* @return
* 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.
* - 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 shortcode
* usage guidelines for the shortcode.
*/
/**
* @param $shortcodes
*/
function hook_shortcode_info_alter(&$shortcodes) {
// Example to change the process callback for quotes.
$shortcodes['quote']['process callback'] = 'MYMODULE_shortcode_quote';
}