Shortcoder - Version 5.5

Version Description

Download this release

Release Info

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

Code changes from version 5.4 to 5.5

admin/admin.php CHANGED
@@ -131,6 +131,22 @@ class SC_Admin{
131
 
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  public static function inline_js_variables(){
135
 
136
  return array(
@@ -146,7 +162,7 @@ class SC_Admin{
146
 
147
  wp_enqueue_style( 'sc-icon-css', SC_ADMIN_URL . 'css/menu-icon.css', array(), SC_VERSION );
148
 
149
- if( !self::is_sc_admin_page() ){
150
  return false;
151
  }
152
 
@@ -259,6 +275,12 @@ class SC_Admin{
259
  return $_GET;
260
  }
261
 
 
 
 
 
 
 
262
  }
263
 
264
  SC_Admin::init();
131
 
132
  }
133
 
134
+ public static function is_edit_page( $new_edit = null ){
135
+
136
+ global $pagenow;
137
+
138
+ if (!is_admin()) return false;
139
+
140
+ if( $new_edit == 'edit' ){
141
+ return in_array( $pagenow, array( 'post.php' ) );
142
+ }elseif( $new_edit == 'new' ){
143
+ return in_array( $pagenow, array( 'post-new.php' ) );
144
+ }else{
145
+ return in_array( $pagenow, array( 'post.php', 'post-new.php' ) );
146
+ }
147
+
148
+ }
149
+
150
  public static function inline_js_variables(){
151
 
152
  return array(
162
 
163
  wp_enqueue_style( 'sc-icon-css', SC_ADMIN_URL . 'css/menu-icon.css', array(), SC_VERSION );
164
 
165
+ if( !self::is_sc_admin_page() || $hook == 'shortcoder_page_settings' ){
166
  return false;
167
  }
168
 
275
  return $_GET;
276
  }
277
 
278
+ public static function clean_post(){
279
+
280
+ return stripslashes_deep( $_POST );
281
+
282
+ }
283
+
284
  }
285
 
286
  SC_Admin::init();
admin/css/style-insert.css CHANGED
@@ -168,71 +168,33 @@ p .button {
168
  display: none;
169
  }
170
 
171
- /** Coffee **/
172
- .cfe_box{
173
- background: #fff;
174
- padding: 15px;
175
- box-shadow: 0 1px 3px 0px rgba(0, 0, 0, 0.2);
176
- margin-top: 25px;
177
- display: flex;
178
- border-top: 3px solid #795548;
179
- }
180
- .cfe_text{
181
- display: flex;
182
- width: 100%;
183
- }
184
- .cfe_text img{
185
- width: 64px;
186
- margin-right: 15px;
187
- }
188
- .cfe_text h2{
189
- font-weight: normal;
190
- font-size: 21px;
191
- margin: 10px 0 15px 0;
192
- }
193
- .cfe_form{
194
- display: flex;
195
- width: 250px;
196
- height: 32px;
197
- margin-top: 18px;
198
- }
199
- .cfe_amt{
200
- font-size: 18px;
201
- padding: 5px;
202
- margin-right: 10px;
203
- border-radius: 3px;
204
  }
205
- .cfe_btn{
206
- text-align: center;
207
  }
208
-
209
- .ufw{
210
- text-decoration: none;
211
- float: right;
212
- color: #000;
213
  position: relative;
214
  }
215
- .ufw:hover{
216
- text-decoration: underline;;
217
- }
218
- .ufw i{
219
  opacity: 0.5;
220
  }
221
- .ufw span{
222
  display: none;
223
  position: absolute;
224
  right: 0;
225
- top: 150%;
226
- text-align: right;
227
- background: #333;
228
- color: #fff;
229
- padding: 5px 10px;
230
- border-radius: 5px;
231
- box-shadow: 0 2px 5px -2px rgba(0, 0, 0, 0.5);
232
  }
233
- .ufw:hover span{
234
  display: block;
235
  }
 
 
 
 
 
236
 
237
  /** Footer **/
238
  .footer_thanks {
168
  display: none;
169
  }
170
 
171
+ .top_btns{
172
+ float: right;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  }
174
+ .top_btns .button{
175
+ margin-left: 10px;
176
  }
177
+ .promo_link{
 
 
 
 
178
  position: relative;
179
  }
180
+ .promo_link i{
 
 
 
181
  opacity: 0.5;
182
  }
183
+ .promo_link span{
184
  display: none;
185
  position: absolute;
186
  right: 0;
187
+ top: 35px;
188
+ z-index: 9999;
 
 
 
 
 
189
  }
190
+ .promo_link:hover span{
191
  display: block;
192
  }
193
+ .promo_link span img{
194
+ width: 300px;
195
+ box-shadow: 0 2px 5px -2px rgb(0 0 0 / 50%);
196
+ border-radius: 10px;
197
+ }
198
 
199
  /** Footer **/
200
  .footer_thanks {
admin/css/style-settings.css ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ #main{
2
+ max-width: 900px;
3
+ }
4
+ .lbl_margin{
5
+ display: block;
6
+ margin: 0 0 1em 0;
7
+ }
admin/css/style.css CHANGED
@@ -198,36 +198,6 @@
198
  font-weight: bold;
199
  }
200
 
201
- /* Coffee - metabox */
202
-
203
- .cfe_bottom{
204
- background: #fff;
205
- padding: 15px;
206
- display: flex;
207
- border: 1px solid #e3bbac;
208
- align-items: center;
209
- box-shadow: 0 1px 1px rgba(0,0,0,.04);
210
- }
211
- .cfe_bottom > * {
212
- margin: 0 15px 0 0;
213
- vertical-align: middle;
214
- }
215
- .cfe_bottom h3{
216
- font-size: 15px;
217
- }
218
- .cfe_bottom img{
219
- height: 32px;
220
- }
221
- .cfe_form{
222
- display: flex;
223
- }
224
- .cfe_form select{
225
- width: 100%;
226
- margin-right: 1em;
227
- }
228
- .cfe_form .button{
229
- text-align: center;
230
- }
231
 
232
  /** Changelog **/
233
  .sc_changelog{
@@ -322,60 +292,52 @@
322
  .feedback a:hover{
323
  text-decoration: underline;
324
  }
325
- .feedback .ufw{
326
- background: linear-gradient(180deg, #2196F3, #58a4e1);
327
- color: #fff;
328
- border-radius: 5px;
329
- padding: 10px;
330
- margin: 15px 0 0 0;
331
  }
332
- .feedback .ufw a{
333
- color: #fff;
334
  }
335
- .feedback .ufw p{
336
- opacity: 0.8;
337
- display: block;
338
- font-style: italic;
339
- margin: 5px 0 0 0;
340
  }
341
- .feedback .ufw h4{
342
- margin: 0 0 10px 0;
343
- font-size: 1.3em;
344
  }
345
- .feedback .ufw h4 i{
346
- font-weight: normal;
347
  }
348
- .feedback .ufw .balloon{
349
- float: right;
 
 
350
  }
351
-
352
- /** Rate & review **/
353
- .rate_review{
354
- display: block;
355
- padding: 15px;
356
- background: #f6f6f6;
357
- margin-top: 15px;
358
- border-radius: 5px;
359
- text-decoration: none;
360
- color: #444;
361
  }
362
- .rate_review h4 {
363
- margin: 0;
364
- font-size: 15px;
365
  }
366
- .rate_review p {
367
- margin: 15px 0 0 0;
368
  }
369
- .rate_review .dashicons {
370
- float: right;
371
- font-size: 32px;
372
- margin: 10px;
373
- color: #FFC107;
374
  }
375
- .rate_review:hover{
376
- background-color: #fcfcfc;
377
  text-decoration: none;
378
  }
 
 
 
 
 
379
 
380
  .stars {
381
  display: inline-flex;
198
  font-weight: bold;
199
  }
200
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  /** Changelog **/
203
  .sc_changelog{
292
  .feedback a:hover{
293
  text-decoration: underline;
294
  }
295
+ .feedback .button{
296
+ display: block;
297
+ text-align: center;
298
+ margin-bottom: 10px;
 
 
299
  }
300
+ .feedback .button:last-child{
301
+ margin-bottom: 0;
302
  }
303
+ .feedback .button .dashicons{
304
+ margin: 5px 5px 0 0;
 
 
 
305
  }
306
+ .feedback .button:hover{
307
+ text-decoration: none;
 
308
  }
309
+ .feedback > *:last-child{
310
+ margin-bottom: 0;
311
  }
312
+ .feedback .twitter_btn.button{
313
+ background: #1b95e0;
314
+ color: #fff;
315
+ border-color: transparent;
316
  }
317
+ .feedback .facebook_btn.button{
318
+ background: #4080ff;
319
+ color: #fff;
320
+ border-color: transparent;
 
 
 
 
 
 
321
  }
322
+ .promo_slides > .promo_slide{
323
+ display: none;
 
324
  }
325
+ .promo_slides > .promo_slide:first-child{
326
+ display: block;
327
  }
328
+ .promo_slide img {
329
+ width: 100%;
330
+ border-radius: 5px;
331
+ margin: 7px 0 0 0;
 
332
  }
333
+ .promo_btn{
 
334
  text-decoration: none;
335
  }
336
+ .promo_btns{
337
+ display: flex;
338
+ justify-content: space-between;
339
+ margin-bottom: 20px;
340
+ }
341
 
342
  .stars {
343
  display: inline-flex;
admin/edit.php CHANGED
@@ -50,7 +50,9 @@ class SC_Admin_Edit{
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
 
@@ -159,6 +161,11 @@ class SC_Admin_Edit{
159
 
160
  $g = SC_Admin::clean_get();
161
 
 
 
 
 
 
162
  $list = array(
163
  'text' => __( 'Text editor', 'shortcoder' ),
164
  'visual' => __( 'Visual editor', 'shortcoder' ),
@@ -193,6 +200,11 @@ class SC_Admin_Edit{
193
  echo '</div>';
194
  echo '</div>';
195
 
 
 
 
 
 
196
  if( $editor[ 'active' ] == 'code' ){
197
  echo '<div class="sc_cm_menu"></div>';
198
  $content = user_can_richedit() ? esc_textarea( $post->post_content ) : $post->post_content;
@@ -211,7 +223,7 @@ class SC_Admin_Edit{
211
 
212
  global $post;
213
 
214
- if( !SC_Admin::is_sc_admin_page() || $hook == 'edit.php' || $hook == 'edit-tags.php' || $hook == 'term.php' ){
215
  return false;
216
  }
217
 
@@ -283,44 +295,48 @@ class SC_Admin_Edit{
283
  echo '<p>Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam.</p>';
284
 
285
  echo '<div class="subscribe_form" data-action="https://aakashweb.us19.list-manage.com/subscribe/post-json?u=b7023581458d048107298247e&id=ef5ab3c5c4&c=">
286
- <input type="email" class="subscribe_email_box" placeholder="Your email address">
287
  <p class="subscribe_confirm">Thanks for subscribing !</p>
288
  <button class="button subscribe_btn"><span class="dashicons dashicons-email"></span> Subscribe</button>
289
  </div>';
290
 
291
- echo '<ul>
292
- <li><a href="https://www.facebook.com/aakashweb" target="_blank">Follow on Facebook <span class="dashicons dashicons-arrow-right-alt2"></span></a></li>
293
- <li><a href="https://twitter.com/aakashweb" target="_blank">Follow on Twitter <span class="dashicons dashicons-arrow-right-alt2"></span></a></li>
294
- </ul>
295
- ';
296
-
297
- echo '<div class="ufw"><h4><a href="https://www.aakashweb.com/wordpress-plugins/ultimate-floating-widgets-pro/?utm_source=shortcoder&utm_medium=sidebar&utm_campaign=ufw-pro" target="_blank">
298
- <i>Create <span class="dashicons dashicons-arrow-right-alt2"></span></i>
299
- <br/> Floating/sticky widgets</a></h4>
300
- <img src="' . SC_ADMIN_URL . 'images/ufw.png" class="balloon" />
301
- <p>If you want to create floating/sticky sidebar widgets, then Ultimate floating widgets plugins lets you do that. Check it out.</p></div>';
302
-
303
- echo '<a class="rate_review" href="https://wordpress.org/support/plugin/shortcoder/reviews/?rate=5#new-post" target="_blank">
304
- <h4>Rate &amp; Review</h4>
305
- <span class="dashicons dashicons-star-filled"></span>
306
- <p>Like this plugin ? please do rate and review.</p>
307
- </a>';
308
-
309
- echo '<div class="cfe_bottom">';
310
- echo '<img src="' . SC_ADMIN_URL . '/images/coffee.svg" />';
311
- echo '<h3>Buy me a Coffee !</h3><p>If you like this plugin, buy me a coffee and help support this plugin !</p>';
312
- echo '<div class="cfe_form">';
313
- echo '<select class="cfe_amt">';
314
- for($i = 5; $i <= 15; $i++){
315
- echo '<option value="' . $i . '" ' . ($i == 6 ? 'selected="selected"' : '') . '>$' . $i . '</option>';
316
- }
317
- echo '<option value="">Custom</option>';
318
- echo '</select>';
319
- echo '<a class="button button-primary cfe_btn" href="https://www.paypal.me/vaakash/6" data-link="https://www.paypal.me/vaakash/" target="_blank">' . __( 'Buy me a coffee !', 'shortcoder' ) . '</a>';
320
  echo '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
321
  echo '</div>';
322
 
 
 
323
  echo '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  }
325
 
326
  public static function footer_text( $text ){
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', __( 'WordPress News', 'shortcoder' ), array( __CLASS__, 'feedback' ), SC_POST_TYPE, 'side', 'default' );
54
+
55
+ add_meta_box( 'sc_mb_more_plugins', __( 'More plugins from us', 'shortcoder' ), array( __CLASS__, 'more_plugins' ), SC_POST_TYPE, 'side', 'default' );
56
 
57
  remove_meta_box( 'slugdiv', SC_POST_TYPE, 'normal' );
58
 
161
 
162
  $g = SC_Admin::clean_get();
163
 
164
+ if( empty( $settings[ '_sc_editor' ] ) ){
165
+ $general_settings = Shortcoder::get_settings();
166
+ $settings[ '_sc_editor' ] = $general_settings[ 'default_editor' ];
167
+ }
168
+
169
  $list = array(
170
  'text' => __( 'Text editor', 'shortcoder' ),
171
  'visual' => __( 'Visual editor', 'shortcoder' ),
200
  echo '</div>';
201
  echo '</div>';
202
 
203
+ if( SC_Admin::is_edit_page( 'new' ) ){
204
+ $general_settings = Shortcoder::get_settings();
205
+ $post->post_content = $general_settings[ 'default_content' ];
206
+ }
207
+
208
  if( $editor[ 'active' ] == 'code' ){
209
  echo '<div class="sc_cm_menu"></div>';
210
  $content = user_can_richedit() ? esc_textarea( $post->post_content ) : $post->post_content;
223
 
224
  global $post;
225
 
226
+ if( !SC_Admin::is_sc_admin_page() || $hook == 'edit.php' || $hook == 'edit-tags.php' || $hook == 'term.php' || $hook == 'shortcoder_page_settings' ){
227
  return false;
228
  }
229
 
295
  echo '<p>Get updates on the WordPress plugins, tips and tricks to enhance your WordPress experience. No spam.</p>';
296
 
297
  echo '<div class="subscribe_form" data-action="https://aakashweb.us19.list-manage.com/subscribe/post-json?u=b7023581458d048107298247e&id=ef5ab3c5c4&c=">
298
+ <input type="email" value="' . get_option( 'admin_email' ) . '" class="subscribe_email_box" placeholder="Your email address">
299
  <p class="subscribe_confirm">Thanks for subscribing !</p>
300
  <button class="button subscribe_btn"><span class="dashicons dashicons-email"></span> Subscribe</button>
301
  </div>';
302
 
303
+ echo '<p>';
304
+ echo '<a href="https://twitter.com/intent/follow?screen_name=aakashweb" target="_blank" class="button twitter_btn"><span class="dashicons dashicons-twitter"></span> Follow us on Twitter</a>';
305
+ echo '<a href="https://www.facebook.com/aakashweb/" target="_blank" class="button facebook_btn"><span class="dashicons dashicons-facebook-alt"></span> on Facebook</a>';
306
+ echo '</p>';
307
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308
  echo '</div>';
309
+ }
310
+
311
+ public static function more_plugins( $post ){
312
+
313
+ echo '<div class="feedback">';
314
+ echo '<div class="promo_slides">';
315
+ echo '<div class="promo_slide">';
316
+ 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>';
317
+ echo '</div>';
318
+
319
+ echo '<div class="promo_slide">';
320
+ 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>';
321
  echo '</div>';
322
 
323
+ echo '<div class="promo_slide">';
324
+ 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>';
325
  echo '</div>';
326
+ echo '</div>';
327
+
328
+ echo '<p class="promo_btns">
329
+ <a href="#" onclick="sc_next_promo_slide(-1, event)" class="promo_btn"><span class="dashicons dashicons-arrow-left-alt2"></span> Prev</a>
330
+ <a href="#" onclick="sc_next_promo_slide(1, event)" class="promo_btn right">Next <span class="dashicons dashicons-arrow-right-alt2"></span></a>
331
+ </p>';
332
+
333
+ echo '<p>';
334
+ echo '<a href="https://wordpress.org/support/plugin/shortcoder/reviews/?rate=5#new-post" target="_blank" class="button"><span class="dashicons dashicons-star-filled"></span> Rate this plugin</a>';
335
+ echo '<a href="https://www.aakashweb.com/forum/discuss/wordpress-plugins/shortcoder/" target="_blank" class="button"><span class="dashicons dashicons-format-chat"></span> Support forum</a>';
336
+ echo '</p>';
337
+
338
+ echo '</div>';
339
+
340
  }
341
 
342
  public static function footer_text( $text ){
admin/form.php CHANGED
@@ -9,7 +9,7 @@ class SC_Admin_Form{
9
  $html = '<table class="form-table ' . $class . '">';
10
 
11
  foreach( $rows as $row ){
12
- $html .= '<tr ' . ( isset( $row[2] ) ? $row[2] : '' ) . '>';
13
  $html .= '<th>' . ( isset( $row[0] ) ? $row[0] : '' ) . '</th>';
14
  $html .= '<td>' . ( isset( $row[1] ) ? $row[1] : '' ) . '</td>';
15
  $html .= '</tr>';
@@ -27,58 +27,40 @@ class SC_Admin_Form{
27
 
28
  public static function field( $field_type, $params = array() ){
29
 
30
- $defaults = array(
31
-
32
- 'text' => array(
33
- 'type' => 'text',
34
- 'value' => '',
35
- 'id' => '',
36
- 'class' => 'regular-text',
37
- 'name' => '',
38
- 'placeholder' => '',
39
- 'required' => '',
40
- 'helper' => '',
41
- 'tooltip' => '',
42
- 'custom' => ''
43
- ),
44
-
45
- 'select' => array(
46
- 'id' => '',
47
- 'class' => '',
48
- 'name' => '',
49
- 'list' => array(),
50
- 'value' => '',
51
- 'helper' => '',
52
- 'tooltip' => '',
53
- 'custom' => ''
54
- ),
55
-
56
- 'textarea' => array(
57
- 'type' => 'text',
58
- 'value' => '',
59
- 'name' => '',
60
- 'id' => '',
61
- 'class' => '',
62
- 'placeholder' => '',
63
- 'rows' => '',
64
- 'cols' => '',
65
- 'helper' => '',
66
- 'tooltip' => '',
67
- 'custom' => ''
68
- )
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  );
 
 
 
 
71
 
72
- $params = wp_parse_args( $params, $defaults[ $field_type ] );
73
  $field_html = '';
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':
@@ -90,7 +72,16 @@ class SC_Admin_Form{
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
  }
9
  $html = '<table class="form-table ' . $class . '">';
10
 
11
  foreach( $rows as $row ){
12
+ $html .= '<tr ' . ( isset( $row[2] ) ? $row[2] : '' ) . '>';
13
  $html .= '<th>' . ( isset( $row[0] ) ? $row[0] : '' ) . '</th>';
14
  $html .= '<td>' . ( isset( $row[1] ) ? $row[1] : '' ) . '</td>';
15
  $html .= '</tr>';
27
 
28
  public static function field( $field_type, $params = array() ){
29
 
30
+ $fields = array( 'text', 'select', 'checkbox', 'textarea' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
 
32
+ $default_props = array(
33
+ 'id' => '',
34
+ 'name' => '',
35
+ 'class' => '',
36
+ 'value' => '',
37
+ 'list' => array(),
38
+ 'type' => '',
39
+ 'required' => '',
40
+ 'placeholder' => '',
41
+ 'rows' => '',
42
+ 'cols' => '',
43
+ 'helper' => '',
44
+ 'tooltip' => '',
45
+ 'before_text' => '',
46
+ 'after_text' => '',
47
+ 'custom' => ''
48
  );
49
+
50
+ if( !in_array( $field_type, $fields ) ){
51
+ return '';
52
+ }
53
 
54
+ $params = Shortcoder::set_defaults( $params, $default_props );
55
  $field_html = '';
56
+
57
  extract( $params, EXTR_SKIP );
58
 
59
  $id_attr = empty( $id ) ? '' : 'id="' . $id . '"';
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':
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':
79
+ $field_html .= '<div class="radios_wrap">';
80
+ foreach( $list as $k => $v ){
81
+ $checked = in_array( $k, $value ) ? ' checked="checked"' : '';
82
+ $field_html .= "<label class='lbl_margin' $custom><input type='checkbox' name='{$name}[]' class='$class' value='$k' $id_attr $checked />&nbsp;$v </label>";
83
+ }
84
+ $field_html .= '</div>';
85
  break;
86
 
87
  }
admin/images/announcer.png ADDED
Binary file
admin/images/super-rss-reader.png ADDED
Binary file
admin/images/ufw.png DELETED
Binary file
admin/images/ultimate-floating-widgets.png ADDED
Binary file
admin/insert.php CHANGED
@@ -12,7 +12,22 @@
12
 
13
  <div class="sc_menu">
14
  <input type="search" class="sc_search" placeholder="Search ..." />
15
- <a href="https://www.aakashweb.com/wordpress-plugins/ultimate-floating-widgets-pro/" target="_blank" class="ufw"><i>Check out</i> : Ultimate floating widgets<span>A WordPress plugin to create floating widgets.</span></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  </div>
17
 
18
  <div class="sc_list">
@@ -57,7 +72,7 @@ if( empty( $shortcodes ) ){
57
  echo '<h3>' . $settings[ '_sc_title' ] . '</h3>';
58
  echo '<div class="sc_tools">';
59
  if( current_user_can( 'edit_post', $id ) ){
60
- echo '<a href="' . admin_url( 'post.php?action=edit&post=' . $id ) . '" class="button" target="_blank">' . __( 'Edit', 'shortcoder' ) . '</a>';
61
  }
62
  echo '<button class="button sc_copy">' . __( 'Copy', 'shortcoder' ) . '</button>';
63
  echo '<button class="button sc_insert">' . __( 'Insert', 'shortcoder' ) . '</button>';
@@ -103,24 +118,6 @@ if( empty( $shortcodes ) ){
103
  ?>
104
  </div>
105
 
106
- <div class="cfe_box">
107
- <?php
108
- echo '<div class="cfe_text">';
109
- echo '<img src="' . SC_ADMIN_URL . '/images/coffee.svg" />';
110
- echo '<div><h2>Buy me a Coffee !</h2><p>If you like this plugin, buy me a coffee !</p></div>';
111
- echo '</div>';
112
- echo '<div class="cfe_form">';
113
- echo '<select class="cfe_amt">';
114
- for($i = 5; $i <= 15; $i++){
115
- echo '<option value="' . $i . '" ' . ($i == 6 ? 'selected="selected"' : '') . '>$' . $i . '</option>';
116
- }
117
- echo '<option value="">Custom</option>';
118
- echo '</select>';
119
- echo '<a class="button button-primary cfe_btn" href="https://www.paypal.me/vaakash/6" data-link="https://www.paypal.me/vaakash/" target="_blank">Buy me coffee !</a>';
120
- echo '</div>';
121
- ?>
122
- </div>
123
-
124
  <div class="footer_thanks">Thanks for using <a href="https://www.aakashweb.com/wordpress-plugins/shortcoder/" target="_blank">Shortcoder</a> &bull; Please <a href="https://wordpress.org/support/plugin/shortcoder/reviews/?rate=5#new-post" target="_blank">rate 5 stars</a> and spread the word.</div>
125
 
126
  <?php do_action( 'sc_do_insert_popup_footer' ); ?>
12
 
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(
20
+ array('super-rss-reader/?utm_source=wp-socializer&utm_medium=insert&utm_campaign=srr-pro', 'Super RSS Reader', 'super-rss-reader.png'),
21
+ array('ultimate-floating-widgets/?utm_source=wp-socializer&utm_medium=insert&utm_campaign=ufw-pro', 'Ultimate Floating Widgets', 'ultimate-floating-widgets.png'),
22
+ array('announcer/?utm_source=wp-socializer&utm_medium=sidebar&utm_campaign=announcer-pro', 'Announcer', 'announcer.png'),
23
+ );
24
+ $promo_link_id = array_rand( $promo_links, 1 );
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>
32
 
33
  <div class="sc_list">
72
  echo '<h3>' . $settings[ '_sc_title' ] . '</h3>';
73
  echo '<div class="sc_tools">';
74
  if( current_user_can( 'edit_post', $id ) ){
75
+ echo '<a href="' . admin_url( 'post.php?action=edit&post=' . $id ) . '" class="button" target="_blank">' . __( 'View', 'shortcoder' ) . '</a>';
76
  }
77
  echo '<button class="button sc_copy">' . __( 'Copy', 'shortcoder' ) . '</button>';
78
  echo '<button class="button sc_insert">' . __( 'Insert', 'shortcoder' ) . '</button>';
118
  ?>
119
  </div>
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  <div class="footer_thanks">Thanks for using <a href="https://www.aakashweb.com/wordpress-plugins/shortcoder/" target="_blank">Shortcoder</a> &bull; Please <a href="https://wordpress.org/support/plugin/shortcoder/reviews/?rate=5#new-post" target="_blank">rate 5 stars</a> and spread the word.</div>
122
 
123
  <?php do_action( 'sc_do_insert_popup_footer' ); ?>
admin/js/blocks/index.asset.php ADDED
@@ -0,0 +1 @@
 
1
+ <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-polyfill', 'wp-rich-text'), 'version' => 'b6daafc6aa91698931c3b9a6fced42ef');
admin/js/blocks/index.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=6)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.components},function(e,t){e.exports=window.wp.richText},function(e,t){e.exports=window.wp.compose},function(e,t){e.exports=window.wp.blocks},function(e,t){e.exports=window.wp.blockEditor},function(e,t,r){"use strict";r.r(t);var n=r(0),o=r(1),c=r(3),i=function(){return Object(n.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,viewBox:"0 0 16.933 16.933"},Object(n.createElement)("g",{fill:"#00aee9",transform:"translate(-22.213 -238.799) scale(.93445)"},Object(n.createElement)("path",{d:"M24.549 257.815a.493.493 0 00-.495.494v12.602c0 .274.22.495.495.495h3.541c.274 0 .494-.22.494-.495v-.993a.493.493 0 00-.494-.494h-2.054v-9.627h2.054c.274 0 .494-.22.494-.494v-.994a.493.493 0 00-.494-.494H24.55z"}),Object(n.createElement)("rect",{ry:.515,transform:"matrix(1 0 -.2671 .96367 0 0)",y:265.478,x:104.75,height:18.217,width:2.464}),Object(n.createElement)("path",{d:"M37.573 257.815a.493.493 0 00-.494.494v.994c0 .273.22.494.494.494h2.054v9.627h-2.054a.493.493 0 00-.494.494v.993c0 .274.22.495.494.495h3.542c.274 0 .494-.22.494-.495V258.31a.493.493 0 00-.494-.494h-3.542z"})))},s=r(4);Object(s.registerBlockType)("shortcoder/shortcoder",{title:"Shortcoder",icon:i,category:"widgets",attributes:{text:{type:"string",source:"html"}},supports:{html:!1,customClassName:!1,className:!1},edit:function e(t){const{attributes:{text:r},setAttributes:i}=t,s=Object(c.useInstanceId)(e),a="shortcoder-input-"+s;return Object(n.createElement)("div",null,Object(n.createElement)(o.TextareaControl,{id:a,value:r,rows:"2",onChange:e=>{i({text:e})},placeholder:"Select/enter shortcode"}),Object(n.createElement)(o.Button,{isPrimary:!0,onClick:()=>{if(window.sc_show_insert){var e=document.getElementById("shortcoder-input-"+s).value;window.sc_show_insert(e,s)}}},"Select shortcode"))},save:function(e){const{attributes:{text:t}}=e;return Object(n.createElement)(n.RawHTML,null,t)}});var a=r(2),l=r(5);Object(a.registerFormatType)("shortcoder/inline-insert",{title:"Shortcoder",tagName:"[sc]",className:null,edit:e=>Object(n.createElement)(l.RichTextToolbarButton,{icon:i,title:"Shortcoder",onClick:()=>{window.sc_inline_insert_props={props:e,insert:a.insert},window.sc_show_insert&&sc_show_insert("",!1,!0)}})})}]);
admin/js/blocks/shortcoder.js DELETED
@@ -1,89 +0,0 @@
1
- (function( blocks, element ){
2
- var el = element.createElement;
3
-
4
- function shortcoderBlock( props ){
5
-
6
- return el( 'div', {
7
- 'id': 'shortcoder_wrap_' + props.instanceId,
8
- 'style': {
9
- 'background-color': '#f8f9f9',
10
- 'padding': '15px',
11
- 'border-radius': '5px'
12
- }
13
- },
14
- el( window.wp.editor.PlainText, {
15
- 'id': 'shortcoder_box_' + props.instanceId,
16
- 'className': 'input-control',
17
- 'onChange': function(value){
18
- props.setAttributes({
19
- text: value
20
- });
21
- },
22
- 'placeholder': 'Select/enter shortcode',
23
- 'spellcheck': 'false',
24
- 'value': props.attributes.text,
25
- 'style': {
26
- 'font-family': 'monospace',
27
- 'font-size': '15px',
28
- 'padding': '10px'
29
- }
30
- }),
31
- el( 'button', {
32
- 'class': 'button button-primary',
33
- 'onClick': function(){
34
- if( window.sc_show_insert ){
35
- var sc_val = document.getElementById('shortcoder_box_' + props.instanceId).value;
36
- window.sc_show_insert( sc_val, props.instanceId );
37
- }
38
- }
39
- }, 'Select shortcode')
40
- );
41
-
42
- }
43
-
44
- function icon() {
45
- return el('svg', {
46
- width: 64,
47
- height: 64,
48
- viewBox: '0 0 16.933 16.933'
49
- }, el('g', {
50
- fill: '#00aee9',
51
- transform: 'translate(-22.213 -238.799) scale(.93445)'
52
- }, el('path', {
53
- d: 'M24.549 257.815a.493.493 0 00-.495.494v12.602c0 .274.22.495.495.495h3.541c.274 0 .494-.22.494-.495v-.993a.493.493 0 00-.494-.494h-2.054v-9.627h2.054c.274 0 .494-.22.494-.494v-.994a.493.493 0 00-.494-.494H24.55z'
54
- }), el('rect', {
55
- ry: 0.515,
56
- transform: 'matrix(1 0 -.2671 .96367 0 0)',
57
- y: 265.478,
58
- x: 104.75,
59
- height: 18.217,
60
- width: 2.464
61
- }), el('path', {
62
- d: 'M37.573 257.815a.493.493 0 00-.494.494v.994c0 .273.22.494.494.494h2.054v9.627h-2.054a.493.493 0 00-.494.494v.993c0 .274.22.495.494.495h3.542c.274 0 .494-.22.494-.495V258.31a.493.493 0 00-.494-.494h-3.542z'
63
- })));
64
- }
65
-
66
- blocks.registerBlockType( 'shortcoder/shortcoder', {
67
- title: 'Shortcoder',
68
- icon: icon,
69
- category: 'widgets',
70
- attributes: {
71
- text: {
72
- type: 'string',
73
- source: 'text'
74
- },
75
- },
76
- supports: {
77
- html: false,
78
- customClassName: false,
79
- className: false
80
- },
81
- edit: wp.compose.withInstanceId( shortcoderBlock ),
82
- save: function(props) {
83
- return el( element.RawHTML, {}, props.attributes.text);
84
- },
85
- });
86
- }(
87
- window.wp.blocks,
88
- window.wp.element
89
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/js/script-insert.js CHANGED
@@ -9,6 +9,12 @@ $(document).ready(function(){
9
  }
10
  }
11
 
 
 
 
 
 
 
12
  if(typeof parent.send_to_editor === 'function'){
13
  parent.send_to_editor(content);
14
  }else{
@@ -50,10 +56,7 @@ $(document).ready(function(){
50
  });
51
 
52
  sc = '[sc name="' + name + '" ' + params + ']';
53
-
54
- if(enclosed == 'true'){
55
- sc += '[/sc]';
56
- }
57
 
58
  return sc;
59
 
9
  }
10
  }
11
 
12
+ if(typeof parent.sc_block_inline_insert === 'function'){
13
+ if(parent.sc_block_inline_insert(content)){
14
+ return true;
15
+ }
16
+ }
17
+
18
  if(typeof parent.send_to_editor === 'function'){
19
  parent.send_to_editor(content);
20
  }else{
56
  });
57
 
58
  sc = '[sc name="' + name + '" ' + params + ']';
59
+ sc += '[/sc]';
 
 
 
60
 
61
  return sc;
62
 
admin/js/script-settings.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($){
2
+ $(document).ready(function(){
3
+
4
+ var init = function(){
5
+
6
+ load_codemirror();
7
+
8
+ }
9
+
10
+ var load_codemirror = function(){
11
+
12
+ try{
13
+ var editor = wp.codeEditor.initialize(document.getElementById('sc_default_content'));
14
+
15
+ editor.codemirror.setSize( null, null );
16
+ editor.codemirror.on('change', function(){
17
+ editor.codemirror.save();
18
+ });
19
+
20
+ window.sc_cm = editor.codemirror;
21
+ }catch(error){
22
+ console.error('Shortcoder: Unable to load code editor.', error);
23
+ return false;
24
+ }
25
+
26
+ }
27
+
28
+ init();
29
+
30
+ });
31
+ })( jQuery );
admin/js/script-tools.js CHANGED
@@ -1,4 +1,4 @@
1
- function sc_show_insert(shortcode=false, block_editor_id=false){
2
  var $ = jQuery;
3
  var popup = '<div id="sci_wrap"><div id="sci_bg"></div><div id="sci_popup"><header><span id="sci_title"></span><span id="sci_close" title="Close"><span class="dashicons dashicons-no"></span></span></header><iframe></iframe></div></div>';
4
 
@@ -7,6 +7,7 @@ function sc_show_insert(shortcode=false, block_editor_id=false){
7
  }
8
 
9
  window.SC_INSERT_VARS.block_editor = block_editor_id;
 
10
 
11
  if($('#sci_wrap').length != 0 && !window.SC_INSERT_VARS.popup_opened){
12
  $('#sci_wrap').show();
@@ -55,12 +56,10 @@ function sc_block_editor_content(content){
55
  var block_id = window.SC_INSERT_VARS.block_editor;
56
 
57
  if(block_id !== false){
58
- var sc_box = document.getElementById('shortcoder_box_' + block_id);
59
- var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set;
60
- nativeInputValueSetter.call(sc_box, content);
61
 
62
- var the_event = new Event('input', {bubbles: true});
63
- sc_box.dispatchEvent(the_event);
64
 
65
  return true;
66
  }
@@ -68,10 +67,38 @@ function sc_block_editor_content(content){
68
  return false;
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  function sc_qt_show_insert(){
72
  sc_show_insert();
73
  }
74
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  if(window.addEventListener){
76
  window.addEventListener('load', function(){
77
  if( typeof QTags === 'function' ){
1
+ function sc_show_insert(shortcode=false, block_editor_id=false, block_inline_insert=false){
2
  var $ = jQuery;
3
  var popup = '<div id="sci_wrap"><div id="sci_bg"></div><div id="sci_popup"><header><span id="sci_title"></span><span id="sci_close" title="Close"><span class="dashicons dashicons-no"></span></span></header><iframe></iframe></div></div>';
4
 
7
  }
8
 
9
  window.SC_INSERT_VARS.block_editor = block_editor_id;
10
+ window.SC_INSERT_VARS.block_inline_insert = block_inline_insert;
11
 
12
  if($('#sci_wrap').length != 0 && !window.SC_INSERT_VARS.popup_opened){
13
  $('#sci_wrap').show();
56
  var block_id = window.SC_INSERT_VARS.block_editor;
57
 
58
  if(block_id !== false){
59
+ var sc_box = document.getElementById('shortcoder-input-' + block_id);
 
 
60
 
61
+ sc_set_native_value(sc_box, content);
62
+ sc_box.dispatchEvent(new Event('input', { bubbles: true }));
63
 
64
  return true;
65
  }
67
  return false;
68
  }
69
 
70
+ function sc_block_inline_insert(content){
71
+
72
+ if(window.SC_INSERT_VARS.block_inline_insert && window.sc_inline_insert_props){
73
+ var props = window.sc_inline_insert_props.props;
74
+ var insert = window.sc_inline_insert_props.insert;
75
+ props.onChange(
76
+ insert(props.value, content)
77
+ );
78
+ window.sc_inline_insert_props = false;
79
+ return true;
80
+ }
81
+
82
+ return false;
83
+
84
+ }
85
+
86
  function sc_qt_show_insert(){
87
  sc_show_insert();
88
  }
89
 
90
+ function sc_set_native_value(element, value) {
91
+ var valueSetter = Object.getOwnPropertyDescriptor(element, 'value').set;
92
+ var prototype = Object.getPrototypeOf(element);
93
+ var prototypeValueSetter = Object.getOwnPropertyDescriptor(prototype, 'value').set;
94
+
95
+ if (valueSetter && valueSetter !== prototypeValueSetter) {
96
+ prototypeValueSetter.call(element, value);
97
+ } else {
98
+ valueSetter.call(element, value);
99
+ }
100
+ }
101
+
102
  if(window.addEventListener){
103
  window.addEventListener('load', function(){
104
  if( typeof QTags === 'function' ){
admin/js/script.js CHANGED
@@ -25,13 +25,6 @@ $(document).ready(function(){
25
  add_top_import_export_btn();
26
  }
27
 
28
- if(SC_VARS['screen']['base'] == 'post'){
29
- var $cfe_button = $('.cfe_bottom');
30
- if($cfe_button.length > 0){
31
- $cfe_button.appendTo('#normal-sortables');
32
- }
33
- }
34
-
35
  add_top_coffee_btn();
36
  }
37
 
@@ -153,6 +146,18 @@ $(document).ready(function(){
153
 
154
  }
155
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  $('#post_name').on('change keyup', function(){
157
  set_sc_preview_text($(this).val());
158
  });
@@ -280,4 +285,33 @@ $(document).ready(function(){
280
  init();
281
 
282
  });
283
- })( jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  add_top_import_export_btn();
26
  }
27
 
 
 
 
 
 
 
 
28
  add_top_coffee_btn();
29
  }
30
 
146
 
147
  }
148
 
149
+ var show_promo_slide = function(){
150
+
151
+ var slides = $('.promo_slide').length;
152
+
153
+ if(!slides){
154
+ return;
155
+ }
156
+ var rand_slide = Math.floor(Math.random() * slides);
157
+ sc_current_slide(rand_slide);
158
+
159
+ }
160
+
161
  $('#post_name').on('change keyup', function(){
162
  set_sc_preview_text($(this).val());
163
  });
285
  init();
286
 
287
  });
288
+ })( jQuery );
289
+
290
+ var promo_slide_index = 1;
291
+
292
+ function sc_next_promo_slide(n, event) {
293
+ event.preventDefault();
294
+ sc_promo_slide(promo_slide_index += n);
295
+ }
296
+
297
+ function sc_current_slide(n) {
298
+ sc_promo_slide(promo_slide_index = n);
299
+ }
300
+
301
+ function sc_promo_slide(n) {
302
+ var slides = document.getElementsByClassName('promo_slide');
303
+ if(slides.length == 0){
304
+ return;
305
+ }
306
+ var i;
307
+ if (n > slides.length) {
308
+ promo_slide_index = 1
309
+ }
310
+ if (n < 1) {
311
+ promo_slide_index = slides.length
312
+ }
313
+ for (i = 0; i < slides.length; i++) {
314
+ slides[i].style.display = 'none';
315
+ }
316
+ slides[promo_slide_index - 1].style.display = 'block';
317
+ }
admin/settings.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SC_Admin_Settings{
4
+
5
+ public static function init(){
6
+
7
+ add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) );
8
+
9
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
10
+
11
+ }
12
+
13
+ public static function admin_menu(){
14
+
15
+ add_submenu_page( 'edit.php?post_type=shortcoder', 'Shortcoder - Settings', 'Settings', 'manage_options', 'settings', array( __CLASS__, 'page' ) );
16
+
17
+ }
18
+
19
+ public static function enqueue_scripts( $hook ){
20
+
21
+ if( $hook != 'shortcoder_page_settings' ){
22
+ return false;
23
+ }
24
+
25
+ wp_enqueue_style( 'sc-admin-settings-css', SC_ADMIN_URL . 'css/style-settings.css', array(), SC_VERSION );
26
+
27
+ wp_enqueue_code_editor( array( 'type' => 'text/html' ) );
28
+
29
+ wp_enqueue_script( 'jquery' );
30
+ wp_enqueue_script( 'sc-admin-settings-js', SC_ADMIN_URL . 'js/script-settings.js', array( 'jquery' ), SC_VERSION );
31
+
32
+ }
33
+
34
+ public static function page(){
35
+
36
+ self::save_settings();
37
+
38
+ echo '<div class="wrap">';
39
+ echo '<div class="head_wrap">';
40
+ echo '<h1>Shortcoder - General Settings</h1>';
41
+ echo '</div>';
42
+
43
+ $settings = Shortcoder::get_settings();
44
+
45
+ echo '<div id="main">';
46
+
47
+ $fields = array(
48
+
49
+ array( __( 'Default editor', 'shortcoder' ), SC_Admin_Form::field( 'select', array(
50
+ 'value' => $settings[ 'default_editor' ],
51
+ 'name' => 'sc_default_editor',
52
+ 'list' => array(
53
+ 'text' => __( 'Text editor', 'shortcoder' ),
54
+ 'visual' => __( 'Visual editor', 'shortcoder' ),
55
+ 'code' => __( 'Code editor', 'shortcoder' )
56
+ ),
57
+ 'helper' => __( 'The default editor mode when creating new shortcodes', 'shortcoder' )
58
+ ))),
59
+
60
+ array( __( 'Default shortcode content', 'shortcoder' ), SC_Admin_Form::field( 'textarea', array(
61
+ 'value' => $settings[ 'default_content' ],
62
+ 'id' => 'sc_default_content',
63
+ 'name' => 'sc_default_content',
64
+ 'class' => 'widefat',
65
+ 'helper' => __( 'The default shortcode content when creating new shortcodes', 'shortcoder' )
66
+ ))),
67
+
68
+ );
69
+
70
+ echo '<form method="post">';
71
+
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>';
79
+
80
+ echo '</div>';
81
+
82
+ }
83
+
84
+ public static function save_settings(){
85
+
86
+ if( $_POST && check_admin_referer( 'sc_settings_nonce' ) ){
87
+
88
+ $defaults = Shortcoder::default_settings();
89
+ $p = Shortcoder::set_defaults( SC_Admin::clean_post(), $defaults );
90
+
91
+ $values = array();
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 );
99
+ self::print_notice( 'Successfully saved the changes !' );
100
+
101
+ }
102
+
103
+ }
104
+
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
+ }
112
+
113
+ }
114
+
115
+ SC_Admin_Settings::init();
116
+
117
+ ?>
admin/tools.php CHANGED
@@ -53,12 +53,18 @@ class SC_Admin_Tools{
53
  return false;
54
  }
55
 
 
 
56
  wp_register_script(
57
- 'shortcoder', SC_ADMIN_URL . '/js/blocks/shortcoder.js', array( 'wp-blocks', 'wp-element' )
 
 
 
58
  );
59
 
60
  register_block_type( 'shortcoder/shortcoder', array(
61
- 'editor_script' => 'shortcoder',
 
62
  ));
63
 
64
  }
@@ -76,11 +82,16 @@ class SC_Admin_Tools{
76
  'insert_page' => admin_url( 'admin-ajax.php?action=sc_insert_window' ),
77
  'popup_title' => __( 'Insert shortcode to editor', 'shortcoder' ),
78
  'popup_opened' => false,
79
- 'block_editor' => false
 
80
  ));
81
 
82
  }
83
 
 
 
 
 
84
  public static function insert_window(){
85
 
86
  include_once( 'insert.php' );
53
  return false;
54
  }
55
 
56
+ $asset_file = include( SC_PATH . 'admin/js/blocks/index.asset.php');
57
+
58
  wp_register_script(
59
+ 'shortcoder',
60
+ SC_ADMIN_URL . '/js/blocks/index.js',
61
+ $asset_file[ 'dependencies' ],
62
+ $asset_file[ 'version' ]
63
  );
64
 
65
  register_block_type( 'shortcoder/shortcoder', array(
66
+ 'render_callback' => array( __CLASS__, 'render_block' ),
67
+ 'editor_script' => 'shortcoder'
68
  ));
69
 
70
  }
82
  'insert_page' => admin_url( 'admin-ajax.php?action=sc_insert_window' ),
83
  'popup_title' => __( 'Insert shortcode to editor', 'shortcoder' ),
84
  'popup_opened' => false,
85
+ 'block_editor' => false,
86
+ 'block_inline_insert' => false
87
  ));
88
 
89
  }
90
 
91
+ public static function render_block( $attributes, $content ){
92
+ return wpautop( $content );
93
+ }
94
+
95
  public static function insert_window(){
96
 
97
  include_once( 'insert.php' );
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.9.0
10
- Tested up to: 5.7
11
- Stable tag: 5.4
12
 
13
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
14
 
@@ -49,6 +49,13 @@ 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/)
@@ -99,6 +106,7 @@ No, right now the plugin supports only HTML, Javascript and CSS as shortcode con
99
  4. A shortcode inserted into post.
100
  5. Shortcoder block for Gutenberg editor.
101
  6. Shortcoder executed in the post.
 
102
 
103
  [More Screenshots](https://www.aakashweb.com/wordpress-plugins/shortcoder/)
104
 
@@ -106,6 +114,15 @@ No, right now the plugin supports only HTML, Javascript and CSS as shortcode con
106
 
107
  ## Changelog
108
 
 
 
 
 
 
 
 
 
 
109
  ### 5.4
110
  * New: Code editor is now loaded locally and not from cloudflare.
111
  * New: Code editor now shows hints and highlights any syntax error.
7
  License: GPLv2 or later
8
  Requires PHP: 5.3
9
  Requires at least: 4.9.0
10
+ Tested up to: 5.7.2
11
+ Stable tag: 5.5
12
 
13
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
14
 
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/)
106
  4. A shortcode inserted into post.
107
  5. Shortcoder block for Gutenberg editor.
108
  6. Shortcoder executed in the post.
109
+ 7. Insert shortcode inline from block editor toolbar.
110
 
111
  [More Screenshots](https://www.aakashweb.com/wordpress-plugins/shortcoder/)
112
 
114
 
115
  ## Changelog
116
 
117
+ ### 5.5
118
+ * New: General settings page to configure default editor and shortcode content.
119
+ * New: Block to insert shortcode rewritten from scratch.
120
+ * New: Toolbar button to insert shortcodes inline.
121
+ * New: Shortcodes are now closed by default when inserted from editor.
122
+ * Fix: Custom fields parsing issue when they are placed next to each other.
123
+ * Fix: Enclosed content in block input now retains multi-line.
124
+ * Fix: Minor refinements to UI.
125
+
126
  ### 5.4
127
  * New: Code editor is now loaded locally and not from cloudflare.
128
  * New: Code editor now shows hints and highlights any syntax error.
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.4
8
  Author URI: https://www.aakashweb.com/
9
  Text Domain: shortcoder
10
  Domain Path: /languages
11
  */
12
 
13
- define( 'SC_VERSION', '5.4' );
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' ) );
@@ -41,6 +41,7 @@ final class Shortcoder{
41
  include_once( SC_PATH . 'admin/admin.php' );
42
  include_once( SC_PATH . 'admin/form.php' );
43
  include_once( SC_PATH . 'admin/edit.php' );
 
44
  include_once( SC_PATH . 'admin/manage.php' );
45
  include_once( SC_PATH . 'admin/tools.php' );
46
 
@@ -109,12 +110,30 @@ final class Shortcoder{
109
  return array(
110
  '_sc_disable_sc' => 'no',
111
  '_sc_disable_admin' => 'no',
112
- '_sc_editor' => 'code',
113
  '_sc_allowed_devices' => 'all'
114
  );
115
 
116
  }
117
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  public static function get_sc_settings( $post_id ){
119
 
120
  $meta_vals = get_post_meta( $post_id, '', true );
@@ -274,7 +293,7 @@ final class Shortcoder{
274
 
275
  global $post;
276
 
277
- preg_match_all('/\$\$[^\s]+\$\$/', $content, $matches );
278
 
279
  $cf_tags = $matches[0];
280
 
@@ -363,6 +382,22 @@ final class Shortcoder{
363
 
364
  }
365
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  public static function load_text_domain(){
367
 
368
  load_plugin_textdomain( 'shortcoder', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
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.5
8
  Author URI: https://www.aakashweb.com/
9
  Text Domain: shortcoder
10
  Domain Path: /languages
11
  */
12
 
13
+ define( 'SC_VERSION', '5.5' );
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' ) );
41
  include_once( SC_PATH . 'admin/admin.php' );
42
  include_once( SC_PATH . 'admin/form.php' );
43
  include_once( SC_PATH . 'admin/edit.php' );
44
+ include_once( SC_PATH . 'admin/settings.php' );
45
  include_once( SC_PATH . 'admin/manage.php' );
46
  include_once( SC_PATH . 'admin/tools.php' );
47
 
110
  return array(
111
  '_sc_disable_sc' => 'no',
112
  '_sc_disable_admin' => 'no',
113
+ '_sc_editor' => '',
114
  '_sc_allowed_devices' => 'all'
115
  );
116
 
117
  }
118
 
119
+ public static function default_settings(){
120
+
121
+ return array(
122
+ 'default_editor' => 'code',
123
+ 'default_content' => ''
124
+ );
125
+
126
+ }
127
+
128
+ public static function get_settings(){
129
+
130
+ $settings = get_option( 'sc_settings', array() );
131
+ $default_settings = self::default_settings();
132
+
133
+ return self::set_defaults( $settings, $default_settings );
134
+
135
+ }
136
+
137
  public static function get_sc_settings( $post_id ){
138
 
139
  $meta_vals = get_post_meta( $post_id, '', true );
293
 
294
  global $post;
295
 
296
+ preg_match_all('/\$\$[^\s^$]+\$\$/', $content, $matches );
297
 
298
  $cf_tags = $matches[0];
299
 
382
 
383
  }
384
 
385
+ public static function set_defaults( $a, $b ){
386
+
387
+ $a = (array) $a;
388
+ $b = (array) $b;
389
+ $result = $b;
390
+
391
+ foreach ( $a as $k => &$v ) {
392
+ if ( is_array( $v ) && isset( $result[ $k ] ) ) {
393
+ $result[ $k ] = self::set_defaults( $v, $result[ $k ] );
394
+ } else {
395
+ $result[ $k ] = $v;
396
+ }
397
+ }
398
+ return $result;
399
+ }
400
+
401
  public static function load_text_domain(){
402
 
403
  load_plugin_textdomain( 'shortcoder', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );