Shortcoder - Version 6.0

Version Description

Download this release

Release Info

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

Code changes from version 5.8 to 6.0

admin/admin.php CHANGED
@@ -20,6 +20,8 @@ class SC_Admin{
20
 
21
  add_filter( 'plugin_action_links_' . SC_BASE_NAME, array( __CLASS__, 'action_links' ) );
22
 
 
 
23
  }
24
 
25
  public static function register_post_type(){
@@ -54,7 +56,7 @@ class SC_Admin{
54
  'filter_items_list' => __( 'Filter shortcodes list', 'shortcoder' ),
55
  );
56
 
57
- $args = array(
58
  'label' => __( 'Shortcode', 'shortcoder' ),
59
  'labels' => $labels,
60
  'supports' => false,
@@ -74,7 +76,7 @@ class SC_Admin{
74
  'show_in_rest' => false,
75
  'map_meta_cap' => true,
76
  'capability_type' => 'shortcoder',
77
- );
78
 
79
  register_post_type( SC_POST_TYPE, $args );
80
 
@@ -214,8 +216,8 @@ class SC_Admin{
214
  }
215
 
216
  echo '<div class="sc_changelog"><main>
217
- <article>' . $changelog . '</article>
218
- <footer><button href="#" class="button button-primary dismiss_btn">' . __( 'Continue using Shortcoder', 'shortcoder' ) . '</a></footer>
219
  </main></div>';
220
 
221
  }
@@ -236,24 +238,24 @@ class SC_Admin{
236
  <div id="contextual-help-columns">
237
  <div class="contextual-help-tabs">
238
  <ul>
239
- <li class="active"><a href="#export-tab" aria-controls="export-tab">' . __( 'Export', 'shortcoder' ) . '</a></li>
240
- <li><a href="#import-tab" aria-controls="import-tab">' . __( 'Import', 'shortcoder' ) . '</a></li>
241
- <li><a href="#import-others-tab" aria-controls="import-others-tab">' . __( 'Import from other sources', 'shortcoder' ) . '</a></li>
242
  </ul>
243
  </div>
244
- <div class="contextual-help-sidebar"><p><a href="https://www.aakashweb.com/docs/shortcoder/" target="_blank">' . __( 'Documentation', 'shortcoder' ) . '</a></p></div>
245
  <div class="contextual-help-tabs-wrap">
246
  <div id="export-tab" class="help-tab-content active">
247
- <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>
248
- <a href="' . admin_url( 'export.php' ) . '" class="button button-primary">' . __( 'Go to export page', 'shortcoder' ) . '</a>
249
  </div>
250
  <div id="import-tab" class="help-tab-content">
251
- <h3>' . __( 'Import', 'shortcoder' ) . '</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.', 'shortcoder' ) . '</p>
252
- <a href="' . admin_url( 'import.php' ) . '" class="button button-primary">' . __( 'Go to import page', 'shortcoder' ) . '</a>
253
  </div>
254
  <div id="import-others-tab" class="help-tab-content">
255
- <h3>' . __( 'Import from other sources', 'shortcoder' ) . '</h3><p>' . __( 'To import from other sources like CSV, excel please read the below linked documentation.', 'shortcoder' ) . '</p>
256
- <a href="https://www.aakashweb.com/docs/shortcoder/import-export/" target="_blank" class="button button-primary">' . __( 'Open documentation', 'shortcoder' ) . '</a>
257
  </div>
258
  </div>
259
  </div>
@@ -262,10 +264,15 @@ class SC_Admin{
262
  }
263
 
264
  public static function action_links( $links ){
265
- array_unshift( $links, '<a href="'. esc_url( admin_url( 'edit.php?post_type=shortcoder') ) .'">' . __( 'Manage shortcodes', 'shortcoder' ) . '</a>' );
 
266
  return $links;
267
  }
268
 
 
 
 
 
269
  public static function clean_get(){
270
 
271
  foreach( $_GET as $k => $v ){
20
 
21
  add_filter( 'plugin_action_links_' . SC_BASE_NAME, array( __CLASS__, 'action_links' ) );
22
 
23
+ add_action( 'admin_menu', array( __CLASS__, 'upgrade_menu' ), 15 );
24
+
25
  }
26
 
27
  public static function register_post_type(){
56
  'filter_items_list' => __( 'Filter shortcodes list', 'shortcoder' ),
57
  );
58
 
59
+ $args = apply_filters( 'sc_mod_post_type_args', array(
60
  'label' => __( 'Shortcode', 'shortcoder' ),
61
  'labels' => $labels,
62
  'supports' => false,
76
  'show_in_rest' => false,
77
  'map_meta_cap' => true,
78
  'capability_type' => 'shortcoder',
79
+ ));
80
 
81
  register_post_type( SC_POST_TYPE, $args );
82
 
216
  }
217
 
218
  echo '<div class="sc_changelog"><main>
219
+ <article>' . wp_kses_post( $changelog ) . '</article>
220
+ <footer><button href="#" class="button button-primary dismiss_btn">' . esc_html__( 'Continue using Shortcoder', 'shortcoder' ) . '</a></footer>
221
  </main></div>';
222
 
223
  }
238
  <div id="contextual-help-columns">
239
  <div class="contextual-help-tabs">
240
  <ul>
241
+ <li class="active"><a href="#export-tab" aria-controls="export-tab">' . esc_html__( 'Export', 'shortcoder' ) . '</a></li>
242
+ <li><a href="#import-tab" aria-controls="import-tab">' . esc_html__( 'Import', 'shortcoder' ) . '</a></li>
243
+ <li><a href="#import-others-tab" aria-controls="import-others-tab">' . esc_html__( 'Import from other sources', 'shortcoder' ) . '</a></li>
244
  </ul>
245
  </div>
246
+ <div class="contextual-help-sidebar"><p><a href="https://www.aakashweb.com/docs/shortcoder/" target="_blank">' . esc_html__( 'Documentation', 'shortcoder' ) . '</a></p></div>
247
  <div class="contextual-help-tabs-wrap">
248
  <div id="export-tab" class="help-tab-content active">
249
+ <h3>' . esc_html__( 'Export', 'shortcoder' ) . '</h3><p>' . wp_kses( __( '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' ), array( 'code' => array() ) ) . '</p>
250
+ <a href="' . esc_url( admin_url( 'export.php' ) ) . '" class="button button-primary">' . esc_html__( 'Go to export page', 'shortcoder' ) . '</a>
251
  </div>
252
  <div id="import-tab" class="help-tab-content">
253
+ <h3>' . esc_html__( 'Import', 'shortcoder' ) . '</h3><p>' . wp_kses( __( '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.', 'shortcoder' ), array( 'code' => array() ) ) . '</p>
254
+ <a href="' . esc_url( admin_url( 'import.php' ) ) . '" class="button button-primary">' . esc_html__( 'Go to import page', 'shortcoder' ) . '</a>
255
  </div>
256
  <div id="import-others-tab" class="help-tab-content">
257
+ <h3>' . esc_html__( 'Import from other sources', 'shortcoder' ) . '</h3><p>' . esc_html__( 'To import from other sources like CSV, excel please read the below linked documentation.', 'shortcoder' ) . '</p>
258
+ <a href="https://www.aakashweb.com/docs/shortcoder/import-export/" target="_blank" class="button button-primary">' . esc_html__( 'Open documentation', 'shortcoder' ) . '</a>
259
  </div>
260
  </div>
261
  </div>
264
  }
265
 
266
  public static function action_links( $links ){
267
+ array_unshift( $links, '<a href="'. esc_url( admin_url( 'edit.php?post_type=shortcoder') ) .'">' . esc_html__( 'View shortcodes', 'shortcoder' ) . '</a>' );
268
+ array_unshift( $links, '<a href="https://www.aakashweb.com/wordpress-plugins/shortcoder/?utm_source=admin&utm_medium=menu&utm_campaign=sc-pro#pro" target="_blank"><span style="font-weight: bold">' . esc_html__( 'Upgrade to PRO', 'shortcoder' ) . '</span></a>' );
269
  return $links;
270
  }
271
 
272
+ public static function upgrade_menu(){
273
+ add_submenu_page( 'edit.php?post_type=shortcoder', 'Shortcoder - Upgrade', '<span style="color: #ff8c29" class="sc_upgrade_link">Upgrade to PRO</span>', 'manage_options', 'https://www.aakashweb.com/wordpress-plugins/shortcoder/?utm_source=admin&utm_medium=menu&utm_campaign=sc-pro#pro', null );
274
+ }
275
+
276
  public static function clean_get(){
277
 
278
  foreach( $_GET as $k => $v ){
admin/css/style.css CHANGED
@@ -279,7 +279,8 @@
279
  font-weight: normal;
280
  }
281
  .sc_changelog h3 {
282
- font-size: 1.75em;
 
283
  }
284
  .sc_changelog p, .sc_changelog ul{
285
  font-size: 1.25em;
@@ -290,28 +291,22 @@
290
  padding-left: 1.5em;
291
  }
292
 
293
- /** Coffee - Top link **/
294
- .cfe_top_link{
295
  float: left;
296
  position: relative;
297
  }
298
- #screen-meta-links .cfe_top_link a.show-settings{
299
- padding-right: 35px !important;
300
  background: #fff !important;
301
  }
302
- .cfe_top_link a:after{
303
  display: none !important;
304
  }
305
- .cfe_top_link a:before{
306
- content: '';
307
- display: block;
308
- position: absolute;
309
- background: url('../images/coffee.svg') no-repeat;
310
- background-size: 100%;
311
- width: 20px;
312
- height: 24px;
313
- right: 10px;
314
- top: 5px;
315
  }
316
 
317
  /** Feedback **/
279
  font-weight: normal;
280
  }
281
  .sc_changelog h3 {
282
+ font-size: 1.5em;
283
+ font-weight: normal;
284
  }
285
  .sc_changelog p, .sc_changelog ul{
286
  font-size: 1.25em;
291
  padding-left: 1.5em;
292
  }
293
 
294
+ /** PRO - Top link **/
295
+ .pro_top_link{
296
  float: left;
297
  position: relative;
298
  }
299
+ #screen-meta-links .pro_top_link a.show-settings{
 
300
  background: #fff !important;
301
  }
302
+ .pro_top_link a:after{
303
  display: none !important;
304
  }
305
+ .pro_top_link .dashicons {
306
+ font-size: 14px;
307
+ margin: 6px 5px 0 0;
308
+ height: 14px;
309
+ color: #ff8c29;
 
 
 
 
 
310
  }
311
 
312
  /** Feedback **/
admin/edit.php CHANGED
@@ -29,14 +29,14 @@ class SC_Admin_Edit{
29
  $settings = Shortcoder::get_sc_settings( $post->ID );
30
 
31
  echo '<div id="sc_name">';
32
- echo '<input type="text" class="widefat" title="' . __( 'Name of the shortcode. Allowed characters are alphabets, numbers, hyphens and underscore.', 'shortcoder' ) . '" value="' . $post->post_name . '" name="post_name" id="post_name" pattern="[a-zA-z0-9\-_]+" required placeholder="' . __( 'Enter shortcode name', 'shortcoder' ) . '" />';
33
  echo '</div>';
34
 
35
  echo '<div id="edit-slug-box">';
36
- echo '<strong>' . __( 'Your shortcode', 'shortcoder' ) . ': </strong>';
37
- echo '<code class="sc_preview_text">' . Shortcoder::get_sc_tag( $post->ID ) . '</code>';
38
- echo '<span id="edit-slug-buttons"><button type="button" class="sc_copy button button-small"><span class="dashicons dashicons-yes"></span> ' . __( 'Copy', 'shortcoder' ) . '</button></span>';
39
- echo '<a href="#sc_mb_settings" class="sc_settings_link">' . __( 'Settings', 'shortcoder' ) . '</a>';
40
  echo '</div>';
41
 
42
  // Editor
@@ -118,7 +118,7 @@ class SC_Admin_Edit{
118
 
119
  );
120
 
121
- echo SC_Admin_Form::table($fields);
122
 
123
  }
124
 
@@ -135,11 +135,16 @@ class SC_Admin_Edit{
135
  }
136
 
137
  $default_settings = Shortcoder::default_sc_settings();
 
138
 
139
  foreach( $default_settings as $key => $val ){
140
 
141
  if( array_key_exists( $key, $_POST ) ){
142
- $val = sanitize_text_field( $_POST[ $key ] );
 
 
 
 
143
  update_post_meta( $post_id, $key, $val );
144
  }
145
 
@@ -153,13 +158,13 @@ class SC_Admin_Edit{
153
  return $post;
154
  }
155
 
156
- $post_title = trim( $post[ 'post_title' ] );
157
  if( empty( $post_title ) ){
158
- $post[ 'post_title' ] = $post[ 'post_name' ];
159
  }
160
 
161
  if( $_POST && isset( $_POST[ 'sc_content' ] ) ){
162
- $post[ 'post_content' ] = $_POST[ 'sc_content' ];
163
  }
164
 
165
  return $post;
@@ -174,18 +179,18 @@ class SC_Admin_Edit{
174
  $settings[ '_sc_editor' ] = $general_settings[ 'default_editor' ];
175
  }
176
 
177
- $list = array(
178
  'text' => __( 'Text editor', 'shortcoder' ),
179
  'visual' => __( 'Visual editor', 'shortcoder' ),
180
  'code' => __( 'Code editor', 'shortcoder' )
181
- );
182
 
183
  $editor = ( isset( $g[ 'editor' ] ) && array_key_exists( $g[ 'editor' ], $list ) ) ? $g[ 'editor' ] : $settings[ '_sc_editor' ];
184
 
185
- $switch = '<span class="sc_editor_list sc_editor_icon_' . $editor . '">';
186
- $switch .= '<select name="_sc_editor" class="sc_editor" title="' . __( 'Switch editor', 'shortcoder' ) . '">';
187
  foreach( $list as $id => $name ){
188
- $switch .= '<option value="' . $id . '" ' . selected( $editor, $id, false ) . '>' . $name . '</option>';
189
  }
190
  $switch .= '</select>';
191
  $switch .= '</span>';
@@ -203,7 +208,7 @@ class SC_Admin_Edit{
203
 
204
  echo '<div class="hidden">';
205
  echo '<div class="sc_editor_toolbar">';
206
- echo '<button class="button button-primary sc_insert_param"><span class="dashicons dashicons-plus"></span>' . __( 'Insert shortcode parameters', 'shortcoder' ) . '<span class="dashicons dashicons-arrow-down"></span></button>';
207
  echo $editor[ 'switch_html' ];
208
  echo '</div>';
209
  echo '</div>';
@@ -215,9 +220,10 @@ class SC_Admin_Edit{
215
 
216
  if( $editor[ 'active' ] == 'code' ){
217
  echo '<div class="sc_cm_menu"></div>';
218
- $content = user_can_richedit() ? esc_textarea( $post->post_content ) : $post->post_content;
219
- echo '<textarea name="sc_content" id="sc_content" class="sc_cm_content">' . $content . '</textarea>';
220
- }else{
 
221
  wp_editor( $post->post_content, 'sc_content', array(
222
  'wpautop'=> false,
223
  'textarea_rows'=> 20,
@@ -225,6 +231,12 @@ class SC_Admin_Edit{
225
  ));
226
  }
227
 
 
 
 
 
 
 
228
  }
229
 
230
  public static function enqueue_scripts( $hook ){
@@ -262,33 +274,33 @@ class SC_Admin_Edit{
262
  echo '<ul class="sc_params_list">';
263
 
264
  foreach( $sc_wp_params as $group => $group_info ){
265
- echo '<li><span class="dashicons dashicons-' . $group_info['icon'] . '"></span>';
266
- echo $group_info[ 'name' ];
267
  echo '<ul class="sc_wp_params">';
268
  foreach( $group_info[ 'params' ] as $param_id => $param_name ){
269
- echo '<li data-id="' . $param_id . '">' . $param_name . '</li>';
270
  }
271
  echo '</ul></li>';
272
  }
273
 
274
- echo '<li><span class="dashicons dashicons-list-view"></span>' . __( 'Custom parameter', 'shortcoder' ) . '<ul>';
275
  echo '<li class="sc_params_form">';
276
- echo '<p>' . __( 'Insert parameters in content and replace them with custom values when using the shortcode.', 'shortcoder' ) . '<a href="https://www.aakashweb.com/docs/shortcoder/custom-parameters/" target="_blank" title="' . __( 'More information', 'shortcoder' ) . '"><span class="dashicons dashicons-info"></span></a></p>';
277
- echo '<h4>' . __( 'Enter custom parameter name', 'shortcoder' ) . '</h4>';
278
  echo '<input type="text" class="sc_cp_box widefat" pattern="[a-zA-Z0-9_-]+"/>';
279
- echo '<h4>' . __( 'Default value', 'shortcoder' ) . '</h4>';
280
  echo '<input type="text" class="sc_cp_default widefat"/>';
281
- echo '<button class="button sc_cp_btn">' . __( 'Insert parameter', 'shortcoder' ) . '</button>';
282
- echo '<p class="sc_cp_info"><small>' . __( 'Only alphabets, numbers, underscores and hyphens are allowed. Custom parameters are case insensitive', 'shortcoder' ) . '</small></p></li>';
283
  echo '</ul></li>';
284
 
285
- echo '<li><span class="dashicons dashicons-screenoptions"></span>' . __( 'Custom Fields', 'shortcoder' ) . '<ul>';
286
  echo '<li class="sc_params_form">';
287
- echo '<p>' . __( 'Pull a custom field value of the current post and display it inside the shortcode content.', 'shortcoder' ) . '<a href="https://www.aakashweb.com/docs/shortcoder/shortcode-parameters/#custom-fields" target="_blank" title="' . __( 'More information', 'shortcoder' ) . '"><span class="dashicons dashicons-info"></span></a></p>';
288
- echo '<h4>' . __( 'Enter custom field name', 'shortcoder' ) . '</h4>';
289
  echo '<input type="text" class="sc_cf_box widefat" pattern="[a-zA-Z0-9_-]+"/>';
290
- echo '<button class="button sc_cf_btn">' . __( 'Insert custom field', 'shortcoder' ) . '</button>';
291
- echo '<p class="sc_cf_info"><small>' . __( 'Only alphabets, numbers, underscore and hyphens are allowed. Cannot be empty.', 'shortcoder' ) . '</small></p></li>';
292
  echo '</ul></li>';
293
 
294
  echo '</ul>';
@@ -307,7 +319,7 @@ class SC_Admin_Edit{
307
  echo '<p>Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam.</p>';
308
 
309
  echo '<div class="subscribe_form" data-action="https://aakashweb.us19.list-manage.com/subscribe/post-json?u=b7023581458d048107298247e&id=ef5ab3c5c4&c=">
310
- <input type="text" value="' . get_option( 'admin_email' ) . '" class="subscribe_email_box" placeholder="Your email address">
311
  <p class="subscribe_confirm">Thanks for subscribing !</p>
312
  <button class="button subscribe_btn"><span class="dashicons dashicons-email"></span> Subscribe</button>
313
  </div>';
@@ -325,15 +337,15 @@ class SC_Admin_Edit{
325
  echo '<div class="feedback">';
326
  echo '<div class="promo_slides">';
327
  echo '<div class="promo_slide">';
328
- echo '<a class="side_banner" href="https://www.aakashweb.com/wordpress-plugins/super-rss-reader/?utm_source=wp-socializer&utm_medium=sidebar&utm_campaign=srr-pro" target="_blank"><img src="' . SC_ADMIN_URL . 'images/super-rss-reader.png" /></a>';
329
  echo '</div>';
330
 
331
  echo '<div class="promo_slide">';
332
- echo '<a class="side_banner" href="https://www.aakashweb.com/wordpress-plugins/ultimate-floating-widgets/?utm_source=wp-socializer&utm_medium=sidebar&utm_campaign=ufw-pro" target="_blank"><img src="' . SC_ADMIN_URL . 'images/ultimate-floating-widgets.png" /></a>';
333
  echo '</div>';
334
 
335
  echo '<div class="promo_slide">';
336
- echo '<a class="side_banner" href="https://www.aakashweb.com/wordpress-plugins/announcer/?utm_source=wp-socializer&utm_medium=sidebar&utm_campaign=announcer-pro" target="_blank"><img src="' . SC_ADMIN_URL . 'images/announcer.png" /></a>';
337
  echo '</div>';
338
  echo '</div>';
339
 
29
  $settings = Shortcoder::get_sc_settings( $post->ID );
30
 
31
  echo '<div id="sc_name">';
32
+ echo '<input type="text" class="widefat" title="' . esc_attr__( 'Name of the shortcode. Allowed characters are alphabets, numbers, hyphens and underscore.', 'shortcoder' ) . '" value="' . esc_attr( $post->post_name ) . '" name="post_name" id="post_name" pattern="[a-zA-z0-9\-_]+" required placeholder="' . esc_attr__( 'Enter shortcode name', 'shortcoder' ) . '" />';
33
  echo '</div>';
34
 
35
  echo '<div id="edit-slug-box">';
36
+ echo '<strong>' . esc_html__( 'Your shortcode', 'shortcoder' ) . ': </strong>';
37
+ echo '<code class="sc_preview_text">' . esc_html( Shortcoder::get_sc_tag( $post->ID ) ) . '</code>';
38
+ echo '<span id="edit-slug-buttons"><button type="button" class="sc_copy button button-small"><span class="dashicons dashicons-yes"></span> ' . esc_html__( 'Copy', 'shortcoder' ) . '</button></span>';
39
+ echo '<a href="#sc_mb_settings" class="sc_settings_link">' . esc_html__( 'Settings', 'shortcoder' ) . '</a>';
40
  echo '</div>';
41
 
42
  // Editor
118
 
119
  );
120
 
121
+ echo SC_Admin_Form::table( apply_filters( 'sc_mod_sc_settings_fields', $fields, $settings ) );
122
 
123
  }
124
 
135
  }
136
 
137
  $default_settings = Shortcoder::default_sc_settings();
138
+ $skip_sanitize = array();
139
 
140
  foreach( $default_settings as $key => $val ){
141
 
142
  if( array_key_exists( $key, $_POST ) ){
143
+ if( in_array( $key, $skip_sanitize ) ){
144
+ $val = current_user_can( 'unfiltered_html' ) ? $_POST[ $key ] : wp_kses_post( $_POST[ $key ] );
145
+ }else{
146
+ $val = sanitize_text_field( $_POST[ $key ] );
147
+ }
148
  update_post_meta( $post_id, $key, $val );
149
  }
150
 
158
  return $post;
159
  }
160
 
161
+ $post_title = sanitize_text_field( $post[ 'post_title' ] );
162
  if( empty( $post_title ) ){
163
+ $post[ 'post_title' ] = sanitize_text_field( $post[ 'post_name' ] );
164
  }
165
 
166
  if( $_POST && isset( $_POST[ 'sc_content' ] ) ){
167
+ $post[ 'post_content' ] = current_user_can( 'unfiltered_html' ) ? $_POST[ 'sc_content' ] : wp_kses_post( $_POST[ 'sc_content' ] );
168
  }
169
 
170
  return $post;
179
  $settings[ '_sc_editor' ] = $general_settings[ 'default_editor' ];
180
  }
181
 
182
+ $list = apply_filters( 'sc_mod_editors', array(
183
  'text' => __( 'Text editor', 'shortcoder' ),
184
  'visual' => __( 'Visual editor', 'shortcoder' ),
185
  'code' => __( 'Code editor', 'shortcoder' )
186
+ ));
187
 
188
  $editor = ( isset( $g[ 'editor' ] ) && array_key_exists( $g[ 'editor' ], $list ) ) ? $g[ 'editor' ] : $settings[ '_sc_editor' ];
189
 
190
+ $switch = '<span class="sc_editor_list sc_editor_icon_' . esc_attr( $editor ) . '">';
191
+ $switch .= '<select name="_sc_editor" class="sc_editor" title="' . esc_attr__( 'Switch editor', 'shortcoder' ) . '">';
192
  foreach( $list as $id => $name ){
193
+ $switch .= '<option value="' . esc_attr( $id ) . '" ' . selected( $editor, $id, false ) . '>' . esc_html( $name ) . '</option>';
194
  }
195
  $switch .= '</select>';
196
  $switch .= '</span>';
208
 
209
  echo '<div class="hidden">';
210
  echo '<div class="sc_editor_toolbar">';
211
+ echo '<button class="button button-primary sc_insert_param"><span class="dashicons dashicons-plus"></span>' . esc_html__( 'Insert shortcode parameters', 'shortcoder' ) . '<span class="dashicons dashicons-arrow-down"></span></button>';
212
  echo $editor[ 'switch_html' ];
213
  echo '</div>';
214
  echo '</div>';
220
 
221
  if( $editor[ 'active' ] == 'code' ){
222
  echo '<div class="sc_cm_menu"></div>';
223
+ echo '<textarea name="sc_content" id="sc_content" class="sc_cm_content">' . esc_textarea( $post->post_content ) . '</textarea>';
224
+ }
225
+
226
+ if( in_array( $editor[ 'active' ], array( 'text', 'visual' ) ) ){
227
  wp_editor( $post->post_content, 'sc_content', array(
228
  'wpautop'=> false,
229
  'textarea_rows'=> 20,
231
  ));
232
  }
233
 
234
+ if( !current_user_can( 'unfiltered_html' ) ){
235
+ echo '<div class="notice notice-info"><p>' . esc_html__( 'Note: Your user role does not permit saving unrestricted HTML. Some tags and attributes will be removed before saving the content.', 'shortcoder' ) . '</p></div>';
236
+ }
237
+
238
+ do_action( 'sc_do_after_editor', $post, $settings, $editor );
239
+
240
  }
241
 
242
  public static function enqueue_scripts( $hook ){
274
  echo '<ul class="sc_params_list">';
275
 
276
  foreach( $sc_wp_params as $group => $group_info ){
277
+ echo '<li><span class="dashicons dashicons-' . esc_attr( $group_info['icon'] ) . '"></span>';
278
+ echo esc_html( $group_info[ 'name' ] );
279
  echo '<ul class="sc_wp_params">';
280
  foreach( $group_info[ 'params' ] as $param_id => $param_name ){
281
+ echo '<li data-id="' . esc_attr( $param_id ) . '">' . esc_html( $param_name ) . '</li>';
282
  }
283
  echo '</ul></li>';
284
  }
285
 
286
+ echo '<li><span class="dashicons dashicons-list-view"></span>' . esc_html__( 'Custom parameter', 'shortcoder' ) . '<ul>';
287
  echo '<li class="sc_params_form">';
288
+ echo '<p>' . esc_html__( 'Insert parameters in content and replace them with custom values when using the shortcode.', 'shortcoder' ) . '<a href="https://www.aakashweb.com/docs/shortcoder/custom-parameters/" target="_blank" title="' . esc_attr__( 'More information', 'shortcoder' ) . '"><span class="dashicons dashicons-info"></span></a></p>';
289
+ echo '<h4>' . esc_html__( 'Enter custom parameter name', 'shortcoder' ) . '</h4>';
290
  echo '<input type="text" class="sc_cp_box widefat" pattern="[a-zA-Z0-9_-]+"/>';
291
+ echo '<h4>' . esc_html__( 'Default value', 'shortcoder' ) . '</h4>';
292
  echo '<input type="text" class="sc_cp_default widefat"/>';
293
+ echo '<button class="button sc_cp_btn">' . esc_html__( 'Insert parameter', 'shortcoder' ) . '</button>';
294
+ echo '<p class="sc_cp_info"><small>' . esc_html__( 'Only alphabets, numbers, underscores and hyphens are allowed. Custom parameters are case insensitive', 'shortcoder' ) . '</small></p></li>';
295
  echo '</ul></li>';
296
 
297
+ echo '<li><span class="dashicons dashicons-screenoptions"></span>' . esc_html__( 'Custom Fields', 'shortcoder' ) . '<ul>';
298
  echo '<li class="sc_params_form">';
299
+ echo '<p>' . esc_html__( 'Pull a custom field value of the current post and display it inside the shortcode content.', 'shortcoder' ) . '<a href="https://www.aakashweb.com/docs/shortcoder/shortcode-parameters/#custom-fields" target="_blank" title="' . esc_attr__( 'More information', 'shortcoder' ) . '"><span class="dashicons dashicons-info"></span></a></p>';
300
+ echo '<h4>' . esc_html__( 'Enter custom field name', 'shortcoder' ) . '</h4>';
301
  echo '<input type="text" class="sc_cf_box widefat" pattern="[a-zA-Z0-9_-]+"/>';
302
+ echo '<button class="button sc_cf_btn">' . esc_html__( 'Insert custom field', 'shortcoder' ) . '</button>';
303
+ echo '<p class="sc_cf_info"><small>' . esc_html__( 'Only alphabets, numbers, underscore and hyphens are allowed. Cannot be empty.', 'shortcoder' ) . '</small></p></li>';
304
  echo '</ul></li>';
305
 
306
  echo '</ul>';
319
  echo '<p>Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam.</p>';
320
 
321
  echo '<div class="subscribe_form" data-action="https://aakashweb.us19.list-manage.com/subscribe/post-json?u=b7023581458d048107298247e&id=ef5ab3c5c4&c=">
322
+ <input type="text" value="' . esc_attr( get_option( 'admin_email' ) ) . '" class="subscribe_email_box" placeholder="Your email address">
323
  <p class="subscribe_confirm">Thanks for subscribing !</p>
324
  <button class="button subscribe_btn"><span class="dashicons dashicons-email"></span> Subscribe</button>
325
  </div>';
337
  echo '<div class="feedback">';
338
  echo '<div class="promo_slides">';
339
  echo '<div class="promo_slide">';
340
+ echo '<a class="side_banner" href="https://www.aakashweb.com/wordpress-plugins/super-rss-reader/?utm_source=wp-socializer&utm_medium=sidebar&utm_campaign=srr-pro" target="_blank"><img src="' . esc_url( SC_ADMIN_URL ) . 'images/super-rss-reader.png" /></a>';
341
  echo '</div>';
342
 
343
  echo '<div class="promo_slide">';
344
+ echo '<a class="side_banner" href="https://www.aakashweb.com/wordpress-plugins/ultimate-floating-widgets/?utm_source=wp-socializer&utm_medium=sidebar&utm_campaign=ufw-pro" target="_blank"><img src="' . esc_url( SC_ADMIN_URL ) . 'images/ultimate-floating-widgets.png" /></a>';
345
  echo '</div>';
346
 
347
  echo '<div class="promo_slide">';
348
+ echo '<a class="side_banner" href="https://www.aakashweb.com/wordpress-plugins/announcer/?utm_source=wp-socializer&utm_medium=sidebar&utm_campaign=announcer-pro" target="_blank"><img src="' . esc_url( SC_ADMIN_URL ) . 'images/announcer.png" /></a>';
349
  echo '</div>';
350
  echo '</div>';
351
 
admin/form.php CHANGED
@@ -6,7 +6,7 @@ class SC_Admin_Form{
6
 
7
  public static function table( $rows = array(), $print = false, $class = '' ){
8
 
9
- $html = '<table class="form-table ' . $class . '">';
10
 
11
  foreach( $rows as $row ){
12
  $html .= '<tr ' . ( isset( $row[2] ) ? $row[2] : '' ) . '>';
@@ -35,7 +35,7 @@ class SC_Admin_Form{
35
  'class' => '',
36
  'value' => '',
37
  'list' => array(),
38
- 'type' => '',
39
  'required' => '',
40
  'placeholder' => '',
41
  'rows' => '',
@@ -52,6 +52,7 @@ class SC_Admin_Form{
52
  }
53
 
54
  $params = Shortcoder::set_defaults( $params, $default_props );
 
55
  $field_html = '';
56
 
57
  extract( $params, EXTR_SKIP );
@@ -60,19 +61,19 @@ class SC_Admin_Form{
60
 
61
  switch( $field_type ){
62
  case 'text':
63
- $field_html = "<input type='text' class='$class' $id_attr name='$name' value='$value' placeholder='$placeholder' " . ( $required ? "required='$required'" : "" ) . " $custom />";
64
  break;
65
 
66
  case 'select':
67
  $field_html .= "<select name='$name' class='$class' $id_attr $custom>";
68
  foreach( $list as $k => $v ){
69
- $field_html .= "<option value='$k' " . selected( $value, $k, false ) . ">$v</option>";
70
  }
71
  $field_html .= "</select>";
72
  break;
73
 
74
  case 'textarea':
75
- $field_html .= "<textarea $id_attr name='$name' class='$class' placeholder='$placeholder' rows='$rows' cols='$cols' $custom>" . esc_textarea( $value ) . "</textarea>";
76
  break;
77
 
78
  case 'checkbox':
@@ -98,6 +99,24 @@ class SC_Admin_Form{
98
 
99
  }
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
 
103
  ?>
6
 
7
  public static function table( $rows = array(), $print = false, $class = '' ){
8
 
9
+ $html = '<table class="form-table ' . esc_attr( $class ) . '">';
10
 
11
  foreach( $rows as $row ){
12
  $html .= '<tr ' . ( isset( $row[2] ) ? $row[2] : '' ) . '>';
35
  'class' => '',
36
  'value' => '',
37
  'list' => array(),
38
+ 'type' => 'text',
39
  'required' => '',
40
  'placeholder' => '',
41
  'rows' => '',
52
  }
53
 
54
  $params = Shortcoder::set_defaults( $params, $default_props );
55
+ $params = self::clean_attr( $params );
56
  $field_html = '';
57
 
58
  extract( $params, EXTR_SKIP );
61
 
62
  switch( $field_type ){
63
  case 'text':
64
+ $field_html = "<input type='$type' class='$class' $id_attr name='$name' value='$value' placeholder='$placeholder' " . ( $required ? "required='$required'" : "" ) . " $custom />";
65
  break;
66
 
67
  case 'select':
68
  $field_html .= "<select name='$name' class='$class' $id_attr $custom>";
69
  foreach( $list as $k => $v ){
70
+ $field_html .= "<option value='$k'" . selected( $value, $k, false ) . ">$v</option>";
71
  }
72
  $field_html .= "</select>";
73
  break;
74
 
75
  case 'textarea':
76
+ $field_html .= "<textarea $id_attr name='$name' class='$class' placeholder='$placeholder' rows='$rows' cols='$cols' $custom>$value</textarea>";
77
  break;
78
 
79
  case 'checkbox':
99
 
100
  }
101
 
102
+ public static function clean_attr( $a ){
103
+
104
+ foreach( $a as $k=>$v ){
105
+ if( is_array( $v ) ){
106
+ $a[ $k ] = self::clean_attr( $v );
107
+ }else{
108
+
109
+ if( in_array( $k, array( 'custom', 'tooltip', 'helper', 'before_text', 'after_text' ) ) ){
110
+ $a[ $k ] = wp_kses_post( $v );
111
+ }else{
112
+ $a[ $k ] = esc_attr( $v );
113
+ }
114
+ }
115
+ }
116
+
117
+ return $a;
118
+ }
119
+
120
  }
121
 
122
  ?>
admin/insert.php CHANGED
@@ -13,7 +13,7 @@
13
  <div class="sc_menu">
14
  <input type="search" class="sc_search" placeholder="Search ..." />
15
  <div class="top_btns">
16
- <a href="<?php echo admin_url( 'post-new.php?post_type=shortcoder' ); ?>" target="_blank" class="button">Create shortcode</a>
17
  <span class="promo_link">
18
  <?php
19
  $promo_links = array(
@@ -25,7 +25,7 @@
25
  $promo_link = $promo_links[$promo_link_id ];
26
  ?>
27
  <a class="button" href="https://www.aakashweb.com/wordpress-plugins/<?php echo $promo_link[0]; ?>" target="_blank"><i>Check out: </i> <?php echo $promo_link[1]; ?></a>
28
- <span><img src="<?php echo SC_ADMIN_URL . '/images/' . $promo_link[2]; ?>" /></span>
29
  </span>
30
  </div>
31
  </div>
@@ -36,7 +36,7 @@
36
  $shortcodes = Shortcoder::get_shortcodes();
37
 
38
  if( empty( $shortcodes ) ){
39
- echo '<p class="sc_note">No shortcodes are created, go ahead create one in <a href="' . admin_url( 'post-new.php?post_type=' . SC_POST_TYPE ) . '" target="_blank">shortcoder admin page</a>.</p>';
40
  }else{
41
 
42
  foreach( $shortcodes as $name => $options ){
@@ -69,21 +69,21 @@ if( empty( $shortcodes ) ){
69
  echo '<div class="sc_wrap" data-name="' . esc_attr( $name ) . '" data-id="' . esc_attr( $id ) . '" data-enclosed="' . $enclosed_sc . '">';
70
  echo '<div class="sc_head">';
71
  echo '<img src="' . SC_ADMIN_URL . '/images/arrow.svg" width="16" />';
72
- echo '<h3>' . $settings[ '_sc_title' ] . '</h3>';
73
  echo '<p>' . esc_html( $settings[ '_sc_description' ] ) . '</p>';
74
  echo '<div class="sc_tools">';
75
  if( current_user_can( 'edit_post', $id ) ){
76
- echo '<a href="' . admin_url( 'post.php?action=edit&post=' . $id ) . '" class="button" target="_blank">' . __( 'View', 'shortcoder' ) . '</a>';
77
  }
78
- echo '<button class="button sc_copy">' . __( 'Copy', 'shortcoder' ) . '</button>';
79
- echo '<button class="button sc_insert">' . __( 'Insert', 'shortcoder' ) . '</button>';
80
  echo '</div>';
81
  echo '</div>';
82
 
83
  echo '<div class="sc_options">';
84
 
85
  if( !empty( $params ) ){
86
- echo '<h4>' . __( 'Available parameters', 'shortcoder' ) . ': </h4>';
87
  echo '<div class="sc_params_wrap">';
88
  $temp = array();
89
 
@@ -91,20 +91,20 @@ if( empty( $shortcodes ) ){
91
  $cleaned = str_replace( '%', '', $v );
92
  if( !in_array( $cleaned, $temp ) ){
93
  array_push( $temp, $cleaned );
94
- echo '<label>' . $cleaned . ': <input type="text" class="sc_param" data-param="' . $cleaned . '"/></label> ';
95
  }
96
  }
97
 
98
  echo '</div>';
99
 
100
  }else{
101
- echo '<p>' . __( 'No parameters present in this shortcode', 'shortcoder' ) . '</p>';
102
  }
103
 
104
  echo '<div class="sc_foot">';
105
- echo '<button class="sc_insert button button-primary">' . __( 'Insert shortcode', 'shortcoder' ) . '</button>';
106
  if( $enclosed_sc == 'true' ){
107
- echo '<span>' . __( 'Has enclosed content parameter', 'shortcoder' ) . '</span>';
108
  }
109
  echo '</div>';
110
 
@@ -112,7 +112,7 @@ if( empty( $shortcodes ) ){
112
  echo '</div>';
113
  }
114
 
115
- echo '<p class="sc_note sc_search_none">' . __( 'No shortcodes match search term !', 'shortcoder' ) . '</p>';
116
 
117
  }
118
 
13
  <div class="sc_menu">
14
  <input type="search" class="sc_search" placeholder="Search ..." />
15
  <div class="top_btns">
16
+ <a href="<?php echo esc_url( admin_url( 'post-new.php?post_type=shortcoder' ) ); ?>" target="_blank" class="button">Create shortcode</a>
17
  <span class="promo_link">
18
  <?php
19
  $promo_links = array(
25
  $promo_link = $promo_links[$promo_link_id ];
26
  ?>
27
  <a class="button" href="https://www.aakashweb.com/wordpress-plugins/<?php echo $promo_link[0]; ?>" target="_blank"><i>Check out: </i> <?php echo $promo_link[1]; ?></a>
28
+ <span><img src="<?php echo esc_url( SC_ADMIN_URL . '/images/' . $promo_link[2] ); ?>" /></span>
29
  </span>
30
  </div>
31
  </div>
36
  $shortcodes = Shortcoder::get_shortcodes();
37
 
38
  if( empty( $shortcodes ) ){
39
+ echo '<p class="sc_note">No shortcodes are created, go ahead create one in <a href="' . esc_url( admin_url( 'post-new.php?post_type=' . SC_POST_TYPE ) ) . '" target="_blank">shortcoder admin page</a>.</p>';
40
  }else{
41
 
42
  foreach( $shortcodes as $name => $options ){
69
  echo '<div class="sc_wrap" data-name="' . esc_attr( $name ) . '" data-id="' . esc_attr( $id ) . '" data-enclosed="' . $enclosed_sc . '">';
70
  echo '<div class="sc_head">';
71
  echo '<img src="' . SC_ADMIN_URL . '/images/arrow.svg" width="16" />';
72
+ echo '<h3>' . esc_html( $settings[ '_sc_title' ] ) . '</h3>';
73
  echo '<p>' . esc_html( $settings[ '_sc_description' ] ) . '</p>';
74
  echo '<div class="sc_tools">';
75
  if( current_user_can( 'edit_post', $id ) ){
76
+ echo '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $id ) ) . '" class="button" target="_blank">' . esc_html__( 'View', 'shortcoder' ) . '</a>';
77
  }
78
+ echo '<button class="button sc_copy">' . esc_html__( 'Copy', 'shortcoder' ) . '</button>';
79
+ echo '<button class="button sc_insert">' . esc_html__( 'Insert', 'shortcoder' ) . '</button>';
80
  echo '</div>';
81
  echo '</div>';
82
 
83
  echo '<div class="sc_options">';
84
 
85
  if( !empty( $params ) ){
86
+ echo '<h4>' . esc_html__( 'Available parameters', 'shortcoder' ) . ': </h4>';
87
  echo '<div class="sc_params_wrap">';
88
  $temp = array();
89
 
91
  $cleaned = str_replace( '%', '', $v );
92
  if( !in_array( $cleaned, $temp ) ){
93
  array_push( $temp, $cleaned );
94
+ echo '<label>' . esc_html( $cleaned ) . ': <input type="text" class="sc_param" data-param="' . esc_attr( $cleaned ) . '"/></label> ';
95
  }
96
  }
97
 
98
  echo '</div>';
99
 
100
  }else{
101
+ echo '<p>' . esc_html__( 'No parameters present in this shortcode', 'shortcoder' ) . '</p>';
102
  }
103
 
104
  echo '<div class="sc_foot">';
105
+ echo '<button class="sc_insert button button-primary">' . esc_html__( 'Insert shortcode', 'shortcoder' ) . '</button>';
106
  if( $enclosed_sc == 'true' ){
107
+ echo '<span>' . esc_html__( 'Has enclosed content parameter', 'shortcoder' ) . '</span>';
108
  }
109
  echo '</div>';
110
 
112
  echo '</div>';
113
  }
114
 
115
+ echo '<p class="sc_note sc_search_none">' . esc_html__( 'No shortcodes match search term !', 'shortcoder' ) . '</p>';
116
 
117
  }
118
 
admin/js/script.js CHANGED
@@ -25,7 +25,7 @@ $(document).ready(function(){
25
  add_top_import_export_btn();
26
  }
27
 
28
- add_top_coffee_btn();
29
  }
30
 
31
  $('.sc_params_list').appendTo('body');
@@ -130,9 +130,9 @@ $(document).ready(function(){
130
  $('.sc_params_list').hide();
131
  }
132
 
133
- var add_top_coffee_btn = function(){
134
 
135
- $('#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>');
136
 
137
  }
138
 
25
  add_top_import_export_btn();
26
  }
27
 
28
+ add_top_pro_btn();
29
  }
30
 
31
  $('.sc_params_list').appendTo('body');
130
  $('.sc_params_list').hide();
131
  }
132
 
133
+ var add_top_pro_btn = function(){
134
 
135
+ $('#screen-meta-links').prepend('<div class="screen-meta-toggle pro_top_link"><a class="show-settings button" href="https://www.aakashweb.com/wordpress-plugins/shortcoder/?utm_source=admin&utm_medium=top&utm_campaign=sc-pro#pro" target="_blank">Upgrade to PRO <span class="dashicons dashicons-plus"></span></a></div>');
136
 
137
  }
138
 
admin/manage.php CHANGED
@@ -35,7 +35,7 @@ class SC_Admin_Manage{
35
 
36
  if( $column == 'shortcode' ){
37
  $sc_tag = Shortcoder::get_sc_tag( $post_id );
38
- echo '<span class="sc_copy_list_wrap"><input type="text" class="widefat sc_copy_text" readonly value="' . esc_attr( $sc_tag ) . '" /><a href="#" class="sc_copy_list" title="' . __( 'Copy', 'shortcoder' ) . '"><span class="dashicons dashicons-clipboard"></span></a></span>';
39
  }
40
 
41
  if( $column == 'desc' ){
35
 
36
  if( $column == 'shortcode' ){
37
  $sc_tag = Shortcoder::get_sc_tag( $post_id );
38
+ echo '<span class="sc_copy_list_wrap"><input type="text" class="widefat sc_copy_text" readonly value="' . esc_attr( $sc_tag ) . '" /><a href="#" class="sc_copy_list" title="' . esc_attr__( 'Copy', 'shortcoder' ) . '"><span class="dashicons dashicons-clipboard"></span></a></span>';
39
  }
40
 
41
  if( $column == 'desc' ){
admin/settings.php CHANGED
@@ -72,7 +72,7 @@ class SC_Admin_Settings{
72
  echo SC_Admin_Form::table($fields);
73
 
74
  wp_nonce_field( 'sc_settings_nonce' );
75
- echo '<p><button type="submit" class="button button-primary">Save settings</button></p>';
76
  echo '</form>';
77
 
78
  echo '</div>';
@@ -92,7 +92,13 @@ class SC_Admin_Settings{
92
 
93
  foreach( $defaults as $field => $default ){
94
  $form_field = 'sc_' . $field;
95
- $values[ $field ] = isset( $p[ $form_field ] ) ? ( $p[ $form_field ] ) : $default;
 
 
 
 
 
 
96
  }
97
 
98
  update_option( 'sc_settings', $values );
@@ -105,7 +111,7 @@ class SC_Admin_Settings{
105
  public static function print_notice( $msg = '', $type = 'success' ){
106
 
107
  if( $msg != '' ){
108
- echo '<div class="notice notice-' . $type . ' is-dismissible"><p>' . $msg . '</p></div>';
109
  }
110
 
111
  }
72
  echo SC_Admin_Form::table($fields);
73
 
74
  wp_nonce_field( 'sc_settings_nonce' );
75
+ echo '<p><button type="submit" class="button button-primary">' . esc_html__( 'Save settings', 'shortcoder' ) . '</button></p>';
76
  echo '</form>';
77
 
78
  echo '</div>';
92
 
93
  foreach( $defaults as $field => $default ){
94
  $form_field = 'sc_' . $field;
95
+ $value = isset( $p[ $form_field ] ) ? $p[ $form_field ] : $default;
96
+
97
+ if( in_array( $field, array( 'default_content' ) ) ){
98
+ $values[ $field ] = current_user_can( 'unfiltered_html' ) ? $value : wp_kses_post( $value );
99
+ }else{
100
+ $values[ $field ] = sanitize_text_field( $value );
101
+ }
102
  }
103
 
104
  update_option( 'sc_settings', $values );
111
  public static function print_notice( $msg = '', $type = 'success' ){
112
 
113
  if( $msg != '' ){
114
+ echo '<div class="notice notice-' . esc_attr( $type ) . ' is-dismissible"><p>' . wp_kses_post( $msg ) . '</p></div>';
115
  }
116
 
117
  }
admin/tools.php CHANGED
@@ -42,7 +42,7 @@ class SC_Admin_Tools{
42
  if( self::is_sc_edit_page() )
43
  return $plugins;
44
 
45
- $plugins[ 'shortcoder' ] = SC_ADMIN_URL . '/js/tinymce/editor_plugin.js';
46
  return $plugins;
47
 
48
  }
42
  if( self::is_sc_edit_page() )
43
  return $plugins;
44
 
45
+ $plugins[ 'shortcoder' ] = SC_ADMIN_URL . '/js/tinymce/editor_plugin.js';
46
  return $plugins;
47
 
48
  }
includes/metadata.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Gives the page details for the services
4
  *
5
  */
6
 
@@ -174,7 +174,7 @@ class Shortcoder_Metadata{
174
  'short_url' => wp_get_shortlink( $id ),
175
 
176
  'post_id' => $id,
177
- 'post_excerpt' => self::excerpt( 100 ),
178
  'post_comments_count' => get_comments_number( $id ),
179
  'post_image' => self::post_image( $id ),
180
  'post_author' => get_the_author(),
@@ -193,7 +193,7 @@ class Shortcoder_Metadata{
193
 
194
  }
195
 
196
- public static function excerpt( $length = 250 ){
197
 
198
  global $post;
199
 
@@ -201,10 +201,7 @@ class Shortcoder_Metadata{
201
  return '';
202
  }
203
 
204
- $excerpt = $post->post_excerpt; // using $post->post_excerpt instead of get_the_excerpt as the_content filter loses shortcode formatting
205
-
206
- $excerpt_text = ( empty( $excerpt ) ) ? strip_tags( strip_shortcodes( $post->post_content ) ) : $excerpt;
207
- return substr( $excerpt_text, 0, $length );
208
 
209
  }
210
 
1
  <?php
2
  /**
3
+ * Gives the page details for WordPress parameters
4
  *
5
  */
6
 
174
  'short_url' => wp_get_shortlink( $id ),
175
 
176
  'post_id' => $id,
177
+ 'post_excerpt' => self::excerpt(),
178
  'post_comments_count' => get_comments_number( $id ),
179
  'post_image' => self::post_image( $id ),
180
  'post_author' => get_the_author(),
193
 
194
  }
195
 
196
+ public static function excerpt(){
197
 
198
  global $post;
199
 
201
  return '';
202
  }
203
 
204
+ return $post->post_excerpt;
 
 
 
205
 
206
  }
207
 
readme.txt CHANGED
@@ -2,21 +2,21 @@
2
  Contributors: vaakash
3
  Author URI: https://www.aakashweb.com/
4
  Plugin URI: https://www.aakashweb.com/wordpress-plugins/shortcoder/
5
- Tags: shortcode, html, javascript, shortcodes, snippets, posts, pages, widgets, insert, adsense, ads, code
6
  Donate link: https://www.paypal.me/vaakash/
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
  Requires at least: 4.9.0
10
- Tested up to: 6.0
11
- Stable tag: 5.8
12
 
13
- Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
14
 
15
 
16
 
17
  ## Description
18
 
19
- 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.
20
 
21
  ### ✍ Create shortcodes easily
22
  1. Give a name for the shortcode
@@ -49,18 +49,30 @@ 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
- ### Using in block editor
53
 
54
  Though shortcodes can be used in **any** place manually, Shortcoder provides below options to select and insert the shortcodes created easily when working with the block editor.
55
 
56
  * Shortcoder block
57
  * Toolbar button to select and insert shortcodes inline (under "more")
58
 
 
 
 
 
 
 
 
 
 
 
 
59
  ### Links
60
 
61
  * [Documentation](https://www.aakashweb.com/docs/shortcoder/)
62
  * [FAQs](https://www.aakashweb.com/docs/shortcoder/faq/)
63
  * [Support forum/Report bugs](https://www.aakashweb.com/forum/)
 
64
 
65
 
66
 
@@ -76,15 +88,15 @@ Though shortcodes can be used in **any** place manually, Shortcoder provides bel
76
 
77
  Please visit the [plugin documentation page](https://www.aakashweb.com/docs/shortcoder/) for complete list of FAQs.
78
 
79
- ### What are the allowed characters for shortcode name ?
80
 
81
  Allowed characters are alphabets, numbers, hyphens and underscores.
82
 
83
- ### My shortcode is not working in my page builder !
84
 
85
  Please check with your page builder plugin to confirm if the block/place/area where the shortcode is being used can execute shortcodes. If yes, then shortcode should work fine just like regular WordPress shortcodes.
86
 
87
- ### My shortcode is not working !
88
 
89
  Please check the following if you notice that the shortcode content is not printed or when the output is not as expected.
90
 
@@ -92,10 +104,14 @@ Please check the following if you notice that the shortcode content is not print
92
  * If shortcode is printed but the output is not as expected, please try the shortcode content in an isolated environment and confirm if the shortcode content is working correctly as expected. Sometimes it might be external factors like theme, other plugin might conflict with the shortcode content being used.
93
  * There is a known limitation in shortcodes API when there is a combination of unclosed and closed shortcodes. Please refer [this document](https://codex.wordpress.org/Shortcode_API#Unclosed_Shortcodes) for more information.
94
 
95
- ### Can I insert PHP code in shortcode content ?
96
 
97
  No, right now the plugin supports only HTML, Javascript and CSS as shortcode content.
98
 
 
 
 
 
99
 
100
 
101
  ## Screenshots
@@ -114,6 +130,13 @@ No, right now the plugin supports only HTML, Javascript and CSS as shortcode con
114
 
115
  ## Changelog
116
 
 
 
 
 
 
 
 
117
  ### 5.8
118
  * New: Option to set description for the shortcode.
119
  * New: New actions and filters introduced.
2
  Contributors: vaakash
3
  Author URI: https://www.aakashweb.com/
4
  Plugin URI: https://www.aakashweb.com/wordpress-plugins/shortcoder/
5
+ Tags: shortcode, html, javascript, shortcodes, snippets, posts, pages, widgets, insert, adsense, ads, code, elementor, WPBakery
6
  Donate link: https://www.paypal.me/vaakash/
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
  Requires at least: 4.9.0
10
+ Tested up to: 6.0.1
11
+ Stable tag: 6.0
12
 
13
+ Create custom "Shortcodes" easily for HTML, JavaScript, CSS code snippets and use the shortcodes within posts, pages & widgets
14
 
15
 
16
 
17
  ## Description
18
 
19
+ Shortcoder plugin allows to create a custom shortcodes for HTML, JavaScript, CSS and other code snippets. Now the shortcodes can be used in posts/pages and the snippet will be replaced in place.
20
 
21
  ### ✍ Create shortcodes easily
22
  1. Give a name for the shortcode
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
+ ### 🧱 Using in block editor
53
 
54
  Though shortcodes can be used in **any** place manually, Shortcoder provides below options to select and insert the shortcodes created easily when working with the block editor.
55
 
56
  * Shortcoder block
57
  * Toolbar button to select and insert shortcodes inline (under "more")
58
 
59
+ ### 💎 Upgrade to PRO
60
+
61
+ Shortcoder also provides a [PRO version](https://www.aakashweb.com/wordpress-plugins/shortcoder/) which has additional features to further enhance the experience. Below features are offered in the PRO version.
62
+
63
+ * **Custom editor** - Edit Shortcode content using block editor or page builder plugins like Elementor and WPBakery.
64
+ * **Revisions** - Revisions support for Shortcode content.
65
+ * **Locate shortcode** - Search posts and pages where a shortcode is used.
66
+ * **Extra code** - Include extra code to the footer when a shortcode is used in a page.
67
+
68
+ [Get started with Shortcoder - PRO](https://www.aakashweb.com/wordpress-plugins/shortcoder/)
69
+
70
  ### Links
71
 
72
  * [Documentation](https://www.aakashweb.com/docs/shortcoder/)
73
  * [FAQs](https://www.aakashweb.com/docs/shortcoder/faq/)
74
  * [Support forum/Report bugs](https://www.aakashweb.com/forum/)
75
+ * [PRO features](https://www.aakashweb.com/wordpress-plugins/shortcoder/#pro)
76
 
77
 
78
 
88
 
89
  Please visit the [plugin documentation page](https://www.aakashweb.com/docs/shortcoder/) for complete list of FAQs.
90
 
91
+ ### What are the allowed characters for shortcode name?
92
 
93
  Allowed characters are alphabets, numbers, hyphens and underscores.
94
 
95
+ ### My shortcode is not working in my page builder!
96
 
97
  Please check with your page builder plugin to confirm if the block/place/area where the shortcode is being used can execute shortcodes. If yes, then shortcode should work fine just like regular WordPress shortcodes.
98
 
99
+ ### My shortcode is not working!
100
 
101
  Please check the following if you notice that the shortcode content is not printed or when the output is not as expected.
102
 
104
  * If shortcode is printed but the output is not as expected, please try the shortcode content in an isolated environment and confirm if the shortcode content is working correctly as expected. Sometimes it might be external factors like theme, other plugin might conflict with the shortcode content being used.
105
  * There is a known limitation in shortcodes API when there is a combination of unclosed and closed shortcodes. Please refer [this document](https://codex.wordpress.org/Shortcode_API#Unclosed_Shortcodes) for more information.
106
 
107
+ ### Can I insert PHP code in shortcode content?
108
 
109
  No, right now the plugin supports only HTML, Javascript and CSS as shortcode content.
110
 
111
+ ### Can I use block editor or page builders like Elementor, WPBakery to create shortcode?
112
+
113
+ Yes, this feature is available in the PRO version. You can upgrade to the [PRO version](https://www.aakashweb.com/wordpress-plugins/shortcoder/) to design using custom editor and create shortcode for that.
114
+
115
 
116
 
117
  ## Screenshots
130
 
131
  ## Changelog
132
 
133
+ ### 6.0
134
+ * New: PRO version is introduced.
135
+ * New: Prevent same shortcode nested loop.
136
+ * New: New actions and filters introduced.
137
+ * Fix: Post excerpt shortcode parameter now prints full post excerpt.
138
+ * Fix: Enhancements to input and output data sanitization.
139
+
140
  ### 5.8
141
  * New: Option to set description for the shortcode.
142
  * New: New actions and filters introduced.
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.8
8
  Author URI: https://www.aakashweb.com/
9
  Text Domain: shortcoder
10
  Domain Path: /languages
11
  */
12
 
13
- define( 'SC_VERSION', '5.8' );
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' ) );
@@ -23,13 +23,13 @@ final class Shortcoder{
23
 
24
  static public $shortcodes = array();
25
 
 
 
26
  public static function init(){
27
 
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
  }
@@ -65,6 +65,12 @@ final class Shortcoder{
65
  return $shortcode;
66
  }
67
 
 
 
 
 
 
 
68
  $sc_content = $shortcode[ 'content' ];
69
  $sc_settings = $shortcode[ 'settings' ];
70
 
@@ -78,7 +84,9 @@ final class Shortcoder{
78
  }
79
 
80
  $sc_content = apply_filters( 'sc_mod_output', $sc_content, $atts, $sc_settings, $enclosed_content );
81
- do_action( 'sc_do_after', $sc_content, $atts, $sc_settings );
 
 
82
 
83
  return $sc_content;
84
 
@@ -100,6 +108,7 @@ final class Shortcoder{
100
  foreach( $shortcode_posts as $index => $post ){
101
  $shortcodes[ $post->post_name ] = array(
102
  'id' => $post->ID,
 
103
  'content' => $post->post_content,
104
  'settings' => self::get_sc_settings( $post->ID )
105
  );
@@ -113,22 +122,22 @@ final class Shortcoder{
113
 
114
  public static function default_sc_settings(){
115
 
116
- return array(
117
  '_sc_description' => '',
118
  '_sc_disable_sc' => 'no',
119
  '_sc_disable_admin' => 'no',
120
  '_sc_editor' => '',
121
  '_sc_allowed_devices' => 'all'
122
- );
123
 
124
  }
125
 
126
  public static function default_settings(){
127
 
128
- return array(
129
  'default_editor' => 'code',
130
  'default_content' => ''
131
- );
132
 
133
  }
134
 
@@ -405,12 +414,6 @@ final class Shortcoder{
405
  return $result;
406
  }
407
 
408
- public static function load_text_domain(){
409
-
410
- load_plugin_textdomain( 'shortcoder', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
411
-
412
- }
413
-
414
  }
415
 
416
  Shortcoder::init();
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: 6.0
8
  Author URI: https://www.aakashweb.com/
9
  Text Domain: shortcoder
10
  Domain Path: /languages
11
  */
12
 
13
+ define( 'SC_VERSION', '6.0' );
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' ) );
23
 
24
  static public $shortcodes = array();
25
 
26
+ static public $current_shortcode = false;
27
+
28
  public static function init(){
29
 
30
  // Include the required
31
  self::includes();
32
 
 
 
33
  add_shortcode( 'sc', array( __CLASS__, 'execute_shortcode' ) );
34
 
35
  }
65
  return $shortcode;
66
  }
67
 
68
+ // Prevent same shortcode nested loop
69
+ if( self::$current_shortcode == $shortcode[ 'name' ] ){
70
+ return '';
71
+ }
72
+ self::$current_shortcode = $shortcode[ 'name' ];
73
+
74
  $sc_content = $shortcode[ 'content' ];
75
  $sc_settings = $shortcode[ 'settings' ];
76
 
84
  }
85
 
86
  $sc_content = apply_filters( 'sc_mod_output', $sc_content, $atts, $sc_settings, $enclosed_content );
87
+ do_action( 'sc_do_after', $shortcode, $atts );
88
+
89
+ self::$current_shortcode = false;
90
 
91
  return $sc_content;
92
 
108
  foreach( $shortcode_posts as $index => $post ){
109
  $shortcodes[ $post->post_name ] = array(
110
  'id' => $post->ID,
111
+ 'name' => $post->post_name,
112
  'content' => $post->post_content,
113
  'settings' => self::get_sc_settings( $post->ID )
114
  );
122
 
123
  public static function default_sc_settings(){
124
 
125
+ return apply_filters( 'sc_mod_sc_settings', array(
126
  '_sc_description' => '',
127
  '_sc_disable_sc' => 'no',
128
  '_sc_disable_admin' => 'no',
129
  '_sc_editor' => '',
130
  '_sc_allowed_devices' => 'all'
131
+ ));
132
 
133
  }
134
 
135
  public static function default_settings(){
136
 
137
+ return apply_filters( 'sc_mod_settings', array(
138
  'default_editor' => 'code',
139
  'default_content' => ''
140
+ ));
141
 
142
  }
143
 
414
  return $result;
415
  }
416
 
 
 
 
 
 
 
417
  }
418
 
419
  Shortcoder::init();