Shortcoder - Version 4.1.4

Version Description

  • New: Codemirror powered syntax highlighted shortcode content code editor (beta).
Download this release

Release Info

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

Code changes from version 4.1.3 to 4.1.4

admin/css/style.css CHANGED
@@ -192,6 +192,7 @@ h1.sc_title .title-count {
192
  position: absolute;
193
  display: none;
194
  background: #fff;
 
195
  }
196
  .params_wrap li{
197
  position: relative;
@@ -418,9 +419,14 @@ h1.sc_title .title-count {
418
  visibility: hidden;
419
  font-size: 0;
420
  }
421
- .sc_enable_vedit{
422
- margin-top: 2px !important;
423
  }
424
- .sc_enable_vedit .dashicons {
425
  margin-top: 4px !important;
 
 
 
 
 
426
  }
192
  position: absolute;
193
  display: none;
194
  background: #fff;
195
+ z-index: 9999;
196
  }
197
  .params_wrap li{
198
  position: relative;
419
  visibility: hidden;
420
  font-size: 0;
421
  }
422
+ .sc_switch_editor{
423
+ margin: 2px 0 0 5px !important;
424
  }
425
+ .sc_switch_editor .dashicons {
426
  margin-top: 4px !important;
427
+ }
428
+
429
+ .CodeMirror{
430
+ border: 1px solid #ccc;
431
+ margin-top: 15px;
432
  }
admin/js/script.js CHANGED
@@ -4,6 +4,21 @@ $(document).ready(function(){
4
  var delete_ctext = 'Are you sure want to delete this shortcode ?';
5
  var last_sort = 'desc';
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  var sort = function( ele, orderby ){
8
  var total = ele.length;
9
  while( total ){
@@ -22,6 +37,15 @@ $(document).ready(function(){
22
  }
23
  }
24
 
 
 
 
 
 
 
 
 
 
25
  $( document ).on( 'click', '.sc_delete', function(e){
26
 
27
  e.preventDefault();
@@ -100,12 +124,23 @@ $(document).ready(function(){
100
  });
101
 
102
  $(window).load(function(){
103
- $( '.wp-media-buttons' ).append(function(){
 
104
  return '<button class="button button-primary sc_insert_params"><span class="dashicons dashicons-plus"></span> Insert shortcode paramerters <span class="dashicons dashicons-arrow-down"></span></button>';
105
- });
 
 
 
 
 
 
 
106
  $( '.params_wrap' ).appendTo( 'body' );
 
107
  $( '.quicktags-toolbar' ).append(function(){
108
- return '<a href="#" class="ed_button button button-small fright sc_enable_vedit" title="Enable visual editor"><span class="dashicons dashicons-visibility"></span> Enable visual editor</a>';
 
 
109
  });
110
  });
111
 
@@ -129,7 +164,7 @@ $(document).ready(function(){
129
  var param_val = $cp_box.val().trim();
130
 
131
  if( param_val != '' && $cp_box[0].checkValidity() ){
132
- send_to_editor( '%%' + param_val + '%%' );
133
  $cp_info.removeClass( 'red' );
134
  $( '.params_wrap' ).hide();
135
  }else{
@@ -139,10 +174,8 @@ $(document).ready(function(){
139
  });
140
 
141
  $( document ).on( 'click', '.wp_params li', function(){
142
-
143
- send_to_editor( '$$' + $(this).data( 'id' ) + '$$' );
144
  $( '.params_wrap' ).hide();
145
-
146
  });
147
 
148
  $( document ).on( 'change', '.coffee_amt', function(){
@@ -210,10 +243,12 @@ $(document).ready(function(){
210
 
211
  });
212
 
213
- $( document ).on( 'click', '.sc_enable_vedit', function(e){
214
  e.preventDefault();
215
- window.location = window.location + '&visual_edit=1';
216
  });
217
 
 
 
218
  });
219
  })( jQuery );
4
  var delete_ctext = 'Are you sure want to delete this shortcode ?';
5
  var last_sort = 'desc';
6
 
7
+ var init = function(){
8
+ if(window.sc_cm_editor){
9
+ window.sc_cm = CodeMirror.fromTextArea( document.getElementById( 'sc_content' ), {
10
+ lineNumbers: true,
11
+ mode: "htmlmixed",
12
+ indentWithTabs: false,
13
+ lineWrapping: true
14
+ });
15
+ sc_cm.setSize( null, 500 );
16
+ sc_cm.on( 'change', function(){
17
+ sc_cm.save();
18
+ });
19
+ }
20
+ }
21
+
22
  var sort = function( ele, orderby ){
23
  var total = ele.length;
24
  while( total ){
37
  }
38
  }
39
 
40
+ var insert_in_editor = function( data ){
41
+ if( window.sc_cm_editor ){
42
+ var doc = window.sc_cm.getDoc();
43
+ doc.replaceRange( data, doc.getCursor() );
44
+ }else{
45
+ send_to_editor( data );
46
+ }
47
+ }
48
+
49
  $( document ).on( 'click', '.sc_delete', function(e){
50
 
51
  e.preventDefault();
124
  });
125
 
126
  $(window).load(function(){
127
+
128
+ var insert_button = function(){
129
  return '<button class="button button-primary sc_insert_params"><span class="dashicons dashicons-plus"></span> Insert shortcode paramerters <span class="dashicons dashicons-arrow-down"></span></button>';
130
+ }
131
+
132
+ $( '.wp-media-buttons' ).append( insert_button );
133
+
134
+ if( window.sc_cm_editor ){
135
+ $( '.CodeMirror' ).before( insert_button );
136
+ }
137
+
138
  $( '.params_wrap' ).appendTo( 'body' );
139
+
140
  $( '.quicktags-toolbar' ).append(function(){
141
+ var html = '<a href="#" class="ed_button button button-small fright sc_switch_editor" data-type="1" title="Enable visual editor"><span class="dashicons dashicons-visibility"></span> Visual editor</a>';
142
+ html += '<a href="#" class="ed_button button button-small fright sc_switch_editor" data-type="2" title="Enable code editor"><span class="dashicons dashicons-editor-code"></span> Code editor (beta)</a>';
143
+ return html;
144
  });
145
  });
146
 
164
  var param_val = $cp_box.val().trim();
165
 
166
  if( param_val != '' && $cp_box[0].checkValidity() ){
167
+ insert_in_editor( '%%' + param_val + '%%' );
168
  $cp_info.removeClass( 'red' );
169
  $( '.params_wrap' ).hide();
170
  }else{
174
  });
175
 
176
  $( document ).on( 'click', '.wp_params li', function(){
177
+ insert_in_editor('$$' + $(this).data( 'id' ) + '$$');
 
178
  $( '.params_wrap' ).hide();
 
179
  });
180
 
181
  $( document ).on( 'change', '.coffee_amt', function(){
243
 
244
  });
245
 
246
+ $( document ).on( 'click', '.sc_switch_editor', function(e){
247
  e.preventDefault();
248
+ window.location = window.location + '&editor=' + $(this).data('type');
249
  });
250
 
251
+ init();
252
+
253
  });
254
  })( jQuery );
admin/sc-admin.php CHANGED
@@ -211,7 +211,15 @@ class Shortcoder_Admin{
211
 
212
  echo '<div class="sc_section">';
213
  echo '<label for="sc_content">' . __( 'Shortcode content', 'shortcoder' ) . '</label>';
214
- wp_editor( $values[ 'content' ], 'sc_content', array( 'wpautop'=> false, 'textarea_rows'=> 15, 'tinymce' => isset( $g[ 'visual_edit' ] ) ) );
 
 
 
 
 
 
 
 
215
  echo '</div>';
216
 
217
  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>';
@@ -405,6 +413,19 @@ class Shortcoder_Admin{
405
  return $plugins;
406
  }
407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  public static function page_bottom(){
409
 
410
  echo '<div class="coffee_box">
211
 
212
  echo '<div class="sc_section">';
213
  echo '<label for="sc_content">' . __( 'Shortcode content', 'shortcoder' ) . '</label>';
214
+
215
+ $editor_type = isset( $g[ 'editor' ] ) ? intval( $g[ 'editor' ] ) : 0;
216
+
217
+ if( $editor_type == 2 ){
218
+ self::load_codemirror_editor( $values[ 'content' ] );
219
+ }else{
220
+ wp_editor( $values[ 'content' ], 'sc_content', array( 'wpautop'=> false, 'textarea_rows'=> 15, 'tinymce' => ( $editor_type == 1 ) ) );
221
+ }
222
+
223
  echo '</div>';
224
 
225
  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>';
413
  return $plugins;
414
  }
415
 
416
+ public static function load_codemirror_editor( $value ){
417
+ echo '<link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.css" rel="stylesheet">';
418
+ echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/codemirror.min.js"></script>';
419
+ echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/mode/htmlmixed/htmlmixed.min.js"></script>';
420
+ echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/mode/css/css.min.js"></script>';
421
+ echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/mode/xml/xml.min.js"></script>';
422
+ echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.32.0/mode/javascript/javascript.min.js"></script>';
423
+
424
+ echo '<textarea name="sc_content" id="sc_content">' . esc_textarea( $value ) . '</textarea>';
425
+
426
+ echo '<script>var sc_cm_editor = true;</script>';
427
+ }
428
+
429
  public static function page_bottom(){
430
 
431
  echo '<div class="coffee_box">
includes/import.php CHANGED
@@ -99,7 +99,7 @@ class Shortcoder_Import{
99
  header('Connection: close');
100
 
101
  echo $export_json;
102
-
103
  }
104
 
105
  public static function print_notice( $msg, $type = 'error' ){
99
  header('Connection: close');
100
 
101
  echo $export_json;
102
+ return;
103
  }
104
 
105
  public static function print_notice( $msg, $type = 'error' ){
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
10
- Stable tag: 4.1.3
11
 
12
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
13
 
@@ -91,6 +91,9 @@ Note: When you disable a shortcode, the shortcode will not be executed in the pa
91
 
92
  == Changelog ==
93
 
 
 
 
94
  = 4.1.3 =
95
  * Fix: Shortcode names with not-allowed characters cannot be edited/deleted.
96
  * New: Shortcode imports made can now be fresh or overwritten.
6
  Donate link: https://goo.gl/qMF3iE
7
  License: GPLv2 or later
8
  Requires at least: 3.3
9
+ Tested up to: 4.9.1
10
+ Stable tag: 4.1.4
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.4 =
95
+ * New: Codemirror powered syntax highlighted shortcode content code editor (beta).
96
+
97
  = 4.1.3 =
98
  * Fix: Shortcode names with not-allowed characters cannot be edited/deleted.
99
  * New: Shortcode imports made can now be fresh or overwritten.
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.3
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
- define( 'SC_VERSION', '4.1.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' ) );
@@ -48,7 +48,7 @@ class Shortcoder{
48
 
49
  }
50
 
51
- public static function execute_shortcode( $atts, $content ) {
52
 
53
  $shortcodes = self::list_all();
54
 
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.4
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
+ define( 'SC_VERSION', '4.1.4' );
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' ) );
48
 
49
  }
50
 
51
+ public static function execute_shortcode( $atts, $content ) {
52
 
53
  $shortcodes = self::list_all();
54