Version Description
- Fix: Shortcode names with not-allowed characters cannot be edited/deleted.
- New: Shortcode imports made can now be fresh or overwritten.
- New: Only users with
manage_options
capability will see "edit shortcode" option in insert window. - Fix: Import failure with UTF-8 characters.
- Fix: Case sensitive search in admin pages.
- Fix: Minor admin interface changes.
Download this release
Release Info
Developer | vaakash |
Plugin | Shortcoder |
Version | 4.1.3 |
Comparing to | |
See all releases |
Code changes from version 4.1.2 to 4.1.3
- admin/css/style-insert.css +10 -0
- admin/css/style.css +13 -5
- admin/js/script-insert.js +1 -1
- admin/js/script.js +12 -4
- admin/sc-admin.php +20 -12
- admin/sc-insert.php +14 -2
- includes/import.php +8 -5
- readme.txt +9 -1
- shortcoder.php +6 -2
admin/css/style-insert.css
CHANGED
@@ -109,6 +109,8 @@ hr{
|
|
109 |
color: #888;
|
110 |
font-size: 11px;
|
111 |
vertical-align: middle;
|
|
|
|
|
112 |
}
|
113 |
.sc_options .button:hover{
|
114 |
box-shadow: 0 1px 4px -3px #333;
|
@@ -170,4 +172,12 @@ hr{
|
|
170 |
}
|
171 |
.coffee_box p{
|
172 |
font-size: 13px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
}
|
109 |
color: #888;
|
110 |
font-size: 11px;
|
111 |
vertical-align: middle;
|
112 |
+
margin-left: -1px;
|
113 |
+
border-radius: 0;
|
114 |
}
|
115 |
.sc_options .button:hover{
|
116 |
box-shadow: 0 1px 4px -3px #333;
|
172 |
}
|
173 |
.coffee_box p{
|
174 |
font-size: 13px;
|
175 |
+
}
|
176 |
+
|
177 |
+
@media screen and (max-width:750px){
|
178 |
+
.sc_menu {
|
179 |
+
display: block;
|
180 |
+
margin: 10px 0 0 -40px;
|
181 |
+
float: none;
|
182 |
+
}
|
183 |
}
|
admin/css/style.css
CHANGED
@@ -345,20 +345,22 @@ h1.sc_title .title-count {
|
|
345 |
}
|
346 |
|
347 |
.sc_note{
|
348 |
-
background: #
|
349 |
padding: 10px;
|
350 |
-
color: #
|
351 |
border-radius: 5px;
|
352 |
position: relative;
|
353 |
-
padding-left:
|
354 |
box-shadow: 0 2px 1px -2px;
|
355 |
}
|
356 |
.sc_note:before {
|
357 |
content: "\f348";
|
358 |
font-family: dashicons;
|
359 |
position: absolute;
|
360 |
-
left:
|
361 |
-
font-size:
|
|
|
|
|
362 |
}
|
363 |
|
364 |
.rate_link{
|
@@ -415,4 +417,10 @@ h1.sc_title .title-count {
|
|
415 |
height: 0;
|
416 |
visibility: hidden;
|
417 |
font-size: 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
}
|
345 |
}
|
346 |
|
347 |
.sc_note{
|
348 |
+
background: #fffbdc;
|
349 |
padding: 10px;
|
350 |
+
color: #965400;
|
351 |
border-radius: 5px;
|
352 |
position: relative;
|
353 |
+
padding-left: 50px;
|
354 |
box-shadow: 0 2px 1px -2px;
|
355 |
}
|
356 |
.sc_note:before {
|
357 |
content: "\f348";
|
358 |
font-family: dashicons;
|
359 |
position: absolute;
|
360 |
+
left: 15px;
|
361 |
+
font-size: 25px;
|
362 |
+
opacity: 0.8;
|
363 |
+
top: 12px;
|
364 |
}
|
365 |
|
366 |
.rate_link{
|
417 |
height: 0;
|
418 |
visibility: hidden;
|
419 |
font-size: 0;
|
420 |
+
}
|
421 |
+
.sc_enable_vedit{
|
422 |
+
margin-top: 2px !important;
|
423 |
+
}
|
424 |
+
.sc_enable_vedit .dashicons {
|
425 |
+
margin-top: 4px !important;
|
426 |
}
|
admin/js/script-insert.js
CHANGED
@@ -88,7 +88,7 @@ $(document).ready(function(){
|
|
88 |
});
|
89 |
|
90 |
$( document ).on( 'keyup', '.search_box', function(){
|
91 |
-
var re = new RegExp($(this).val(), '
|
92 |
$('.sc_wrap .sc_shortcode').each(function(){
|
93 |
var name = $(this).attr('data-name');
|
94 |
if( name.match(re) === null ){
|
88 |
});
|
89 |
|
90 |
$( document ).on( 'keyup', '.search_box', function(){
|
91 |
+
var re = new RegExp($(this).val(), 'gi');
|
92 |
$('.sc_wrap .sc_shortcode').each(function(){
|
93 |
var name = $(this).attr('data-name');
|
94 |
if( name.match(re) === null ){
|
admin/js/script.js
CHANGED
@@ -105,7 +105,7 @@ $(document).ready(function(){
|
|
105 |
});
|
106 |
$( '.params_wrap' ).appendTo( 'body' );
|
107 |
$( '.quicktags-toolbar' ).append(function(){
|
108 |
-
return '<a href="#" class="ed_button button button-small fright sc_enable_vedit" title="Enable visual editor"><span class="dashicons dashicons-visibility"></span
|
109 |
});
|
110 |
});
|
111 |
|
@@ -158,9 +158,17 @@ $(document).ready(function(){
|
|
158 |
});
|
159 |
|
160 |
$( document ).on( 'change', '#import', function(){
|
161 |
-
if( confirm( $( '.import_desc' ).text() ) ){
|
162 |
-
|
163 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
});
|
165 |
|
166 |
$( document ).on( 'click', '.search_btn', function(e){
|
@@ -174,7 +182,7 @@ $(document).ready(function(){
|
|
174 |
|
175 |
$( document ).on( 'keyup', '.search_box', function(){
|
176 |
var search_term = $(this).val();
|
177 |
-
var re = new RegExp(search_term, '
|
178 |
$('.sc_list li').each(function(){
|
179 |
var name = $(this).attr('data-name');
|
180 |
if(name.match(re) === null){
|
105 |
});
|
106 |
$( '.params_wrap' ).appendTo( 'body' );
|
107 |
$( '.quicktags-toolbar' ).append(function(){
|
108 |
+
return '<a href="#" class="ed_button button button-small fright sc_enable_vedit" title="Enable visual editor"><span class="dashicons dashicons-visibility"></span> Enable visual editor</a>';
|
109 |
});
|
110 |
});
|
111 |
|
158 |
});
|
159 |
|
160 |
$( document ).on( 'change', '#import', function(){
|
161 |
+
if( !confirm( $( '.import_desc' ).text() ) ){
|
162 |
+
return false;
|
163 |
}
|
164 |
+
|
165 |
+
if( confirm( $( '.import_desc2' ).text() ) ){
|
166 |
+
$( '#fresh_import' ).prop( 'checked', true );
|
167 |
+
}else{
|
168 |
+
$( '#fresh_import' ).prop( 'checked', false );
|
169 |
+
}
|
170 |
+
|
171 |
+
$( '#import_form' ).submit();
|
172 |
});
|
173 |
|
174 |
$( document ).on( 'click', '.search_btn', function(e){
|
182 |
|
183 |
$( document ).on( 'keyup', '.search_box', function(){
|
184 |
var search_term = $(this).val();
|
185 |
+
var re = new RegExp(search_term, 'gi');
|
186 |
$('.sc_list li').each(function(){
|
187 |
var name = $(this).attr('data-name');
|
188 |
if(name.match(re) === null){
|
admin/sc-admin.php
CHANGED
@@ -88,17 +88,17 @@ class Shortcoder_Admin{
|
|
88 |
$shortcodes = Shortcoder::list_all();
|
89 |
$g = self::clean_get();
|
90 |
|
91 |
-
echo '<h3 class="page_title">' . __( 'List of shortcodes created', 'shortcoder' );
|
92 |
echo '<span class="sc_menu">';
|
93 |
|
94 |
echo '<span class="button search_btn" title="' . __( 'Search shortcodes', 'shortcoder' ) . '"><span class="dashicons dashicons-search"></span><input type="search" class="search_box" placeholder="Search ..."/></span>';
|
95 |
|
96 |
-
echo '<label for="import" class="button"><span class="dashicons dashicons-
|
97 |
|
98 |
echo '<a href="' . self::get_link(array(
|
99 |
'action' => 'sc_export',
|
100 |
'_wpnonce' => wp_create_nonce( 'sc_export_data' )
|
101 |
-
), 'admin-ajax.php' ) . '" class="button"><span class="dashicons dashicons-
|
102 |
|
103 |
|
104 |
echo '<button class="button sort_btn" title="' . __( 'Sort list', 'shortcoder' ) . '"><span class="dashicons dashicons-menu"></span> <span class="dashicons dashicons-arrow-down-alt sort_icon"></span></button>';
|
@@ -125,20 +125,20 @@ class Shortcoder_Admin{
|
|
125 |
|
126 |
$link = self::get_link(array(
|
127 |
'action' => 'edit',
|
128 |
-
'
|
129 |
));
|
130 |
|
131 |
$delete_link = self::get_link(array(
|
132 |
'action' => 'sc_admin_ajax',
|
133 |
'do' => 'delete',
|
134 |
-
'
|
135 |
'_wpnonce' => wp_create_nonce( 'sc_delete_nonce' )
|
136 |
), 'admin-ajax.php' );
|
137 |
|
138 |
$disabled_text = ( $data[ 'disabled' ] == '1' ) ? '<small class="disabled_text">' . __( 'Temporarily disabled', 'shortcoder' ) . '</small>' : '';
|
139 |
|
140 |
echo '<li data-name="' . esc_attr( $name ) . '">';
|
141 |
-
echo '<a href="' . $link . '" class="sc_link" title="' . __( 'Edit shortcode', 'shortcoder' ) . '">' . $name . $disabled_text . '</a>';
|
142 |
echo '<span class="sc_controls">';
|
143 |
echo '<a href="#" class="sc_copy" title="' . __( 'Copy shortcode', 'shortcoder' ) . '"><span class="dashicons dashicons-editor-code"></span></a>';
|
144 |
echo '<a href="' . $delete_link . '" class="sc_delete" title="' . __( 'Delete', 'shortcoder' ) . '"><span class="dashicons dashicons-trash"></span></a>';
|
@@ -176,12 +176,18 @@ class Shortcoder_Admin{
|
|
176 |
$page_title = __( 'Edit shortcode', 'shortcoder' );
|
177 |
$action_btn = __( 'Save settings', 'shortcoder' );
|
178 |
|
179 |
-
if( !
|
180 |
-
echo '<p align="center">' . __( '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
return false;
|
182 |
}
|
183 |
|
184 |
-
$sc_name = $g[ 'name' ];
|
185 |
$values = $shortcodes[ $sc_name ];
|
186 |
|
187 |
}
|
@@ -241,7 +247,7 @@ class Shortcoder_Admin{
|
|
241 |
$delete_link = self::get_link(array(
|
242 |
'action' => 'sc_admin_ajax',
|
243 |
'do' => 'delete',
|
244 |
-
'
|
245 |
'_wpnonce' => wp_create_nonce( 'sc_delete_nonce' )
|
246 |
), 'admin-ajax.php' );
|
247 |
echo '<a href="' . $delete_link . '" class="button sc_delete_ep" title="' . __( 'Delete', 'shortcoder' ) . '"><span class="dashicons dashicons-trash"></span></a>';
|
@@ -341,8 +347,9 @@ class Shortcoder_Admin{
|
|
341 |
|
342 |
$g = self::clean_get();
|
343 |
|
344 |
-
if( $g[ 'do' ] == 'delete' && isset( $g[ '
|
345 |
-
|
|
|
346 |
echo 'DELETED';
|
347 |
}else{
|
348 |
echo 'FAILED';
|
@@ -436,6 +443,7 @@ class Shortcoder_Admin{
|
|
436 |
|
437 |
<a href="https://goo.gl/r8Qr7Y" class="help_link" target="_blank" title="Help"><span class="dashicons dashicons-editor-help"></span></a>
|
438 |
<a href="https://goo.gl/URfxp2" class="help_link" target="_blank" title="Report issue"><span class="dashicons dashicons-flag"></span></a>
|
|
|
439 |
|
440 |
<a class="share_btn googleplus" href="https://plus.google.com/share?url=https%3A%2F%2Fwww.aakashweb.com%2Fwordpress-plugins%2Fshortcoder%2F" target="_blank"><span class="dashicons dashicons-googleplus"></span> Share</a>
|
441 |
<a class="share_btn twitter" href="https://twitter.com/intent/tweet?ref_src=twsrc%5Etfw&related=vaakash&text=Check%20out%20Shortcoder,%20a%20%23wordpress%20plugin%20to%20create%20shortcodes%20for%20HTML,%20JavaScript%20snippets%20easily&tw_p=tweetbutton&url=https%3A%2F%2Fwww.aakashweb.com%2Fwordpress-plugins%2Fshortcoder%2F&via=vaakash" target="_blank"><span class="dashicons dashicons-twitter"></span> Tweet about Shortcoder</a>
|
88 |
$shortcodes = Shortcoder::list_all();
|
89 |
$g = self::clean_get();
|
90 |
|
91 |
+
echo '<h3 class="page_title">' . __( 'List of shortcodes created', 'shortcoder' ) . ' (' . count( $shortcodes ) . ')';
|
92 |
echo '<span class="sc_menu">';
|
93 |
|
94 |
echo '<span class="button search_btn" title="' . __( 'Search shortcodes', 'shortcoder' ) . '"><span class="dashicons dashicons-search"></span><input type="search" class="search_box" placeholder="Search ..."/></span>';
|
95 |
|
96 |
+
echo '<label for="import" class="button"><span class="dashicons dashicons-download"></span><em>' . __( 'Import shortcodes', 'shortcoder' ) . '</em></label>';
|
97 |
|
98 |
echo '<a href="' . self::get_link(array(
|
99 |
'action' => 'sc_export',
|
100 |
'_wpnonce' => wp_create_nonce( 'sc_export_data' )
|
101 |
+
), 'admin-ajax.php' ) . '" class="button"><span class="dashicons dashicons-upload"></span><em>' . __( 'Export shortcodes', 'shortcoder' ) . '</em></a>';
|
102 |
|
103 |
|
104 |
echo '<button class="button sort_btn" title="' . __( 'Sort list', 'shortcoder' ) . '"><span class="dashicons dashicons-menu"></span> <span class="dashicons dashicons-arrow-down-alt sort_icon"></span></button>';
|
125 |
|
126 |
$link = self::get_link(array(
|
127 |
'action' => 'edit',
|
128 |
+
'id' => base64_encode( $name )
|
129 |
));
|
130 |
|
131 |
$delete_link = self::get_link(array(
|
132 |
'action' => 'sc_admin_ajax',
|
133 |
'do' => 'delete',
|
134 |
+
'id' => base64_encode( $name ),
|
135 |
'_wpnonce' => wp_create_nonce( 'sc_delete_nonce' )
|
136 |
), 'admin-ajax.php' );
|
137 |
|
138 |
$disabled_text = ( $data[ 'disabled' ] == '1' ) ? '<small class="disabled_text">' . __( 'Temporarily disabled', 'shortcoder' ) . '</small>' : '';
|
139 |
|
140 |
echo '<li data-name="' . esc_attr( $name ) . '">';
|
141 |
+
echo '<a href="' . $link . '" class="sc_link" title="' . __( 'Edit shortcode', 'shortcoder' ) . '">' . esc_attr( $name ) . $disabled_text . '</a>';
|
142 |
echo '<span class="sc_controls">';
|
143 |
echo '<a href="#" class="sc_copy" title="' . __( 'Copy shortcode', 'shortcoder' ) . '"><span class="dashicons dashicons-editor-code"></span></a>';
|
144 |
echo '<a href="' . $delete_link . '" class="sc_delete" title="' . __( 'Delete', 'shortcoder' ) . '"><span class="dashicons dashicons-trash"></span></a>';
|
176 |
$page_title = __( 'Edit shortcode', 'shortcoder' );
|
177 |
$action_btn = __( 'Save settings', 'shortcoder' );
|
178 |
|
179 |
+
if( !isset( $g[ 'id' ] ) ){
|
180 |
+
echo '<p align="center">' . __( 'No shortcode ID provided !' ) . '</p>';
|
181 |
+
return false;
|
182 |
+
}
|
183 |
+
|
184 |
+
$sc_name = base64_decode( $g[ 'id' ] );
|
185 |
+
|
186 |
+
if( !array_key_exists( $sc_name, $shortcodes ) ){
|
187 |
+
echo '<p align="center">' . __( 'Invalid shortcode ID or no such shortcode with name [' . esc_attr( $sc_name ) . '] exists !' ) . '</p>';
|
188 |
return false;
|
189 |
}
|
190 |
|
|
|
191 |
$values = $shortcodes[ $sc_name ];
|
192 |
|
193 |
}
|
247 |
$delete_link = self::get_link(array(
|
248 |
'action' => 'sc_admin_ajax',
|
249 |
'do' => 'delete',
|
250 |
+
'id' => base64_encode( $sc_name ),
|
251 |
'_wpnonce' => wp_create_nonce( 'sc_delete_nonce' )
|
252 |
), 'admin-ajax.php' );
|
253 |
echo '<a href="' . $delete_link . '" class="button sc_delete_ep" title="' . __( 'Delete', 'shortcoder' ) . '"><span class="dashicons dashicons-trash"></span></a>';
|
347 |
|
348 |
$g = self::clean_get();
|
349 |
|
350 |
+
if( $g[ 'do' ] == 'delete' && isset( $g[ 'id' ] ) && check_admin_referer( 'sc_delete_nonce' ) ){
|
351 |
+
$sc_name = base64_decode( $g[ 'id' ] );
|
352 |
+
if( self::delete_shortcode( $sc_name ) ){
|
353 |
echo 'DELETED';
|
354 |
}else{
|
355 |
echo 'FAILED';
|
443 |
|
444 |
<a href="https://goo.gl/r8Qr7Y" class="help_link" target="_blank" title="Help"><span class="dashicons dashicons-editor-help"></span></a>
|
445 |
<a href="https://goo.gl/URfxp2" class="help_link" target="_blank" title="Report issue"><span class="dashicons dashicons-flag"></span></a>
|
446 |
+
<a href="https://goo.gl/ltvnIE" class="help_link" target="_blank" title="Rate 5 stars"><span class="dashicons dashicons-star-filled"></span></a>
|
447 |
|
448 |
<a class="share_btn googleplus" href="https://plus.google.com/share?url=https%3A%2F%2Fwww.aakashweb.com%2Fwordpress-plugins%2Fshortcoder%2F" target="_blank"><span class="dashicons dashicons-googleplus"></span> Share</a>
|
449 |
<a class="share_btn twitter" href="https://twitter.com/intent/tweet?ref_src=twsrc%5Etfw&related=vaakash&text=Check%20out%20Shortcoder,%20a%20%23wordpress%20plugin%20to%20create%20shortcodes%20for%20HTML,%20JavaScript%20snippets%20easily&tw_p=tweetbutton&url=https%3A%2F%2Fwww.aakashweb.com%2Fwordpress-plugins%2Fshortcoder%2F&via=vaakash" target="_blank"><span class="dashicons dashicons-twitter"></span> Tweet about Shortcoder</a>
|
admin/sc-insert.php
CHANGED
@@ -11,7 +11,11 @@
|
|
11 |
<span class="sc_menu">
|
12 |
<input type="search" class="button search_box" placeholder="Search ..." />
|
13 |
<a href="#" class="button sort_btn">Sort list</a>
|
14 |
-
|
|
|
|
|
|
|
|
|
15 |
</span>
|
16 |
</h2>
|
17 |
|
@@ -30,7 +34,15 @@ if( empty( $shortcodes ) ){
|
|
30 |
$name = esc_attr( $key );
|
31 |
$value = wp_parse_args( $value, Shortcoder::defaults() );
|
32 |
$disabled_text = ( $value[ 'disabled' ] == '1' ) ? '<small class="disabled_text">Temporarily disabled</small>' : '';
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
echo '<div class="sc_shortcode" data-name="' . $name . '">';
|
36 |
echo '<div class="sc_shortcode_name">' . $name . $disabled_text . $options . '</div>';
|
11 |
<span class="sc_menu">
|
12 |
<input type="search" class="button search_box" placeholder="Search ..." />
|
13 |
<a href="#" class="button sort_btn">Sort list</a>
|
14 |
+
<?php
|
15 |
+
if( Shortcoder::can_edit_sc( 'manage_options' ) ){
|
16 |
+
echo '<a href="' . admin_url( 'options-general.php?page=shortcoder&action=new' ) . '" target="_blank" class="button new_btn">Create new shortcode</a>';
|
17 |
+
}
|
18 |
+
?>
|
19 |
</span>
|
20 |
</h2>
|
21 |
|
34 |
$name = esc_attr( $key );
|
35 |
$value = wp_parse_args( $value, Shortcoder::defaults() );
|
36 |
$disabled_text = ( $value[ 'disabled' ] == '1' ) ? '<small class="disabled_text">Temporarily disabled</small>' : '';
|
37 |
+
|
38 |
+
$options = '<span class="sc_options">';
|
39 |
+
$options .= '<button class="button sc_quick_insert">Quick insert</button>';
|
40 |
+
|
41 |
+
if( Shortcoder::can_edit_sc( 'manage_options' ) ){
|
42 |
+
$options .= '<a href="' . esc_attr( admin_url( 'options-general.php?page=shortcoder&action=edit&id=' . base64_encode( $name ) ) ) . '" target="_blank" class="button">Edit</a>';
|
43 |
+
}
|
44 |
+
|
45 |
+
$options .= '</span>';
|
46 |
|
47 |
echo '<div class="sc_shortcode" data-name="' . $name . '">';
|
48 |
echo '<div class="sc_shortcode_name">' . $name . $disabled_text . $options . '</div>';
|
includes/import.php
CHANGED
@@ -12,6 +12,8 @@ class Shortcoder_Import{
|
|
12 |
|
13 |
echo '<form method="post" enctype="multipart/form-data" id="import_form">';
|
14 |
echo '<p class="import_desc"> ' . __( 'Are you sure want to import shortcodes ?', 'shortcoder' ) . '</p>';
|
|
|
|
|
15 |
echo '<input type="file" name="import" id="import" accept="text/plain"/>';
|
16 |
wp_nonce_field( 'sc_import_data' );
|
17 |
echo '<input type="submit" />';
|
@@ -34,25 +36,26 @@ class Shortcoder_Import{
|
|
34 |
|
35 |
$file_id = absint( $file['id'] );
|
36 |
$file_path = get_attached_file( $file_id );
|
|
|
37 |
|
38 |
-
self::do_import( $file_path );
|
39 |
|
40 |
}
|
41 |
|
42 |
}
|
43 |
|
44 |
-
public static function do_import( $file_path ){
|
45 |
|
46 |
if ( !is_file( $file_path ) ){
|
47 |
self::print_notice( __( 'Uploaded file does not exist for import. ', 'shortcoder' ) . $file_path );
|
48 |
}
|
49 |
|
50 |
-
$imported_json = file_get_contents( $file_path );
|
51 |
$imported_data = json_decode( $imported_json, true );
|
52 |
|
53 |
if( $imported_data && !empty( $imported_data ) ){
|
54 |
|
55 |
-
$shortcodes = Shortcoder::list_all();
|
56 |
$import_count = 0;
|
57 |
|
58 |
if( isset( $imported_data[ 'shortcodes' ] ) ){
|
@@ -72,7 +75,7 @@ class Shortcoder_Import{
|
|
72 |
}
|
73 |
|
74 |
}else{
|
75 |
-
self::print_notice( __( 'Failed to decode JSON in imported data.', 'shortcoder' ) );
|
76 |
}
|
77 |
|
78 |
}
|
12 |
|
13 |
echo '<form method="post" enctype="multipart/form-data" id="import_form">';
|
14 |
echo '<p class="import_desc"> ' . __( 'Are you sure want to import shortcodes ?', 'shortcoder' ) . '</p>';
|
15 |
+
echo '<p class="import_desc2"> ' . __( 'Do you want to delete existing shortcodes and perform a clean import ? (selecting "cancel" will overwrite existing shortcodes)', 'shortcoder' ) . '</p>';
|
16 |
+
echo '<input type="checkbox" name="fresh_import" id="fresh_import" value="1" />';
|
17 |
echo '<input type="file" name="import" id="import" accept="text/plain"/>';
|
18 |
wp_nonce_field( 'sc_import_data' );
|
19 |
echo '<input type="submit" />';
|
36 |
|
37 |
$file_id = absint( $file['id'] );
|
38 |
$file_path = get_attached_file( $file_id );
|
39 |
+
$fresh_import = isset( $_POST[ 'fresh_import' ] ) && $_POST[ 'fresh_import' ] == '1' ? true : false;
|
40 |
|
41 |
+
self::do_import( $file_path, $fresh_import );
|
42 |
|
43 |
}
|
44 |
|
45 |
}
|
46 |
|
47 |
+
public static function do_import( $file_path, $fresh_import = false ){
|
48 |
|
49 |
if ( !is_file( $file_path ) ){
|
50 |
self::print_notice( __( 'Uploaded file does not exist for import. ', 'shortcoder' ) . $file_path );
|
51 |
}
|
52 |
|
53 |
+
$imported_json = utf8_encode( file_get_contents( $file_path ) );
|
54 |
$imported_data = json_decode( $imported_json, true );
|
55 |
|
56 |
if( $imported_data && !empty( $imported_data ) ){
|
57 |
|
58 |
+
$shortcodes = $fresh_import ? array() : Shortcoder::list_all();
|
59 |
$import_count = 0;
|
60 |
|
61 |
if( isset( $imported_data[ 'shortcodes' ] ) ){
|
75 |
}
|
76 |
|
77 |
}else{
|
78 |
+
self::print_notice( __( 'Failed to decode JSON in imported data. Error code: ', 'shortcoder' ) . json_last_error() );
|
79 |
}
|
80 |
|
81 |
}
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Donate link: https://goo.gl/qMF3iE
|
|
7 |
License: GPLv2 or later
|
8 |
Requires at least: 3.3
|
9 |
Tested up to: 4.9
|
10 |
-
Stable tag: 4.1.
|
11 |
|
12 |
Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
|
13 |
|
@@ -91,6 +91,14 @@ Note: When you disable a shortcode, the shortcode will not be executed in the pa
|
|
91 |
|
92 |
== Changelog ==
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
= 4.1.2 =
|
95 |
* New: Search box for shortcodes in admin page.
|
96 |
|
7 |
License: GPLv2 or later
|
8 |
Requires at least: 3.3
|
9 |
Tested up to: 4.9
|
10 |
+
Stable tag: 4.1.3
|
11 |
|
12 |
Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
|
13 |
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
= 4.1.3 =
|
95 |
+
* Fix: Shortcode names with not-allowed characters cannot be edited/deleted.
|
96 |
+
* New: Shortcode imports made can now be fresh or overwritten.
|
97 |
+
* New: Only users with `manage_options` capability will see "edit shortcode" option in insert window.
|
98 |
+
* Fix: Import failure with UTF-8 characters.
|
99 |
+
* Fix: Case sensitive search in admin pages.
|
100 |
+
* Fix: Minor admin interface changes.
|
101 |
+
|
102 |
= 4.1.2 =
|
103 |
* New: Search box for shortcodes in admin page.
|
104 |
|
shortcoder.php
CHANGED
@@ -4,11 +4,11 @@ Plugin Name: Shortcoder
|
|
4 |
Plugin URI: https://www.aakashweb.com/
|
5 |
Description: Shortcoder is a plugin which allows to create a custom shortcode and store HTML, JavaScript and other snippets in it. So if that shortcode is used in any post or pages, then the code stored in the shortcode get executed in that place. You can create a shortcode for Youtube videos, adsense ads, buttons and more.
|
6 |
Author: Aakash Chakravarthy
|
7 |
-
Version: 4.1.
|
8 |
Author URI: https://www.aakashweb.com/
|
9 |
*/
|
10 |
|
11 |
-
define( 'SC_VERSION', '4.1.
|
12 |
define( 'SC_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
|
13 |
define( 'SC_URL', plugin_dir_url( __FILE__ ) );
|
14 |
define( 'SC_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );
|
@@ -209,6 +209,10 @@ class Shortcoder{
|
|
209 |
);
|
210 |
}
|
211 |
|
|
|
|
|
|
|
|
|
212 |
public static function wp_44_workaround( $content ){
|
213 |
return str_replace( '[sc:', '[sc name=', $content );
|
214 |
}
|
4 |
Plugin URI: https://www.aakashweb.com/
|
5 |
Description: Shortcoder is a plugin which allows to create a custom shortcode and store HTML, JavaScript and other snippets in it. So if that shortcode is used in any post or pages, then the code stored in the shortcode get executed in that place. You can create a shortcode for Youtube videos, adsense ads, buttons and more.
|
6 |
Author: Aakash Chakravarthy
|
7 |
+
Version: 4.1.3
|
8 |
Author URI: https://www.aakashweb.com/
|
9 |
*/
|
10 |
|
11 |
+
define( 'SC_VERSION', '4.1.3' );
|
12 |
define( 'SC_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
|
13 |
define( 'SC_URL', plugin_dir_url( __FILE__ ) );
|
14 |
define( 'SC_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );
|
209 |
);
|
210 |
}
|
211 |
|
212 |
+
public static function can_edit_sc(){
|
213 |
+
return current_user_can( 'manage_options' );
|
214 |
+
}
|
215 |
+
|
216 |
public static function wp_44_workaround( $content ){
|
217 |
return str_replace( '[sc:', '[sc name=', $content );
|
218 |
}
|