Shortcoder - Version 5.1

Version Description

  • New: Import/Export link added to the shortcoder list page.
  • Fix: empty() was throwing error at some places for users using PHP 5.5 below as function return value was passed to it.
  • Fix: Shortcoder QTTags button was loading in frontends.
  • Fix: "Insert shortcode" popup was hidden behind in theme customizer page.
  • Fix: array_key_exists array but bool given warning.
  • Fix: Hide comments metabox in shortcode edit page as it was shown in certain conditions.
Download this release

Release Info

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

Code changes from version 5.0.4 to 5.1

admin/admin.php CHANGED
@@ -14,6 +14,8 @@ class SC_Admin{
14
 
15
  add_action( 'admin_footer', array( __class__, 'changelog' ) );
16
 
 
 
17
  add_action( 'wp_ajax_sc_admin_ajax', array( __class__, 'admin_ajax' ) );
18
 
19
  }
@@ -181,7 +183,7 @@ class SC_Admin{
181
  return false;
182
  }
183
 
184
- $response = wp_remote_get( 'https://vaakash.github.io/misc/shortcoder/changelogs/' . SC_VERSION . '.html' );
185
  $changelog = false;
186
 
187
  if( !is_wp_error( $response ) && $response[ 'response' ][ 'code' ] == 200 ){
@@ -200,6 +202,47 @@ class SC_Admin{
200
 
201
  }
202
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
203
  public static function clean_get(){
204
 
205
  foreach( $_GET as $k => $v ){
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
  }
183
  return false;
184
  }
185
 
186
+ $response = wp_remote_get( 'https://raw.githubusercontent.com/vaakash/vaakash.github.io/master/misc/shortcoder/changelogs/' . SC_VERSION . '.html' );
187
  $changelog = false;
188
 
189
  if( !is_wp_error( $response ) && $response[ 'response' ][ 'code' ] == 200 ){
202
 
203
  }
204
 
205
+ public static function import_export(){
206
+
207
+ if( !self::is_sc_admin_page() ){
208
+ return false;
209
+ }
210
+
211
+ $screen = get_current_screen();
212
+ if( $screen->base != 'edit' ){
213
+ return false;
214
+ }
215
+
216
+ echo '<div id="ie_content" class="hidden"><div>
217
+ <div id="contextual-help-back"></div>
218
+ <div id="contextual-help-columns">
219
+ <div class="contextual-help-tabs">
220
+ <ul>
221
+ <li class="active"><a href="#export-tab" aria-controls="export-tab">Export</a></li>
222
+ <li><a href="#import-tab" aria-controls="import-tab">Import</a></li>
223
+ <li><a href="#import-others-tab" aria-controls="import-others-tab">Import from other sources</a></li>
224
+ </ul>
225
+ </div>
226
+ <div class="contextual-help-sidebar"><p><a href="https://www.aakashweb.com/docs/shortcoder-doc/" target="_blank">Documentation</a></p></div>
227
+ <div class="contextual-help-tabs-wrap">
228
+ <div id="export-tab" class="help-tab-content active">
229
+ <h3>' . __( 'Export', 'sc' ) . '</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.', 'sc' ) . '</p>
230
+ <a href="' . admin_url( 'export.php' ) . '" class="button button-primary">' . __( 'Go to export page', 'sc' ) . '</a>
231
+ </div>
232
+ <div id="import-tab" class="help-tab-content">
233
+ <h3>' . __( 'Import', 'sc' ) . '</h3><p>' . __( 'The XML file downloaded through the native export process can be imported via WordPress\'s own import tool. Navigate to <code>Tools -> Import</code>, install the importer plugin if not installed and run the importer under WordPress section.', 'sc' ) . '</p>
234
+ <a href="' . admin_url( 'import.php' ) . '" class="button button-primary">' . __( 'Go to import page', 'sc' ) . '</a>
235
+ </div>
236
+ <div id="import-others-tab" class="help-tab-content">
237
+ <h3>' . __( 'Import from other sources', 'sc' ) . '</h3><p>' . __( 'To import from other sources like CSV, excel please read the below linked documentation.', 'sc' ) . '</p>
238
+ <a href="https://www.aakashweb.com/docs/shortcoder-doc/import-export/" target="_blank" class="button button-primary">' . __( 'Open documentation', 'sc' ) . '</a>
239
+ </div>
240
+ </div>
241
+ </div>
242
+ </div></div>';
243
+
244
+ }
245
+
246
  public static function clean_get(){
247
 
248
  foreach( $_GET as $k => $v ){
admin/css/style-tools.css CHANGED
@@ -5,12 +5,12 @@
5
  right: 0;
6
  bottom: 0;
7
  background: rgba(0, 0, 0, 0.5);
8
- z-index: 99999;
9
  }
10
 
11
  #sci_popup {
12
  position: fixed;
13
- z-index: 99999;
14
  background: #fff;
15
  top: 50px;
16
  bottom: 50px;
5
  right: 0;
6
  bottom: 0;
7
  background: rgba(0, 0, 0, 0.5);
8
+ z-index: 999999;
9
  }
10
 
11
  #sci_popup {
12
  position: fixed;
13
+ z-index: 999999;
14
  background: #fff;
15
  top: 50px;
16
  bottom: 50px;
admin/css/style.css CHANGED
@@ -320,6 +320,15 @@
320
  color: #FF9800;
321
  }
322
 
 
 
 
 
 
 
 
 
 
323
  /** Footer **/
324
  .footer_thanks{
325
  font-style: italic;
320
  color: #FF9800;
321
  }
322
 
323
+ /** Import/Export link **/
324
+ .ie_top_link{
325
+ float: left;
326
+ margin: 0 0 0 6px;
327
+ }
328
+ #import-export-tab{
329
+ margin: 0;
330
+ }
331
+
332
  /** Footer **/
333
  .footer_thanks{
334
  font-style: italic;
admin/edit.php CHANGED
@@ -56,6 +56,10 @@ class SC_Admin_Edit{
56
 
57
  remove_meta_box( 'slugdiv', SC_POST_TYPE, 'normal' );
58
 
 
 
 
 
59
  }
60
 
61
  public static function settings_form( $post ){
@@ -141,7 +145,8 @@ class SC_Admin_Edit{
141
  return $post;
142
  }
143
 
144
- if( empty( trim( $post[ 'post_title' ] ) ) ){
 
145
  $post[ 'post_title' ] = $post[ 'post_name' ];
146
  }
147
 
56
 
57
  remove_meta_box( 'slugdiv', SC_POST_TYPE, 'normal' );
58
 
59
+ remove_meta_box( 'commentstatusdiv', SC_POST_TYPE, 'normal' );
60
+
61
+ remove_meta_box( 'commentsdiv', SC_POST_TYPE, 'normal' );
62
+
63
  }
64
 
65
  public static function settings_form( $post ){
145
  return $post;
146
  }
147
 
148
+ $post_title = trim( $post[ 'post_title' ] );
149
+ if( empty( $post_title ) ){
150
  $post[ 'post_title' ] = $post[ 'post_name' ];
151
  }
152
 
admin/js/script.js CHANGED
@@ -94,7 +94,15 @@ $(document).ready(function(){
94
  }
95
 
96
  var add_top_coffee_btn = function(){
 
 
 
97
  $('#screen-meta-links').prepend('<div class="screen-meta-toggle cfe_top_link"><a class="show-settings button" href="https://www.paypal.me/vaakash/" target="_blank">Buy me a Coffee</a></div>');
 
 
 
 
 
98
  }
99
 
100
  $('#post_name').on('change keyup', function(){
94
  }
95
 
96
  var add_top_coffee_btn = function(){
97
+
98
+ $('#screen-meta-links').prepend('<div class="screen-meta-toggle ie_top_link hide-if-no-js"><button aria-controls="import-export-tab" aria-expanded="false" class="show-settings button">Import / Export</button></div>');
99
+
100
  $('#screen-meta-links').prepend('<div class="screen-meta-toggle cfe_top_link"><a class="show-settings button" href="https://www.paypal.me/vaakash/" target="_blank">Buy me a Coffee</a></div>');
101
+
102
+ $('#screen-meta').append('<div id="import-export-tab" class="hidden"></div>');
103
+
104
+ $('#ie_content > div').appendTo('#import-export-tab');
105
+
106
  }
107
 
108
  $('#post_name').on('change keyup', function(){
admin/tools.php CHANGED
@@ -65,7 +65,7 @@ class SC_Admin_Tools{
65
 
66
  public static function enqueue_insert_scripts(){
67
 
68
- if( self::is_sc_edit_page() )
69
  return;
70
 
71
  wp_enqueue_script( 'sc-tools-js', SC_ADMIN_URL . 'js/script-tools.js', array( 'jquery' ), SC_VERSION );
65
 
66
  public static function enqueue_insert_scripts(){
67
 
68
+ if( self::is_sc_edit_page() || !is_admin() )
69
  return;
70
 
71
  wp_enqueue_script( 'sc-tools-js', SC_ADMIN_URL . 'js/script-tools.js', array( 'jquery' ), SC_VERSION );
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.0.4
12
 
13
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
14
 
@@ -88,6 +88,14 @@ Please check the following if you notice that the shortcode content is not print
88
 
89
  == Changelog ==
90
 
 
 
 
 
 
 
 
 
91
  = 5.0.4 =
92
  * Fix: `script` and `style` tags stripped after 4.x upgrade. New migration will run in this version and shortcode content will now be fixed.
93
 
8
  Requires PHP: 5.3
9
  Requires at least: 4.4
10
  Tested up to: 5.3.2
11
+ Stable tag: 5.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.1 =
92
+ * New: Import/Export link added to the shortcoder list page.
93
+ * Fix: `empty()` was throwing error at some places for users using PHP 5.5 below as function return value was passed to it.
94
+ * Fix: Shortcoder QTTags button was loading in frontends.
95
+ * Fix: "Insert shortcode" popup was hidden behind in theme customizer page.
96
+ * Fix: `array_key_exists` array but bool given warning.
97
+ * Fix: Hide comments metabox in shortcode edit page as it was shown in certain conditions.
98
+
99
  = 5.0.4 =
100
  * Fix: `script` and `style` tags stripped after 4.x upgrade. New migration will run in this version and shortcode content will now be fixed.
101
 
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.0.4
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
- define( 'SC_VERSION', '5.0.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' ) );
@@ -118,6 +118,10 @@ final class Shortcoder{
118
  $default_vals = self::default_sc_settings();
119
  $settings = array();
120
 
 
 
 
 
121
  foreach( $default_vals as $key => $val ){
122
  $settings[ $key ] = array_key_exists( $key, $meta_vals ) ? $meta_vals[$key][0] : $val;
123
  }
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.1
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
+ define( 'SC_VERSION', '5.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' ) );
118
  $default_vals = self::default_sc_settings();
119
  $settings = array();
120
 
121
+ if( !is_array( $meta_vals ) ){
122
+ return $default_vals;
123
+ }
124
+
125
  foreach( $default_vals as $key => $val ){
126
  $settings[ $key ] = array_key_exists( $key, $meta_vals ) ? $meta_vals[$key][0] : $val;
127
  }