Shortcoder - Version 4.3

Version Description

  • New: Edit shortcode name after creating.
  • New: Post modified date parameter added.
  • Fix: Date parameters now display in site language.
Download this release

Release Info

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

Code changes from version 4.2 to 4.3

Files changed (4) hide show
  1. admin/sc-admin.php +29 -11
  2. includes/metadata.php +13 -11
  3. readme.txt +7 -2
  4. shortcoder.php +3 -2
admin/sc-admin.php CHANGED
@@ -213,17 +213,22 @@ class Shortcoder_Admin{
213
  echo '</div>';
214
  echo '</h3>';
215
 
 
 
216
  echo '<form method="post" id="sc_edit_form">';
217
 
218
  echo '<div class="sc_section">';
219
  echo '<label for="sc_name">' . __( 'Name', 'shortcoder' ) . '</label>';
220
- echo '<div class="sc_name_wrap"><input type="text" id="sc_name" name="sc_name" value="' . esc_attr( $sc_name ) . '" class="widefat" required="required" ' . ( ( $action == 'edit' ) ? 'readonly="readonly"' : 'placeholder="' . __( 'Enter a name for the shortcode, case sensitive', 'shortcoder' ) . '"' ) . ' pattern="[a-zA-z0-9 \-]+" />';
221
  echo ( $action == 'edit' ) ? '<div class="copy_shortcode">Your shortcode is - <input type="text" value="' . esc_attr( self::get_shortcode( $sc_name ) ) . '" class="sc_copy_field" readonly="readonly" title="' . __( 'Copy shortcode', 'shortcoder' ) . '"/></div>' : '';
222
  echo ( $action != 'edit' ) ? '<div class="copy_shortcode">' . __( 'Allowed characters A to Z, a to z, 0 to 9, hyphens, underscores and space', 'shortcoder' ) . '</div>' : '';
223
- echo '</div></div>';
 
 
 
224
 
225
  echo '<div class="sc_section">';
226
- echo '<label for="sc_content">' . __( 'Shortcode content', 'shortcoder' ) . '<span class="dashicons dashicons-info sc_note_btn" title="Open note"></span></label>';
227
 
228
  echo '<p class="sc_note">' . __( 'Note: You can use any HTML, JavaScript, CSS as shortcode content. Shortcoder does not manipulate the shortcode content. What you provide above is what you get as output. Please verify the shortcode content for any syntax or JavaScript errors.', 'shortcoder' ) . '</p>';
229
 
@@ -331,6 +336,7 @@ class Shortcoder_Admin{
331
 
332
  $p = wp_parse_args( self::clean_post(), array(
333
  'sc_name' => '',
 
334
  'sc_content' => '',
335
  'sc_disable' => 0,
336
  'sc_hide_admin' => 0,
@@ -339,13 +345,16 @@ class Shortcoder_Admin{
339
  'sc_tags' => array()
340
  ));
341
 
342
- if( !trim( $p[ 'sc_name' ] ) ){
 
 
 
 
343
  self::print_notice( 0 );
344
  return false;
345
  }
346
 
347
  $shortcodes = Shortcoder::list_all();
348
- $name = self::clean_name( $p[ 'sc_name' ] );
349
  $values = array(
350
  'content' => $p[ 'sc_content' ],
351
  'disabled' => $p[ 'sc_disable' ],
@@ -355,6 +364,10 @@ class Shortcoder_Admin{
355
  'tags' => $p[ 'sc_tags' ]
356
  );
357
 
 
 
 
 
358
  if( array_key_exists( $name, $shortcodes ) ){
359
  self::print_notice( 2 );
360
  }else{
@@ -365,12 +378,13 @@ class Shortcoder_Admin{
365
 
366
  update_option( 'shortcoder_data', $shortcodes );
367
 
368
- /*
369
- wp_safe_redirect( self::get_link( array(
370
- 'action' => 'edit',
371
- 'name' => urlencode( $name ),
372
- 'msg' => ( $todo == 'new' ) ? 1 : 2
373
- )));*/
 
374
  }
375
 
376
  }
@@ -575,6 +589,10 @@ class Shortcoder_Admin{
575
  $msg = __( 'Shortcode deleted successfully', 'shortcoder' );
576
  }
577
 
 
 
 
 
578
  if( $msg != '' ){
579
  echo '<div class="notice notice-' . $type . ' is-dismissible"><p>' . $msg . '</p></div>';
580
  }
213
  echo '</div>';
214
  echo '</h3>';
215
 
216
+ $note_btn = '<span class="dashicons dashicons-info sc_note_btn" title="Open note"></span>';
217
+
218
  echo '<form method="post" id="sc_edit_form">';
219
 
220
  echo '<div class="sc_section">';
221
  echo '<label for="sc_name">' . __( 'Name', 'shortcoder' ) . '</label>';
222
+ echo '<div class="sc_name_wrap"><input type="text" id="sc_name" name="sc_name" value="' . esc_attr( $sc_name ) . '" class="widefat" required="required" placeholder="' . __( 'Enter a name for the shortcode, case sensitive', 'shortcoder' ) . '" pattern="[a-zA-z0-9 \-]+" />';
223
  echo ( $action == 'edit' ) ? '<div class="copy_shortcode">Your shortcode is - <input type="text" value="' . esc_attr( self::get_shortcode( $sc_name ) ) . '" class="sc_copy_field" readonly="readonly" title="' . __( 'Copy shortcode', 'shortcoder' ) . '"/></div>' : '';
224
  echo ( $action != 'edit' ) ? '<div class="copy_shortcode">' . __( 'Allowed characters A to Z, a to z, 0 to 9, hyphens, underscores and space', 'shortcoder' ) . '</div>' : '';
225
+ echo '</div>';
226
+ echo '</div>';
227
+
228
+ echo '<input type="hidden" name="sc_old_name" value="' . esc_attr( $sc_name ) . '" />';
229
 
230
  echo '<div class="sc_section">';
231
+ echo '<label for="sc_content">' . __( 'Shortcode content', 'shortcoder' ) . $note_btn . '</label>';
232
 
233
  echo '<p class="sc_note">' . __( 'Note: You can use any HTML, JavaScript, CSS as shortcode content. Shortcoder does not manipulate the shortcode content. What you provide above is what you get as output. Please verify the shortcode content for any syntax or JavaScript errors.', 'shortcoder' ) . '</p>';
234
 
336
 
337
  $p = wp_parse_args( self::clean_post(), array(
338
  'sc_name' => '',
339
+ 'sc_old_name' => '',
340
  'sc_content' => '',
341
  'sc_disable' => 0,
342
  'sc_hide_admin' => 0,
345
  'sc_tags' => array()
346
  ));
347
 
348
+ $name = trim( self::clean_name( $p[ 'sc_name' ] ) );
349
+ $old_name = trim( self::clean_name( $p[ 'sc_old_name' ] ) );
350
+ $sc_name_changed = ( !empty( $old_name ) && $old_name != $name );
351
+
352
+ if( empty( $name ) ){
353
  self::print_notice( 0 );
354
  return false;
355
  }
356
 
357
  $shortcodes = Shortcoder::list_all();
 
358
  $values = array(
359
  'content' => $p[ 'sc_content' ],
360
  'disabled' => $p[ 'sc_disable' ],
364
  'tags' => $p[ 'sc_tags' ]
365
  );
366
 
367
+ if( $sc_name_changed ){
368
+ unset( $shortcodes[ $old_name ] );
369
+ }
370
+
371
  if( array_key_exists( $name, $shortcodes ) ){
372
  self::print_notice( 2 );
373
  }else{
378
 
379
  update_option( 'shortcoder_data', $shortcodes );
380
 
381
+ if( $sc_name_changed ){
382
+ wp_safe_redirect( self::get_link( array(
383
+ 'action' => 'edit',
384
+ 'id' => base64_encode( $name )
385
+ )));
386
+ }
387
+
388
  }
389
 
390
  }
589
  $msg = __( 'Shortcode deleted successfully', 'shortcoder' );
590
  }
591
 
592
+ if( $id == 4 ){
593
+ $msg = __( 'Shortcode name edited successfully', 'shortcoder' );
594
+ }
595
+
596
  if( $msg != '' ){
597
  echo '<div class="notice notice-' . $type . ' is-dismissible"><p>' . $msg . '</p></div>';
598
  }
includes/metadata.php CHANGED
@@ -26,6 +26,7 @@ class Shortcoder_Metadata{
26
  'post_image' => '',
27
  'post_author' => '',
28
  'post_date' => '',
 
29
 
30
  'site_name' => get_bloginfo( 'name' ),
31
  'site_description' => get_bloginfo( 'description' ),
@@ -39,16 +40,16 @@ class Shortcoder_Metadata{
39
  'atom_url' => get_bloginfo( 'atom_url' ),
40
  'rss_url' => get_bloginfo( 'rss2_url' ),
41
 
42
- 'day' => current_time( 'j' ),
43
- 'day_lz' => current_time( 'd' ),
44
- 'day_ws' => current_time( 'D' ),
45
- 'day_wf' => current_time( 'l' ),
46
- 'month' => current_time( 'n' ),
47
- 'month_lz' => current_time( 'm' ),
48
- 'month_ws' => current_time( 'M' ),
49
- 'month_wf' => current_time( 'F' ),
50
- 'year' => current_time( 'Y' ),
51
- 'year_2d' => current_time( 'y' ),
52
 
53
  );
54
 
@@ -169,7 +170,8 @@ class Shortcoder_Metadata{
169
  'post_comments_count' => get_comments_number( $id ),
170
  'post_image' => self::post_image( $id ),
171
  'post_author' => get_the_author(),
172
- 'post_date' => get_the_date()
 
173
  );
174
  }
175
 
26
  'post_image' => '',
27
  'post_author' => '',
28
  'post_date' => '',
29
+ 'post_modified_date' => '',
30
 
31
  'site_name' => get_bloginfo( 'name' ),
32
  'site_description' => get_bloginfo( 'description' ),
40
  'atom_url' => get_bloginfo( 'atom_url' ),
41
  'rss_url' => get_bloginfo( 'rss2_url' ),
42
 
43
+ 'day' => date_i18n( 'j' ),
44
+ 'day_lz' => date_i18n( 'd' ),
45
+ 'day_ws' => date_i18n( 'D' ),
46
+ 'day_wf' => date_i18n( 'l' ),
47
+ 'month' => date_i18n( 'n' ),
48
+ 'month_lz' => date_i18n( 'm' ),
49
+ 'month_ws' => date_i18n( 'M' ),
50
+ 'month_wf' => date_i18n( 'F' ),
51
+ 'year' => date_i18n( 'Y' ),
52
+ 'year_2d' => date_i18n( 'y' ),
53
 
54
  );
55
 
170
  'post_comments_count' => get_comments_number( $id ),
171
  'post_image' => self::post_image( $id ),
172
  'post_author' => get_the_author(),
173
+ 'post_date' => get_the_date(),
174
+ 'post_modified_date' => get_the_modified_date()
175
  );
176
  }
177
 
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: 4.4.0
9
- Tested up to: 4.9.8
10
- Stable tag: 4.2
11
 
12
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
13
 
@@ -91,6 +91,11 @@ Note: When you disable a shortcode, the shortcode will not be executed in the pa
91
 
92
  == Changelog ==
93
 
 
 
 
 
 
94
  = 4.2 =
95
  * Fix: Some plugins fail to fire onload JS event since it was overwritten by shortcoder.
96
  * Fix: Javascript in insert shortcode popup not working in IE 11.
6
  Donate link: https://goo.gl/qMF3iE
7
  License: GPLv2 or later
8
  Requires at least: 4.4.0
9
+ Tested up to: 5.0.3
10
+ Stable tag: 4.3
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.3 =
95
+ * New: Edit shortcode name after creating.
96
+ * New: Post modified date parameter added.
97
+ * Fix: Date parameters now display in site language.
98
+
99
  = 4.2 =
100
  * Fix: Some plugins fail to fire onload JS event since it was overwritten by shortcoder.
101
  * Fix: Javascript in insert shortcode popup not working in IE 11.
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.2
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
- define( 'SC_VERSION', '4.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' ) );
@@ -228,6 +228,7 @@ class Shortcoder{
228
  'post_excerpt' => __( 'Post excerpt', 'shortcoder' ),
229
  'post_author' => __( 'Post author', 'shortcoder' ),
230
  'post_date' => __( 'Post date', 'shortcoder' ),
 
231
  'post_comments_count' => __( 'Post comments count', 'shortcoder' ),
232
 
233
  'site_name' => __( 'Site title', '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.3
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
+ define( 'SC_VERSION', '4.3' );
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' ) );
228
  'post_excerpt' => __( 'Post excerpt', 'shortcoder' ),
229
  'post_author' => __( 'Post author', 'shortcoder' ),
230
  'post_date' => __( 'Post date', 'shortcoder' ),
231
+ 'post_modified_date' => __( 'Post modified date', 'shortcoder' ),
232
  'post_comments_count' => __( 'Post comments count', 'shortcoder' ),
233
 
234
  'site_name' => __( 'Site title', 'shortcoder' ),