Shortcoder - Version 5.3.3

Version Description

Download this release

Release Info

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

Code changes from version 5.3.2 to 5.3.3

admin/admin.php CHANGED
@@ -6,17 +6,17 @@ class SC_Admin{
6
 
7
  public static function init(){
8
 
9
- add_action( 'init', array( __class__, 'register_post_type' ), 0 );
10
 
11
- add_action( 'init', array( __class__, 'register_taxonomy' ), 0 );
12
 
13
- add_action( 'admin_enqueue_scripts', array( __class__, 'enqueue_scripts' ) );
14
 
15
- add_action( 'admin_footer', array( __class__, 'changelog' ) );
16
 
17
- add_action( 'admin_footer', array( __class__, 'import_export' ) );
18
 
19
- add_action( 'wp_ajax_sc_admin_ajax', array( __class__, 'admin_ajax' ) );
20
 
21
  add_filter( 'plugin_action_links_' . SC_BASE_NAME, array( __CLASS__, 'action_links' ) );
22
 
@@ -225,7 +225,7 @@ class SC_Admin{
225
  <li><a href="#import-others-tab" aria-controls="import-others-tab">' . __( 'Import from other sources', 'shortcoder' ) . '</a></li>
226
  </ul>
227
  </div>
228
- <div class="contextual-help-sidebar"><p><a href="https://www.aakashweb.com/docs/shortcoder-doc/" target="_blank">' . __( 'Documentation', 'shortcoder' ) . '</a></p></div>
229
  <div class="contextual-help-tabs-wrap">
230
  <div id="export-tab" class="help-tab-content active">
231
  <h3>' . __( 'Export', 'shortcoder' ) . '</h3><p>' . __( 'WordPress has a native exporter tool which can be used to export shortcoder data. Navigate to <code>Tools -> Export</code> and select "Shortcoder" as the content to export.', 'shortcoder' ) . '</p>
@@ -237,7 +237,7 @@ class SC_Admin{
237
  </div>
238
  <div id="import-others-tab" class="help-tab-content">
239
  <h3>' . __( 'Import from other sources', 'shortcoder' ) . '</h3><p>' . __( 'To import from other sources like CSV, excel please read the below linked documentation.', 'shortcoder' ) . '</p>
240
- <a href="https://www.aakashweb.com/docs/shortcoder-doc/import-export/" target="_blank" class="button button-primary">' . __( 'Open documentation', 'shortcoder' ) . '</a>
241
  </div>
242
  </div>
243
  </div>
6
 
7
  public static function init(){
8
 
9
+ add_action( 'init', array( __CLASS__, 'register_post_type' ), 0 );
10
 
11
+ add_action( 'init', array( __CLASS__, 'register_taxonomy' ), 0 );
12
 
13
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
14
 
15
+ add_action( 'admin_footer', array( __CLASS__, 'changelog' ) );
16
 
17
+ add_action( 'admin_footer', array( __CLASS__, 'import_export' ) );
18
 
19
+ add_action( 'wp_ajax_sc_admin_ajax', array( __CLASS__, 'admin_ajax' ) );
20
 
21
  add_filter( 'plugin_action_links_' . SC_BASE_NAME, array( __CLASS__, 'action_links' ) );
22
 
225
  <li><a href="#import-others-tab" aria-controls="import-others-tab">' . __( 'Import from other sources', 'shortcoder' ) . '</a></li>
226
  </ul>
227
  </div>
228
+ <div class="contextual-help-sidebar"><p><a href="https://www.aakashweb.com/docs/shortcoder/" target="_blank">' . __( 'Documentation', 'shortcoder' ) . '</a></p></div>
229
  <div class="contextual-help-tabs-wrap">
230
  <div id="export-tab" class="help-tab-content active">
231
  <h3>' . __( 'Export', 'shortcoder' ) . '</h3><p>' . __( 'WordPress has a native exporter tool which can be used to export shortcoder data. Navigate to <code>Tools -> Export</code> and select "Shortcoder" as the content to export.', 'shortcoder' ) . '</p>
237
  </div>
238
  <div id="import-others-tab" class="help-tab-content">
239
  <h3>' . __( 'Import from other sources', 'shortcoder' ) . '</h3><p>' . __( 'To import from other sources like CSV, excel please read the below linked documentation.', 'shortcoder' ) . '</p>
240
+ <a href="https://www.aakashweb.com/docs/shortcoder/import-export/" target="_blank" class="button button-primary">' . __( 'Open documentation', 'shortcoder' ) . '</a>
241
  </div>
242
  </div>
243
  </div>
admin/edit.php CHANGED
@@ -6,17 +6,17 @@ class SC_Admin_Edit{
6
 
7
  public static function init(){
8
 
9
- add_action( 'edit_form_after_title', array( __class__, 'after_title' ) );
10
 
11
- add_action( 'add_meta_boxes', array( __class__, 'add_meta_boxes' ) );
12
 
13
- add_action( 'save_post_' . SC_POST_TYPE, array( __class__, 'save_post' ) );
14
 
15
- add_filter( 'wp_insert_post_data' , array( __class__, 'before_insert_post' ) , 99, 1 );
16
 
17
- add_action( 'admin_enqueue_scripts', array( __class__, 'enqueue_scripts' ) );
18
 
19
- add_filter( 'admin_footer_text', array( __class__, 'footer_text' ) );
20
 
21
  }
22
 
@@ -48,9 +48,9 @@ class SC_Admin_Edit{
48
 
49
  public static function add_meta_boxes(){
50
 
51
- add_meta_box( 'sc_mb_settings', __( 'Shortcode settings', 'shortcoder' ), array( __class__, 'settings_form' ), SC_POST_TYPE, 'normal', 'default' );
52
 
53
- add_meta_box( 'sc_mb_links', __( 'Get updates', 'shortcoder' ), array( __class__, 'feedback' ), SC_POST_TYPE, 'side', 'default' );
54
 
55
  remove_meta_box( 'slugdiv', SC_POST_TYPE, 'normal' );
56
 
@@ -224,7 +224,7 @@ class SC_Admin_Edit{
224
  return false;
225
  }
226
 
227
- $cm_cdn_url = 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.46.0/';
228
  $cm_files = array(
229
  'css' => array(
230
  'codemirror.min.css'
6
 
7
  public static function init(){
8
 
9
+ add_action( 'edit_form_after_title', array( __CLASS__, 'after_title' ) );
10
 
11
+ add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ) );
12
 
13
+ add_action( 'save_post_' . SC_POST_TYPE, array( __CLASS__, 'save_post' ) );
14
 
15
+ add_filter( 'wp_insert_post_data' , array( __CLASS__, 'before_insert_post' ) , 99, 1 );
16
 
17
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
18
 
19
+ add_filter( 'admin_footer_text', array( __CLASS__, 'footer_text' ) );
20
 
21
  }
22
 
48
 
49
  public static function add_meta_boxes(){
50
 
51
+ add_meta_box( 'sc_mb_settings', __( 'Shortcode settings', 'shortcoder' ), array( __CLASS__, 'settings_form' ), SC_POST_TYPE, 'normal', 'default' );
52
 
53
+ add_meta_box( 'sc_mb_links', __( 'Get updates', 'shortcoder' ), array( __CLASS__, 'feedback' ), SC_POST_TYPE, 'side', 'default' );
54
 
55
  remove_meta_box( 'slugdiv', SC_POST_TYPE, 'normal' );
56
 
224
  return false;
225
  }
226
 
227
+ $cm_cdn_url = 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.58.2/';
228
  $cm_files = array(
229
  'css' => array(
230
  'codemirror.min.css'
admin/form.php CHANGED
@@ -74,13 +74,15 @@ class SC_Admin_Form{
74
 
75
  extract( $params, EXTR_SKIP );
76
 
 
 
77
  switch( $field_type ){
78
  case 'text':
79
- $field_html = "<input type='$type' class='$class' id='$id' name='$name' value='$value' placeholder='$placeholder' " . ( $required ? "required='$required'" : "" ) . " $custom />";
80
  break;
81
 
82
  case 'select':
83
- $field_html .= "<select name='$name' class='$class' id='$id' $custom>";
84
  foreach( $list as $k => $v ){
85
  $field_html .= "<option value='$k' " . selected( $value, $k, false ) . ">$v</option>";
86
  }
@@ -88,7 +90,7 @@ class SC_Admin_Form{
88
  break;
89
 
90
  case 'textarea':
91
- $field_html .= "<textarea id='$id' name='$name' class='$class' placeholder='$placeholder' rows='$rows' cols='$cols' $custom>$value</textarea>";
92
  break;
93
 
94
  }
74
 
75
  extract( $params, EXTR_SKIP );
76
 
77
+ $id_attr = empty( $id ) ? '' : 'id="' . $id . '"';
78
+
79
  switch( $field_type ){
80
  case 'text':
81
+ $field_html = "<input type='$type' class='$class' $id_attr name='$name' value='$value' placeholder='$placeholder' " . ( $required ? "required='$required'" : "" ) . " $custom />";
82
  break;
83
 
84
  case 'select':
85
+ $field_html .= "<select name='$name' class='$class' $id_attr $custom>";
86
  foreach( $list as $k => $v ){
87
  $field_html .= "<option value='$k' " . selected( $value, $k, false ) . ">$v</option>";
88
  }
90
  break;
91
 
92
  case 'textarea':
93
+ $field_html .= "<textarea $id_attr name='$name' class='$class' placeholder='$placeholder' rows='$rows' cols='$cols' $custom>$value</textarea>";
94
  break;
95
 
96
  }
admin/js/script.js CHANGED
@@ -5,20 +5,24 @@ $(document).ready(function(){
5
 
6
  if(window.SC_EDITOR == 'code'){
7
 
8
- load_cm_sc_mode();
9
-
10
- window.sc_cm = CodeMirror.fromTextArea(document.getElementById('sc_content'), {
11
- lineNumbers: true,
12
- mode: 'sc_mode',
13
- indentWithTabs: false,
14
- lineWrapping: true,
15
- styleActiveLine: true,
16
- htmlMode: true
17
- });
18
- sc_cm.setSize( null, 500 );
19
- sc_cm.on('change', function(){
20
- sc_cm.save();
21
- });
 
 
 
 
22
 
23
  $('.sc_editor_toolbar').appendTo('.sc_cm_menu');
24
 
5
 
6
  if(window.SC_EDITOR == 'code'){
7
 
8
+ if(typeof window.CodeMirror === 'function' && typeof CodeMirror.fromTextArea === 'function'){
9
+ load_cm_sc_mode();
10
+
11
+ window.sc_cm = CodeMirror.fromTextArea(document.getElementById('sc_content'), {
12
+ lineNumbers: true,
13
+ mode: 'sc_mode',
14
+ indentWithTabs: false,
15
+ lineWrapping: true,
16
+ styleActiveLine: true,
17
+ htmlMode: true
18
+ });
19
+ sc_cm.setSize( null, 500 );
20
+ sc_cm.on('change', function(){
21
+ sc_cm.save();
22
+ });
23
+ }else{
24
+ $('.sc_editor_toolbar').append('<p>Unable to load code editor. Please check console for errors or try deactivating other plugin/themes.</p>');
25
+ }
26
 
27
  $('.sc_editor_toolbar').appendTo('.sc_cm_menu');
28
 
admin/manage.php CHANGED
@@ -5,11 +5,11 @@ class SC_Admin_Manage{
5
 
6
  public static function init(){
7
 
8
- add_filter( 'manage_' . SC_POST_TYPE . '_posts_columns', array( __class__, 'column_head' ) );
9
 
10
- add_action( 'manage_' . SC_POST_TYPE . '_posts_custom_column', array( __class__, 'column_content' ), 10, 2 );
11
 
12
- add_filter( 'edit_posts_per_page', array( __class__, 'per_page_count' ), 10, 2 );
13
 
14
  }
15
 
5
 
6
  public static function init(){
7
 
8
+ add_filter( 'manage_' . SC_POST_TYPE . '_posts_columns', array( __CLASS__, 'column_head' ) );
9
 
10
+ add_action( 'manage_' . SC_POST_TYPE . '_posts_custom_column', array( __CLASS__, 'column_content' ), 10, 2 );
11
 
12
+ add_filter( 'edit_posts_per_page', array( __CLASS__, 'per_page_count' ), 10, 2 );
13
 
14
  }
15
 
admin/tools.php CHANGED
@@ -10,20 +10,20 @@ class SC_Admin_Tools{
10
  add_action( 'wp_ajax_sc_insert_window', array( __CLASS__, 'insert_window' ) );
11
 
12
  // Add TinyMCE button
13
- add_action( 'admin_init', array( __class__, 'register_mce' ) );
14
 
15
- add_action( 'wp_enqueue_editor', array( __class__, 'enqueue_insert_scripts' ) );
16
 
17
  // Gutenberg block
18
- add_action( 'init', array( __class__, 'register_block' ) );
19
 
20
  }
21
 
22
  public static function register_mce(){
23
 
24
- add_filter( 'mce_buttons', array( __class__, 'register_mce_button' ) );
25
 
26
- add_filter( 'mce_external_plugins', array( __class__, 'register_mce_js' ) );
27
 
28
  }
29
 
10
  add_action( 'wp_ajax_sc_insert_window', array( __CLASS__, 'insert_window' ) );
11
 
12
  // Add TinyMCE button
13
+ add_action( 'admin_init', array( __CLASS__, 'register_mce' ) );
14
 
15
+ add_action( 'wp_enqueue_editor', array( __CLASS__, 'enqueue_insert_scripts' ) );
16
 
17
  // Gutenberg block
18
+ add_action( 'init', array( __CLASS__, 'register_block' ) );
19
 
20
  }
21
 
22
  public static function register_mce(){
23
 
24
+ add_filter( 'mce_buttons', array( __CLASS__, 'register_mce_button' ) );
25
 
26
+ add_filter( 'mce_external_plugins', array( __CLASS__, 'register_mce_js' ) );
27
 
28
  }
29
 
includes/metadata.php CHANGED
@@ -29,6 +29,7 @@ class Shortcoder_Metadata{
29
  'post_author' => '',
30
  'post_date' => '',
31
  'post_modified_date' => '',
 
32
 
33
  'site_name' => get_bloginfo( 'name' ),
34
  'site_description' => get_bloginfo( 'description' ),
@@ -173,7 +174,8 @@ class Shortcoder_Metadata{
173
  'post_image' => self::post_image( $id ),
174
  'post_author' => get_the_author(),
175
  'post_date' => get_the_date(),
176
- 'post_modified_date' => get_the_modified_date()
 
177
  );
178
 
179
  if( $d[ 'short_url' ] == '' ){
@@ -213,6 +215,18 @@ class Shortcoder_Metadata{
213
 
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  }
217
 
218
  Shortcoder_Metadata::init();
29
  'post_author' => '',
30
  'post_date' => '',
31
  'post_modified_date' => '',
32
+ 'post_slug' => '',
33
 
34
  'site_name' => get_bloginfo( 'name' ),
35
  'site_description' => get_bloginfo( 'description' ),
174
  'post_image' => self::post_image( $id ),
175
  'post_author' => get_the_author(),
176
  'post_date' => get_the_date(),
177
+ 'post_modified_date' => get_the_modified_date(),
178
+ 'post_slug' => self::post_slug()
179
  );
180
 
181
  if( $d[ 'short_url' ] == '' ){
215
 
216
  }
217
 
218
+ public static function post_slug(){
219
+
220
+ global $post;
221
+
222
+ if( !is_object( $post ) ){
223
+ return '';
224
+ }
225
+
226
+ return $post->post_name;
227
+
228
+ }
229
+
230
  }
231
 
232
  Shortcoder_Metadata::init();
includes/updates.php CHANGED
@@ -6,7 +6,7 @@ class Shortcoder_Updates{
6
 
7
  public static function init(){
8
 
9
- add_action( 'admin_init', array( __class__, 'do_update' ) );
10
 
11
  }
12
 
6
 
7
  public static function init(){
8
 
9
+ add_action( 'admin_init', array( __CLASS__, 'do_update' ) );
10
 
11
  }
12
 
readme.txt CHANGED
@@ -7,8 +7,8 @@ Donate link: https://www.paypal.me/vaakash/
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
  Requires at least: 4.4
10
- Tested up to: 5.5
11
- Stable tag: 5.3.2
12
 
13
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
14
 
@@ -47,12 +47,12 @@ Shortcoder plugin allows to create a custom shortcodes for HTML, JavaScript and
47
 
48
  Similarly shortcodes can be created for frequently used snippets.
49
 
50
- You can also add [custom parameters](https://www.aakashweb.com/docs/shortcoder-doc/) (like `%%id%%`) inside the snippets, and change it's value like `[sc name="youtube" id="GrlRADfvjII"]` when using them.
51
 
52
  ### Links
53
 
54
- * [Documentation](https://www.aakashweb.com/docs/shortcoder-doc/)
55
- * [FAQs](https://www.aakashweb.com/docs/shortcoder-doc/)
56
  * [Support forum/Report bugs](https://www.aakashweb.com/forum/)
57
 
58
 
@@ -67,7 +67,7 @@ You can also add [custom parameters](https://www.aakashweb.com/docs/shortcoder-d
67
 
68
  ## Frequently Asked Questions
69
 
70
- Please visit the [plugin documentation page](https://www.aakashweb.com/docs/shortcoder-doc/) for complete list of FAQs.
71
 
72
  ### What are the allowed characters for shortcode name ?
73
 
@@ -106,6 +106,14 @@ No, right now the plugin supports only HTML, Javascript and CSS as shortcode con
106
 
107
  ## Changelog
108
 
 
 
 
 
 
 
 
 
109
  ### 5.3.2
110
  * New: In code editor, shortcodes will be highlighted and code editor font size is slightly bigger.
111
 
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
  Requires at least: 4.4
10
+ Tested up to: 5.5.3
11
+ Stable tag: 5.3.3
12
 
13
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
14
 
47
 
48
  Similarly shortcodes can be created for frequently used snippets.
49
 
50
+ You can also add [custom parameters](https://www.aakashweb.com/docs/shortcoder/) (like `%%id%%`) inside the snippets, and change it's value like `[sc name="youtube" id="GrlRADfvjII"]` when using them.
51
 
52
  ### Links
53
 
54
+ * [Documentation](https://www.aakashweb.com/docs/shortcoder/)
55
+ * [FAQs](https://www.aakashweb.com/docs/shortcoder/faq/)
56
  * [Support forum/Report bugs](https://www.aakashweb.com/forum/)
57
 
58
 
67
 
68
  ## Frequently Asked Questions
69
 
70
+ Please visit the [plugin documentation page](https://www.aakashweb.com/docs/shortcoder/) for complete list of FAQs.
71
 
72
  ### What are the allowed characters for shortcode name ?
73
 
106
 
107
  ## Changelog
108
 
109
+ ### 5.3.3
110
+ * New: Support for `post slug` as the new shortcode parameter under WordPress information.
111
+ * New: Codemirror has been updated to latest version.
112
+ * Fix: Handle code editor loading issue when there is any collision.
113
+ * Fix: Handle input fields which have empty `id` attribute.
114
+ * Fix: Handle issue of `$post` object being undefined at some cases.
115
+ * Fix: Renamed usages of `__class__` to `__CLASS__`
116
+
117
  ### 5.3.2
118
  * New: In code editor, shortcodes will be highlighted and code editor font size is slightly bigger.
119
 
shortcoder.php CHANGED
@@ -4,13 +4,13 @@ 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.3.2
8
  Author URI: https://www.aakashweb.com/
9
  Text Domain: shortcoder
10
  Domain Path: /languages
11
  */
12
 
13
- define( 'SC_VERSION', '5.3.2' );
14
  define( 'SC_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
15
  define( 'SC_URL', plugin_dir_url( __FILE__ ) );
16
  define( 'SC_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );
@@ -28,9 +28,9 @@ final class Shortcoder{
28
  // Include the required
29
  self::includes();
30
 
31
- add_action( 'plugins_loaded', array( __class__, 'load_text_domain' ) );
32
 
33
- add_shortcode( 'sc', array( __class__, 'execute_shortcode' ) );
34
 
35
  }
36
 
@@ -285,7 +285,7 @@ final class Shortcoder{
285
  }
286
 
287
  $match = substr( $match[0], 1 );
288
- $value = get_post_meta( $post->ID, $match, true );
289
  $content = str_replace( $tag, $value, $content );
290
 
291
  }
@@ -312,6 +312,7 @@ final class Shortcoder{
312
  'post_date' => __( 'Post date', 'shortcoder' ),
313
  'post_modified_date' => __( 'Post modified date', 'shortcoder' ),
314
  'post_comments_count' => __( 'Post comments count', 'shortcoder' ),
 
315
 
316
  'site_name' => __( 'Site title', 'shortcoder' ),
317
  'site_description' => __( 'Site description', '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.3.3
8
  Author URI: https://www.aakashweb.com/
9
  Text Domain: shortcoder
10
  Domain Path: /languages
11
  */
12
 
13
+ define( 'SC_VERSION', '5.3.3' );
14
  define( 'SC_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
15
  define( 'SC_URL', plugin_dir_url( __FILE__ ) );
16
  define( 'SC_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );
28
  // Include the required
29
  self::includes();
30
 
31
+ add_action( 'plugins_loaded', array( __CLASS__, 'load_text_domain' ) );
32
 
33
+ add_shortcode( 'sc', array( __CLASS__, 'execute_shortcode' ) );
34
 
35
  }
36
 
285
  }
286
 
287
  $match = substr( $match[0], 1 );
288
+ $value = is_object( $post ) ? get_post_meta( $post->ID, $match, true ) : '';
289
  $content = str_replace( $tag, $value, $content );
290
 
291
  }
312
  'post_date' => __( 'Post date', 'shortcoder' ),
313
  'post_modified_date' => __( 'Post modified date', 'shortcoder' ),
314
  'post_comments_count' => __( 'Post comments count', 'shortcoder' ),
315
+ 'post_slug' => __( 'Post slug', 'shortcoder' ),
316
 
317
  'site_name' => __( 'Site title', 'shortcoder' ),
318
  'site_description' => __( 'Site description', 'shortcoder' ),