Version Description
- Fix: Custom parameters being not replaced in some scenarios.
- Fix: Minor enhancement to insert custom parameter form.
Download this release
Release Info
Developer | vaakash |
Plugin | Shortcoder |
Version | 5.2.1 |
Comparing to | |
See all releases |
Code changes from version 5.2 to 5.2.1
- admin/js/script.js +15 -7
- readme.txt +5 -1
- shortcoder.php +15 -27
admin/js/script.js
CHANGED
@@ -152,29 +152,37 @@ $(document).ready(function(){
|
|
152 |
});
|
153 |
|
154 |
$('.sc_cp_btn').on('click', function(){
|
155 |
-
|
156 |
var $cp_box = $('.sc_cp_box');
|
157 |
var $cp_default = $('.sc_cp_default');
|
158 |
var $cp_info = $('.sc_cp_info');
|
159 |
var param_val = $cp_box.val().trim();
|
160 |
var default_val = $cp_default.val().trim();
|
161 |
-
|
162 |
if( param_val != '' && $cp_box[0].checkValidity() ){
|
163 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
$cp_info.removeClass('red');
|
165 |
close_params_list();
|
166 |
}else{
|
167 |
$cp_info.addClass('red');
|
168 |
}
|
169 |
-
|
170 |
});
|
171 |
|
172 |
$('.sc_cf_btn').on('click', function(){
|
173 |
-
|
174 |
var $cf_box = $('.sc_cf_box');
|
175 |
var $cf_info = $('.sc_cf_info');
|
176 |
var param_val = $cf_box.val().trim();
|
177 |
-
|
178 |
if( param_val != '' && $cf_box[0].checkValidity() ){
|
179 |
insert_in_editor('$$custom_field:' + param_val + '$$');
|
180 |
$cf_info.removeClass('red');
|
@@ -182,7 +190,7 @@ $(document).ready(function(){
|
|
182 |
}else{
|
183 |
$cf_info.addClass('red');
|
184 |
}
|
185 |
-
|
186 |
});
|
187 |
|
188 |
$('.sc_copy').on('click', function(){
|
152 |
});
|
153 |
|
154 |
$('.sc_cp_btn').on('click', function(){
|
155 |
+
|
156 |
var $cp_box = $('.sc_cp_box');
|
157 |
var $cp_default = $('.sc_cp_default');
|
158 |
var $cp_info = $('.sc_cp_info');
|
159 |
var param_val = $cp_box.val().trim();
|
160 |
var default_val = $cp_default.val().trim();
|
161 |
+
|
162 |
if( param_val != '' && $cp_box[0].checkValidity() ){
|
163 |
+
|
164 |
+
var the_code = '';
|
165 |
+
if(default_val == ''){
|
166 |
+
the_code = '%%' + param_val + '%%';
|
167 |
+
}else{
|
168 |
+
the_code = '%%' + param_val + ':' + default_val + '%%';
|
169 |
+
}
|
170 |
+
|
171 |
+
insert_in_editor(the_code);
|
172 |
$cp_info.removeClass('red');
|
173 |
close_params_list();
|
174 |
}else{
|
175 |
$cp_info.addClass('red');
|
176 |
}
|
177 |
+
|
178 |
});
|
179 |
|
180 |
$('.sc_cf_btn').on('click', function(){
|
181 |
+
|
182 |
var $cf_box = $('.sc_cf_box');
|
183 |
var $cf_info = $('.sc_cf_info');
|
184 |
var param_val = $cf_box.val().trim();
|
185 |
+
|
186 |
if( param_val != '' && $cf_box[0].checkValidity() ){
|
187 |
insert_in_editor('$$custom_field:' + param_val + '$$');
|
188 |
$cf_info.removeClass('red');
|
190 |
}else{
|
191 |
$cf_info.addClass('red');
|
192 |
}
|
193 |
+
|
194 |
});
|
195 |
|
196 |
$('.sc_copy').on('click', function(){
|
readme.txt
CHANGED
@@ -8,7 +8,7 @@ License: GPLv2 or later
|
|
8 |
Requires PHP: 5.3
|
9 |
Requires at least: 4.4
|
10 |
Tested up to: 5.3.2
|
11 |
-
Stable tag: 5.2
|
12 |
|
13 |
Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
|
14 |
|
@@ -88,6 +88,10 @@ Please check the following if you notice that the shortcode content is not print
|
|
88 |
|
89 |
== Changelog ==
|
90 |
|
|
|
|
|
|
|
|
|
91 |
= 5.2 =
|
92 |
* New: Default values can now be provided to custom parameters.
|
93 |
* Fix: Script tags, custom field placeholder and backslash being stripped after saving the shortcode sometimes.
|
8 |
Requires PHP: 5.3
|
9 |
Requires at least: 4.4
|
10 |
Tested up to: 5.3.2
|
11 |
+
Stable tag: 5.2.1
|
12 |
|
13 |
Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
|
14 |
|
88 |
|
89 |
== Changelog ==
|
90 |
|
91 |
+
= 5.2.1 =
|
92 |
+
* Fix: Custom parameters being not replaced in some scenarios.
|
93 |
+
* Fix: Minor enhancement to insert custom parameter form.
|
94 |
+
|
95 |
= 5.2 =
|
96 |
* New: Default values can now be provided to custom parameters.
|
97 |
* Fix: Script tags, custom field placeholder and backslash being stripped after saving the shortcode sometimes.
|
shortcoder.php
CHANGED
@@ -4,11 +4,11 @@ Plugin Name: Shortcoder
|
|
4 |
Plugin URI: https://www.aakashweb.com/wordpress-plugins/shortcoder/
|
5 |
Description: Shortcoder plugin allows to create a custom shortcodes for HTML, JavaScript and other snippets. Now the shortcodes can be used in posts/pages and the snippet will be replaced in place.
|
6 |
Author: Aakash Chakravarthy
|
7 |
-
Version: 5.2
|
8 |
Author URI: https://www.aakashweb.com/
|
9 |
*/
|
10 |
|
11 |
-
define( 'SC_VERSION', '5.2' );
|
12 |
define( 'SC_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
|
13 |
define( 'SC_URL', plugin_dir_url( __FILE__ ) );
|
14 |
define( 'SC_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );
|
@@ -200,41 +200,29 @@ final class Shortcoder{
|
|
200 |
|
201 |
public static function replace_sc_params( $content, $params ){
|
202 |
|
203 |
-
$
|
204 |
-
$values = array();
|
205 |
|
206 |
-
preg_match_all('/%%(.*?)%%/', $content, $matches);
|
207 |
|
208 |
$cp_tags = $matches[0];
|
209 |
-
$
|
210 |
-
|
211 |
-
if( empty( $matches[0] ) ){
|
212 |
-
return $content;
|
213 |
-
}
|
214 |
-
|
215 |
$to_replace = array();
|
216 |
|
217 |
-
|
218 |
|
219 |
-
$
|
220 |
-
$
|
221 |
-
$
|
222 |
|
223 |
-
if( $
|
224 |
-
$
|
225 |
-
}else{
|
226 |
-
$cp_name = substr( $data, 0, $colon_pos );
|
227 |
}
|
228 |
|
229 |
-
if(
|
230 |
-
array_push( $to_replace, $
|
231 |
}else{
|
232 |
-
|
233 |
-
array_push( $to_replace, '' ); # Has no default parameter
|
234 |
-
}else{
|
235 |
-
$cp_value = substr( $data, $colon_pos+1 );
|
236 |
-
array_push( $to_replace, $cp_value );
|
237 |
-
}
|
238 |
}
|
239 |
|
240 |
}
|
4 |
Plugin URI: https://www.aakashweb.com/wordpress-plugins/shortcoder/
|
5 |
Description: Shortcoder plugin allows to create a custom shortcodes for HTML, JavaScript and other snippets. Now the shortcodes can be used in posts/pages and the snippet will be replaced in place.
|
6 |
Author: Aakash Chakravarthy
|
7 |
+
Version: 5.2.1
|
8 |
Author URI: https://www.aakashweb.com/
|
9 |
*/
|
10 |
|
11 |
+
define( 'SC_VERSION', '5.2.1' );
|
12 |
define( 'SC_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
|
13 |
define( 'SC_URL', plugin_dir_url( __FILE__ ) );
|
14 |
define( 'SC_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );
|
200 |
|
201 |
public static function replace_sc_params( $content, $params ){
|
202 |
|
203 |
+
$params = array_change_key_case( $params, CASE_LOWER );
|
|
|
204 |
|
205 |
+
preg_match_all('/%%([a-zA-Z-0-9]+)\:?(.*?)%%/', $content, $matches);
|
206 |
|
207 |
$cp_tags = $matches[0];
|
208 |
+
$cp_names = $matches[1];
|
209 |
+
$cp_defaults = $matches[2];
|
|
|
|
|
|
|
|
|
210 |
$to_replace = array();
|
211 |
|
212 |
+
for( $i = 0; $i < count( $cp_names ); $i++ ){
|
213 |
|
214 |
+
$name = strtolower( $cp_names[ $i ] );
|
215 |
+
$default = $cp_defaults[ $i ];
|
216 |
+
$value = '';
|
217 |
|
218 |
+
if( array_key_exists( $name, $params ) ){
|
219 |
+
$value = $params[ $name ];
|
|
|
|
|
220 |
}
|
221 |
|
222 |
+
if( empty( $value ) ){
|
223 |
+
array_push( $to_replace, $default );
|
224 |
}else{
|
225 |
+
array_push( $to_replace, $value );
|
|
|
|
|
|
|
|
|
|
|
226 |
}
|
227 |
|
228 |
}
|