forked from nathanielks/Shortcodes-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
152 lines (112 loc) · 4.7 KB
/
README.txt
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
=== Shortcodes Generator ===
Contributors: fightthecurrent
Donate link: http://bit.ly/QhXuBc
Tags: shortcodes, theme, generator, develop
Requires at least: 3.0
Tested up to: 3.8.1
Stable tag: 1.2.1
A plugin to generate shortcodes and a corresponding button in the WordPress visual editor. Wicked!
== Description ==
Adding shortcodes to the Visual Editor can be a pain in the buttocks. Not anymore.
Now, you can add shortcodes and a button to the editor as simply as using an
array and this plugin. [How neat is that?](http://bit.ly/Pvj4ie)
You can check out more details on how to use the plugin, please visit [the plugin site.](http://fightthecurrent.org/plugins/shortcodes-generator)
Note: This plugin requires at LEAST PHP 5.3. If you're not sure what version of PHP you're using, consult your host.
== Credits ==
Some icons by [Yusuke Kamiyamane](http://p.yusukekamiyamane.com/). All rights reserved. Licensed under a [Creative Commons Attribution 3.0 License](href="http://creativecommons.org/licenses/by/3.0/).
== Installation ==
1. Upload `shortcodes-generator.zip` to the `/wp-content/plugins/` directory and unzip it
2. Activate the plugin through the 'Plugins' menu in WordPress
3. Drag the `shortcodes` folder inside `shortcodes-generator` to the root of your theme
4. Create your shortcode via arrays. For more details, check out the FAQ, or visit [the plugin site.](http://fightthecurrent.org/plugins/shortcodes-generator)
5. That's it! Enjoy!
== Frequently Asked Questions ==
= So how do I add the shortcodes, anyway? =
Well, after you've moved the `shortcodes` folder to your theme, open up
`shortcodes/array.php`. The simplest one you can make would look like this:
$shortcodes['button'] = array(
'shortcode' => 'button'
);
That would create a shortcode that looks like this: `[button]`
Then, for every shortcode you wish to add, just repeat
`$shortcodes['shortcode']` with the details filled in!
The template is as follows:
$shortcodes['name'] = array(
'shortcode' => '',
'function' => '',
'tag' => '',
'selectable' => 0
'atts' => array(
'name', 'name2'
),
'children'=> array(
'child' => array(
'shortcode' => '',
'function' => '',
'tag' => '',
'selectable' => 0
'atts' => array(
'name', 'name2'
),
),
)
);
= This seems too simple. What if I want more control? =
To use a specific function along with the short code, all you have to do is pass
`'function' => 'function_name'` as one of the paramaters for the array. Here's
an example:
$shortcodes['button'] = array(
'shortcode' => 'button',
'function' => 'cur_button_shortcode',
'selectable' => 1
'atts' => array(
'class', 'color'
),
);
The shortcode will now use `cur_button_shortcode` as the function to run for
the shortcode. The shortcode will look like this:
[button class="" color""][/button]
If you want to define some default parameters, just change atts to this:
'atts' => array(
'class' => 'small',
'color' => 'green'
)
It will produce this output:
[button class="small" color"green"][/button]
Want to be able to select text and have the shortcode wrap around it? Just pass
`'selectable' => 1`.
I will eventually add a ThickBox dialogue so that people can have default
selections picked out for them, and actually have more of a UI. But this will
do for now.
= Is it possible to embed into themes? =
Sure is! To do that, move the plugin file into your theme and include this code
in your functions.php file:
add_action( 'after_setup_theme', 'cur_shortcodes_theme_setup');
function cur_shortcodes_theme_setup(){
// We're assuming the plugin directory is located in
// /wp-content/themes/themename/shortcodes-generator/
define( 'CSG_URI', get_template_directory_uri() . '/shortcodes-generator/' );
require_once 'shortcodes-generator/cur-shortcodes-generator.php';
$csg = Cur_Shortcodes_Generator::get_instance();
}
It'll take care of the rest!
== Changelog ==
= 1.2.1 =
* Added CSG_URI to more easily embed plugin into themes
= 1.2 =
* BREAKING CHANGE: Changed params to atts in shortcode definition array
* Added cur_shortcode_atts so as to reduce repitition of shortcode attribute definitions. There was too much repition across array.php and functions.php
* Updated plugin to singleton pattern. Use Cur_Shortcodes_Generator::get_instance() to retreive instance of the class.
* Updated example array and functions
= 1.1.1 =
* fixed error where functions weren't required in the correct order
= 1.1 =
* editor_plugin.js is now stored in the theme's shortcodes directory.
= 1.0.2 =
* Fixed error where child shortcodes weren't being generated correctly.
= 1.0.1 =
* Fixed error where functions weren't being included.
* Fixed issue where $tags wasn't being unset.
*
= 1.0 =
* Initial Release