Shortcoder - Version 3.1

Version Description

  • Changed the "Custom parameter" syntax from %param% to %%param%%
  • Code revision.
Download this release

Release Info

Developer vaakash
Plugin Icon 128x128 Shortcoder
Version 3.1
Comparing to
See all releases

Code changes from version 3.0.1 to 3.1

Files changed (3) hide show
  1. readme.txt +8 -4
  2. sc-editor.php +1 -1
  3. shortcoder.php +36 -33
readme.txt CHANGED
@@ -6,8 +6,8 @@ Tags: shortcode, ads, adsense, advertising, bookmark, bookmarking, bookmarks, cu
6
  Donate link: http://bit.ly/scdonate
7
  License: GPLv2 or later
8
  Requires at least: 2.5
9
- Tested up to: 3.4
10
- Stable tag: 3.0.1
11
 
12
  Create custom "Shortcodes" with HTML, Javascript snippets stored in it and use that shortcode within posts and pages. Check the demo video.
13
 
@@ -25,7 +25,7 @@ Shortcoder is a plugin which allows to create a custom shortcode and store HTML,
25
  1. Tada !!! the ad appears in the post.
26
 
27
  * Using this idea, shortcodes can be created for frequently used snippets.
28
- * You can also add parameters (like `%id%`) inside the snippets, and vary it like `[sc:youtube id="GrlRADfvjII"]`
29
  * This plugin will be hugely useful to all !!!
30
 
31
  = Features =
@@ -74,7 +74,7 @@ For more FAQs please visit the [Plugin homepage](http://www.aakashweb.com/faqs/s
74
 
75
  == Screenshots ==
76
 
77
- 1. Shortcoder admin page with a Shortcode created (youtube) with a parameter `%id%`.
78
  2. Using the shortcode `[sc:youtube id="GrlRADfvjII"]` in a post.
79
  3. Output of the Shortcode (The shortcode gets replaced with the youtube video).
80
  4. Select the shortcodes created using the toolbar button.
@@ -83,6 +83,10 @@ For more FAQs please visit the [Plugin homepage](http://www.aakashweb.com/faqs/s
83
 
84
  == Changelog ==
85
 
 
 
 
 
86
  = 3.0.1 =
87
  * Added license tag to the readme file.
88
 
6
  Donate link: http://bit.ly/scdonate
7
  License: GPLv2 or later
8
  Requires at least: 2.5
9
+ Tested up to: 3.4.1
10
+ Stable tag: 3.1
11
 
12
  Create custom "Shortcodes" with HTML, Javascript snippets stored in it and use that shortcode within posts and pages. Check the demo video.
13
 
25
  1. Tada !!! the ad appears in the post.
26
 
27
  * Using this idea, shortcodes can be created for frequently used snippets.
28
+ * You can also add parameters (like `%%id%%`) inside the snippets, and vary it like `[sc:youtube id="GrlRADfvjII"]`
29
  * This plugin will be hugely useful to all !!!
30
 
31
  = Features =
74
 
75
  == Screenshots ==
76
 
77
+ 1. Shortcoder admin page with a Shortcode created (youtube) with a parameter `%%id%%`.
78
  2. Using the shortcode `[sc:youtube id="GrlRADfvjII"]` in a post.
79
  3. Output of the Shortcode (The shortcode gets replaced with the youtube video).
80
  4. Select the shortcodes created using the toolbar button.
83
 
84
  == Changelog ==
85
 
86
+ = 3.1 =
87
+ * Changed the "Custom parameter" syntax from %param% to %%param%%
88
+ * Code revision.
89
+
90
  = 3.0.1 =
91
  * Added license tag to the readme file.
92
 
sc-editor.php CHANGED
@@ -201,7 +201,7 @@ foreach($sc_options as $key=>$value){
201
  if($key != '_version_fix'){
202
  echo '<div class="sc_shortcode"><div class="sc_shortcode_name">' . $key;
203
  echo '</div>';
204
- preg_match_all('/%[^%\s]+%/', $value['content'], $matches);
205
  echo '<div class="sc_params">';
206
  if(!empty($matches[0])){
207
  echo '<h4>Available parameters: </h4>';
201
  if($key != '_version_fix'){
202
  echo '<div class="sc_shortcode"><div class="sc_shortcode_name">' . $key;
203
  echo '</div>';
204
+ preg_match_all('/%%[^%\s]+%%/', $value['content'], $matches);
205
  echo '<div class="sc_params">';
206
  if(!empty($matches[0])){
207
  echo '<h4>Available parameters: </h4>';
shortcoder.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Shortcoder
4
  Plugin URI: http://www.aakashweb.com
5
  Description: Shortcoder is a plugin which allows to create a custom shortcode and store HTML, Javascript and other snippets in it. So if that shortcode is used in any post or pages, then the code stored in the shortcode get exceuted in that place. You can create a shortcode for Youtube videos, adsense ads, buttons and more. <a href="http://www.youtube.com/watch?v=GrlRADfvjII" title="Shortcoder demo video" target="_blank">Check out the demo video</a>.
6
  Author: Aakash Chakravarthy
7
- Version: 3.0.1
8
  Author URI: http://www.aakashweb.com/
9
  License: GPLv2 or later
10
  */
@@ -15,7 +15,7 @@ if(!defined('WP_CONTENT_URL')) {
15
  $sc_url = WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)) . '/';
16
  }
17
 
18
- define('SC_VERSION', '3.0.1');
19
  define('SC_AUTHOR', 'Aakash Chakravarthy');
20
  define('SC_URL', $sc_url);
21
 
@@ -109,7 +109,7 @@ function shortcoder($atts, $content) {
109
  // Seperate Key and value from atts
110
  foreach($atts as $k=>$v){
111
  if($k !== 0){
112
- $keys[$i] = "%" . $k . "%";
113
  $values[$i] = $v;
114
  }
115
  $i++;
@@ -118,14 +118,14 @@ function shortcoder($atts, $content) {
118
  // Replace the params
119
  $sc_content = $sc_options[$sc_name]['content'];
120
  $sc_content_rep1 = str_replace($keys, $values, $sc_content);
121
- $sc_content_rep2 = preg_replace('/%[^%\s]+%/', '', $sc_content_rep1);
122
  return "<!-- Start Shortcoder content -->" . $sc_content_rep2 . "<!-- End Shortcoder content -->";
123
  }
124
  else{
125
 
126
  // If the SC has no params, then replace the %vars%
127
  $sc_content = $sc_options[$sc_name]['content'];
128
- $sc_content_rep = preg_replace('/%[^%\s]+%/', '', $sc_content);
129
  return "<!-- Start Shortcoder content -->" . $sc_content_rep . "<!-- End Shortcoder content -->";
130
  }
131
 
@@ -134,34 +134,37 @@ function shortcoder($atts, $content) {
134
  }
135
  }
136
 
137
- // Shortcoder admin page
138
- function sc_admin_page(){
139
-
140
- $sc_updated = false;
141
- $sc_options = get_option('shortcoder_data');
142
 
143
- // Old version fix
144
- if(!isset($sc_options['_version_fix'])){
145
- $temp = array();
146
- if(!empty($sc_options)){
147
- for($i=0; $i<=20; $i++){
148
- $name = $sc_options[$i]['sc_name'];
149
- $cnt = $sc_options[$i]['sc_content'];
150
- $disable = $sc_options[$i]['sc_disable'];
151
- $admin = $sc_options[$i]['sc_is_admin'];
152
- if(isset($name)){
153
- $temp[$name]['content'] = $cnt;
154
- $temp[$name]['disabled'] = $disable;
155
- $temp[$name]['hide_admin'] = $admin;
156
- }
157
- }
158
  }
159
- unset($sc_options);
160
- $sc_options = $temp;
161
- unset($temp);
162
- $sc_options['_version_fix'] = 1;
163
- update_option("shortcoder_data", $sc_options);
164
  }
 
 
 
 
 
 
 
 
 
165
 
166
  $title = "Create a Shortcode";
167
  $button = "Create Shortcode";
@@ -212,6 +215,7 @@ function sc_admin_page(){
212
  echo '<div class="message updated fade"><p>' . __('Shortcode deleted successfully !', 'sc') . '</p></div>';
213
  }
214
  }
 
215
 
216
  ?>
217
 
@@ -245,7 +249,7 @@ function sc_admin_page(){
245
 
246
  <?php wp_nonce_field('shortcoder_create_form'); ?>
247
  <input name="sc_form_main" type="hidden" value="1" />
248
- <small class="grey">Note: Use <strong>%someParameter%</strong> to insert custom parameters. <a href="http://www.aakashweb.com/wordpress-plugins/shortcoder/" target="_blank">Learn More</a>.</small>
249
  </form>
250
 
251
  <h3>Created shortcodes <small>(Click to edit)</small></h3>
@@ -254,8 +258,7 @@ function sc_admin_page(){
254
  <?php
255
  $sc_options = get_option('shortcoder_data');
256
  foreach($sc_options as $key=>$value){
257
- if($key != '_version_fix')
258
- echo '<li>' . $key . '</li>';
259
  }
260
  ?>
261
  </ul>
4
  Plugin URI: http://www.aakashweb.com
5
  Description: Shortcoder is a plugin which allows to create a custom shortcode and store HTML, Javascript and other snippets in it. So if that shortcode is used in any post or pages, then the code stored in the shortcode get exceuted in that place. You can create a shortcode for Youtube videos, adsense ads, buttons and more. <a href="http://www.youtube.com/watch?v=GrlRADfvjII" title="Shortcoder demo video" target="_blank">Check out the demo video</a>.
6
  Author: Aakash Chakravarthy
7
+ Version: 3.1
8
  Author URI: http://www.aakashweb.com/
9
  License: GPLv2 or later
10
  */
15
  $sc_url = WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)) . '/';
16
  }
17
 
18
+ define('SC_VERSION', '3.1');
19
  define('SC_AUTHOR', 'Aakash Chakravarthy');
20
  define('SC_URL', $sc_url);
21
 
109
  // Seperate Key and value from atts
110
  foreach($atts as $k=>$v){
111
  if($k !== 0){
112
+ $keys[$i] = "%%" . $k . "%%";
113
  $values[$i] = $v;
114
  }
115
  $i++;
118
  // Replace the params
119
  $sc_content = $sc_options[$sc_name]['content'];
120
  $sc_content_rep1 = str_replace($keys, $values, $sc_content);
121
+ $sc_content_rep2 = preg_replace('/%%[^%\s]+%%/', '', $sc_content_rep1);
122
  return "<!-- Start Shortcoder content -->" . $sc_content_rep2 . "<!-- End Shortcoder content -->";
123
  }
124
  else{
125
 
126
  // If the SC has no params, then replace the %vars%
127
  $sc_content = $sc_options[$sc_name]['content'];
128
+ $sc_content_rep = preg_replace('/%%[^%\s]+%%/', '', $sc_content);
129
  return "<!-- Start Shortcoder content -->" . $sc_content_rep . "<!-- End Shortcoder content -->";
130
  }
131
 
134
  }
135
  }
136
 
137
+ // Plugin on activate fixes
138
+ function sc_onactivate(){
139
+ $sc_options = get_option('shortcoder_data');
140
+ $sc_flags = get_option('shortcoder_flags');
 
141
 
142
+ // Move the flag version fix to sc_flags option
143
+ if(isset($sc_options['_version_fix'])){
144
+ unset($sc_options['_version_fix']);
145
+ update_option('shortcoder_data', $sc_options);
146
+ }
147
+
148
+ // Double percentage fix and flag
149
+ if(!isset($sc_flags['double_percent'])){
150
+ foreach($sc_options as $key => $val){
151
+ $temp = str_replace('%', '%%', $sc_options[$key]['content']);
152
+ $sc_options[$key]['content'] = $temp;
 
 
 
 
153
  }
154
+
155
+ update_option('shortcoder_data', $sc_options);
156
+ $sc_flags['double_percent'] = 1;
157
+ update_option('shortcoder_flags', $sc_flags);
 
158
  }
159
+ }
160
+ register_activation_hook(__FILE__, 'sc_onactivate');
161
+
162
+ // Shortcoder admin page
163
+ function sc_admin_page(){
164
+
165
+ $sc_updated = false;
166
+ $sc_options = get_option('shortcoder_data');
167
+ $sc_flags = get_option('shortcoder_flags');
168
 
169
  $title = "Create a Shortcode";
170
  $button = "Create Shortcode";
215
  echo '<div class="message updated fade"><p>' . __('Shortcode deleted successfully !', 'sc') . '</p></div>';
216
  }
217
  }
218
+
219
 
220
  ?>
221
 
249
 
250
  <?php wp_nonce_field('shortcoder_create_form'); ?>
251
  <input name="sc_form_main" type="hidden" value="1" />
252
+ <small class="grey">Note: Use <strong style="color:#006600">%%someParameter%%</strong> to insert custom parameters. <a href="http://www.aakashweb.com/faqs/wordpress-plugins/shortcoder/using-attributes/" target="_blank">Learn More</a>. Custom parameter format is now changed as in previous line (<a href="http://www.aakashweb.com/forum/shortcoder-f8/change-parameter-symbol-t1532.html" target="_blank">Issue: 2526</a>)</small>
253
  </form>
254
 
255
  <h3>Created shortcodes <small>(Click to edit)</small></h3>
258
  <?php
259
  $sc_options = get_option('shortcoder_data');
260
  foreach($sc_options as $key=>$value){
261
+ echo '<li>' . $key . '</li>';
 
262
  }
263
  ?>
264
  </ul>