You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. sets shortcode's name. Must not have spaces in it.<br/><br/>
48
+
2. defines shortcode parameters and their defaults. In this example we expect a parameter called _lang_ and it has a default value of _html_.<br/><br/>Then using _[code][/code]_ the resulting code will still use _html_, while using _[code lang="php"][/code]_ you will override the default value.<br/><br/>
49
+
3. FALSE if there are no contents (first example), TRUE if contents will be used within (second example)<br/><br/>
50
+
4. May be a function name triggering a callback or an [anonymous function](http://php.net/manual/en/functions.anonymous.php) (as used in the example).<br/>The function will have two parameters: and contents.<br/><br/>
51
+
1. __*shortcode attributes*__ - an associative array containing every attribute found in the shortcode implementation. It contains also custom ones not declared in shortcode registration (eg. _[hello param1="hey!"]_ )
52
+
2. __*contents*__ - this is empty if $has_contents is set to false
53
+
54
+
55
+
<br/>
56
+
57
+
#### Shortcodes execution
58
+
Once everything is properly registered, just let the class execute your string
59
+
60
+
```php
61
+
/**
62
+
* Execute shortcodes in a text string
63
+
*
64
+
* @param (string) $txt = text
65
+
* @param (bool) $bbcodes = whether to execute found BBcodes first (see https://www.bbcode.org/reference.php )
66
+
*
67
+
* @return (string) executed text
68
+
*/
69
+
70
+
$string = 'Lorem ipsum [code]dolor sit amet[/code]';
71
+
echo $lcqs->process($string, $bbcodes = true);
72
+
73
+
/* Resulting string:
74
+
* Lorem ipsum <preclass="language-html"><code>dolor sit amet</code></pre>
75
+
*/
76
+
```
77
+
78
+
First parameter is your string, while second ones sets whether to execute also BBcodes or not.
79
+
80
+
Here's the list of supported BBcodes:
81
+
82
+
| Example | Description |
83
+
| ------------- |:-------------:|
84
+
|[b]_test_[/b]| bold text |
85
+
|[i]_test_[/i]| italic text |
86
+
|[u]_test_[/u]| underlined text |
87
+
|[code]_test_[/code]| PRE code block |
88
+
|[size=20]_test_[/size]| sets font size (in pixels) |
89
+
|[color=#ff0000]_test_[/color]| sets text color (hex vlue) |
90
+
|[url]_http://mypage.com_[/url]| creates a link |
91
+
|[ul]<br/>[\*] test 1 <br/>[\*] test 2 <br/>[/ul]| unordered list |
92
+
|[ol]<br/>[\*] test 1 <br/>[\*] test 2 <br/>[/ol]| ordered list |
0 commit comments