Shortcoder - Version 4.1.8

Version Description

  • New: Insert custom fields in shortcode content.
  • Fix: Removed comments in shortcode output
Download this release

Release Info

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

Code changes from version 4.1.7 to 4.1.8

Files changed (5) hide show
  1. admin/css/style.css +5 -5
  2. admin/js/script.js +16 -0
  3. admin/sc-admin.php +8 -2
  4. readme.txt +6 -2
  5. shortcoder.php +40 -3
admin/css/style.css CHANGED
@@ -313,17 +313,17 @@ h1.sc_title .title-count {
313
  display: block;
314
  }
315
 
316
- .params_wrap .cp_form{
317
  cursor: auto;
318
- width: 300px;
319
  }
320
- .cp_form h4{
321
  margin: 0 0 15px 0;
322
  }
323
- .cp_info{
324
  margin: 5px 0;
325
  }
326
- .cp_info.red{
327
  color: red;
328
  }
329
 
313
  display: block;
314
  }
315
 
316
+ .params_wrap .isc_form{
317
  cursor: auto;
318
+ width: 330px;
319
  }
320
+ .isc_form h4{
321
  margin: 0 0 15px 0;
322
  }
323
+ .isc_info{
324
  margin: 5px 0;
325
  }
326
+ .isc_info.red{
327
  color: red;
328
  }
329
 
admin/js/script.js CHANGED
@@ -247,6 +247,22 @@ $(document).ready(function(){
247
 
248
  });
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
  $( document ).on( 'click', '.wp_params li', function(){
251
  insert_in_editor('$$' + $(this).data( 'id' ) + '$$');
252
  $( '.params_wrap' ).hide();
247
 
248
  });
249
 
250
+ $( document ).on( 'click', '.cf_btn', function(){
251
+
252
+ var $cf_box = $( '.cf_box' );
253
+ var $cf_info = $( '.cf_info' );
254
+ var param_val = $cf_box.val().trim();
255
+
256
+ if( param_val != '' && $cf_box[0].checkValidity() ){
257
+ insert_in_editor( '$$custom_field:' + param_val + '$$' );
258
+ $cf_info.removeClass( 'red' );
259
+ $( '.params_wrap' ).hide();
260
+ }else{
261
+ $cf_info.addClass( 'red' );
262
+ }
263
+
264
+ });
265
+
266
  $( document ).on( 'click', '.wp_params li', function(){
267
  insert_in_editor('$$' + $(this).data( 'id' ) + '$$');
268
  $( '.params_wrap' ).hide();
admin/sc-admin.php CHANGED
@@ -313,9 +313,15 @@ class Shortcoder_Admin{
313
  }
314
 
315
  echo '<li>' . __( 'Custom parameter', 'shortcoder' ) . '<ul>';
316
- echo '<li class="cp_form"><h4>' . __( 'Enter custom parameter name', 'shortcoder' ) . '</h4>';
317
- echo '<input type="text" class="cp_box" pattern="[a-zA-Z0-9]+"/> <button class="button cp_btn">' . __( 'Insert parameter', 'shortcoder' ) . '</button><p class="cp_info"><small>' . __( 'Only alphabets and numbers allowed. Custom parameters are case insensitive', 'shortcoder' ) . '</small></p></li>';
318
  echo '</ul></li>';
 
 
 
 
 
 
319
  echo '</ul>';
320
  }
321
 
313
  }
314
 
315
  echo '<li>' . __( 'Custom parameter', 'shortcoder' ) . '<ul>';
316
+ echo '<li class="isc_form"><h4>' . __( 'Enter custom parameter name', 'shortcoder' ) . '</h4>';
317
+ echo '<input type="text" class="cp_box" pattern="[a-zA-Z0-9]+"/> <button class="button cp_btn">' . __( 'Insert parameter', 'shortcoder' ) . '</button><p class="isc_info cp_info"><small>' . __( 'Only alphabets and numbers allowed. Custom parameters are case insensitive', 'shortcoder' ) . '</small></p></li>';
318
  echo '</ul></li>';
319
+
320
+ echo '<li>' . __( 'Custom Fields', 'shortcoder' ) . '<ul>';
321
+ echo '<li class="isc_form"><h4>' . __( 'Enter custom field name', 'shortcoder' ) . '</h4>';
322
+ echo '<input type="text" class="cf_box" pattern="[a-zA-Z0-9_-]+"/> <button class="button cf_btn">' . __( 'Insert custom field', 'shortcoder' ) . '</button><p class="isc_info cf_info"><small>' . __( 'Only alphabets, numbers, underscore and hyphens are allowed. Cannot be empty.', 'shortcoder' ) . '</small></p></li>';
323
+ echo '</ul></li>';
324
+
325
  echo '</ul>';
326
  }
327
 
readme.txt CHANGED
@@ -6,8 +6,8 @@ Tags: shortcode, html, javascript, shortcodes, short code, posts, pages, widgets
6
  Donate link: https://goo.gl/qMF3iE
7
  License: GPLv2 or later
8
  Requires at least: 3.3
9
- Tested up to: 4.9.6
10
- Stable tag: 4.1.7
11
 
12
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
13
 
@@ -91,6 +91,10 @@ Note: When you disable a shortcode, the shortcode will not be executed in the pa
91
 
92
  == Changelog ==
93
 
 
 
 
 
94
  = 4.1.7 =
95
  * New: Categorize, search and filter shortcodes using "tags".
96
  * New: Last used shortcode editor will be saved along with shortcode.
6
  Donate link: https://goo.gl/qMF3iE
7
  License: GPLv2 or later
8
  Requires at least: 3.3
9
+ Tested up to: 4.9.8
10
+ Stable tag: 4.1.8
11
 
12
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
13
 
91
 
92
  == Changelog ==
93
 
94
+ = 4.1.8 =
95
+ * New: Insert custom fields in shortcode content.
96
+ * Fix: Removed comments in shortcode output
97
+
98
  = 4.1.7 =
99
  * New: Categorize, search and filter shortcodes using "tags".
100
  * New: Last used shortcode editor will be saved along with shortcode.
shortcoder.php CHANGED
@@ -4,11 +4,11 @@ Plugin Name: Shortcoder
4
  Plugin URI: https://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 executed in that place. You can create a shortcode for Youtube videos, adsense ads, buttons and more.
6
  Author: Aakash Chakravarthy
7
- Version: 4.1.7
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
- define( 'SC_VERSION', '4.1.7' );
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' ) );
@@ -111,7 +111,10 @@ class Shortcoder{
111
  }
112
 
113
  $sc_content_final = self::replace_wp_params( $sc_content_final, $enc_content );
114
- return '<!-- Start shortcoder -->' . do_shortcode( $sc_content_final ) . '<!-- End shortcoder v' . SC_VERSION . '-->';
 
 
 
115
 
116
  }else{
117
  return '<!-- Shortcoder conditions not met -->';
@@ -177,6 +180,40 @@ class Shortcoder{
177
 
178
  }
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
  public static function wp_params_list(){
181
  return apply_filters( 'sc_mod_wp_params', array(
182
  'wp_info' => array(
4
  Plugin URI: https://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 executed in that place. You can create a shortcode for Youtube videos, adsense ads, buttons and more.
6
  Author: Aakash Chakravarthy
7
+ Version: 4.1.8
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
+ define( 'SC_VERSION', '4.1.8' );
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' ) );
111
  }
112
 
113
  $sc_content_final = self::replace_wp_params( $sc_content_final, $enc_content );
114
+
115
+ $sc_content_final = self::replace_custom_fields( $sc_content_final );
116
+
117
+ return do_shortcode( $sc_content_final );
118
 
119
  }else{
120
  return '<!-- Shortcoder conditions not met -->';
180
 
181
  }
182
 
183
+ public static function replace_custom_fields( $content ){
184
+
185
+ global $post;
186
+
187
+ preg_match_all('/\$\$[^\s]+\$\$/', $content, $matches );
188
+
189
+ $cf_tags = $matches[0];
190
+
191
+ if( empty( $cf_tags ) ){
192
+ return $content;
193
+ }
194
+
195
+ foreach( $cf_tags as $tag ){
196
+
197
+ if( strpos( $tag, 'custom_field:' ) === false ){
198
+ continue;
199
+ }
200
+
201
+ preg_match( '/:[^\s\$]+/', $tag, $match );
202
+
203
+ if( empty( $match ) ){
204
+ continue;
205
+ }
206
+
207
+ $match = substr( $match[0], 1 );
208
+ $value = get_post_meta( $post->ID, $match, true );
209
+ $content = str_replace( $tag, $value, $content );
210
+
211
+ }
212
+
213
+ return $content;
214
+
215
+ }
216
+
217
  public static function wp_params_list(){
218
  return apply_filters( 'sc_mod_wp_params', array(
219
  'wp_info' => array(