Shortcoder - Version 5.0.1

Version Description

  • Fix: Code editor escaping HTML characters.
  • Fix: get_current_screen() undefined.
  • Fix: Code editor breaks if there is any other plugin which loads codemirror.
  • Fix: tools.php is not found.
Download this release

Release Info

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

Code changes from version 4.6 to 5.0.1

admin/admin.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class SC_Admin{
6
+
7
+ public static function init(){
8
+
9
+ add_action( 'init', array( __class__, 'register_post_type' ), 0 );
10
+
11
+ add_action( 'init', array( __class__, 'register_taxonomy' ), 0 );
12
+
13
+ add_action( 'admin_enqueue_scripts', array( __class__, 'enqueue_scripts' ) );
14
+
15
+ add_action( 'admin_footer', array( __class__, 'changelog' ) );
16
+
17
+ add_action( 'wp_ajax_sc_admin_ajax', array( __class__, 'admin_ajax' ) );
18
+
19
+ }
20
+
21
+ public static function register_post_type(){
22
+
23
+ $labels = array(
24
+ 'name' => _x( 'Shortcoder', 'Post Type General Name', 'sc' ),
25
+ 'singular_name' => _x( 'Shortcode', 'Post Type Singular Name', 'sc' ),
26
+ 'menu_name' => __( 'Shortcoder', 'sc' ),
27
+ 'name_admin_bar' => __( 'Shortcode', 'sc' ),
28
+ 'archives' => __( 'Shortcode Archives', 'sc' ),
29
+ 'attributes' => __( 'Shortcode Attributes', 'sc' ),
30
+ 'parent_item_colon' => __( 'Parent Shortcode:', 'sc' ),
31
+ 'all_items' => __( 'All Shortcodes', 'sc' ),
32
+ 'add_new_item' => __( 'Create shortcode', 'sc' ),
33
+ 'add_new' => __( 'Create shortcode', 'sc' ),
34
+ 'new_item' => __( 'New Shortcode', 'sc' ),
35
+ 'edit_item' => __( 'Edit Shortcode', 'sc' ),
36
+ 'update_item' => __( 'Update Shortcode', 'sc' ),
37
+ 'view_item' => __( 'View Shortcode', 'sc' ),
38
+ 'view_items' => __( 'View Shortcodes', 'sc' ),
39
+ 'search_items' => __( 'Search Shortcode', 'sc' ),
40
+ 'not_found' => __( 'Not found', 'sc' ),
41
+ 'not_found_in_trash' => __( 'Not found in Trash', 'sc' ),
42
+ 'featured_image' => __( 'Featured Image', 'sc' ),
43
+ 'set_featured_image' => __( 'Set featured image', 'sc' ),
44
+ 'remove_featured_image' => __( 'Remove featured image', 'sc' ),
45
+ 'use_featured_image' => __( 'Use as featured image', 'sc' ),
46
+ 'insert_into_item' => __( 'Insert into shortcode', 'sc' ),
47
+ 'uploaded_to_this_item' => __( 'Uploaded to this shortcode', 'sc' ),
48
+ 'items_list' => __( 'Shortcodes list', 'sc' ),
49
+ 'items_list_navigation' => __( 'Shortcodes list navigation', 'sc' ),
50
+ 'filter_items_list' => __( 'Filter shortcodes list', 'sc' ),
51
+ );
52
+
53
+ $args = array(
54
+ 'label' => __( 'Shortcode', 'sc' ),
55
+ 'labels' => $labels,
56
+ 'supports' => false,
57
+ 'taxonomies' => array( 'sc_tag' ),
58
+ 'hierarchical' => false,
59
+ 'public' => false,
60
+ 'show_ui' => true,
61
+ 'show_in_menu' => true,
62
+ 'menu_position' => 25,
63
+ 'menu_icon' => '',
64
+ 'show_in_admin_bar' => true,
65
+ 'show_in_nav_menus' => true,
66
+ 'can_export' => true,
67
+ 'has_archive' => false,
68
+ 'exclude_from_search' => true,
69
+ 'publicly_queryable' => false,
70
+ 'show_in_rest' => false,
71
+ 'map_meta_cap' => true,
72
+ 'capability_type' => 'shortcoder',
73
+ );
74
+
75
+ register_post_type( SC_POST_TYPE, $args );
76
+
77
+ }
78
+
79
+ public static function register_taxonomy(){
80
+
81
+ $labels = array(
82
+ 'name' => _x( 'Tags', 'Taxonomy General Name', 'sc' ),
83
+ 'singular_name' => _x( 'Tag', 'Taxonomy Singular Name', 'sc' ),
84
+ 'menu_name' => __( 'Tags', 'sc' ),
85
+ 'all_items' => __( 'All Tags', 'sc' ),
86
+ 'parent_item' => __( 'Parent Tag', 'sc' ),
87
+ 'parent_item_colon' => __( 'Parent Tag:', 'sc' ),
88
+ 'new_item_name' => __( 'New Tag Name', 'sc' ),
89
+ 'add_new_item' => __( 'Add New Tag', 'sc' ),
90
+ 'edit_item' => __( 'Edit Tag', 'sc' ),
91
+ 'update_item' => __( 'Update Tag', 'sc' ),
92
+ 'view_item' => __( 'View Tag', 'sc' ),
93
+ 'separate_items_with_commas' => __( 'Separate tags with commas', 'sc' ),
94
+ 'add_or_remove_items' => __( 'Add or remove tags', 'sc' ),
95
+ 'choose_from_most_used' => __( 'Choose from the most used', 'sc' ),
96
+ 'popular_items' => __( 'Popular Tags', 'sc' ),
97
+ 'search_items' => __( 'Search Tags', 'sc' ),
98
+ 'not_found' => __( 'Not Found', 'sc' ),
99
+ 'no_terms' => __( 'No tags', 'sc' ),
100
+ 'items_list' => __( 'Tags list', 'sc' ),
101
+ 'items_list_navigation' => __( 'Tags list navigation', 'sc' ),
102
+ );
103
+ $args = array(
104
+ 'labels' => $labels,
105
+ 'hierarchical' => false,
106
+ 'public' => false,
107
+ 'show_ui' => true,
108
+ 'show_admin_column' => true,
109
+ 'show_in_nav_menus' => false,
110
+ 'show_tagcloud' => false,
111
+ 'show_in_rest' => false,
112
+ );
113
+
114
+ register_taxonomy( 'sc_tag', array( SC_POST_TYPE ), $args );
115
+
116
+ }
117
+
118
+ public static function is_sc_admin_page(){
119
+
120
+ $screen = get_current_screen();
121
+
122
+ if( $screen && $screen->post_type == SC_POST_TYPE ){
123
+ return true;
124
+ }else{
125
+ return false;
126
+ }
127
+
128
+ }
129
+
130
+ public static function inline_js_variables(){
131
+
132
+ return array(
133
+ 'sc_version' => SC_VERSION,
134
+ 'ajax_url' => get_admin_url() . 'admin-ajax.php',
135
+ 'screen' => get_current_screen(),
136
+ 'text_editor_switch_notice' => __( 'Switching editor will refresh the page. Please save your changes before refreshing. Do you want to refresh the page now ?', 'sc' )
137
+ );
138
+
139
+ }
140
+
141
+ public static function enqueue_scripts( $hook ){
142
+
143
+ wp_enqueue_style( 'sc-icon-css', SC_ADMIN_URL . 'css/menu-icon.css', array(), SC_VERSION );
144
+
145
+ if( !self::is_sc_admin_page() ){
146
+ return false;
147
+ }
148
+
149
+ wp_enqueue_style( 'sc-admin-css', SC_ADMIN_URL . 'css/style.css', array(), SC_VERSION );
150
+
151
+ wp_enqueue_script( 'jquery' );
152
+ wp_enqueue_script( 'sc-admin-js', SC_ADMIN_URL . 'js/script.js', array( 'jquery' ), SC_VERSION );
153
+
154
+ wp_localize_script( 'sc-admin-js', 'SC_VARS', self::inline_js_variables() );
155
+
156
+ }
157
+
158
+ public static function admin_ajax(){
159
+
160
+ $g = self::clean_get();
161
+ $do = $g[ 'do' ];
162
+
163
+ if( $do == 'close_changelog' ){
164
+ update_option( 'shortcoder_last_changelog', SC_VERSION );
165
+ echo 'done';
166
+ }
167
+
168
+ die( 0 );
169
+
170
+ }
171
+
172
+ public static function changelog(){
173
+
174
+ if( !self::is_sc_admin_page() ){
175
+ return false;
176
+ }
177
+
178
+ $last_changelog = get_option( 'shortcoder_last_changelog' );
179
+
180
+ if( $last_changelog && version_compare( $last_changelog, SC_VERSION, '>=' ) ){
181
+ return false;
182
+ }
183
+
184
+ $response = wp_remote_get( 'https://vaakash.github.io/misc/shortcoder/changelogs/' . SC_VERSION . '.html' );
185
+ $changelog = false;
186
+
187
+ if( !is_wp_error( $response ) && $response[ 'response' ][ 'code' ] == 200 ){
188
+ $changelog = wp_remote_retrieve_body( $response );
189
+ }
190
+
191
+ if( !$changelog ){
192
+ update_option( 'shortcoder_last_changelog', SC_VERSION );
193
+ return false;
194
+ }
195
+
196
+ echo '<div class="sc_changelog"><main>
197
+ <article>' . $changelog . '</article>
198
+ <footer><button href="#" class="button button-primary dismiss_btn">' . __( 'Continue using Shortcoder', 'sc' ) . '</a></footer>
199
+ </main></div>';
200
+
201
+ }
202
+
203
+ public static function clean_get(){
204
+
205
+ foreach( $_GET as $k => $v ){
206
+ $_GET[$k] = sanitize_text_field( $v );
207
+ }
208
+
209
+ return $_GET;
210
+ }
211
+
212
+ }
213
+
214
+ SC_Admin::init();
215
+
216
+ ?>
admin/css/menu-icon.css ADDED
@@ -0,0 +1 @@
 
1
+ @font-face{font-family:shortcoder;src:url(../font/shortcoder.eot);src:url(../font/shortcoder.eot?#iefix) format("embedded-opentype"),url(../font/shortcoder.ttf) format("truetype"),url(../font/shortcoder.woff) format("woff"),url(../font/shortcoder.svg#shortcoder) format("svg");font-weight:400;font-style:normal}#menu-posts-shortcoder div.wp-menu-image:before{font-family:shortcoder!important;content:"\e900"}
admin/css/style-insert.css CHANGED
@@ -1,127 +1,25 @@
 
 
 
1
  body{
2
- font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
3
  color: #444;
4
- padding: 0 10px 10px 10px;
5
- background: #f1f1f1;
6
- }
7
- h2{
8
- font-size: 23px;
9
- font-weight: normal;
10
- }
11
- h4{
12
- margin: 0 0 20px 0;
13
- }
14
- hr{
15
- border-width: 0px;
16
- margin: 15px 0;
17
- border-bottom: 1px solid #DFDFDF;
18
- }
19
- .sc_wrap{
20
- border: 1px solid #DFDFDF;
21
- box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
22
- }
23
- .sc_head{
24
- background: url(../images/shortcoder.png) no-repeat left 2px;
25
- padding-left: 40px;
26
- background-size: 32px;
27
- }
28
- .sc_shortcode{
29
- border-bottom: 1px solid #CCC;
30
- padding: 0px;
31
- background: #FFF;
32
- }
33
- .sc_shortcode:last-child{
34
- border:0;
35
- }
36
- .sc_shortcode_name{
37
- cursor: pointer;
38
- padding: 10px 10px 10px 35px;
39
- position: relative;
40
- }
41
- .sc_shortcode_name:hover{
42
- background: #fffeea;
43
- }
44
- .sc_params{
45
- border: 1px solid #DFDFDF;
46
- background: #F9F9F9;
47
- margin: 0 -1px -1px;
48
  padding: 20px;
49
- display: none;
50
- box-shadow: inset 0 2px 6px -5px;
51
- position: relative;
52
- }
53
- .sc_params label {
54
- flex-basis: 33%;
55
- line-height: 1;
56
- font-size: 14px;
57
- padding: 10px;
58
- box-sizing: border-box;
59
- }
60
- .sc_params:before {
61
- content: '';
62
- position: absolute;
63
- border: 12px solid;
64
- border-color: #bbb transparent transparent transparent;
65
- top: 0px;
66
- left: 12px;
67
- }
68
- .sc_params:after {
69
- content: '';
70
- position: absolute;
71
- border: 12px solid;
72
- border-color: #fff transparent transparent transparent;
73
- top: -1px;
74
- left: 12px;
75
- }
76
- .sc_params_wrap{
77
- display: flex;
78
- flex-wrap: wrap;
79
  }
80
-
81
- .sc_insert:hover{
82
- opacity: 0.8;
83
  }
84
- .sc_wrap input[type=text]{
85
  padding: 5px;
86
  border: 1px solid #CCC;
87
- margin: 10px 25px 0 0px;
88
- display: block;
89
- width: 100%;
90
- }
91
- .sc_toggle{
92
- background: url(../images/toggle-arrow.png) no-repeat;
93
- width: 16px;
94
- height: 16px;
95
- position: absolute;
96
- left: 15px;
97
- top: 50%;
98
- margin-top: -6px;
99
- opacity: 0.4;
100
- }
101
-
102
- .sc_options{
103
- position: absolute;
104
- right: 10px;
105
- top: 7px;
106
  }
107
- .sc_options .button{
108
- background: transparent;
109
- border: 1px solid transparent;
110
- color: #888;
111
- font-size: 11px;
112
- vertical-align: middle;
113
- margin-left: -1px;
114
- border-radius: 0;
115
  }
116
- .sc_options .button:hover{
117
- box-shadow: 0 1px 4px -3px #333;
118
- color: #333;
119
- background-color: #fff;
120
- }
121
- .sc_shortcode:hover .sc_options .button{
122
- border-color: #607D8B;
123
- }
124
-
125
  .button{
126
  display: inline-block;
127
  text-decoration: none;
@@ -131,123 +29,191 @@ hr{
131
  margin: 0;
132
  padding: 0 10px 1px;
133
  cursor: pointer;
134
- border-width: 1px;
135
- border-style: solid;
136
- -webkit-appearance: none;
137
- -webkit-border-radius: 3px;
138
  border-radius: 3px;
139
  white-space: nowrap;
140
- -webkit-box-sizing: border-box;
141
- -moz-box-sizing: border-box;
142
  box-sizing: border-box;
 
 
 
 
 
143
  }
144
- .button.button-primary{
145
  background: #0085ba;
146
  border-color: #0073aa #006799 #006799;
147
- -webkit-box-shadow: 0 1px 0 #006799;
148
  box-shadow: 0 1px 0 #006799;
149
  color: #fff;
150
  text-decoration: none;
151
  text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
152
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
 
154
- .disabled_text{
155
- font-size: 10px;
156
- background: #ffdfdd;
157
- border-radius: 10px;
158
- padding: 2px 10px;
159
- margin: 0 0 0 10px;
160
- color: #F44336;
161
  }
162
 
163
- .sc_menu{
164
- margin: 0 0 1em 0;
 
165
  }
166
- .sc_menu .button{
167
- border: 1px solid #cecece;
168
- color: #333;
169
- opacity: 0.8;
170
- margin: 0 5px 0 0;
171
  }
172
- .sc_menu .button:hover{
173
- opacity: 1;
174
  }
175
-
176
- .search_box{
177
- width: 150px;
178
- cursor: auto;
 
179
  }
180
 
181
- .sc_tags {
182
- padding: 0.75em 0 0 0;
183
- background: #ffffff8a;
184
- border: 1px solid #dfdfdf;
185
- border-radius: 3px;
186
  display: none;
187
  }
188
- .sc_tags li {
189
- float: left;
190
- list-style: none;
191
- margin: 0;
192
- font-size: 13px;
193
- margin: 0 1em 1em 1em;
194
- color: #287aa0;
195
- font-weight: bold;
196
- cursor: pointer;
197
  }
198
- .sc_tags li.active{
199
- opacity: 0.5;
200
  }
201
- .sc_tags li:hover{
202
- color: #333;
 
 
203
  }
204
 
205
- .sc_tags_disp {
206
- font-size: 13px;
207
- margin: 0;
208
- border-right: 1px solid #dfdfdf;
209
- padding: 0 10px 0 0;
210
- color: #888;
211
  }
212
 
213
- .coffee_box{
214
- padding: 10px;
215
- border: 1px solid #4CAF50;
216
- padding-left: 20%;
217
- background: url(../images/coffee.svg) no-repeat;
218
- border-radius: 3px;
219
- background-position: 30px center;
220
- margin: 30px 0 15px 0;
221
- background-size: 84px;
222
  }
223
- .coffee_box .coffee_amt {
224
- width: 120px;
225
- padding: 5px;
226
- height: auto;
227
- font-size: 1.5em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  }
229
- .coffee_amt_wrap{
230
  float: right;
231
- margin: 0 30px;
232
  }
233
- .coffee_box h3{
234
- margin: 5px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  font-weight: normal;
 
 
236
  }
237
- .coffee_box p{
238
- font-size: 13px;
 
 
 
 
 
 
 
 
 
239
  }
240
- .clearfix:after{
241
- clear: both;
242
- content: ".";
243
- display: block;
244
- height: 0;
245
- visibility: hidden;
246
- font-size: 0;
247
  }
248
 
249
- @media screen and (max-width: 750px){
250
- .sc_params label {
251
- flex-basis: 50%;
252
- }
 
 
 
 
 
 
253
  }
1
+ *{
2
+ box-sizing: border-box;
3
+ }
4
  body{
 
5
  color: #444;
6
+ font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
7
+ font-size: 13px;
8
+ line-height: 1.4em;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  padding: 20px;
10
+ margin: 0;
11
+ background: #f7f7f7;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
+ p, h3, h4 {
14
+ margin: 0;
 
15
  }
16
+ input[type="text"], input[type="search"]{
17
  padding: 5px;
18
  border: 1px solid #CCC;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  }
20
+ a {
21
+ color: #0073aa;
 
 
 
 
 
 
22
  }
 
 
 
 
 
 
 
 
 
23
  .button{
24
  display: inline-block;
25
  text-decoration: none;
29
  margin: 0;
30
  padding: 0 10px 1px;
31
  cursor: pointer;
32
+ border: 1px solid;
 
 
 
33
  border-radius: 3px;
34
  white-space: nowrap;
 
 
35
  box-sizing: border-box;
36
+ color: #555;
37
+ border-color: #ccc;
38
+ background: #f7f7f7;
39
+ box-shadow: 0 1px 0 #ccc;
40
+ vertical-align: top
41
  }
42
+ .button-primary {
43
  background: #0085ba;
44
  border-color: #0073aa #006799 #006799;
 
45
  box-shadow: 0 1px 0 #006799;
46
  color: #fff;
47
  text-decoration: none;
48
  text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799, -1px 0 1px #006799;
49
  }
50
+ p .button {
51
+ vertical-align: baseline
52
+ }
53
+ .button:focus, .button:hover {
54
+ background: #fafafa;
55
+ border-color: #999;
56
+ color: #23282d
57
+ }
58
+ .button:focus {
59
+ border-color: #5b9dd9;
60
+ box-shadow: 0 0 3px rgba(0,115,170,.8)
61
+ }
62
+ .button:active {
63
+ background: #eee;
64
+ border-color: #999;
65
+ box-shadow: inset 0 2px 5px -3px rgba(0,0,0,.5);
66
+ transform: translateY(1px)
67
+ }
68
+ .button-primary:hover, .button-primary:focus {
69
+ background: #008ec2;
70
+ border-color: #006799;
71
+ color: #fff;
72
+ }
73
 
74
+ .sc_menu {
75
+ margin: 0 0 20px 0;
 
 
 
 
 
76
  }
77
 
78
+ .sc_list {
79
+ background: #fff;
80
+ box-shadow: 0 1px 3px 0px rgba(0, 0, 0, 0.2);
81
  }
82
+ .sc_wrap {
83
+ border-bottom: 1px solid #eee;
84
+ overflow: hidden;
 
 
85
  }
86
+ .sc_wrap:last-child{
87
+ border-bottom: none;
88
  }
89
+ .sc_wrap:hover .sc_tools{
90
+ display: block;
91
+ }
92
+ .sc_wrap.open .sc_head img{
93
+ transform: rotate(180deg);
94
  }
95
 
96
+ .sc_options{
97
+ padding: 15px 15px 10px 15px;
98
+ background: #fcfcfc;
 
 
99
  display: none;
100
  }
101
+ .sc_options > *{
102
+ margin-bottom: 20px;
 
 
 
 
 
 
 
103
  }
104
+ .sc_options > *:last-child{
105
+ margin-bottom: 0;
106
  }
107
+
108
+ .sc_params_wrap {
109
+ display: flex;
110
+ flex-wrap: wrap;
111
  }
112
 
113
+ .sc_params_wrap label {
114
+ flex-basis: 33%;
115
+ padding: 0 10px 10px 0;
 
 
 
116
  }
117
 
118
+ .sc_params_wrap label input {
119
+ display: block;
120
+ width: 100%;
121
+ margin: 10px 25px 0 0px;
 
 
 
 
 
122
  }
123
+
124
+ .sc_head {
125
+ padding: 15px;
126
+ cursor: pointer;
127
+ position: relative;
128
+ box-shadow: 0 1px 5px -3px rgba(0, 0, 0, 0.5);
129
+ }
130
+ .sc_head:hover {
131
+ background: lightyellow;
132
+ }
133
+ .sc_head h3{
134
+ display: inline-block;
135
+ }
136
+ .sc_head img{
137
+ vertical-align: middle;
138
+ margin-right: 10px;
139
+ transition: transform 0.8s;
140
+ }
141
+ .sc_tools{
142
+ position: absolute;
143
+ top: 10px;
144
+ right: 10px;
145
+ display: none;
146
+ }
147
+ .sc_tools .button{
148
+ margin-left: 10px;
149
+ }
150
+
151
+ .sc_foot {
152
+ padding: 0 0 10px 0;
153
+ }
154
+ .sc_foot:after{
155
+ content: '';
156
+ clear: both;
157
+ display: block;
158
  }
159
+ .sc_foot .sc_insert{
160
  float: right;
 
161
  }
162
+
163
+ .sc_note{
164
+ padding: 15px;
165
+ text-align: center;
166
+ }
167
+ .sc_search_none{
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
+ /** Footer **/
210
+ .footer_thanks {
211
+ margin: 20px 0 0 0;
212
+ font-style: italic;
213
+ }
214
+ .footer_thanks a{
215
+ text-decoration: none;
216
+ }
217
+ .footer_thanks a:hover{
218
+ text-decoration: underline;
219
  }
admin/css/style-tools.css ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #sci_bg{
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ background: rgba(0, 0, 0, 0.5);
8
+ z-index: 99999;
9
+ }
10
+
11
+ #sci_popup {
12
+ position: fixed;
13
+ z-index: 99999;
14
+ background: #fff;
15
+ top: 50px;
16
+ bottom: 50px;
17
+ left: 25%;
18
+ right: 25%;
19
+ border: 1px solid #dfdfdf;
20
+ box-shadow: 0 0 9px -4px;
21
+ display: flex;
22
+ flex-wrap: nowrap;
23
+ flex-direction: column;
24
+ }
25
+
26
+ #sci_popup iframe {
27
+ height: 100%;
28
+ background: #fff;
29
+ }
30
+
31
+ #sci_popup header {
32
+ position: relative;
33
+ padding: 10px 20px;
34
+ border-bottom: 1px solid #eee;
35
+ }
36
+ #sci_title{
37
+ background: url(../images/shortcoder.svg) no-repeat;
38
+ background-size: 16px;
39
+ padding-left: 28px;
40
+ background-position: left center;
41
+ }
42
+ #sci_close{
43
+ position: absolute;
44
+ right: 0;
45
+ top: 0;
46
+ bottom: 0;
47
+ width: 40px;
48
+ border-left: 1px solid #eee;
49
+ cursor: pointer;
50
+ }
51
+ #sci_close:hover{
52
+ background: #fafafa;
53
+ }
54
+ #sci_close > .dashicons {
55
+ position: absolute;
56
+ top: 50%;
57
+ left: 50%;
58
+ margin: -10px 0 0 -10px;
59
+ }
admin/css/style.css CHANGED
@@ -1,302 +1,80 @@
1
- .wrap{
2
- max-width: 1000px;
3
- margin: 0 auto;
 
 
4
  }
5
 
6
- h1.sc_title {
7
- background: url(../images/shortcoder.png) no-repeat left;
8
- background-size: 32px 32px;
9
- padding-left: 40px;
10
- padding-bottom: 9px;
11
- }
12
- h1.sc_title .title-count {
13
- font-size: 10px;
14
- padding: 2px 8px;
15
- opacity: 0.7;
16
- }
17
- .head_wrap {
18
- padding: 15px 0;
19
  position: relative;
20
  }
21
-
22
- #content{
23
- background: #fff;
24
- padding: 20px;
25
- border: 1px solid #dfdfdf;
26
- border-radius: 3px;
27
- box-shadow: 0 0 4px -3px;
 
 
28
  }
29
 
30
- .page_title {
31
- border-bottom: 1px solid #dfdfdf;
32
- margin: -20px -20px 20px -20px;
33
- padding: 1em;
34
- background: #fafafa;
35
- position: relative;
36
- }
37
-
38
- .sc_list {
39
- margin: -20px 0;
40
- position: relative;
41
- counter-reset: sccounter;
42
  }
43
- .sc_list > li {
44
- margin: 0;
45
- position: relative;
46
- counter-increment: sccounter;
47
- }
48
- .sc_list li a {
49
- text-decoration: none;
50
- }
51
- .sc_list > li .sc_link {
52
- display: block;
53
- margin: 0 -20px;
54
- padding: 15px;
55
- border-bottom: 1px solid #dfdfdf;
56
- font-size: 17px;
57
- padding-left: 65px;
58
- }
59
- .sc_list > li:last-child .sc_link{
60
- border-bottom: 0;
61
- }
62
- .sc_list > li:before {
63
- content: counter(sccounter);
64
- position: absolute;
65
- left: 0;
66
- top: 50%;
67
- border-right: 1px solid #dfdfdf;
68
- padding-right: 15px;
69
- margin-top: -10px;
70
- color: #666;
71
- }
72
- .sc_link:hover{
73
- background: #fffeea;
74
- }
75
- .sc_link:hover:after {
76
- font-family: dashicons;
77
- content: "\f464";
78
- font-size: 15px;
79
- position: absolute;
80
- margin-left: 10px;
81
- }
82
- .sc_controls {
83
- position: absolute;
84
- top: 5px;
85
- right: 0;
86
  }
87
- .sc_list .sc_controls a {
88
- padding: 8px;
89
- border-radius: 50%;
90
- margin: 0 0 0 15px;
91
- border: 1px solid transparent;
92
  display: inline-block;
93
  }
94
- .sc_list .sc_controls a:hover{
95
- border: 1px solid #dfdfdf;
96
- }
97
-
98
- .sc_list .sc_delete:hover{
99
- border-color: red;
100
- color: red;
101
- }
102
 
103
- .sc_list:empty:before {
104
- content: attr( data-empty );
105
- position: absolute;
106
- left: 0;
107
- right: 0;
108
- text-align: center;
109
- font-style: italic;
110
- top: 25px;
111
- }
112
- .sc_list:empty {
113
- height: 70px;
114
- }
115
- .spin{
116
- animation: spin infinite 1s;
117
- }
118
- .sc_copy_box {
119
- position: absolute;
120
- top: 0px;
121
- font-size: 19px;
122
- width: 91%;
123
- padding: 10px;
124
- left: -20px;
125
- display: none;
126
- cursor: copy;
127
- background: #f9f9f9 !important;
128
- box-shadow: none !important;
129
- text-align: center;
130
- border: none !important;
131
- bottom: 0;
132
  }
133
- .sc_list .disabled_text{
134
- font-size: 10px;
135
- background: #ffdfdd;
136
- border-radius: 10px;
137
- padding: 2px 10px;
138
- margin: 0 0 0 10px;
139
- color: #F44336;
140
  }
141
 
142
- .sc_tags_list {
143
- display: inline-block;
144
- vertical-align: middle;
145
  position: relative;
 
146
  }
147
- .sc_tags_list li {
148
- float: left;
149
- background: transparent;
150
- padding: 0.5em;
151
  border-radius: 3px;
152
- margin-left: 0.75em;
153
- color: #717171;
154
- /*box-shadow: 0 1px 2px -1px;*/
155
- cursor: pointer;
156
  }
157
- .sc_tags_list li:hover {
158
- box-shadow: 0 1px 2px -1px;
159
- background: #fff;
160
- }
161
- .sc_tags_list:before {
162
- content: "\f323";
163
  font-family: Dashicons;
164
  position: absolute;
165
- left: -15px;
166
- top: 10px;
167
- color: #9c9c9c;
168
- }
169
-
170
-
171
- .sc_tags_filt_btn{
172
- padding: 0 !important;
173
- }
174
- .sc_tags_filt_btn .sc_tags_filt_icon{
175
- padding: 0 10px;
176
- }
177
- .sc_tags_filt_btn.active .sc_tags_filt_icon{
178
- padding: 0 5px;
179
- }
180
- .sc_tags_filt_btn:active, .sc_tags_filt_btn.active{
181
- transform: none !important;
182
- }
183
- .sc_tags_filt_btn.active .sc_tags_filter_wrap{
184
- display: inline-block;
185
- }
186
- .sc_tags_filter_wrap{
187
- width: 260px;
188
- display: none;
189
- }
190
- .sc_tags_filter_wrap .selectize-input{
191
- height: 26px;
192
- padding: 2px !important;
193
- border-radius: 0 3px 3px 0;
194
- border: none;
195
- border-left: 1px solid #dfdfdf;
196
- }
197
- .sc_tags_filter_wrap .selectize-control{
198
- margin: 0;
199
- text-align: left;
200
- }
201
- .sc_tags_filter_wrap .item{
202
- background: #e1f6ff !important;
203
- color: #2196F3 !important;
204
- font-size: 10px;
205
- }
206
- .sc_tags_filter_wrap .item:hover{
207
- opacity: 0.5;
208
- }
209
- .sc_tags_filter_wrap .item.active{
210
- color: red !important;
211
- background: #ffe1e1 !important;
212
- }
213
-
214
- .sc_copy_field {
215
- font-family: "Courier New", serif;
216
- background: transparent !important;
217
- border: none !important;
218
- box-shadow: none !important;
219
- font-size: 13px;
220
- padding: 0 !important;
221
- cursor: text;
222
- margin: 0 !important;
223
- }
224
- .sc_copy_field:readonly{
225
- color: #000;
226
- }
227
-
228
- .sc_menu{
229
- position: absolute;
230
- top: 10px;
231
- right: 20px;
232
- }
233
- .sc_menu > *{
234
- margin-left: 10px !important;
235
- }
236
-
237
- #content .button .dashicons{
238
- margin: 0.5em 0 0 0;
239
- font-size: 15px;
240
- }
241
-
242
- .sc_section{
243
- margin: 0 0 20px 0;
244
- }
245
- .sc_section label{
246
- display: block;
247
- margin: 0 0 10px 0;
248
- }
249
- .sc_section label select{
250
- font-size: 12px;
251
- margin-top: 10px;
252
- }
253
-
254
- .sc_settings {
255
- display: flex;
256
- flex-wrap: wrap;
257
- }
258
- .sc_settings .sc_section {
259
- flex: 1;
260
- margin-bottom: 0;
261
  }
262
-
263
- #sc_name{
264
- padding: 10px;
265
  }
266
- .sc_name_wrap {
267
- position: relative;
268
  }
269
-
270
- .sc_name_wrap > .copy_shortcode {
271
- position: absolute;
272
- top: 1px;
273
- right: 1px;
274
- bottom: 1px;
275
- padding: 10px;
276
- border-left: 1px solid #d0d0d0;
277
- background: rgba(255, 255, 255, 0.5);
278
  }
279
 
280
- .page_footer{
281
- margin: 30px -20px -20px -20px;
282
- background: #f7f7f7;
283
- padding: 20px;
284
- border-top: 1px solid #dfdfdf;
285
- border-radius: 0 0 5px 5px;
286
- }
287
- .page_footer .sc_delete_ep{
288
- float: right;
289
- }
290
- .page_footer .sc_delete_ep:hover{
291
- color: red;
292
  }
293
-
294
- .wrap .notice{
295
- margin-bottom: 0;
296
  }
297
 
298
- .params_wrap{
299
- box-shadow: 0 3px 5px rgba(0,0,0,.2);
300
  border: 1px solid #dfdfdf;
301
  margin: 0;
302
  position: absolute;
@@ -304,324 +82,251 @@ h1.sc_title .title-count {
304
  background: #fff;
305
  z-index: 9999;
306
  }
307
- .params_wrap li{
308
  position: relative;
309
  background: #fff;
310
  margin: 0;
311
- padding: 7px 10px;
312
  width: 200px;
313
- border-bottom: 1px solid #dfdfdf;
314
  cursor: pointer;
315
  }
316
- .params_wrap li:hover{
317
  background: lightyellow;
318
  }
319
- .params_wrap > li:after{
 
 
 
320
  position: absolute;
321
  font-family: dashicons;
322
  content: "\f139";
323
  right: 5px;
324
- top: 7px;
325
  }
326
- .params_wrap li:last-child{
327
  border: 0;
328
  }
329
- .params_wrap li ul{
330
  background: #fff;
331
  position: absolute;
332
  display: none;
333
  top: 0;
334
  left: 100%;
335
- box-shadow: 0 3px 5px rgba(0,0,0,.2);
336
  border: 1px solid #dfdfdf;
337
  z-index: 9999;
338
  max-height: 300px;
339
  overflow: auto;
340
  }
341
- .params_wrap li:hover ul{
342
  display: block;
343
  }
344
 
345
- .params_wrap .isc_form{
346
  cursor: auto;
347
  width: 330px;
348
  }
349
- .isc_form h4{
350
- margin: 0 0 15px 0;
351
- }
352
- .isc_info{
353
- margin: 5px 0;
354
- }
355
- .isc_info.red{
356
- color: red;
357
- }
358
-
359
- .top_sharebar{
360
  position: absolute;
361
- right: 0;
362
- top: 24px;
363
- }
364
- .top_sharebar > * {
365
- vertical-align: middle;
366
- margin-left: 10px;
367
- float: right;
368
  }
369
- .share_text {
370
- font-size: 10px;
371
- text-align: right;
372
- line-height: 1.5;
373
- margin-right: 5px;
374
- color: #838383;
375
  }
376
- .share_btn{
377
- background: #333;
378
- color: #fff;
379
- text-decoration: none;
380
- padding: 2px 10px;
381
- border-radius: 2em;
382
- font-size: 12px;
383
- line-height: 2em;
384
  }
385
- .share_btn:hover{
386
- opacity: 0.5;
387
- color: #fff;
388
  }
389
- .share_btn:active, .share_btn:focus{
390
- color: #fff;
391
  }
392
- .share_btn .dashicons {
393
- font-size: 14px;
394
- margin: 5px 2px 0 0;
395
- height: 14px;
396
  }
397
- .share_btn.twitter{
398
- background-color: #2196F3;
 
399
  }
400
- .share_btn.googleplus{
401
- background-color: #dd4b39;
 
 
 
402
  }
403
- .share_btn.rate_btn .dashicons{
404
- color: #FF9800;
 
405
  }
406
 
407
- .coffee_box{
408
- padding: 15px 15px 25px 15px;
409
- border: 1px solid #4CAF50;
410
- padding-left: 18%;
411
- background: url(../images/coffee.svg) no-repeat;
412
- border-radius: 3px;
413
- background-position: 30px center;
414
- margin: 30px 0 15px 0;
415
- background-size: 84px;
416
- }
417
- .coffee_box .coffee_amt {
418
- width: 120px;
419
- padding: 5px;
420
- height: auto;
421
- font-size: 1.5em;
422
- }
423
- .coffee_amt_wrap{
424
- float: right;
425
- margin: 0 30px;
426
- }
427
- .credits_box{
428
- font-size: 12px;
429
- font-style: italic;
430
- color: #757575;
431
  }
432
- .credits_box img {
433
- vertical-align: middle;
434
- margin-right: 5px;
 
435
  }
436
 
437
- #import_form{
438
  display: none;
439
  }
440
- .search_btn .search_box{
441
  display: none;
442
  }
443
- .search_btn.active .search_box{
444
- display: inline;
445
  }
446
- .search_box{
447
- height: 26px;
448
- border: 0;
449
- margin: 0 -10px 0 10px;
450
- border-left: 1px solid #ccc;
451
- border-radius: 0 3px 3px 0;
452
  }
453
- .search_btn .dashicons-search{
454
- position: relative;
 
 
 
455
  }
456
- .search_btn.filtered .dashicons-search{
457
- color: #f44336;
 
 
 
458
  }
459
- .search_empty_msg{
460
- margin: 40px 0 20px 0;
461
  }
462
-
463
- .sc_note{
464
- background: #fffbdc;
465
- padding: 10px;
466
- color: #965400;
467
- border-radius: 5px;
468
- position: relative;
469
- padding-left: 50px;
470
- box-shadow: 0 2px 1px -2px;
471
- display: none;
472
  }
473
- .sc_note:before {
474
- content: "\f348";
475
- font-family: dashicons;
476
- position: absolute;
477
- left: 15px;
478
- font-size: 25px;
479
- opacity: 0.8;
480
- top: 12px;
481
  }
482
- .sc_note_btn {
483
- margin: 0 0 0 5px;
484
- font-size: 15px;
485
- height: 15px;
486
- vertical-align: middle;
487
  }
488
 
489
- .sc_editor_list {
490
- position: relative;
491
- display: inline-block;
 
 
 
 
 
 
492
  }
493
- .sc_editor_list select{
494
- padding: 0 30px !important;
 
 
 
 
 
 
 
 
 
495
  }
496
- .sc_editor_list:before {
497
- font-family: Dashicons;
498
- position: absolute;
499
- left: 10px;
500
- top: 6px;
501
  }
502
- .sc_editor_icon_text:before{
503
- content: "\f215";
 
 
 
 
 
504
  }
505
- .sc_editor_icon_visual:before{
506
- content: "\f177";
 
507
  }
508
- .sc_editor_icon_code:before{
509
- content: "\f475";
510
  }
511
- .sc_editor_list:after{
512
- font-family: Dashicons;
513
- content: "\f140";
514
- position: absolute;
515
- right: 25px;
516
- top: 15px;
517
- font-size: 15px;
518
- padding: 0;
519
- width: 0;
520
- height: 0;
521
- line-height: 0;
522
  }
523
-
524
- .sc_cm_menu .sc_editor_list{
525
- margin-left: 5px;
526
  }
527
 
528
- .rate_link{
529
- float: right;
 
 
530
  }
531
- .rate_link .dashicons{
532
- color: #e7711b;
533
- text-decoration: none;
534
- font-size: 13px;
535
  }
536
- .rate_link:hover .dashicons{
537
- text-decoration: underline;
538
  }
539
- .rate_link .dashicons {
540
- font-size: 12px;
541
- margin: 5px 0 0 0;
 
 
 
 
 
 
 
542
  }
543
 
544
- .help_link{
545
- margin-left: 10px;
546
- text-decoration: none;
547
  }
548
- .help_link .dashicons{
549
- font-size: 32px;
550
- width: 32px;
551
- height: 32px;
552
- color: #607D8B;
553
  }
554
- .help_link:hover .dashicons{
555
- color: #000;
556
  }
557
-
558
- .fright{
559
- float: right;
560
  }
561
-
562
- @keyframes spin {
563
- from {transform:rotate(0deg);}
564
- to {transform:rotate(360deg);}
565
  }
566
-
567
- .clearfix:after{
568
- clear: both;
569
- content: ".";
570
- display: block;
571
- height: 0;
572
- visibility: hidden;
573
- font-size: 0;
574
  }
575
-
576
- .CodeMirror{
577
- border: 1px solid #ccc;
578
- margin-top: 15px;
 
 
579
  }
580
 
581
- @media screen and (max-width: 950px) {
582
- .sc_settings {
583
- display: block;
584
- }
585
- .sc_settings .sc_section {
586
- margin-bottom: 20px;
587
- }
588
  }
589
-
590
- [tooltip]{
591
- margin: 20px 60px;
592
- position:relative;
593
- display:inline-block;
594
  }
595
- [tooltip]::before {
596
- content: "";
597
- position: absolute;
598
- top:-6px;
599
- left:50%;
600
- transform: translateX(-50%);
601
- border-width: 4px 6px 0 6px;
602
- border-style: solid;
603
- border-color: rgba(0,0,0,0.7) transparent transparent transparent;
604
- z-index: 99;
605
- opacity:0;
606
- }
607
- [tooltip]::after {
608
- content: attr(tooltip);
609
- position: absolute;
610
- left:50%;
611
- top:-6px;
612
- transform: translateX(-50%) translateY(-100%);
613
- background: rgba(0,0,0,0.7);
614
- text-align: center;
615
- color: #fff;
616
- padding: 2px 8px !important;
617
- font-size: 12px;
618
- min-width: 80px;
619
- border-radius: 5px;
620
- pointer-events: none;
621
- padding: 4px 4px;
622
- z-index:99;
623
- opacity:0;
624
- }
625
- [tooltip]:hover::after,[tooltip]:hover::before {
626
- opacity:1
627
  }
1
+ .wp-heading-inline small{
2
+ vertical-align: super;
3
+ font-size: 13px;
4
+ margin: 0 0 0 5px;
5
+ color: #888;
6
  }
7
 
8
+ #sc_name{
 
 
 
 
 
 
 
 
 
 
 
 
9
  position: relative;
10
  }
11
+ #sc_name #post_name{
12
+ padding: 3px 8px;
13
+ font-size: 1.7em;
14
+ line-height: 100%;
15
+ height: 1.7em;
16
+ width: 100%;
17
+ outline: 0;
18
+ margin: 0 0 3px;
19
+ background-color: #fff;
20
  }
21
 
22
+ .sc_preview_text{
23
+ background: #f1f1f1;
 
 
 
 
 
 
 
 
 
 
24
  }
25
+ .sc_copy .dashicons{
26
+ margin-top: 1.5px;
27
+ display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
+ .sc_copy.copied .dashicons{
 
 
 
 
30
  display: inline-block;
31
  }
 
 
 
 
 
 
 
 
32
 
33
+ .sc_editor_toolbar{
34
+ display: inline-block;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
+ .sc_cm_menu .sc_editor_toolbar > *{
37
+ margin-right: 5px;
 
 
 
 
 
38
  }
39
 
40
+ .sc_editor_list {
 
 
41
  position: relative;
42
+ display: inline-block;
43
  }
44
+ .sc_editor_list select {
45
+ padding: 0 25px 0 35px!important;
 
 
46
  border-radius: 3px;
 
 
 
 
47
  }
48
+ .sc_editor_list:before {
 
 
 
 
 
49
  font-family: Dashicons;
50
  position: absolute;
51
+ left: 10px;
52
+ top: 5px;
53
+ font-size: 20px;
54
+ color: #82878c;
55
+ line-height: 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
+ .sc_editor_icon_text:before{
58
+ content: "\f215";
 
59
  }
60
+ .sc_editor_icon_visual:before{
61
+ content: "\f177";
62
  }
63
+ .sc_editor_icon_code:before{
64
+ content: "\f475";
 
 
 
 
 
 
 
65
  }
66
 
67
+ .sc_insert_param .dashicons-plus{
68
+ margin-top: 5px;
69
+ margin-right: 5px;
 
 
 
 
 
 
 
 
 
70
  }
71
+ .sc_insert_param .dashicons-arrow-down{
72
+ margin-top: 3px;
73
+ margin-left: 5px;
74
  }
75
 
76
+ .sc_params_list{
77
+ box-shadow: 0 2px 5px -2px rgba(0,0,0,.2);
78
  border: 1px solid #dfdfdf;
79
  margin: 0;
80
  position: absolute;
82
  background: #fff;
83
  z-index: 9999;
84
  }
85
+ .sc_params_list li{
86
  position: relative;
87
  background: #fff;
88
  margin: 0;
89
+ padding: 10px;
90
  width: 200px;
91
+ border-bottom: 1px solid #e5e5e5;
92
  cursor: pointer;
93
  }
94
+ .sc_params_list li:hover{
95
  background: lightyellow;
96
  }
97
+ .sc_params_list > li{
98
+ padding-left: 40px;
99
+ }
100
+ .sc_params_list > li:after{
101
  position: absolute;
102
  font-family: dashicons;
103
  content: "\f139";
104
  right: 5px;
105
+ top: 10px;
106
  }
107
+ .sc_params_list li:last-child{
108
  border: 0;
109
  }
110
+ .sc_params_list li ul{
111
  background: #fff;
112
  position: absolute;
113
  display: none;
114
  top: 0;
115
  left: 100%;
116
+ box-shadow: 0 2px 5px -2px rgba(0,0,0,.2);
117
  border: 1px solid #dfdfdf;
118
  z-index: 9999;
119
  max-height: 300px;
120
  overflow: auto;
121
  }
122
+ .sc_params_list li:hover ul{
123
  display: block;
124
  }
125
 
126
+ .sc_params_list .isc_form{
127
  cursor: auto;
128
  width: 330px;
129
  }
130
+ .sc_params_list .dashicons {
 
 
 
 
 
 
 
 
 
 
131
  position: absolute;
132
+ left: 10px;
133
+ font-size: 15px;
134
+ top: 13px;
135
+ color: #555;
 
 
 
136
  }
137
+
138
+ .sc_params_form{
139
+ cursor: auto !important;
140
+ width: 330px;
 
 
141
  }
142
+ .sc_params_form h4{
143
+ margin: 0 0 15px 0;
 
 
 
 
 
 
144
  }
145
+ .sc_params_form p{
146
+ margin: 5px 0;
 
147
  }
148
+ .sc_params_form p.red{
149
+ color: red;
150
  }
151
+ .sc_params_form .button {
152
+ margin: 15px 0 5px 0;
 
 
153
  }
154
+
155
+ .sc_cm_menu {
156
+ margin: 15px 0 10px 0;
157
  }
158
+ .sc_cm_content{
159
+ height: 500px;
160
+ width: 100%;
161
+ font-size: 15px;
162
+ line-height: 1.75em;
163
  }
164
+ .CodeMirror {
165
+ border: 1px solid #e5e5e5;
166
+ line-height: 1.5em;
167
  }
168
 
169
+ #sc_mb_settings .form-table th{
170
+ width: 300px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  }
172
+
173
+ /* Modifying post edit page */
174
+ #edit-slug-buttons{
175
+ margin-left: 6px;
176
  }
177
 
178
+ #misc-publishing-actions #visibility{
179
  display: none;
180
  }
181
+ #misc-publishing-actions .misc-pub-post-status{
182
  display: none;
183
  }
184
+ #misc-publishing-actions a{
185
+ display: none;
186
  }
187
+ .misc-pub-curtime{
188
+ margin-bottom: 10px;
 
 
 
 
189
  }
190
+
191
+ /* Codemirror */
192
+
193
+ .cm-sc_param{
194
+ font-weight: bold;
195
  }
196
+
197
+ /* Coffee - metabox */
198
+ .cfe_mb .cfe_form, .cfe_mb .cfe_text{
199
+ display: flex;
200
+ flex-wrap: nowrap;
201
  }
202
+ .cfe_form{
203
+ margin-top: 1em;
204
  }
205
+ .cfe_form select{
206
+ width: 100%;
207
+ margin-right: 1em;
 
 
 
 
 
 
 
208
  }
209
+ .cfe_form .button{
210
+ text-align: center;
 
 
 
 
 
 
211
  }
212
+ .cfe_text img{
213
+ width: 48px;
214
+ margin-left: 1em;
 
 
215
  }
216
 
217
+ /** Changelog **/
218
+ .sc_changelog{
219
+ background: rgba(70, 50, 50, 0.3);
220
+ position: fixed;
221
+ top: 32px;
222
+ bottom: 0;
223
+ left: 0;
224
+ right: 0;
225
+ z-index: 999;
226
  }
227
+ .sc_changelog main{
228
+ margin: 0 auto;
229
+ background: #fff;
230
+ width: 50%;
231
+ padding: 25px;
232
+ z-index: 99999;
233
+ box-shadow: 0 0 8px 0px rgba(0, 0, 0, 0.5);
234
+ display: flex;
235
+ flex-direction: column;
236
+ height: 100%;
237
+ box-sizing: border-box;
238
  }
239
+ .sc_changelog article{
240
+ height: 100%;
241
+ overflow: auto;
242
+ padding: 0 15px;
 
243
  }
244
+ .sc_changelog footer {
245
+ bottom: 0;
246
+ left: 0;
247
+ right: 0;
248
+ padding-top: 25px;
249
+ border-top: 1px solid #dfdfdf;
250
+ text-align: center;
251
  }
252
+ .sc_changelog h2 {
253
+ font-size: 2em;
254
+ font-weight: normal;
255
  }
256
+ .sc_changelog h3 {
257
+ font-size: 1.75em;
258
  }
259
+ .sc_changelog p, .sc_changelog ul{
260
+ font-size: 1.25em;
261
+ line-height: 1.5;
 
 
 
 
 
 
 
 
262
  }
263
+ .sc_changelog ul{
264
+ list-style: disc;
265
+ padding-left: 1.5em;
266
  }
267
 
268
+ /** Coffee - Top link **/
269
+ .cfe_top_link{
270
+ float: left;
271
+ position: relative;
272
  }
273
+ #screen-meta-links .cfe_top_link a.show-settings{
274
+ padding-right: 35px !important;
275
+ background: #fff !important;
 
276
  }
277
+ .cfe_top_link a:after{
278
+ display: none !important;
279
  }
280
+ .cfe_top_link a:before{
281
+ content: '';
282
+ display: block;
283
+ position: absolute;
284
+ background: url('../images/coffee.svg') no-repeat;
285
+ background-size: 100%;
286
+ width: 20px;
287
+ height: 24px;
288
+ right: 10px;
289
+ top: 5px;
290
  }
291
 
292
+ /** Feedback **/
293
+ .feedback ul {
294
+ margin: -7px -12px -12px -12px;
295
  }
296
+ .feedback ul li{
297
+ margin: 0;
298
+ padding: 12px;
299
+ border-bottom: 1px solid #eee;
 
300
  }
301
+ .feedback ul li:last-child{
302
+ border-bottom: none;
303
  }
304
+ .feedback a{
305
+ text-decoration: none;
 
306
  }
307
+ .feedback a:hover{
308
+ text-decoration: underline;
 
 
309
  }
310
+ .stars {
311
+ display: inline-flex;
312
+ line-height: 1;
313
+ margin-left: 5px;
 
 
 
 
314
  }
315
+ .stars .dashicons{
316
+ font-size: 13px;
317
+ width: 13px;
318
+ margin-top: 4px;
319
+ height: 13px;
320
+ color: #FF9800;
321
  }
322
 
323
+ /** Footer **/
324
+ .footer_thanks{
325
+ font-style: italic;
 
 
 
 
326
  }
327
+ .footer_thanks a{
328
+ text-decoration: none;
 
 
 
329
  }
330
+ .footer_thanks a:hover{
331
+ text-decoration: underline;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  }
admin/edit.php ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class SC_Admin_Edit{
6
+
7
+ public static function init(){
8
+
9
+ add_action( 'edit_form_after_title', array( __class__, 'after_title' ) );
10
+
11
+ add_action( 'add_meta_boxes', array( __class__, 'add_meta_boxes' ) );
12
+
13
+ add_action( 'save_post_' . SC_POST_TYPE, array( __class__, 'save_post' ) );
14
+
15
+ add_filter( 'wp_insert_post_data' , array( __class__, 'before_insert_post' ) , '99', 1 );
16
+
17
+ add_action( 'admin_enqueue_scripts', array( __class__, 'enqueue_scripts' ) );
18
+
19
+ add_filter( 'admin_footer_text', array( __class__, 'footer_text' ) );
20
+
21
+ }
22
+
23
+ public static function after_title( $post ){
24
+
25
+ if( $post->post_type != SC_POST_TYPE ){
26
+ return;
27
+ }
28
+
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.', 'sc' ) . '" value="' . $post->post_name . '" name="post_name" id="post_name" pattern="[a-zA-z0-9\-_]+" required placeholder="' . __( 'Enter shortcode name', 'sc' ) . '" />';
33
+ echo '</div>';
34
+
35
+ echo '<div id="edit-slug-box">';
36
+ echo '<strong>' . __( 'Your shortcode', 'sc' ) . ': </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</button></span>';
39
+ echo '</div>';
40
+
41
+ // Editor
42
+ self::editor( $post, $settings );
43
+
44
+ // Hidden section
45
+ self::hidden_section( $post, $settings );
46
+
47
+ }
48
+
49
+ public static function add_meta_boxes(){
50
+
51
+ add_meta_box( 'sc_mb_settings', __( 'Shortcode settings', 'sc' ), array( __class__, 'settings_form' ), SC_POST_TYPE, 'normal', 'default' );
52
+
53
+ add_meta_box( 'sc_mb_coffee', __( 'Buy me a coffee !', 'sc' ), array( __class__, 'coffee_box' ), SC_POST_TYPE, 'side', 'default' );
54
+
55
+ add_meta_box( 'sc_mb_links', __( 'Feedback', 'sc' ), array( __class__, 'feedback' ), SC_POST_TYPE, 'side', 'default' );
56
+
57
+ remove_meta_box( 'slugdiv', SC_POST_TYPE, 'normal' );
58
+
59
+ }
60
+
61
+ public static function settings_form( $post ){
62
+
63
+ wp_nonce_field( 'sc_post_nonce', 'sc_nonce' );
64
+
65
+ $settings = Shortcoder::get_sc_settings( $post->ID );
66
+
67
+ $fields = array(
68
+
69
+ array( __( 'Display name', 'sc' ), SC_Admin_Form::field( 'text', array(
70
+ 'value' => $post->post_title,
71
+ 'name' => 'post_title',
72
+ 'class' => 'widefat',
73
+ 'helper' => __( 'Name of the shortcode to display when it is listed', 'sc' )
74
+ ))),
75
+
76
+ array( __( 'Temporarily disable shortcode', 'sc' ), SC_Admin_Form::field( 'select', array(
77
+ 'value' => $settings[ '_sc_disable_sc' ],
78
+ 'name' => '_sc_disable_sc',
79
+ 'list' => array(
80
+ 'yes' => 'Yes',
81
+ 'no' => 'No'
82
+ ),
83
+ 'helper' => __( 'Select to disable the shortcode from executing in all the places where it is used.', 'sc' )
84
+ ))),
85
+
86
+ array( __( 'Disable shortcode for administrators', 'sc' ), SC_Admin_Form::field( 'select', array(
87
+ 'value' => $settings[ '_sc_disable_admin' ],
88
+ 'name' => '_sc_disable_admin',
89
+ 'list' => array(
90
+ 'yes' => 'Yes',
91
+ 'no' => 'No'
92
+ ),
93
+ 'helper' => __( 'Select to disable the shortcode from executing for administrators.', 'sc' )
94
+ ))),
95
+
96
+ array( __( 'Execute shortcode in devices', 'sc' ), SC_Admin_Form::field( 'select', array(
97
+ 'value' => $settings[ '_sc_allowed_devices' ],
98
+ 'name' => '_sc_allowed_devices',
99
+ 'list' => array(
100
+ 'all' => 'All devices',
101
+ 'desktop_only' => 'Desktop only',
102
+ 'mobile_only' => 'Mobile only'
103
+ ),
104
+ 'helper' => __( 'Select the devices where the shortcode should be executed. Note: If any caching plugin is used, a separate caching for desktop and mobile might be required.', 'sc' )
105
+ ))),
106
+
107
+ );
108
+
109
+ echo SC_Admin_Form::table($fields);
110
+
111
+ }
112
+
113
+ public static function save_post( $post_id ){
114
+
115
+ // Checks save status
116
+ $is_autosave = wp_is_post_autosave( $post_id );
117
+ $is_revision = wp_is_post_revision( $post_id );
118
+ $is_valid_nonce = ( isset( $_POST[ 'sc_nonce' ] ) && wp_verify_nonce( $_POST[ 'sc_nonce' ], 'sc_post_nonce' ) );
119
+
120
+ // Exits script depending on save status
121
+ if ( $is_autosave || $is_revision || !$is_valid_nonce ){
122
+ return;
123
+ }
124
+
125
+ $default_settings = Shortcoder::default_sc_settings();
126
+
127
+ foreach( $default_settings as $key => $val ){
128
+
129
+ if( array_key_exists( $key, $_POST ) ){
130
+ $val = sanitize_text_field( $_POST[ $key ] );
131
+ update_post_meta( $post_id, $key, $val );
132
+ }
133
+
134
+ }
135
+
136
+ }
137
+
138
+ public static function before_insert_post( $post ){
139
+
140
+ if( $post[ 'post_type' ] != SC_POST_TYPE ){
141
+ return $post;
142
+ }
143
+
144
+ if( empty( trim( $post[ 'post_title' ] ) ) ){
145
+ $post[ 'post_title' ] = $post[ 'post_name' ];
146
+ }
147
+
148
+ return $post;
149
+ }
150
+
151
+ public static function editor_props( $settings ){
152
+
153
+ $g = SC_Admin::clean_get();
154
+
155
+ $list = array(
156
+ 'text' => __( 'Text editor', 'sc' ),
157
+ 'visual' => __( 'Visual editor', 'sc' ),
158
+ 'code' => __( 'Code editor', 'sc' )
159
+ );
160
+
161
+ $editor = ( isset( $g[ 'editor' ] ) && array_key_exists( $g[ 'editor' ], $list ) ) ? $g[ 'editor' ] : $settings[ '_sc_editor' ];
162
+
163
+ $switch = '<span class="sc_editor_list sc_editor_icon_' . $editor . '">';
164
+ $switch .= '<select name="_sc_editor" class="sc_editor" title="' . __( 'Switch editor', 'sc' ) . '">';
165
+ foreach( $list as $id => $name ){
166
+ $switch .= '<option value="' . $id . '" ' . selected( $editor, $id, false ) . '>' . $name . '</option>';
167
+ }
168
+ $switch .= '</select>';
169
+ $switch .= '</span>';
170
+
171
+ return array(
172
+ 'active' => $editor,
173
+ 'switch_html' => $switch
174
+ );
175
+
176
+ }
177
+
178
+ public static function editor( $post, $settings ){
179
+
180
+ $editor = self::editor_props( $settings );
181
+
182
+ echo '<div class="hidden">';
183
+ echo '<div class="sc_editor_toolbar">';
184
+ 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>';
185
+ echo $editor[ 'switch_html' ];
186
+ echo '</div>';
187
+ echo '</div>';
188
+
189
+ if( $editor[ 'active' ] == 'code' ){
190
+ echo '<div class="sc_cm_menu"></div>';
191
+ echo '<textarea name="content" id="content" class="sc_cm_content">' . $post->post_content . '</textarea>';
192
+ }else{
193
+ wp_editor( $post->post_content, 'content', array(
194
+ 'wpautop'=> false,
195
+ 'textarea_rows'=> 20,
196
+ 'tinymce' => ( $editor[ 'active' ] == 'visual' )
197
+ ));
198
+ }
199
+
200
+ }
201
+
202
+ public static function enqueue_scripts( $hook ){
203
+
204
+ global $post;
205
+
206
+ if( !SC_Admin::is_sc_admin_page() || $hook == 'edit.php' || $hook == 'edit-tags.php' || $hook == 'term.php' ){
207
+ return false;
208
+ }
209
+
210
+ $settings = Shortcoder::get_sc_settings( $post->ID );
211
+ $editor = self::editor_props( $settings );
212
+
213
+ wp_localize_script( 'sc-admin-js', 'SC_EDITOR', $editor[ 'active' ] );
214
+
215
+ if( $editor[ 'active' ] != 'code' ){
216
+ return false;
217
+ }
218
+
219
+ $cm_cdn_url = 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.46.0/';
220
+ $cm_files = array(
221
+ 'css' => array(
222
+ 'codemirror.min.css'
223
+ ),
224
+ 'js' => array(
225
+ 'codemirror.min.js',
226
+ 'mode/htmlmixed/htmlmixed.min.js',
227
+ 'mode/css/css.min.js',
228
+ 'mode/xml/xml.min.js',
229
+ 'mode/javascript/javascript.min.js',
230
+ 'addon/selection/active-line.min.js',
231
+ 'addon/mode/overlay.min.js'
232
+ )
233
+ );
234
+
235
+ foreach( $cm_files as $type => $files ){
236
+ foreach( $files as $index => $file ){
237
+ $url = $cm_cdn_url . $file;
238
+ $id = 'sc-cm-' . $index;
239
+ if( $type == 'css' ){
240
+ wp_enqueue_style( $id, $url, array(), SC_VERSION );
241
+ }else{
242
+ wp_enqueue_script( $id, $url, array( 'sc-admin-js' ), SC_VERSION );
243
+ }
244
+ }
245
+ }
246
+
247
+ }
248
+
249
+ public static function custom_params_list(){
250
+
251
+ $sc_wp_params = Shortcoder::wp_params_list();
252
+
253
+ echo '<ul class="sc_params_list">';
254
+
255
+ foreach( $sc_wp_params as $group => $group_info ){
256
+ echo '<li><span class="dashicons dashicons-' . $group_info['icon'] . '"></span>';
257
+ echo $group_info[ 'name' ];
258
+ echo '<ul class="sc_wp_params">';
259
+ foreach( $group_info[ 'params' ] as $param_id => $param_name ){
260
+ echo '<li data-id="' . $param_id . '">' . $param_name . '</li>';
261
+ }
262
+ echo '</ul></li>';
263
+ }
264
+
265
+ echo '<li><span class="dashicons dashicons-list-view"></span>' . __( 'Custom parameter', 'shortcoder' ) . '<ul>';
266
+ echo '<li class="sc_params_form"><h4>' . __( 'Enter custom parameter name', 'shortcoder' ) . '</h4>';
267
+ echo '<input type="text" class="sc_cp_box widefat" pattern="[a-zA-Z0-9]+"/>';
268
+ echo '<button class="button sc_cp_btn">' . __( 'Insert parameter', 'shortcoder' ) . '</button>';
269
+ echo '<p class="sc_cp_info"><small>' . __( 'Only alphabets and numbers allowed. Custom parameters are case insensitive', 'shortcoder' ) . '</small></p></li>';
270
+ echo '</ul></li>';
271
+
272
+ echo '<li><span class="dashicons dashicons-screenoptions"></span>' . __( 'Custom Fields', 'shortcoder' ) . '<ul>';
273
+ echo '<li class="sc_params_form"><h4>' . __( 'Enter custom field name', 'shortcoder' ) . '</h4>';
274
+ echo '<input type="text" class="sc_cf_box widefat" pattern="[a-zA-Z0-9_-]+"/>';
275
+ echo '<button class="button sc_cf_btn">' . __( 'Insert custom field', 'shortcoder' ) . '</button>';
276
+ echo '<p class="sc_cf_info"><small>' . __( 'Only alphabets, numbers, underscore and hyphens are allowed. Cannot be empty.', 'shortcoder' ) . '</small></p></li>';
277
+ echo '</ul></li>';
278
+
279
+ echo '</ul>';
280
+
281
+ }
282
+
283
+ public static function hidden_section( $post, $settings ){
284
+
285
+ self::custom_params_list();
286
+
287
+ }
288
+
289
+ public static function coffee_box( $post ){
290
+ echo '<div class="cfe_mb">';
291
+ echo '<div class="cfe_text">';
292
+ echo '<p>If you like this plugin, buy me a coffee !</p>';
293
+ echo '<img src="' . SC_ADMIN_URL . '/images/coffee.svg" />';
294
+ echo '</div>';
295
+ echo '<div class="cfe_form">';
296
+ echo '<select class="cfe_amt">';
297
+ for($i = 5; $i <= 15; $i++){
298
+ echo '<option value="' . $i . '" ' . ($i == 6 ? 'selected="selected"' : '') . '>$' . $i . '</option>';
299
+ }
300
+ echo '<option value="">Custom</option>';
301
+ echo '</select>';
302
+ 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>';
303
+ echo '</div>';
304
+ echo '</div>';
305
+ }
306
+
307
+ public static function feedback( $post ){
308
+ echo '<div class="feedback">';
309
+ echo '<ul>
310
+ <li><a href="https://wordpress.org/support/plugin/shortcoder/reviews/?rate=5#new-post" target="_blank">Rate and review</a><div class="stars"><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span></div></li>
311
+ <li><a href="https://www.aakashweb.com/forum/discuss/wordpress-plugins/shortcoder/#new-post" target="_blank">Request a feature</a></li>
312
+ <li><a href="https://www.aakashweb.com/forum/discuss/wordpress-plugins/shortcoder/#new-post" target="_blank">Report a bug</a></li>
313
+ <li><a href="https://www.aakashweb.com/docs/shortcoder-doc/" target="_blank">FAQ</a></li>
314
+ <li><a href="https://www.aakashweb.com/wordpress-plugins/" target="_blank">More plugins</a></li>
315
+ </ul>';
316
+ echo '</div>';
317
+ }
318
+
319
+ public static function footer_text( $text ){
320
+
321
+ if( SC_Admin::is_sc_admin_page() ){
322
+ return '<span 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 &bull; <a href="https://www.paypal.me/vaakash/" target="_blank">Buy me a coffee !</a></span>';
323
+ }
324
+
325
+ return $text;
326
+
327
+ }
328
+
329
+ }
330
+
331
+ SC_Admin_Edit::init();
332
+
333
+ ?>
admin/font/shortcoder.eot ADDED
Binary file
admin/font/shortcoder.svg ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Generated by IcoMoon</metadata>
5
+ <defs>
6
+ <font id="icomoon" horiz-adv-x="1024">
7
+ <font-face units-per-em="1024" ascent="960" descent="-64" />
8
+ <missing-glyph horiz-adv-x="1024" />
9
+ <glyph unicode="&#x20;" horiz-adv-x="512" d="" />
10
+ <glyph unicode="&#xe900;" glyph-name="shortcoder" d="M58.3 832.001h27.401c23.361 0 42.299-18.938 42.299-42.299v-683.401c0-23.361-18.938-42.299-42.299-42.299h-27.401c-23.361 0-42.299 18.938-42.299 42.299v683.401c0 23.361 18.938 42.299 42.299 42.299zM16 747.937v56.127c0 15.429 12.508 27.937 27.937 27.937h200.127c15.429 0 27.937-12.508 27.937-27.937v-56.127c0-15.429-12.508-27.937-27.937-27.937h-200.127c-15.429 0-27.937 12.508-27.937 27.937zM16 91.938v56.127c0 15.429 12.508 27.937 27.937 27.937h200.127c15.429 0 27.937-12.508 27.937-27.937v-56.127c0-15.429-12.508-27.937-27.937-27.937h-200.127c-15.429 0-27.937 12.508-27.937 27.937zM598.249 944h80.973c16.088 0 25.646-12.568 21.349-28.072l-259.387-935.857c-4.297-15.504-20.822-28.072-36.91-28.072h-80.973c-16.088 0-25.646 12.568-21.349 28.072l259.387 935.857c4.297 15.504 20.822 28.072 36.91 28.072zM965.701 832h-27.401c-23.361 0-42.299-18.938-42.299-42.299v-683.401c0-23.361 18.938-42.299 42.299-42.299h27.401c23.361 0 42.299 18.938 42.299 42.299v683.401c0 23.361-18.938 42.299-42.299 42.299zM1008 747.937v56.127c0 15.429-12.508 27.937-27.937 27.937h-200.127c-15.429 0-27.937-12.508-27.937-27.937v-56.127c0-15.429 12.508-27.937 27.937-27.937h200.127c15.429 0 27.937 12.508 27.937 27.937zM1008 91.937v56.127c0 15.429-12.508 27.937-27.937 27.937h-200.127c-15.429 0-27.937-12.508-27.937-27.937v-56.127c0-15.429 12.508-27.937 27.937-27.937h200.127c15.429 0 27.937 12.508 27.937 27.937z" />
11
+ </font></defs></svg>
admin/font/shortcoder.ttf ADDED
Binary file
admin/font/shortcoder.woff ADDED
Binary file
admin/form.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ 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] : '' ) . '>';
13
+ $html .= '<th>' . ( isset( $row[0] ) ? $row[0] : '' ) . '</th>';
14
+ $html .= '<td>' . ( isset( $row[1] ) ? $row[1] : '' ) . '</td>';
15
+ $html .= '</tr>';
16
+ }
17
+
18
+ $html .= '</table>';
19
+
20
+ if( $print ){
21
+ echo $html;
22
+ }else{
23
+ return $html;
24
+ }
25
+
26
+ }
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
+ switch( $field_type ){
78
+ case 'text':
79
+ $field_html = "<input type='$type' class='$class' id='$id' name='$name' value='$value' placeholder='$placeholder' " . ( $required ? "required='$required'" : "" ) . " $custom />";
80
+ break;
81
+
82
+ case 'select':
83
+ $field_html .= "<select name='$name' class='$class' id='$id' $custom>";
84
+ foreach( $list as $k => $v ){
85
+ $field_html .= "<option value='$k' " . selected( $value, $k, false ) . ">$v</option>";
86
+ }
87
+ $field_html .= "</select>";
88
+ break;
89
+
90
+ case 'textarea':
91
+ $field_html .= "<textarea id='$id' name='$name' class='$class' placeholder='$placeholder' rows='$rows' cols='$cols' $custom>$value</textarea>";
92
+ break;
93
+
94
+ }
95
+
96
+ if( !empty( $tooltip ) ){
97
+ $field_html .= "<div class='sc-tt'><span class='dashicons dashicons-editor-help'></span><span class='sc-tt-text'>$tooltip</span></div>";
98
+ }
99
+
100
+ if( !empty( $helper ) ){
101
+ $field_html .= "<p class='description'>$helper</p>";
102
+ }
103
+
104
+ return $field_html;
105
+
106
+ }
107
+
108
+ }
109
+
110
+ ?>
admin/images/arrow.svg ADDED
@@ -0,0 +1 @@
 
1
+ <?xml version="1.0" ?><!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'><svg height="512px" id="Layer_1" style="enable-background:new 0 0 512 512;" version="1.1" viewBox="0 0 512 512" width="512px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><polygon points="396.6,160 416,180.7 256,352 96,180.7 115.3,160 256,310.5 "/></svg>
admin/images/aw.png DELETED
Binary file
admin/images/coffee.svg CHANGED
@@ -1,99 +1 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <svg
3
- xmlns:dc="http://purl.org/dc/elements/1.1/"
4
- xmlns:cc="http://creativecommons.org/ns#"
5
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
- xmlns:svg="http://www.w3.org/2000/svg"
7
- xmlns="http://www.w3.org/2000/svg"
8
- xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9
- xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10
- height="128"
11
- version="1.1"
12
- viewBox="0 0 128 128"
13
- width="128"
14
- id="svg4495"
15
- sodipodi:docname="1494109658_food-drink-cup-coffee-tea-drink-outline-stroke.svg"
16
- inkscape:version="0.92.0 r15299">
17
- <metadata
18
- id="metadata4499">
19
- <rdf:RDF>
20
- <cc:Work
21
- rdf:about="">
22
- <dc:format>image/svg+xml</dc:format>
23
- <dc:type
24
- rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
25
- <dc:title></dc:title>
26
- </cc:Work>
27
- </rdf:RDF>
28
- </metadata>
29
- <sodipodi:namedview
30
- pagecolor="#ffffff"
31
- bordercolor="#666666"
32
- borderopacity="1"
33
- objecttolerance="10"
34
- gridtolerance="10"
35
- guidetolerance="10"
36
- inkscape:pageopacity="0"
37
- inkscape:pageshadow="2"
38
- inkscape:window-width="1920"
39
- inkscape:window-height="1013"
40
- id="namedview4497"
41
- showgrid="false"
42
- inkscape:zoom="2.2265625"
43
- inkscape:cx="60.701019"
44
- inkscape:cy="100.20618"
45
- inkscape:window-x="-9"
46
- inkscape:window-y="-9"
47
- inkscape:window-maximized="1"
48
- inkscape:current-layer="Layer_2" />
49
- <desc
50
- id="desc4487" />
51
- <defs
52
- id="defs4489" />
53
- <g
54
- id="miu"
55
- style="fill:none;fill-rule:evenodd;stroke:none;stroke-width:1"
56
- transform="matrix(5.5327011,0,0,5.5327011,-1.3569238,10.877533)">
57
- <g
58
- id="Artboard-1"
59
- transform="translate(-503,-515)">
60
- <g
61
- id="slice"
62
- transform="translate(215,119)" />
63
- <path
64
- d="m 521.02703,523.35506 c 0.009,-0.39125 0.004,-0.77169 -0.0131,-1.1361 C 521.00824,522.09555 521,521.50003 521,521.5 v 0 c 0,-1.28644 -2.85422,-2 -6.5,-2 -3.64578,0 -6.5,0.71356 -6.5,2 0,10e-6 -0.008,0.59555 -0.014,0.71896 -0.0659,1.41455 0.0458,3.07056 0.4816,4.66302 0.86614,3.1649 2.79873,5.11802 6.03238,5.11802 2.27915,0 3.91196,-0.97026 4.98059,-2.65121 2.90061,-0.0524 6.22639,-2.61697 5.22565,-4.88902 -0.40287,-0.91465 -1.1392,-1.36254 -2.05478,-1.39971 -0.50445,-0.0205 -1.02662,0.0826 -1.542,0.26513 -0.0281,0.01 -0.0556,0.0199 -0.0824,0.0299 z m -0.0645,1.11607 c -0.0739,0.79385 -0.21104,1.61037 -0.4301,2.41085 -0.138,0.50424 -0.30306,0.97772 -0.49615,1.41744 2.14097,-0.32376 4.32372,-2.145 3.75485,-3.43656 -0.24026,-0.54547 -0.62779,-0.7812 -1.18019,-0.80363 -0.35902,-0.0146 -0.76224,0.065 -1.16757,0.20859 -0.21942,0.0777 -0.38848,0.1545 -0.48084,0.20331 z m -0.9347,-1.83112 c 0.0265,1.23414 -0.094,2.64091 -0.45994,3.97801 C 518.80907,529.39062 517.21661,531 514.5,531 c -2.71661,0 -4.30907,-1.60938 -5.06784,-4.38198 -0.36593,-1.3371 -0.48646,-2.74387 -0.45994,-3.97801 1.13669,0.56058 3.16617,0.85999 5.52778,0.85999 2.36161,0 4.39109,-0.29941 5.52778,-0.85999 v 0 z M 509,521.5 c 0,-0.37041 2.51836,-1 5.5,-1 2.98164,0 5.5,0.62959 5.5,1 0,0.37041 -2.51836,1 -5.5,1 -2.98164,0 -5.5,-0.62959 -5.5,-1 z m -4.5,11.5 c 0,0 -0.5,0 -0.5,0.5 0,0.5 0.5,0.5 0.5,0.5 h 21 c 0,0 0.5,0 0.5,-0.5 0,-0.5 -0.5,-0.5 -0.5,-0.5 z"
65
- id="food-drink-cup-coffee-tea-drink-outline-stroke"
66
- inkscape:connector-curvature="0"
67
- style="fill:#000000" />
68
- </g>
69
- </g>
70
- <g
71
- id="g4561"
72
- transform="translate(180.23158,1.9807019)">
73
- <g
74
- id="Layer_2"
75
- transform="translate(10.329825,-94.315789)">
76
- <g
77
- id="g4534"
78
- transform="matrix(2.4713604,0,0,2.4713604,-210.98683,57.600819)">
79
- <path
80
- id="path4532"
81
- d="m 33.114,51.204 v -1.315 c -0.927,-0.041 -1.827,-0.29 -2.353,-0.595 l 0.415,-1.619 c 0.582,0.318 1.398,0.608 2.297,0.608 0.789,0 1.329,-0.304 1.329,-0.857 0,-0.525 -0.443,-0.857 -1.467,-1.204 -1.481,-0.498 -2.491,-1.19 -2.491,-2.532 0,-1.219 0.858,-2.174 2.339,-2.464 V 39.91 h 1.356 v 1.219 c 0.927,0.041 1.55,0.235 2.007,0.457 l -0.401,1.563 c -0.36,-0.152 -0.997,-0.471 -1.993,-0.471 -0.899,0 -1.19,0.388 -1.19,0.774 0,0.457 0.484,0.748 1.661,1.191 1.647,0.58 2.311,1.342 2.311,2.588 0,1.231 -0.872,2.283 -2.463,2.561 v 1.411 h -1.357 z"
82
- inkscape:connector-curvature="0"
83
- style="fill:#92278f" />
84
- </g>
85
- <path
86
- id="path4528-3"
87
- d="m -133.27695,122.08016 c 4.05154,0 8.24277,-3.06272 8.24277,-8.18852 0,-2.81586 -1.89351,-4.22515 -3.41673,-5.35909 -1.48389,-1.10275 -2.32214,-1.7945 -2.32214,-3.18209 0,-1.45269 0.95218,-2.16073 2.50389,-3.19294 1.44184,-0.96032 3.23498,-2.15259 3.23498,-4.492359 0,-0.750083 -0.60765,-1.356389 -1.35638,-1.356389 -0.74873,0 -1.35639,0.606306 -1.35639,1.356389 0,0.802982 -0.61716,1.296708 -2.02508,2.232616 -1.56664,1.044423 -3.7138,2.471343 -3.7138,5.452683 0,2.81586 1.89351,4.22515 3.41674,5.35909 1.48389,1.10275 2.32214,1.79451 2.32214,3.18209 0,3.55645 -2.84841,5.47574 -5.53,5.47574 -0.74872,0 -1.35638,0.60631 -1.35638,1.35639 0,0.75009 0.60766,1.35639 1.35638,1.35639 z"
88
- inkscape:connector-curvature="0"
89
- style="fill:#ffcf06;fill-opacity:1;stroke-width:1.35638893" />
90
- <path
91
- id="path4530-4"
92
- d="m -125.24305,122.08016 c 4.05153,0 8.24277,-3.06272 8.24277,-8.18852 0,-2.81586 -1.89352,-4.22515 -3.41675,-5.35909 -1.48389,-1.10275 -2.32214,-1.7945 -2.32214,-3.18209 0,-1.45269 0.95219,-2.16073 2.5039,-3.19294 1.44184,-0.96032 3.23499,-2.15259 3.23499,-4.492359 0,-0.750083 -0.60766,-1.356389 -1.35638,-1.356389 -0.74873,0 -1.3564,0.606306 -1.3564,1.356389 0,0.802982 -0.61716,1.296708 -2.02509,2.232616 -1.56662,1.044423 -3.71379,2.471343 -3.71379,5.452683 0,2.81586 1.89352,4.22515 3.41674,5.35909 1.48254,1.1041 2.32214,1.79451 2.32214,3.18209 0,3.55645 -2.84977,5.47574 -5.52999,5.47574 -0.74873,0 -1.3564,0.60631 -1.3564,1.35639 0,0.75009 0.60767,1.35639 1.3564,1.35639 z"
93
- inkscape:connector-curvature="0"
94
- style="fill:#ffcf06;fill-opacity:1;stroke-width:1.35638893" />
95
- </g>
96
- <g
97
- id="Layer_3" />
98
- </g>
99
- </svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#FFC107" d="M11.143 15L13 28 35 28 36.857 15z"/><path fill="#795548" d="M39,15v-2.5c0-0.828-0.672-1.5-1.5-1.5h-27C9.672,11,9,11.672,9,12.5V15H39z"/><path fill="#77574F" d="M13.143 29L15 42 33 42 34.857 29z"/><path fill="#77574F" d="M24 23A5 5 0 1 0 24 33A5 5 0 1 0 24 23Z"/><path fill="#4E342E" d="M20 28c0-.732.211-1.409.555-2h-7.84l.714 5h7.951C20.541 30.267 20 29.201 20 28zM27.445 26C27.789 26.591 28 27.268 28 28c0 1.201-.541 2.267-1.38 3h7.951l.714-5H27.445zM36 6L12 6 11 11 37 11z"/><path fill="#5D4037" d="M24,21c3.866,0,7,3.134,7,7s-3.134,7-7,7s-7-3.134-7-7S20.134,21,24,21 M24,20c-4.411,0-8,3.589-8,8s3.589,8,8,8s8-3.589,8-8S28.411,20,24,20L24,20z"/><path fill="#FFF3E0" d="M24,21c-3.866,0-7,3.134-7,7s3.134,7,7,7s7-3.134,7-7S27.866,21,24,21z M24,32c-2.209,0-4-1.791-4-4s1.791-4,4-4s4,1.791,4,4S26.209,32,24,32z"/></svg>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/images/index.html DELETED
File without changes
admin/images/shortcoder-2.png DELETED
Binary file
admin/images/shortcoder.png DELETED
Binary file
admin/images/shortcoder.svg ADDED
@@ -0,0 +1 @@
 
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 16.933332 16.933334"><defs><linearGradient id="a"><stop offset="0" stop-color="#809f80" stop-opacity=".49803922"/><stop offset="1" stop-color="#ff02d1" stop-opacity="0"/></linearGradient></defs><g fill="#00aee9" transform="translate(-22.2128657 -238.798828) scale(.93445)"><path d="M24.54856298 257.81493295c-.27388469 0-.4943942.22050952-.4943942.4943942v12.60207458c0 .27388477.22050951.49439426.4943942.49439426h3.54149921c.27388478 0 .49439427-.22050949.49439427-.49439426v-.99321234c0-.27388477-.2205095-.49439426-.49439426-.49439426h-2.05389256v-9.62686132h2.05389256c.27388477 0 .49439426-.22050949.49439426-.49439426v-.9932124c0-.27388468-.2205095-.4943942-.49439426-.4943942h-3.54149922z"/><rect ry=".51549578" transform="matrix(1 0 -.2671 .96367 0 0)" y="265.47775" x="104.7504" height="18.216675" width="2.4639277"/><path d="M37.5731395 257.81493153c-.27388477 0-.49439426.22050952-.49439426.4943942v.9932124c0 .27388478.2205095.49439426.49439426.49439426h2.05389256v9.62686132H37.5731395c-.27388477 0-.49439426.2205095-.49439426.49439426v.99321234c0 .27388478.2205095.49439426.49439426.49439426h3.54149916c.27388478 0 .49439426-.22050948.49439426-.49439426v-12.60207458c0-.27388468-.22050948-.4943942-.49439426-.4943942H37.5731395z"/></g></svg>
admin/images/toggle-arrow.png DELETED
Binary file
admin/insert.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if( ! defined( 'ABSPATH' ) ) exit; ?>
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>Insert shortcode</title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <link href="<?php echo SC_ADMIN_URL; ?>css/style-insert.css<?php echo '?ver=' . SC_VERSION; ?>" media="all" rel="stylesheet" />
8
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
9
+ <script src="<?php echo SC_ADMIN_URL; ?>js/script-insert.js<?php echo '?ver=' . SC_VERSION; ?>"></script>
10
+ </head>
11
+ <body>
12
+
13
+ <div class="sc_menu">
14
+ <input type="search" class="sc_search" placeholder="Search ..." />
15
+ </div>
16
+
17
+ <div class="sc_list">
18
+ <?php
19
+
20
+ $shortcodes = Shortcoder::get_shortcodes();
21
+
22
+ if( empty( $shortcodes ) ){
23
+ 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>';
24
+ }else{
25
+
26
+ foreach( $shortcodes as $name => $options ){
27
+ $id = $options[ 'id' ];
28
+ $content = $options[ 'content' ];
29
+ $settings = $options[ 'settings' ];
30
+
31
+ preg_match_all( '/%%[^%\s]+%%/', $content, $params );
32
+
33
+ $enclosed_sc = strpos( $content, '$$enclosed_content$$' ) !== false ? 'true' : 'false';
34
+
35
+ echo '<div class="sc_wrap" data-name="' . esc_attr( $name ) . '" data-id="' . esc_attr( $id ) . '" data-enclosed="' . $enclosed_sc . '">';
36
+ echo '<div class="sc_head">';
37
+ echo '<img src="' . SC_ADMIN_URL . '/images/arrow.svg" width="16" />';
38
+ echo '<h3>' . $settings[ '_sc_title' ] . '</h3>';
39
+ echo '<div class="sc_tools">';
40
+ if( current_user_can( 'edit_post', $id ) ){
41
+ echo '<a href="' . admin_url( 'post.php?action=edit&post=' . $id ) . '" class="button" target="_blank">' . __( 'Edit', 'shortcoder' ) . '</a>';
42
+ }
43
+ echo '<button class="button sc_copy">' . __( 'Copy', 'shortcoder' ) . '</button>';
44
+ echo '<button class="button sc_insert">' . __( 'Insert', 'shortcoder' ) . '</button>';
45
+ echo '</div>';
46
+ echo '</div>';
47
+
48
+ echo '<div class="sc_options">';
49
+
50
+ if( !empty( $params[0] ) ){
51
+ echo '<h4>' . __( 'Available parameters', 'shortcoder' ) . ': </h4>';
52
+ echo '<div class="sc_params_wrap">';
53
+ $temp = array();
54
+
55
+ foreach( $params[0] as $k => $v ){
56
+ $cleaned = str_replace( '%', '', $v );
57
+ if( !in_array( $cleaned, $temp ) ){
58
+ array_push( $temp, $cleaned );
59
+ echo '<label>' . $cleaned . ': <input type="text" class="sc_param" data-param="' . $cleaned . '"/></label> ';
60
+ }
61
+ }
62
+
63
+ echo '</div>';
64
+
65
+ }else{
66
+ echo '<p>' . __( 'No parameters present in this shortcode', 'shortcoder' ) . '</p>';
67
+ }
68
+
69
+ echo '<div class="sc_foot">';
70
+ echo '<button class="sc_insert button button-primary">' . __( 'Insert shortcode', 'sc' ) . '</button>';
71
+ if( $enclosed_sc == 'true' ){
72
+ echo '<span>' . __( 'Has enclosed content parameter', 'shortcoder' ) . '</span>';
73
+ }
74
+ echo '</div>';
75
+
76
+ echo '</div>';
77
+ echo '</div>';
78
+ }
79
+
80
+ echo '<p class="sc_note sc_search_none">' . __( 'No shortcodes match search term !', 'shortcoder' ) . '</p>';
81
+
82
+ }
83
+
84
+ ?>
85
+ </div>
86
+
87
+ <div class="cfe_box">
88
+ <?php
89
+ echo '<div class="cfe_text">';
90
+ echo '<img src="' . SC_ADMIN_URL . '/images/coffee.svg" />';
91
+ echo '<div><h2>Buy me a Coffee !</h2><p>If you like this plugin, buy me a coffee !</p></div>';
92
+ echo '</div>';
93
+ echo '<div class="cfe_form">';
94
+ echo '<select class="cfe_amt">';
95
+ for($i = 5; $i <= 15; $i++){
96
+ echo '<option value="' . $i . '" ' . ($i == 6 ? 'selected="selected"' : '') . '>$' . $i . '</option>';
97
+ }
98
+ echo '<option value="">Custom</option>';
99
+ echo '</select>';
100
+ 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>';
101
+ echo '</div>';
102
+ ?>
103
+ </div>
104
+
105
+ <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>
106
+
107
+ </body>
108
+ </html>
admin/js/blocks/shortcoder.js ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
29
+ }),
30
+ el( 'button', {
31
+ 'class': 'button button-primary',
32
+ 'onClick': function(){
33
+ if( window.sc_show_insert ){
34
+ var sc_val = document.getElementById('shortcoder_box_' + props.instanceId).value;
35
+ window.sc_show_insert( sc_val, props.instanceId );
36
+ }
37
+ }
38
+ }, 'Select shortcode')
39
+ );
40
+
41
+ }
42
+
43
+ function icon() {
44
+ return el('svg', {
45
+ width: 64,
46
+ height: 64,
47
+ viewBox: '0 0 16.933 16.933'
48
+ }, el('g', {
49
+ fill: '#00aee9',
50
+ transform: 'translate(-22.213 -238.799) scale(.93445)'
51
+ }, el('path', {
52
+ 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'
53
+ }), el('rect', {
54
+ ry: 0.515,
55
+ transform: 'matrix(1 0 -.2671 .96367 0 0)',
56
+ y: 265.478,
57
+ x: 104.75,
58
+ height: 18.217,
59
+ width: 2.464
60
+ }), el('path', {
61
+ 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'
62
+ })));
63
+ }
64
+
65
+ blocks.registerBlockType( 'shortcoder/shortcoder', {
66
+ title: 'Shortcoder',
67
+ icon: icon,
68
+ category: 'widgets',
69
+ attributes: {
70
+ text: {
71
+ type: 'string',
72
+ source: 'text'
73
+ },
74
+ },
75
+ supports: {
76
+ html: false,
77
+ customClassName: false,
78
+ className: false
79
+ },
80
+ edit: wp.compose.withInstanceId( shortcoderBlock ),
81
+ save: function(props) {
82
+ return el( element.RawHTML, {}, props.attributes.text);
83
+ },
84
+ });
85
+ }(
86
+ window.wp.blocks,
87
+ window.wp.element
88
+ ));
admin/js/script-insert.js CHANGED
@@ -1,160 +1,188 @@
1
  (function($){
2
-
3
  $(document).ready(function(){
4
-
5
- var last_sort = 'desc';
6
-
7
- var send_editor = function( content ){
8
- if( typeof parent.send_to_editor === 'function' ){
9
- parent.send_to_editor( content );
 
 
 
 
 
10
  }else{
11
- alert( 'Editor does not exist. Cannot insert shortcode !' );
12
  }
 
13
  }
14
-
15
  var close_window = function(){
16
- if( typeof parent.tb_remove === 'function' ){
17
- parent.tb_remove();
18
- }
19
- }
20
-
21
- var sort = function( ele, orderby ){
22
- var total = ele.length;
23
- while( total ){
24
- ele.each(function(){
25
- var $cur = $(this);
26
- var $next = $cur.next();
27
- if( $next.length ){
28
- var cur_name = $cur.attr( 'data-name' ).toLowerCase();
29
- var nxt_name = $next.attr( 'data-name' ).toLowerCase();
30
- if( ( orderby == 'asc' && cur_name > nxt_name ) || ( orderby == 'desc' && cur_name < nxt_name ) ){
31
- $next.after( $cur );
32
- }
33
- }
34
- });
35
- total--;
36
  }
37
  }
38
-
39
- $('.sc_shortcode_name').append('<span class="sc_toggle"></span>');
40
-
41
- $( document ).on( 'click', '.sc_insert', function(){
42
-
 
 
 
 
 
 
 
 
 
 
 
 
43
  var params = '';
44
- var scname = $(this).closest( '.sc_shortcode' ).attr( 'data-name' );
45
- var sc = '';
46
-
47
- $(this).parent().children().find('input[type="text"]').each(function(){
48
  if($(this).val() != ''){
49
  attr = $(this).attr('data-param');
50
  val = $(this).val().replace( /\"/g, '' );
51
  params += attr + '="' + val + '" ';
52
  }
53
  });
 
 
54
 
55
- sc = '[sc name="' + scname + '" ' + params + ']';
56
-
57
- if( $(this).hasClass( 'has_enclosed_sc' ) ){
58
  sc += '[/sc]';
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
- send_editor( sc );
62
  close_window();
63
-
64
  });
65
 
66
- $( document ).on( 'click', '.sc_quick_insert', function(){
67
-
68
- var scname = $(this).closest( '.sc_shortcode' ).attr( 'data-name' );
69
- var sc = '[sc name="' + scname + '"]';
70
-
71
- send_editor( sc );
72
  close_window();
73
-
74
  });
75
-
76
- $( document ).on( 'click', '.sc_shortcode_name', function(e){
77
- $('.sc_params').slideUp();
78
- if($(this).next('.sc_params').is(':visible')){
79
- $(this).next('.sc_params').slideUp();
 
80
  }else{
81
- $(this).next('.sc_params').slideDown();
 
82
  }
83
  });
84
-
85
- $( document ).on( 'change', '.coffee_amt', function(){
86
- var btn = $( '.buy_coffee_btn' );
87
- btn.attr( 'href', btn.data( 'link' ) + $(this).val() );
88
- });
89
-
90
- $( document ).on( 'click', '.sort_btn', function(){
91
- last_sort = ( last_sort == 'asc' ) ? 'desc' : 'asc';
92
- sort( $( '.sc_shortcode' ), last_sort );
93
- });
94
-
95
- $( document ).on( 'keyup', '.search_box', function(){
96
  var re = new RegExp($(this).val(), 'gi');
97
- $('.sc_wrap .sc_shortcode').each(function(){
98
- var name = $(this).attr('data-name');
99
- if( name.match(re) === null ){
 
100
  $(this).hide();
101
  }else{
102
  $(this).show();
103
  }
104
  });
105
-
106
- var visible = $('.sc_wrap .sc_shortcode:visible').length;
107
- var $no_scs_msg = $('.sc_wrap').find('p');
 
108
  if( visible == 0 ){
109
- if( $no_scs_msg.length == 0 ){
110
- $('.sc_wrap').append( '<p align="center"><i>No shortcodes match search term !</i></p>' );
111
- }
112
  }else{
113
- $no_scs_msg.remove();
114
  }
 
115
  });
116
-
117
- $( document ).on( 'click', '.tags_filter_btn', function(){
118
- $( '.sc_tags' ).slideToggle();
 
119
  });
120
-
121
- $( document ).on( 'click', '.sc_tags li', function(){
122
-
123
- $(this).toggleClass( 'active' );
124
- var tags_sel = [];
125
-
126
- $('.sc_tags li.active').each(function(){
127
- var tag = $(this).attr('data-value');
128
- tags_sel.push(tag);
129
- });
130
-
131
- if(tags_sel.length == 0){
132
- $('.sc_wrap .sc_shortcode').show();
133
  return true;
134
  }
135
-
136
- $('.sc_wrap .sc_shortcode').each(function(){
137
- var tags = $(this).attr('data-tags');
138
- var tags_split = $.map(tags.split(','), $.trim);
139
- var has_tag = false;
140
-
141
- $.each(tags_sel, function(i, tag){
142
- if(tags_split.includes(tag)){
143
- has_tag = true;
144
- return true;
145
- }
146
- });
147
-
148
- if(has_tag){
149
- $(this).show();
150
- }else{
151
- $(this).hide();
152
- }
153
-
154
- });
155
-
156
- });
157
-
158
  });
159
-
160
  })( jQuery );
1
  (function($){
 
2
  $(document).ready(function(){
3
+
4
+ var send_editor = function(content){
5
+
6
+ if(typeof parent.sc_block_editor_content === 'function'){
7
+ if(parent.sc_block_editor_content(content)){
8
+ return true;
9
+ }
10
+ }
11
+
12
+ if(typeof parent.send_to_editor === 'function'){
13
+ parent.send_to_editor(content);
14
  }else{
15
+ alert('Editor does not exist. Cannot insert shortcode !');
16
  }
17
+
18
  }
19
+
20
  var close_window = function(){
21
+ if( typeof parent.sc_close_insert === 'function' ){
22
+ parent.sc_close_insert();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
  }
25
+
26
+ var copy_to_clipboard = function(str){
27
+ var el = document.createElement('textarea');
28
+ el.value = str;
29
+ el.setAttribute('readonly', '');
30
+ el.style.position = 'absolute';
31
+ el.style.left = '-9999px';
32
+ document.body.appendChild(el);
33
+ el.select();
34
+ document.execCommand('copy');
35
+ document.body.removeChild(el);
36
+ };
37
+
38
+ var generate_sc = function(id){
39
+ var $wrap = $('.sc_wrap[data-id="' + id + '"]');
40
+ var name = $wrap.attr('data-name');
41
+ var enclosed = $wrap.attr('data-enclosed');
42
  var params = '';
43
+
44
+ $wrap.find('.sc_param').each(function(){
 
 
45
  if($(this).val() != ''){
46
  attr = $(this).attr('data-param');
47
  val = $(this).val().replace( /\"/g, '' );
48
  params += attr + '="' + val + '" ';
49
  }
50
  });
51
+
52
+ sc = '[sc name="' + name + '" ' + params + ']';
53
 
54
+ if(enclosed == 'true'){
 
 
55
  sc += '[/sc]';
56
  }
57
+
58
+ return sc;
59
+
60
+ }
61
+
62
+ var set_shortcode = function(shortcode){
63
+
64
+ var re_attrs_text = /\[sc ([^\]]*)+\]/g;
65
+ var re_attrs = /(\w+?)="(.+?)"/g;
66
+
67
+ var attributes_text_matches = re_attrs_text.exec(shortcode);
68
+
69
+ if(attributes_text_matches.length < 1){
70
+ return false;
71
+ }
72
+
73
+ var attributes_text = attributes_text_matches[1];
74
+ var attributes = {};
75
+
76
+ while(true){
77
+ var attributes_matches = re_attrs.exec(attributes_text);
78
+
79
+ if(attributes_matches !== null){
80
+ var name = attributes_matches[1];
81
+ var val = attributes_matches[2];
82
+ attributes[name] = val;
83
+ }else{
84
+ break;
85
+ }
86
+ }
87
+
88
+ if(!('name' in attributes)){
89
+ return false;
90
+ }
91
+
92
+ var sc_name = attributes['name'];
93
+ var $sc_wrap = $('.sc_wrap[data-name="' + sc_name + '"]');
94
+
95
+ if($sc_wrap.length == 0){
96
+ return false;
97
+ }
98
+
99
+ var $sc_options = $sc_wrap.find('.sc_options');
100
+ var $sc_head = $sc_wrap.find('.sc_head');
101
+
102
+ delete attributes['name'];
103
+
104
+ for (var attribute in attributes) {
105
+ if (attributes.hasOwnProperty(attribute)) {
106
+ var attr_val = attributes[attribute];
107
+ $sc_options.find('input[data-param="' + attribute + '"]').val(attr_val);
108
+ }
109
+ }
110
+
111
+ if(!$sc_wrap.hasClass('open')){
112
+ $sc_head.trigger('click');
113
+ }
114
+
115
+ $sc_wrap[0].scrollIntoView();
116
+
117
+ }
118
+
119
+ $('.sc_insert').on('click', function(){
120
+ var sc_id = $(this).closest('.sc_wrap').attr('data-id');
121
+ var sc = generate_sc(sc_id);
122
 
123
+ send_editor(sc);
124
  close_window();
 
125
  });
126
 
127
+ $('.sc_copy').on('click', function(){
128
+ var sc_id = $(this).closest('.sc_wrap').attr('data-id');
129
+ var sc = generate_sc(sc_id);
130
+
131
+ copy_to_clipboard(sc);
 
132
  close_window();
 
133
  });
134
+
135
+ $('.sc_head').on('click', function(){
136
+ $('.sc_options').slideUp();
137
+ $('.sc_wrap').removeClass('open');
138
+ if($(this).next('.sc_options').is(':visible')){
139
+ $(this).next().slideUp();
140
  }else{
141
+ $(this).next().slideDown();
142
+ $(this).closest('.sc_wrap').addClass('open');
143
  }
144
  });
145
+
146
+ $('.sc_search').on('keyup search', function(){
147
+
 
 
 
 
 
 
 
 
 
148
  var re = new RegExp($(this).val(), 'gi');
149
+
150
+ $('.sc_wrap').each(function(){
151
+ var name = $(this).find('.sc_head h3').text();
152
+ if(name.match(re) === null){
153
  $(this).hide();
154
  }else{
155
  $(this).show();
156
  }
157
  });
158
+
159
+ var $no_scs_msg = $('.sc_search_none');
160
+ var visible = $('.sc_wrap:visible').length;
161
+
162
  if( visible == 0 ){
163
+ $no_scs_msg.show();
 
 
164
  }else{
165
+ $no_scs_msg.hide();
166
  }
167
+
168
  });
169
+
170
+ $('.cfe_amt').on('click', function(){
171
+ var $btn = $(this).closest('.cfe_form').find('.cfe_btn');
172
+ $btn.attr('href', $btn.data('link') + $(this).val());
173
  });
174
+
175
+ window.addEventListener('message', function(e){
176
+ var key = e.message ? 'message' : 'data';
177
+ var data = e[key];
178
+
179
+ if(data == false){
 
 
 
 
 
 
 
180
  return true;
181
  }
182
+
183
+ set_shortcode(data);
184
+
185
+ }, false);
186
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  });
 
188
  })( jQuery );
admin/js/script-tools.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
5
+ if(typeof window.SC_INSERT_VARS === 'undefined'){
6
+ console.log('Cannot load shortcode insert window as the script is not loaded properly');
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();
13
+ sc_notify_insert(shortcode);
14
+ return;
15
+ }
16
+
17
+ $('body').append(popup);
18
+
19
+ $('#sci_title').text(window.SC_INSERT_VARS.popup_title);
20
+ $('#sci_popup > iframe').attr('src', window.SC_INSERT_VARS.insert_page);
21
+
22
+ $('#sci_close').on('click', function(){
23
+ sc_close_insert();
24
+ });
25
+
26
+ window.SC_INSERT_VARS.popup_opened = true;
27
+ window.SC_INSERT_VARS.iframe = $('#sci_popup > iframe');
28
+
29
+ window.SC_INSERT_VARS.iframe.load(function(){
30
+ sc_notify_insert(shortcode);
31
+ });
32
+
33
+ }
34
+
35
+ function sc_close_insert(){
36
+ jQuery('#sci_wrap').hide();
37
+ window.SC_INSERT_VARS.popup_opened = false;
38
+ window.SC_INSERT_VARS.block_editor = false;
39
+ }
40
+
41
+ function sc_notify_insert(shortcode){
42
+
43
+ if(shortcode === false){
44
+ return false;
45
+ }
46
+
47
+ var $iframe = window.SC_INSERT_VARS.iframe;
48
+ var content_window = $iframe[0].contentWindow;
49
+
50
+ content_window.postMessage(shortcode);
51
+
52
+ }
53
+
54
+ 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
+ }
67
+
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' ){
78
+ QTags.addButton( 'QT_sc_insert', 'Shortcoder', sc_qt_show_insert );
79
+ }
80
+ });
81
+ }
admin/js/script.js CHANGED
@@ -1,363 +1,200 @@
1
  (function($){
2
  $(document).ready(function(){
3
-
4
- var delete_ctext = 'Are you sure want to delete this shortcode ?';
5
- var last_sort = 'desc';
6
- var tags_filt_api = false;
7
-
8
  var init = function(){
9
- if(window.sc_cm_editor){
10
- if( typeof CodeMirror.fromTextArea !== 'undefined' ){
11
- window.sc_cm = CodeMirror.fromTextArea( document.getElementById( 'sc_content' ), {
12
- lineNumbers: true,
13
- mode: "htmlmixed",
14
- indentWithTabs: false,
15
- lineWrapping: true,
16
- styleActiveLine: true
17
- });
18
- sc_cm.setSize( null, 500 );
19
- sc_cm.on( 'change', function(){
20
- sc_cm.save();
21
- });
22
- }else{
23
- alert('Cannot load code editor. Looks like there is a conflict with some other plugin.');
24
- }
25
- }
26
-
27
- if( $.fn.selectize ){
28
-
29
- $('.sc_edit_tags').selectize({
30
- create: true
31
  });
32
-
33
- if( $('.sc_tags_filter').length ){
34
-
35
- $tags_filter_ele = $('.sc_tags_filter').selectize({
36
- onChange: filter_list_tags
37
- });
38
-
39
- tags_filt_api = $tags_filter_ele[0].selectize;
40
-
 
 
 
 
 
 
 
 
 
 
41
  }
42
  }
43
-
44
- var $sc_copy_field = $('.sc_copy_field');
45
- if( $sc_copy_field.length ){
46
- var sc_code = $sc_copy_field.val();
47
- $sc_copy_field.width(sc_code.length * 8);
48
- }
49
-
50
  }
51
-
52
- var sort = function( ele, orderby ){
53
- var total = ele.length;
54
- while( total ){
55
- ele.each(function(){
56
- var $cur = $(this);
57
- var $next = $cur.next();
58
- if( $next.length ){
59
- var cur_name = $cur.attr( 'data-name' ).toLowerCase();
60
- var nxt_name = $next.attr( 'data-name' ).toLowerCase();
61
- if( ( orderby == 'asc' && cur_name > nxt_name ) || ( orderby == 'desc' && cur_name < nxt_name ) ){
62
- $next.after( $cur );
63
- }
64
- }
65
- });
66
- total--;
67
- }
68
  }
69
-
70
- var insert_in_editor = function( data ){
71
- if( window.sc_cm_editor ){
 
72
  var doc = window.sc_cm.getDoc();
73
- doc.replaceRange( data, doc.getCursor() );
74
  }else{
75
- send_to_editor( data );
76
  }
77
  }
78
-
79
- var filter_list_tags = function(){
80
-
81
- var sel_tags = tags_filt_api.items;
82
- var $sc_list = $( '.sc_list > li' );
83
-
84
- if( sel_tags.length == 0){
85
- $sc_list.show();
86
- return true;
 
 
 
 
 
 
 
 
87
  }
88
-
89
- $sc_list.each(function(){
90
- var $sc_item = $( this );
91
- var sc_tags = $sc_item.attr( 'data-tags' );
92
-
93
- if( typeof sc_tags === 'undefined' ){
94
- $sc_item.hide();
95
- return true;
96
- }else{
97
- $sc_item.show();
98
- }
99
-
100
- var sc_tags_split = sc_tags.split( ',' );
101
- var has_tag = false;
102
-
103
- $.each( sel_tags, function( i, tag ){
104
- if( sc_tags_split.includes( tag ) ){
105
- has_tag = true;
106
- return true;
107
  }
108
- });
109
-
110
- if( has_tag ){
111
- $sc_item.show();
112
- }else{
113
- $sc_item.hide();
114
- }
115
-
116
  });
117
  }
118
-
119
- $( document ).on( 'click', '.sc_delete', function(e){
120
-
121
- e.preventDefault();
122
-
123
- var del_btn = $(this);
124
- var href = del_btn.attr( 'href' );
125
- var confirm_user = confirm( delete_ctext );
126
-
127
- if( confirm_user ){
128
-
129
- var ajax = $.get( href );
130
- del_btn.addClass( 'spin' );
131
-
132
- ajax.done(function( data ){
133
- if( data.search( 'DELETED' ) != -1 ){
134
- del_btn.closest( 'li' ).fadeOut( 'slow', function(){
135
- $(this).remove();
136
- });
137
- }else{
138
- alert( 'Delete failed ! - ' + data );
139
- }
140
- });
141
-
142
- ajax.fail(function(){
143
- alert( 'Auth failed !' );
144
- });
145
-
146
- }
147
-
148
- });
149
-
150
- $( document ).on( 'click', '.sc_delete_ep', function(e){
151
-
152
- e.preventDefault();
153
-
154
- var $delete_btn = $(this);
155
- var href = $delete_btn.attr( 'href' );
156
- var confirm_user = confirm( delete_ctext );
157
-
158
- if( confirm_user ){
159
-
160
- var ajax = $.get( href );
161
- $delete_btn.addClass( 'spin' );
162
-
163
- ajax.done(function( data ){
164
- if( data.search( 'DELETED' ) != -1 ){
165
- var back_href = $( '.sc_back_btn' ).attr( 'href' );
166
- window.location = back_href + '&msg=3';
167
- }else{
168
- alert( 'Delete failed ! - ' + data );
169
- }
170
- });
171
-
172
- ajax.fail(function(){
173
- alert( 'Auth failed !' );
174
- });
175
-
176
- $delete_btn.removeClass( 'spin' );
177
-
178
- }
179
-
180
- });
181
-
182
- $( document ).on( 'click', '.sc_copy', function(e){
183
-
184
- e.preventDefault();
185
-
186
- var btn = $(this);
187
- var box = btn.closest( 'li' ).find( '.sc_copy_box' );
188
-
189
- $( '.sc_copy_box' ).not( box ).hide();
190
-
191
- box.fadeToggle();
192
- box.select();
193
-
194
- });
195
-
196
- $(window).load(function(){
197
-
198
- var insert_button = function(){
199
- return '<button class="button button-primary sc_insert_params"><span class="dashicons dashicons-plus"></span> Insert shortcode paramerters <span class="dashicons dashicons-arrow-down"></span></button>';
200
- }
201
-
202
- $( '.wp-media-buttons' ).append( insert_button );
203
- $( '.sc_editor_list' ).appendTo( '.wp-media-buttons' );
204
-
205
- if( window.sc_cm_editor ){
206
- $( '.sc_cm_menu' ).append( insert_button );
207
- $( '.sc_editor_list' ).appendTo( '.sc_cm_menu' );
208
  }
209
-
210
- $( '.params_wrap' ).appendTo( 'body' );
211
-
212
  });
213
-
214
- $( document ).on( 'click', '.sc_insert_params', function(e){
215
 
216
  e.preventDefault();
217
 
218
  var offset = $(this).offset();
219
  var mtop = offset.top + $(this).outerHeight();
220
-
221
- $( '.params_wrap' ).css({
222
  top: mtop,
223
  left: offset.left
224
  }).toggle();
 
225
  });
226
-
227
- $( document ).on( 'click', '.sc_tags_filt_icon', function(e){
228
-
229
- e.preventDefault();
230
- $( this ).closest( '.sc_tags_filt_btn' ).toggleClass( 'active' );
231
-
232
  });
233
-
234
- $( document ).on( 'click', '.sc_tags_list li', function(e){
235
 
236
- if(tags_filt_api){
237
- var tag = $(this).attr( 'data-tag-id' );
238
- tags_filt_api.addItem( tag );
239
- $( '.sc_tags_filt_btn' ).addClass( 'active' );
240
- }
241
-
242
- });
243
-
244
- $( document ).on( 'click', '.sc_copy_field', function(e){
245
- e.preventDefault();
246
- $(this).select();
247
- });
248
-
249
- $( document ).on( 'click', '.cp_btn', function(){
250
-
251
- var $cp_box = $( '.cp_box' );
252
- var $cp_info = $( '.cp_info' );
253
  var param_val = $cp_box.val().trim();
254
 
255
  if( param_val != '' && $cp_box[0].checkValidity() ){
256
- insert_in_editor( '%%' + param_val + '%%' );
257
- $cp_info.removeClass( 'red' );
258
- $( '.params_wrap' ).hide();
259
  }else{
260
- $cp_info.addClass( 'red' );
261
  }
262
 
263
  });
264
 
265
- $( document ).on( 'click', '.cf_btn', function(){
266
 
267
- var $cf_box = $( '.cf_box' );
268
- var $cf_info = $( '.cf_info' );
269
  var param_val = $cf_box.val().trim();
270
 
271
  if( param_val != '' && $cf_box[0].checkValidity() ){
272
- insert_in_editor( '$$custom_field:' + param_val + '$$' );
273
- $cf_info.removeClass( 'red' );
274
- $( '.params_wrap' ).hide();
275
  }else{
276
- $cf_info.addClass( 'red' );
277
- }
278
-
279
- });
280
-
281
- $( document ).on( 'click', '.wp_params li', function(){
282
- insert_in_editor('$$' + $(this).data( 'id' ) + '$$');
283
- $( '.params_wrap' ).hide();
284
- });
285
-
286
- $( document ).on( 'change', '.coffee_amt', function(){
287
- var btn = $( '.buy_coffee_btn' );
288
- btn.attr( 'href', btn.data( 'link' ) + $(this).val() );
289
- });
290
-
291
- $( document ).on( 'click', '.sort_btn', function(){
292
- last_sort = ( last_sort == 'asc' ) ? 'desc' : 'asc';
293
- sort( $( '.sc_list > li' ), last_sort );
294
- $( '.sort_icon' ).toggleClass( 'dashicons-arrow-down-alt' );
295
- $( '.sort_icon' ).toggleClass( 'dashicons-arrow-up-alt' );
296
- });
297
-
298
- $( document ).on( 'change', '#import', function(){
299
- if( !confirm( $( '.import_desc' ).text() ) ){
300
- return false;
301
- }
302
-
303
- if( confirm( $( '.import_desc2' ).text() ) ){
304
- $( '#fresh_import' ).prop( 'checked', true );
305
- }else{
306
- $( '#fresh_import' ).prop( 'checked', false );
307
- }
308
-
309
- $( '#import_form' ).submit();
310
- });
311
-
312
- $( document ).on( 'change', '.sc_editor', function(e){
313
- window.location = window.location + '&editor=' + $(this).val();
314
- });
315
-
316
- $( document ).on( 'click', '.search_btn', function(e){
317
- var $search_box = $(this).find('.search_box');
318
- if(e.target === $search_box[0]){
319
- return false;
320
- }
321
- $(this).toggleClass('active');
322
- $search_box.focus();
323
-
324
- });
325
-
326
- $( document ).on( 'keyup', '.search_box', function(){
327
- var search_term = $(this).val();
328
- var re = new RegExp(search_term, 'gi');
329
- $('.sc_list > li').each(function(){
330
- var name = $(this).attr('data-name');
331
- if(name.match(re) === null){
332
- $(this).hide();
333
  }else{
334
- $(this).show();
335
  }
336
  });
337
-
338
- if(search_term){
339
- $(this).parent().addClass('filtered');
340
- }else{
341
- $(this).parent().removeClass('filtered');
342
- }
343
-
344
- var visible = $('.sc_list > li:visible').length;
345
- var $no_scs_msg = $('.sc_list').find('p');
346
- if( visible == 0 ){
347
- if( $no_scs_msg.length == 0 ){
348
- $('.sc_list').append( '<p align="center" class="search_empty_msg"><i>No shortcodes match search term !</i></p>' );
349
- }
350
- }else{
351
- $no_scs_msg.remove();
352
- }
353
-
354
  });
355
-
356
- $( document ).on( 'click', '.sc_note_btn', function(e){
357
- $('.sc_note').slideToggle();
 
358
  });
359
-
360
  init();
361
-
362
  });
363
  })( jQuery );
1
  (function($){
2
  $(document).ready(function(){
3
+
 
 
 
 
4
  var init = function(){
5
+
6
+ if(window.SC_EDITOR == 'code'){
7
+
8
+ load_cm_sc_mode();
9
+
10
+ window.sc_cm = CodeMirror.fromTextArea(document.getElementById('content'), {
11
+ lineNumbers: true,
12
+ mode: 'sc_mode',
13
+ indentWithTabs: false,
14
+ lineWrapping: true,
15
+ styleActiveLine: true,
16
+ htmlMode: true
 
 
 
 
 
 
 
 
 
 
17
  });
18
+ sc_cm.setSize( null, 500 );
19
+ sc_cm.on('change', function(){
20
+ sc_cm.save();
21
+ });
22
+
23
+ $('.sc_editor_toolbar').appendTo('.sc_cm_menu');
24
+
25
+ }else{
26
+ $('.sc_editor_toolbar').appendTo('.wp-media-buttons');
27
+ }
28
+
29
+ if(typeof window.SC_VARS !== 'undefined'){
30
+ if(SC_VARS['screen']['base'] == 'edit'){
31
+
32
+ var version = '<small>v' + SC_VARS['sc_version'] + '</small>';
33
+ $('.wp-heading-inline').append(version);
34
+
35
+ add_top_coffee_btn();
36
+
37
  }
38
  }
39
+
40
+ $('.sc_params_list').appendTo('body');
41
+
 
 
 
 
42
  }
43
+
44
+ var set_sc_preview_text = function(name){
45
+ $('.sc_preview_text').text('[sc name="' + name + '"]');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  }
47
+
48
+ var insert_in_editor = function(data){
49
+ console.log(data);
50
+ if(window.SC_EDITOR == 'code'){
51
  var doc = window.sc_cm.getDoc();
52
+ doc.replaceRange(data, doc.getCursor());
53
  }else{
54
+ send_to_editor(data);
55
  }
56
  }
57
+
58
+ var copy_to_clipboard = function(str){
59
+ var el = document.createElement('textarea');
60
+ el.value = str;
61
+ el.setAttribute('readonly', '');
62
+ el.style.position = 'absolute';
63
+ el.style.left = '-9999px';
64
+ document.body.appendChild(el);
65
+ el.select();
66
+ document.execCommand('copy');
67
+ document.body.removeChild(el);
68
+ };
69
+
70
+ var load_cm_sc_mode = function(){
71
+
72
+ if(typeof CodeMirror.overlayMode === 'undefined'){
73
+ return false;
74
  }
75
+
76
+ CodeMirror.defineMode('sc_mode', function(config, parserConfig){
77
+ var mustacheOverlay = {
78
+ token: function(stream, state){
79
+ if(stream.match(/\$\$[a-z0-9A-Z:_]+\$\$/)){
80
+ return 'number sc_param';
81
+ }
82
+ if(stream.match(/%%[a-z0-9A-Z_]+%%/)){
83
+ return 'atom sc_param';
84
+ }
85
+ stream.next();
 
 
 
 
 
 
 
 
86
  }
87
+ };
88
+ return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || 'htmlmixed'), mustacheOverlay);
 
 
 
 
 
 
89
  });
90
  }
91
+
92
+ var close_params_list = function(){
93
+ $('.sc_params_list').hide();
94
+ }
95
+
96
+ var add_top_coffee_btn = function(){
97
+ $('#screen-meta-links').prepend('<div class="screen-meta-toggle cfe_top_link"><a class="show-settings button" href="https://www.paypal.me/vaakash/" target="_blank">Buy me a Coffee</a></div>');
98
+ }
99
+
100
+ $('#post_name').on('change keyup', function(){
101
+ set_sc_preview_text($(this).val());
102
+ });
103
+
104
+ $('.sc_editor').on('focus', function(){
105
+ window.sc_old_editor = $(this).val();
106
+ }).on('change', function(e){
107
+
108
+ new_editor = $(this).val();
109
+ response = confirm(SC_VARS.text_editor_switch_notice);
110
+
111
+ if(!response){
112
+ e.preventDefault();
113
+ $(this).val(window.sc_old_editor);
114
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
+
117
+ window.location = window.location + '&editor=' + $(this).val();
118
+
119
  });
120
+
121
+ $('.sc_insert_param').on('click', function(e){
122
 
123
  e.preventDefault();
124
 
125
  var offset = $(this).offset();
126
  var mtop = offset.top + $(this).outerHeight();
127
+
128
+ $('.sc_params_list').css({
129
  top: mtop,
130
  left: offset.left
131
  }).toggle();
132
+
133
  });
134
+
135
+ $('.sc_wp_params li').on('click', function(){
136
+ insert_in_editor('$$' + $(this).data('id') + '$$');
137
+ close_params_list();
 
 
138
  });
139
+
140
+ $('.sc_cp_btn').on('click', function(){
141
 
142
+ var $cp_box = $('.sc_cp_box');
143
+ var $cp_info = $('.sc_cp_info');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  var param_val = $cp_box.val().trim();
145
 
146
  if( param_val != '' && $cp_box[0].checkValidity() ){
147
+ insert_in_editor('%%' + param_val + '%%');
148
+ $cp_info.removeClass('red');
149
+ close_params_list();
150
  }else{
151
+ $cp_info.addClass('red');
152
  }
153
 
154
  });
155
 
156
+ $('.sc_cf_btn').on('click', function(){
157
 
158
+ var $cf_box = $('.sc_cf_box');
159
+ var $cf_info = $('.sc_cf_info');
160
  var param_val = $cf_box.val().trim();
161
 
162
  if( param_val != '' && $cf_box[0].checkValidity() ){
163
+ insert_in_editor('$$custom_field:' + param_val + '$$');
164
+ $cf_info.removeClass('red');
165
+ close_params_list();
166
  }else{
167
+ $cf_info.addClass('red');
168
+ }
169
+
170
+ });
171
+
172
+ $('.sc_copy').on('click', function(){
173
+ copy_to_clipboard($('.sc_preview_text').text());
174
+ $this = $(this);
175
+ $this.addClass('copied');
176
+ setTimeout(function() {
177
+ $this.removeClass('copied');
178
+ }, 3000);
179
+ })
180
+
181
+ $('.sc_changelog .dismiss_btn').on('click', function(){
182
+ var url = SC_VARS.ajax_url + '?action=sc_admin_ajax&do=close_changelog';
183
+ $.get(url, function( data ){
184
+ if(data.search( /done/g ) == -1){
185
+ $( '.sc_changelog article' ).html('Failed to close window. <a href="' + url + '" target="_blank">Please click here to close</a>');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  }else{
187
+ $( '.sc_changelog' ).fadeOut();
188
  }
189
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  });
191
+
192
+ $('.cfe_amt').on('click', function(){
193
+ var $btn = $(this).closest('.cfe_form').find('.cfe_btn');
194
+ $btn.attr('href', $btn.data('link') + $(this).val());
195
  });
196
+
197
  init();
198
+
199
  });
200
  })( jQuery );
admin/js/tinymce/editor_plugin.js CHANGED
@@ -3,20 +3,21 @@
3
  */
4
 
5
  (function() {
6
-
7
  tinymce.create( 'tinymce.plugins.SCButton',{
8
 
9
- init : function( ed, url ){
 
10
  ed.addButton( 'shortcoder', {
11
  title : 'Insert shortcodes created using Shortcoder',
12
- image : url + '/icon.png',
13
- onclick : function() {
14
- if( typeof sc_show_insert !== 'undefined' ) sc_show_insert();
15
  }
16
- });
17
  },
18
-
19
- getInfo : function() {
20
  return {
21
  longname : 'Shortcoder',
22
  author : 'Aakash Chakravarthy',
@@ -27,7 +28,7 @@
27
  }
28
 
29
  });
30
-
31
  tinymce.PluginManager.add( 'shortcoder', tinymce.plugins.SCButton );
32
-
33
  })();
3
  */
4
 
5
  (function() {
6
+
7
  tinymce.create( 'tinymce.plugins.SCButton',{
8
 
9
+ init : function(ed, url){
10
+ var url = url.replace('/js/tinymce', '');
11
  ed.addButton( 'shortcoder', {
12
  title : 'Insert shortcodes created using Shortcoder',
13
+ image : url + '/images/shortcoder.svg',
14
+ onclick : function(){
15
+ if(typeof sc_show_insert !== 'undefined') sc_show_insert();
16
  }
17
+ });
18
  },
19
+
20
+ getInfo : function(){
21
  return {
22
  longname : 'Shortcoder',
23
  author : 'Aakash Chakravarthy',
28
  }
29
 
30
  });
31
+
32
  tinymce.PluginManager.add( 'shortcoder', tinymce.plugins.SCButton );
33
+
34
  })();
admin/js/tinymce/icon.png DELETED
Binary file
admin/js/tinymce/index.html DELETED
File without changes
admin/manage.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if( ! defined( 'ABSPATH' ) ) exit;
3
+
4
+ class SC_Admin_Manage{
5
+
6
+ public static function init(){
7
+
8
+ add_filter( 'manage_' . SC_POST_TYPE . '_posts_columns', array( __class__, 'column_head' ) );
9
+
10
+ add_action( 'manage_' . SC_POST_TYPE . '_posts_custom_column', array( __class__, 'column_content' ), 10, 2 );
11
+
12
+ add_filter( 'edit_posts_per_page', array( __class__, 'per_page_count' ), 10, 2 );
13
+
14
+ }
15
+
16
+ public static function column_head( $columns ){
17
+
18
+ unset( $columns[ 'views' ] );
19
+
20
+ $columns[ 'shortcode' ] = __( 'Shortcode', 'sc');
21
+
22
+ return $columns;
23
+
24
+ }
25
+
26
+ public static function column_content( $column, $post_id ){
27
+
28
+ if( $column == 'shortcode' ){
29
+ $sc_tag = Shortcoder::get_sc_tag( $post_id );
30
+ echo '<code>' . $sc_tag . '</code>';
31
+ }
32
+
33
+ }
34
+
35
+ public static function per_page_count( $count, $post_type ){
36
+ if( $post_type == SC_POST_TYPE && $count == 20 ){
37
+ return 500;
38
+ }
39
+ return $count;
40
+ }
41
+
42
+ }
43
+
44
+ SC_Admin_Manage::init();
45
+
46
+ ?>
admin/sc-admin.php DELETED
@@ -1,651 +0,0 @@
1
- <?php
2
-
3
- class Shortcoder_Admin{
4
-
5
- private static $pagehook = 'settings_page_shortcoder';
6
-
7
- public static function init(){
8
-
9
- // Add menu
10
- add_action( 'admin_menu', array( __class__, 'add_menu' ) );
11
-
12
- // Enqueue the scripts and styles
13
- add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
14
-
15
- // Register the action for admin ajax features
16
- add_action( 'wp_ajax_sc_admin_ajax', array( __CLASS__, 'admin_ajax' ) );
17
-
18
- // Register action links
19
- add_filter( 'plugin_action_links_' . SC_BASE_NAME, array( __CLASS__, 'action_links' ) );
20
-
21
- // Add Quick Tag button to the editor
22
- add_action( 'admin_footer', array( __class__, 'add_qt_button' ) );
23
-
24
- // Add TinyMCE button
25
- add_action( 'admin_init', array( __class__, 'register_mce' ) );
26
-
27
- }
28
-
29
- public static function add_menu(){
30
-
31
- add_options_page( 'Shortcoder', 'Shortcoder', 'manage_options', 'shortcoder', array( __class__, 'admin_page' ) );
32
-
33
- }
34
-
35
- public static function enqueue_scripts( $hook ){
36
-
37
- if( $hook == self::$pagehook ){
38
-
39
- wp_enqueue_style( 'sc-admin-css', SC_ADMIN_URL . '/css/style.css', array(), SC_VERSION );
40
- wp_enqueue_style( 'sc-selectize', 'https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.4/css/selectize.min.css', array(), SC_VERSION );
41
-
42
- wp_enqueue_script( 'jquery' );
43
- wp_enqueue_script( 'sc-admin-js', SC_ADMIN_URL . '/js/script.js', array( 'jquery' ), SC_VERSION );
44
- wp_enqueue_script( 'sc-selectize', 'https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.12.4/js/standalone/selectize.min.js', array( 'jquery' ), SC_VERSION );
45
-
46
- }
47
- }
48
-
49
- public static function admin_page(){
50
-
51
- echo '<div class="wrap">';
52
- echo '<div class="head_wrap">';
53
- echo '<h1 class="sc_title">Shortcoder <span class="title-count">' . SC_VERSION . '</span></h1>';
54
- self::top_sharebar();
55
- self::print_notice();
56
- echo '</div>';
57
-
58
- echo '<div id="content">';
59
-
60
- $g = self::clean_get();
61
-
62
- if( !isset( $g[ 'action' ] ) ){
63
- $g[ 'action' ] = 'list';
64
- }
65
-
66
- if( $g[ 'action' ] == 'list' ){
67
- self::list_shortcodes();
68
- }
69
-
70
- if( $g[ 'action' ] == 'edit' ){
71
- self::edit_shortcode();
72
- }
73
-
74
- if( $g[ 'action' ] == 'new' ){
75
- self::new_shortcode();
76
- }
77
-
78
- echo '</div>';
79
-
80
- self::page_bottom();
81
-
82
- echo '</div>';
83
-
84
- }
85
-
86
- public static function list_shortcodes(){
87
-
88
- Shortcoder_Import::check_import();
89
-
90
- $shortcodes = Shortcoder::list_all();
91
- $g = self::clean_get();
92
-
93
- echo '<h3 class="page_title">' . __( 'List of shortcodes created', 'shortcoder' ) . ' (' . count( $shortcodes ) . ')';
94
- echo '<span class="sc_menu">';
95
-
96
- echo '<button class="button sc_tags_filt_btn" tooltip="' . __( 'Filter by tags', 'shortcoder' ) . '"><span class="dashicons dashicons-tag sc_tags_filt_icon"></span>';
97
- echo '<div class="sc_tags_filter_wrap"><select class="sc_tags_filter" multiple>';
98
- $all_tags = Shortcoder::get_tags();
99
- foreach($all_tags as $tag){
100
- echo '<option value="' . $tag . '">' . $tag . '</option>';
101
- }
102
- echo '</select></div>';
103
- echo '</button>';
104
-
105
- echo '<span class="button search_btn" tooltip="' . __( 'Search shortcodes', 'shortcoder' ) . '"><span class="dashicons dashicons-search"></span><input type="search" class="search_box" placeholder="Search ..."/></span>';
106
-
107
- echo '<label for="import" class="button" tooltip="' . __( 'Import shortcodes', 'shortcoder' ) . '"><span class="dashicons dashicons-download"></span></label>';
108
-
109
- echo '<a href="' . self::get_link(array(
110
- 'action' => 'sc_export',
111
- '_wpnonce' => wp_create_nonce( 'sc_export_data' )
112
- ), 'admin-ajax.php' ) . '" class="button" tooltip="' . __( 'Export shortcodes', 'shortcoder' ) . '"><span class="dashicons dashicons-upload"></span></a>';
113
-
114
-
115
- echo '<button class="button sort_btn" tooltip="' . __( 'Sort list', 'shortcoder' ) . '"><span class="dashicons dashicons-menu"></span> <span class="dashicons dashicons-arrow-down-alt sort_icon"></span></button>';
116
-
117
- echo '<a href="' . self::get_link(array( 'action' => 'new' )) . '" class="button button-primary sc_new_btn"><span class="dashicons dashicons-plus"></span> ' . __( 'Create a new shortcode', 'shortcoder' ) . '</a>';
118
-
119
- echo '</span>';
120
- echo '</h3>';
121
-
122
- echo '<ul class="sc_list" data-empty="' . __( 'No shortcodes are created. Go ahead create one !', 'shortcoder' ) . '">';
123
- foreach( $shortcodes as $name => $data ){
124
-
125
- $data = wp_parse_args( $data, Shortcoder::defaults() );
126
-
127
- $link = self::get_link(array(
128
- 'action' => 'edit',
129
- 'id' => base64_encode( $name )
130
- ));
131
-
132
- $delete_link = self::get_link(array(
133
- 'action' => 'sc_admin_ajax',
134
- 'do' => 'delete',
135
- 'id' => base64_encode( $name ),
136
- '_wpnonce' => wp_create_nonce( 'sc_delete_nonce' )
137
- ), 'admin-ajax.php' );
138
-
139
- $disabled_text = ( $data[ 'disabled' ] == '1' ) ? '<small class="disabled_text">' . __( 'Temporarily disabled', 'shortcoder' ) . '</small>' : '';
140
-
141
- $selected_tags = implode( ',', $data[ 'tags' ] );
142
-
143
- echo '<li data-name="' . esc_attr( $name ) . '" data-tags="' . esc_attr( $selected_tags ) . '">';
144
- echo '<a href="' . $link . '" class="sc_link" title="' . __( 'Edit shortcode', 'shortcoder' ) . '">' . esc_attr( $name ) . $disabled_text . '</a>';
145
-
146
- echo '<span class="sc_controls">';
147
-
148
- if( isset( $data[ 'tags' ] ) && !empty( $data[ 'tags' ] ) && is_array( $data[ 'tags' ] ) ){
149
- echo '<ul class="sc_tags_list">';
150
- foreach( $data['tags'] as $tag ){
151
- echo '<li data-tag-id="' . $tag . '">' . $tag . '</li>';
152
- }
153
- echo '</ul>';
154
- }
155
-
156
- echo '<a href="#" class="sc_copy" title="' . __( 'Copy shortcode', 'shortcoder' ) . '"><span class="dashicons dashicons-editor-code"></span></a>';
157
- echo '<a href="' . $delete_link . '" class="sc_delete" title="' . __( 'Delete', 'shortcoder' ) . '"><span class="dashicons dashicons-trash"></span></a>';
158
- echo '</span>';
159
-
160
- echo '<input type="text" value="' . self::get_shortcode( $name ) . '" class="sc_copy_box" readonly="readonly" title="' . __( 'Copy shortcode', 'shortcoder' ) . '" />';
161
-
162
- echo '</li>';
163
-
164
- }
165
- echo '</ul>';
166
-
167
- Shortcoder_Import::import_form();
168
-
169
- }
170
-
171
- public static function new_shortcode(){
172
- self::edit_shortcode( 'new' );
173
- }
174
-
175
- public static function edit_shortcode( $action = 'edit' ){
176
-
177
- self::save_shortcode();
178
-
179
- $shortcodes = Shortcoder::list_all();
180
- $g = self::clean_get();
181
-
182
- $page_title = __( 'New shortcode', 'shortcoder' );
183
- $action_btn = __( 'Create shortcode', 'shortcoder' );
184
- $sc_name = '';
185
- $values = array();
186
-
187
- if( $action == 'edit' ){
188
-
189
- $page_title = __( 'Edit shortcode', 'shortcoder' );
190
- $action_btn = __( 'Save settings', 'shortcoder' );
191
-
192
- if( !isset( $g[ 'id' ] ) ){
193
- echo '<p align="center">' . __( 'No shortcode ID provided !' ) . '</p>';
194
- return false;
195
- }
196
-
197
- $sc_name = base64_decode( $g[ 'id' ] );
198
-
199
- if( !array_key_exists( $sc_name, $shortcodes ) ){
200
- echo '<p align="center">' . __( 'Invalid shortcode ID or no such shortcode with name [' . esc_attr( $sc_name ) . '] exists !' ) . '</p>';
201
- return false;
202
- }
203
-
204
- $values = $shortcodes[ $sc_name ];
205
-
206
- }
207
-
208
- $values = wp_parse_args( $values, Shortcoder::defaults() );
209
-
210
- echo '<h3 class="page_title">' . $page_title;
211
- echo '<div class="sc_menu">';
212
- echo '<a href="' . self::get_link() . '" class="button sc_back_btn"><span class="dashicons dashicons-arrow-left-alt2"></span> ' . __( 'Back', 'shortcoder' ) . '</a>';
213
- echo '</div>';
214
- echo '</h3>';
215
-
216
- $note_btn = '<span class="dashicons dashicons-info sc_note_btn" title="Open note"></span>';
217
-
218
- echo '<form method="post" id="sc_edit_form">';
219
-
220
- echo '<div class="sc_section">';
221
- echo '<label for="sc_name">' . __( 'Name', 'shortcoder' ) . '</label>';
222
- echo '<div class="sc_name_wrap"><input type="text" id="sc_name" name="sc_name" value="' . esc_attr( $sc_name ) . '" class="widefat" required="required" placeholder="' . __( 'Enter a name for the shortcode, case sensitive', 'shortcoder' ) . '" pattern="[a-zA-z0-9 \-]+" />';
223
- echo ( $action == 'edit' ) ? '<div class="copy_shortcode">Your shortcode is - <input type="text" value="' . esc_attr( self::get_shortcode( $sc_name ) ) . '" class="sc_copy_field" readonly="readonly" title="' . __( 'Copy shortcode', 'shortcoder' ) . '"/></div>' : '';
224
- echo ( $action != 'edit' ) ? '<div class="copy_shortcode">' . __( 'Allowed characters A to Z, a to z, 0 to 9, hyphens, underscores and space', 'shortcoder' ) . '</div>' : '';
225
- echo '</div>';
226
- echo '</div>';
227
-
228
- echo '<input type="hidden" name="sc_old_name" value="' . esc_attr( $sc_name ) . '" />';
229
-
230
- echo '<div class="sc_section">';
231
- echo '<label for="sc_content">' . __( 'Shortcode content', 'shortcoder' ) . $note_btn . '</label>';
232
-
233
- echo '<p class="sc_note">' . __( 'Note: You can use any HTML, JavaScript, CSS as shortcode content. Shortcoder does not manipulate the shortcode content. What you provide above is what you get as output. Please verify the shortcode content for any syntax or JavaScript errors.', 'shortcoder' ) . '</p>';
234
-
235
- $editors_list = array(
236
- 'text' => 'Text editor',
237
- 'visual' => 'Visual editor',
238
- 'code' => 'Code editor'
239
- );
240
- $editor = ( isset( $g[ 'editor' ] ) && array_key_exists( $g[ 'editor' ], $editors_list ) ) ? $g[ 'editor' ] : $values[ 'editor' ];
241
-
242
- echo '<span class="sc_editor_list sc_editor_icon_' . $editor . '"><select name="sc_editor" class="sc_editor button">';
243
- foreach( $editors_list as $id => $name ){
244
- echo '<option value="' . $id . '" ' . selected( $editor, $id ) . '>' . $name . '</option>';
245
- }
246
- echo '</select></span>';
247
-
248
- self::load_editor( $editor, $values[ 'content' ] );
249
-
250
- echo '</div>';
251
-
252
- $device_options = array(
253
- 'all' => __( 'On both desktop and mobile devices', 'shortcoder' ),
254
- 'mobile_only' => __( 'On mobile devices alone', 'shortcoder' ),
255
- 'desktop_only' => __( 'On desktops alone', 'shortcoder' )
256
- );
257
-
258
- echo '<div class="sc_settings">';
259
-
260
- echo '<div class="sc_section">';
261
- echo '<h4>' . __( 'Settings', 'shortcoder' ) . '</h4>';
262
- echo '<label><input type="checkbox" name="sc_disable" value="1" ' . checked( $values[ 'disabled' ], '1', false ) . '/> ' . __( 'Temporarily disable this shortcode', 'shortcoder' ) . '</label>';
263
- echo '<label><input type="checkbox" name="sc_hide_admin" value="1" ' . checked( $values[ 'hide_admin' ], '1', false ) . '/> ' . __( 'Disable this Shortcode for administrators' ) . '</label>';
264
- echo '</div>';
265
-
266
- echo '<div class="sc_section">';
267
- echo '<h4>' . __( 'Visibility', 'shortcoder' ) . '</h4>';
268
- echo '<label>' . __( 'Show this shortcode', 'shortcoder' );
269
- echo '<select name="sc_devices">';
270
- foreach( $device_options as $id => $name ){
271
- echo '<option value="' . $id . '" ' . selected( $values[ 'devices' ], $id ) . '>' . $name . '</option>';
272
- }
273
- echo '</select></label>';
274
- echo '</div>';
275
-
276
- echo '<div class="sc_section">';
277
- echo '<h4>' . __( 'Tags', 'shortcoder' ) . '</h4>';
278
- echo '<select name="sc_tags[]" class="sc_edit_tags" multiple>';
279
- $all_tags = Shortcoder::get_tags();
280
- foreach($all_tags as $tag){
281
- echo '<option value="' . $tag . '" ' . ( in_array( $tag, $values[ 'tags' ] ) ? 'selected="selected"' : '' ) . '>' . $tag . '</option>';
282
- }
283
- echo '</select>';
284
- echo '</div>';
285
-
286
- echo '</div>';
287
-
288
- wp_nonce_field( 'sc_edit_nonce' );
289
-
290
- echo '<footer class="page_footer">';
291
- echo '<button class="button button-primary sc_save">' . $action_btn . '</button>';
292
-
293
- if( $action == 'edit' ){
294
- $delete_link = self::get_link(array(
295
- 'action' => 'sc_admin_ajax',
296
- 'do' => 'delete',
297
- 'id' => base64_encode( $sc_name ),
298
- '_wpnonce' => wp_create_nonce( 'sc_delete_nonce' )
299
- ), 'admin-ajax.php' );
300
- echo '<a href="' . $delete_link . '" class="button sc_delete_ep" title="' . __( 'Delete', 'shortcoder' ) . '"><span class="dashicons dashicons-trash"></span></a>';
301
- }
302
-
303
- echo '</footer>';
304
-
305
- echo '</form>';
306
-
307
- $sc_wp_params = Shortcoder::wp_params_list();
308
-
309
- echo '<ul class="params_wrap">';
310
-
311
- foreach( $sc_wp_params as $group => $group_info ){
312
- echo '<li>' . $group_info[ 'name' ];
313
- echo '<ul class="wp_params">';
314
- foreach( $group_info[ 'params' ] as $param_id => $param_name ){
315
- echo '<li data-id="' . $param_id . '">' . $param_name . '</li>';
316
- }
317
- echo '</ul></li>';
318
- }
319
-
320
- echo '<li>' . __( 'Custom parameter', 'shortcoder' ) . '<ul>';
321
- echo '<li class="isc_form"><h4>' . __( 'Enter custom parameter name', 'shortcoder' ) . '</h4>';
322
- echo '<input type="text" class="cp_box" pattern="[a-zA-Z0-9]+"/> <button class="button cp_btn">' . __( 'Insert parameter', 'shortcoder' ) . '</button><p class="isc_info cp_info"><small>' . __( 'Only alphabets and numbers allowed. Custom parameters are case insensitive', 'shortcoder' ) . '</small></p></li>';
323
- echo '</ul></li>';
324
-
325
- echo '<li>' . __( 'Custom Fields', 'shortcoder' ) . '<ul>';
326
- echo '<li class="isc_form"><h4>' . __( 'Enter custom field name', 'shortcoder' ) . '</h4>';
327
- echo '<input type="text" class="cf_box" pattern="[a-zA-Z0-9_-]+"/> <button class="button cf_btn">' . __( 'Insert custom field', 'shortcoder' ) . '</button><p class="isc_info cf_info"><small>' . __( 'Only alphabets, numbers, underscore and hyphens are allowed. Cannot be empty.', 'shortcoder' ) . '</small></p></li>';
328
- echo '</ul></li>';
329
-
330
- echo '</ul>';
331
- }
332
-
333
- public static function save_shortcode(){
334
-
335
- if( $_POST && check_admin_referer( 'sc_edit_nonce' ) ){
336
-
337
- $p = wp_parse_args( self::clean_post(), array(
338
- 'sc_name' => '',
339
- 'sc_old_name' => '',
340
- 'sc_content' => '',
341
- 'sc_disable' => 0,
342
- 'sc_hide_admin' => 0,
343
- 'sc_devices' => 'all',
344
- 'sc_editor' => 'text',
345
- 'sc_tags' => array()
346
- ));
347
-
348
- $name = trim( self::clean_name( $p[ 'sc_name' ] ) );
349
- $old_name = trim( self::clean_name( $p[ 'sc_old_name' ] ) );
350
- $sc_name_changed = ( !empty( $old_name ) && $old_name != $name );
351
-
352
- if( empty( $name ) ){
353
- self::print_notice( 0 );
354
- return false;
355
- }
356
-
357
- $shortcodes = Shortcoder::list_all();
358
- $values = array(
359
- 'content' => $p[ 'sc_content' ],
360
- 'disabled' => $p[ 'sc_disable' ],
361
- 'hide_admin' => $p[ 'sc_hide_admin' ],
362
- 'devices' => $p[ 'sc_devices' ],
363
- 'editor' => $p[ 'sc_editor' ],
364
- 'tags' => $p[ 'sc_tags' ]
365
- );
366
-
367
- if( $sc_name_changed ){
368
- unset( $shortcodes[ $old_name ] );
369
- }
370
-
371
- $is_new_shortcode = array_key_exists( $name, $shortcodes );
372
-
373
- $shortcodes[ $name ] = $values;
374
-
375
- $save_success = update_option( 'shortcoder_data', $shortcodes );
376
-
377
- if( $save_success ){
378
- if( $is_new_shortcode ){
379
- self::print_notice( 2 );
380
- }else{
381
- self::print_notice( 1 );
382
- }
383
- }else{
384
- self::print_notice( 5 );
385
- }
386
-
387
- if( $sc_name_changed ){
388
- wp_safe_redirect( self::get_link( array(
389
- 'action' => 'edit',
390
- 'id' => base64_encode( $name )
391
- )));
392
- }
393
-
394
- }
395
-
396
- }
397
-
398
- public static function delete_shortcode( $name ){
399
-
400
- $shortcodes = Shortcoder::list_all();
401
-
402
- if( array_key_exists( $name, $shortcodes ) ){
403
- unset( $shortcodes[ $name ] );
404
- update_option( 'shortcoder_data', $shortcodes );
405
- return true;
406
- }else{
407
- return false;
408
- }
409
-
410
- }
411
-
412
- public static function get_link( $params = array(), $page = 'options-general.php' ){
413
-
414
- $params[ 'page' ] = 'shortcoder';
415
- return add_query_arg( $params, admin_url( $page ) );
416
-
417
- }
418
-
419
- public static function get_shortcode( $name = '' ){
420
- return esc_attr( '[sc name="' . $name . '"]' );
421
- }
422
-
423
- public static function admin_ajax(){
424
-
425
- $g = self::clean_get();
426
-
427
- if( $g[ 'do' ] == 'delete' && isset( $g[ 'id' ] ) && check_admin_referer( 'sc_delete_nonce' ) ){
428
- $sc_name = base64_decode( $g[ 'id' ] );
429
- if( self::delete_shortcode( $sc_name ) ){
430
- echo 'DELETED';
431
- }else{
432
- echo 'FAILED';
433
- }
434
- }
435
-
436
- if( $g[ 'do' ] == 'insert_shortcode' ){
437
- include_once( 'sc-insert.php' );
438
- }
439
-
440
- die(0);
441
- }
442
-
443
- public static function add_qt_button(){
444
-
445
- $screen = get_current_screen();
446
- if( self::$pagehook == $screen->id )
447
- return;
448
-
449
- add_thickbox();
450
-
451
- echo '
452
- <script>
453
- if(window.addEventListener){
454
- window.addEventListener("load", function(){
455
- if( typeof QTags === "function" ){
456
- QTags.addButton( "QT_sc_insert", "Shortcoder", sc_show_insert );
457
- }
458
- });
459
- }
460
-
461
- function sc_show_insert(){
462
- tb_show( "Insert a Shortcode", "' . admin_url( 'admin-ajax.php?action=sc_admin_ajax&do=insert_shortcode&TB_iframe=true' ) . '" );
463
- }
464
- </script>';
465
- }
466
-
467
- public static function register_mce(){
468
- add_filter( 'mce_buttons', array( __class__, 'register_mce_button' ) );
469
- add_filter( 'mce_external_plugins', array( __class__, 'register_mce_js' ) );
470
- }
471
-
472
- public static function register_mce_button( $buttons ){
473
-
474
- if( self::is_sc_admin() )
475
- return $buttons;
476
-
477
- array_push( $buttons, 'separator', 'shortcoder' );
478
- return $buttons;
479
-
480
- }
481
-
482
- public static function register_mce_js( $plugins ){
483
-
484
- if( self::is_sc_admin() )
485
- return $plugins;
486
-
487
- $plugins[ 'shortcoder' ] = SC_ADMIN_URL . '/js/tinymce/editor_plugin.js';
488
- return $plugins;
489
-
490
- }
491
-
492
- public static function load_editor( $type, $value ){
493
-
494
- if( $type == 'code' ){
495
- self::load_codemirror_editor( $value );
496
- }else{
497
- wp_editor( $value, 'sc_content', array( 'wpautop'=> false, 'textarea_rows'=> 15, 'tinymce' => ( $type == 'visual' ) ) );
498
- }
499
-
500
- }
501
-
502
- public static function load_codemirror_editor( $value ){
503
- echo '<link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.47.0/codemirror.min.css" rel="stylesheet">';
504
- echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.47.0/codemirror.min.js"></script>';
505
- echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.47.0/mode/htmlmixed/htmlmixed.min.js"></script>';
506
- echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.47.0/mode/css/css.min.js"></script>';
507
- echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.47.0/mode/xml/xml.min.js"></script>';
508
- echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.47.0/mode/javascript/javascript.min.js"></script>';
509
- echo '<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.47.0/addon/selection/active-line.min.js"></script>';
510
-
511
- echo '<div class="sc_cm_menu"></div>';
512
- echo '<textarea name="sc_content" id="sc_content">' . esc_textarea( $value ) . '</textarea>';
513
-
514
- echo '<script>var sc_cm_editor = true;</script>';
515
- }
516
-
517
- public static function page_bottom(){
518
-
519
- echo '<div class="coffee_box">
520
- <div class="coffee_amt_wrap">
521
- <p><select class="coffee_amt">
522
- <option value="2">$2</option>
523
- <option value="3">$3</option>
524
- <option value="4">$4</option>
525
- <option value="5" selected="selected">$5</option>
526
- <option value="6">$6</option>
527
- <option value="7">$7</option>
528
- <option value="8">$8</option>
529
- <option value="9">$9</option>
530
- <option value="10">$10</option>
531
- <option value="11">$11</option>
532
- <option value="12">$12</option>
533
- <option value="">Custom</option>
534
- </select></p>
535
- <a class="button button-primary buy_coffee_btn" href="https://www.paypal.me/vaakash/5" data-link="https://www.paypal.me/vaakash/" target="_blank">Buy me a coffee !</a>
536
- </div>
537
- <h2>Buy me a coffee !</h2>
538
- <p>Thank you for using Shortcoder. If you found the plugin useful buy me a coffee ! Your donation will motivate and make me happy for all the efforts. You can donate via PayPal.</p>';
539
- echo '</div>';
540
-
541
- echo '<p class="credits_box"><img src="' . SC_ADMIN_URL . '/images/aw.png" /> Created by <a href="https://goo.gl/aHKnsM" target="_blank">Aakash Chakravarthy</a> - Follow me on <a href="https://twitter.com/vaakash" target="_blank">Twitter</a>, <a href="https://fb.com/aakashweb" target="_blank">Facebook</a>, <a href="https://www.linkedin.com/in/vaakash/" target="_blank">LinkedIn</a>. Check out <a href="https://goo.gl/OAxx4l" target="_blank">my other works</a>.
542
-
543
- <a href="https://goo.gl/ltvnIE" class="rate_link" target="_blank">Rate <span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span> if you like Shortcoder</a>
544
-
545
- </p>';
546
-
547
- }
548
-
549
- public static function top_sharebar(){
550
- echo '
551
- <div class="top_sharebar">
552
-
553
- <a href="https://goo.gl/r8Qr7Y" class="help_link" target="_blank" title="Help"><span class="dashicons dashicons-editor-help"></span></a>
554
- <a href="https://goo.gl/URfxp2" class="help_link" target="_blank" title="Report issue"><span class="dashicons dashicons-flag"></span></a>
555
-
556
- <a class="share_btn rate_btn" href="https://goo.gl/ltvnIE" target="_blank" title="Please rate 5 stars if you like Shortcoder"><span class="dashicons dashicons-star-filled"></span> Rate 5 stars</a>
557
- <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>
558
-
559
- </div>';
560
- }
561
-
562
- public static function action_links( $links ){
563
- array_unshift( $links, '<a href="https://goo.gl/qMF3iE" target="_blank">Donate</a>' );
564
- array_unshift( $links, '<a href="'. esc_url( admin_url( 'options-general.php?page=shortcoder' ) ) .'">Settings</a>' );
565
- return $links;
566
- }
567
-
568
- public static function print_notice( $id = '' ){
569
-
570
- $g = self::clean_get();
571
- $type = 'success';
572
- $msg = '';
573
-
574
- if( $id == '' ){
575
- if( !isset( $g[ 'msg' ] ) ){
576
- return false;
577
- }
578
- $id = $g[ 'msg' ];
579
- }
580
-
581
- if( $id == 0 ){
582
- $msg = __( 'Shortcode name is empty. Cannot save settings !', 'shortcoder' );
583
- $type = 'error';
584
- }
585
-
586
- if( $id == 1 ){
587
- $msg = __( 'Shortcode created successfully', 'shortcoder' );
588
- }
589
-
590
- if( $id == 2 ){
591
- $msg = __( 'Shortcode updated successfully', 'shortcoder' );
592
- }
593
-
594
- if( $id == 3 ){
595
- $msg = __( 'Shortcode deleted successfully', 'shortcoder' );
596
- }
597
-
598
- if( $id == 4 ){
599
- $msg = __( 'Shortcode name edited successfully', 'shortcoder' );
600
- }
601
-
602
- if( $id == 5 ){
603
- $msg = __( 'Failed to save shortcode. Please check if any other plugin is interfering while saving the shortcode content.', 'shortcoder' );
604
- $type = 'error';
605
- }
606
-
607
- if( $msg != '' ){
608
- echo '<div class="notice notice-' . $type . ' is-dismissible"><p>' . $msg . '</p></div>';
609
- }
610
- }
611
-
612
- public static function clean_name( $name = '' ){
613
-
614
- return trim( preg_replace('/[^0-9a-zA-Z\- _]/', '', $name ) );
615
-
616
- }
617
-
618
- public static function clean_get(){
619
-
620
- foreach( $_GET as $k=>$v ){
621
- $_GET[$k] = sanitize_text_field( $v );
622
- }
623
-
624
- return $_GET;
625
- }
626
-
627
- public static function clean_post(){
628
-
629
- return stripslashes_deep( $_POST );
630
-
631
- }
632
-
633
- public static function is_sc_admin(){
634
-
635
- if( !function_exists( 'get_current_screen' ) )
636
- return false;
637
-
638
- $screen = get_current_screen();
639
- if( self::$pagehook == $screen->id ){
640
- return true;
641
- }else{
642
- return false;
643
- }
644
-
645
- }
646
-
647
- }
648
-
649
- Shortcoder_Admin::init();
650
-
651
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/sc-insert.php DELETED
@@ -1,119 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Insert shortcode</title>
5
- <meta name="viewport" content="width=device-width, initial-scale=1" />
6
- <link href="<?php echo SC_ADMIN_URL; ?>css/style-insert.css<?php echo '?ver=' . SC_VERSION; ?>" media="all" rel="stylesheet" />
7
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
8
- <script src="<?php echo SC_ADMIN_URL; ?>js/script-insert.js<?php echo '?ver=' . SC_VERSION; ?>"></script>
9
- </head>
10
- <body>
11
-
12
- <h2 class="sc_head">Insert shortcode to editor</h2>
13
-
14
- <div class="sc_menu">
15
- <input type="search" class="button search_box" placeholder="Search ..." />
16
- <a href="#" class="button tags_filter_btn">Filter by tags</a>
17
- <a href="#" class="button sort_btn">Sort list</a>
18
- <?php
19
- if( Shortcoder::can_edit_sc( 'manage_options' ) ){
20
- echo '<a href="' . admin_url( 'options-general.php?page=shortcoder&action=new' ) . '" target="_blank" class="button new_btn">Create new shortcode</a>';
21
- }
22
- ?>
23
- </div>
24
-
25
- <ul class="sc_tags clearfix">
26
- <?php
27
- $all_tags = Shortcoder::get_tags();
28
- foreach($all_tags as $tag){
29
- echo '<li data-value="' . $tag . '">' . $tag . '</li>';
30
- }
31
- ?>
32
- </ul>
33
-
34
- <div class="sc_wrap">
35
- <?php
36
-
37
- $shortcodes = Shortcoder::list_all();
38
-
39
- if( empty( $shortcodes ) ){
40
- echo '<p align="center">No shortcodes are created, go ahead create one in <a href="' . admin_url( 'options-general.php?page=shortcoder' ) . '" target="_blank">shortcoder admin page</a>.</p>';
41
- }else{
42
-
43
- foreach( $shortcodes as $key=>$value ){
44
- if($key != '_version_fix'){
45
-
46
- $name = esc_attr( $key );
47
- $value = wp_parse_args( $value, Shortcoder::defaults() );
48
- $disabled_text = ( $value[ 'disabled' ] == '1' ) ? '<small class="disabled_text">Temporarily disabled</small>' : '';
49
- $selected_tags = esc_attr( implode( ', ', $value[ 'tags' ] ) );
50
-
51
- $options = '<span class="sc_options">';
52
- $options .= '<span class="sc_tags_disp">' . $selected_tags . '</span>';
53
-
54
- $options .= '<button class="button sc_quick_insert">Quick insert</button>';
55
-
56
- if( Shortcoder::can_edit_sc( 'manage_options' ) ){
57
- $options .= '<a href="' . esc_attr( admin_url( 'options-general.php?page=shortcoder&action=edit&id=' . base64_encode( $name ) ) ) . '" target="_blank" class="button">Edit</a>';
58
- }
59
-
60
- $options .= '</span>';
61
-
62
- echo '<div class="sc_shortcode" data-name="' . $name . '" data-tags="' . $selected_tags . '">';
63
- echo '<div class="sc_shortcode_name">' . $name . $disabled_text . $options . '</div>';
64
- preg_match_all('/%%[^%\s]+%%/', $value['content'], $matches );
65
-
66
- echo '<div class="sc_params">';
67
- if(!empty($matches[0])){
68
- echo '<h4>Available parameters: </h4>';
69
- echo '<div class="sc_params_wrap">';
70
- $temp = array();
71
- foreach($matches[0] as $k=>$v){
72
- $cleaned = str_replace('%', '', $v);
73
- if(!in_array($cleaned, $temp)){
74
- array_push($temp, $cleaned);
75
- echo '<label>' . $cleaned . ': <input type="text" data-param="' . $cleaned . '"/></label> ';
76
- }
77
- }
78
- echo '</div>';
79
- echo'<hr/>';
80
- }else{
81
- echo 'No parameters available - ';
82
- }
83
-
84
- $enclosed_sc = ( strpos( $value['content'], '$$enclosed_content$$' ) !== false ) ? 'has_enclosed_sc' : '';
85
-
86
- echo '<input type="button" class="sc_insert button button-primary ' . $enclosed_sc . '" value="Insert Shortcode"/>';
87
- echo '</div>';
88
- echo '</div>';
89
- }
90
- }
91
-
92
- }
93
- ?>
94
- </div>
95
-
96
- <footer class="coffee_box">
97
- <div class="coffee_amt_wrap">
98
- <p><select class="coffee_amt">
99
- <option value="2">$2</option>
100
- <option value="3">$3</option>
101
- <option value="4">$4</option>
102
- <option value="5" selected="selected">$5</option>
103
- <option value="6">$6</option>
104
- <option value="7">$7</option>
105
- <option value="8">$8</option>
106
- <option value="9">$9</option>
107
- <option value="10">$10</option>
108
- <option value="11">$11</option>
109
- <option value="12">$12</option>
110
- <option value="">Custom</option>
111
- </select></p>
112
- <a class="button button-primary buy_coffee_btn" href="https://www.paypal.me/vaakash/5" data-link="https://www.paypal.me/vaakash/" target="_blank">Buy me a coffee !</a>
113
- </div>
114
- <h3>Buy me a coffee !</h3>
115
- <p>Thank you for using Shortcoder. If you found the plugin useful buy me a coffee ! Your donation will motivate and make me happy for all the efforts. You can donate via PayPal.</p>
116
- </footer>
117
-
118
- </body>
119
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tools.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class SC_Admin_Tools{
6
+
7
+ public static function init(){
8
+
9
+ // Register the action for admin ajax features
10
+ add_action( 'wp_ajax_sc_insert_window', array( __CLASS__, 'insert_window' ) );
11
+
12
+ // Add TinyMCE button
13
+ add_action( 'admin_init', array( __class__, 'register_mce' ) );
14
+
15
+ add_action( 'wp_enqueue_editor', array( __class__, 'enqueue_insert_scripts' ) );
16
+
17
+ // Gutenberg block
18
+ add_action( 'init', array( __class__, 'register_block' ) );
19
+
20
+ }
21
+
22
+ public static function register_mce(){
23
+
24
+ add_filter( 'mce_buttons', array( __class__, 'register_mce_button' ) );
25
+
26
+ add_filter( 'mce_external_plugins', array( __class__, 'register_mce_js' ) );
27
+
28
+ }
29
+
30
+ public static function register_mce_button( $buttons ){
31
+
32
+ if( self::is_sc_edit_page() )
33
+ return $buttons;
34
+
35
+ array_push( $buttons, 'separator', 'shortcoder' );
36
+ return $buttons;
37
+
38
+ }
39
+
40
+ public static function register_mce_js( $plugins ){
41
+
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
+ }
49
+
50
+ public static function register_block(){
51
+
52
+ wp_register_script(
53
+ 'shortcoder', SC_ADMIN_URL . '/js/blocks/shortcoder.js', array( 'wp-blocks', 'wp-element' )
54
+ );
55
+
56
+ register_block_type( 'shortcoder/shortcoder', array(
57
+ 'editor_script' => 'shortcoder',
58
+ ));
59
+
60
+ }
61
+
62
+ public static function enqueue_insert_scripts(){
63
+
64
+ if( self::is_sc_edit_page() )
65
+ return;
66
+
67
+ wp_enqueue_script( 'sc-tools-js', SC_ADMIN_URL . 'js/script-tools.js', array( 'jquery' ), SC_VERSION );
68
+
69
+ wp_enqueue_style( 'sc-tools-css', SC_ADMIN_URL . 'css/style-tools.css', array(), SC_VERSION );
70
+
71
+ wp_localize_script( 'sc-tools-js', 'SC_INSERT_VARS', array(
72
+ 'insert_page' => admin_url( 'admin-ajax.php?action=sc_insert_window' ),
73
+ 'popup_title' => __( 'Insert shortcode to editor', 'shortcoder' ),
74
+ 'popup_opened' => false,
75
+ 'block_editor' => false
76
+ ));
77
+
78
+ }
79
+
80
+ public static function insert_window(){
81
+
82
+ include_once( 'insert.php' );
83
+ die(0);
84
+
85
+ }
86
+
87
+ public static function is_sc_edit_page(){
88
+
89
+ if( !is_admin() ){
90
+ return false;
91
+ }
92
+
93
+ $screen = get_current_screen();
94
+ return ( $screen->post_type == SC_POST_TYPE && $screen->base == 'post' );
95
+
96
+ }
97
+
98
+ }
99
+
100
+ SC_Admin_Tools::init();
101
+
102
+ ?>
includes/import.php DELETED
@@ -1,114 +0,0 @@
1
- <?php
2
-
3
- class Shortcoder_Import{
4
-
5
- public static function init(){
6
-
7
- add_action( 'wp_ajax_sc_export', array( __CLASS__, 'do_export' ) );
8
-
9
- }
10
-
11
- public static function import_form(){
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" />';
20
- echo '</form>';
21
-
22
- }
23
-
24
- public static function check_import(){
25
-
26
- if( isset( $_POST ) && !empty( $_FILES[ 'import' ][ 'tmp_name' ] ) ){
27
-
28
- check_admin_referer( 'sc_import_data' );
29
-
30
- $file = wp_import_handle_upload();
31
-
32
- if ( isset( $file['error'] ) ){
33
- self::print_notice( __( 'Failed to import file. Error: ', 'shortcoder' ) . $file['error'] );
34
- return false;
35
- }
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_json = ( substr($imported_json, -1) == '0' ) ? substr($imported_json, 0 , -1) : $imported_json;
55
- $imported_data = json_decode( $imported_json, true );
56
-
57
- if( $imported_data && !empty( $imported_data ) ){
58
-
59
- $shortcodes = $fresh_import ? array() : Shortcoder::list_all();
60
- $import_count = 0;
61
-
62
- if( isset( $imported_data[ 'shortcodes' ] ) ){
63
-
64
- foreach( $imported_data[ 'shortcodes' ] as $name => $content ){
65
- $shortcodes[ $name ] = wp_parse_args( $content, Shortcoder::defaults() );
66
- $import_count++;
67
- }
68
-
69
- if( update_option( 'shortcoder_data', $shortcodes ) ){
70
- self::print_notice( $import_count . __( ' shortcodes imported successfully !', 'shortcoder' ), 'success' );
71
- }else{
72
- self::print_notice( __( 'Shortcodes are not updated because all the shortcodes remain the same.', 'shortcoder' ) );
73
- return false;
74
- }
75
-
76
- }
77
-
78
- }else{
79
- self::print_notice( __( 'Failed to decode JSON in imported data. Error code: ', 'shortcoder' ) . json_last_error() );
80
- }
81
-
82
- }
83
-
84
- public static function do_export(){
85
-
86
- check_admin_referer( 'sc_export_data' );
87
-
88
- $export_file_name = 'shortcoder export ' . date( 'm/d/Y' ) . '.txt';
89
- $shortcodes = Shortcoder::list_all();
90
-
91
- $to_export = array(
92
- 'shortcodes' => $shortcodes
93
- );
94
-
95
- $export_json = json_encode( $to_export );
96
-
97
- header('Content-Disposition: attachment; filename="' . $export_file_name . '"');
98
- header('Content-Type: text/plain');
99
- header('Content-Length: ' . strlen( $export_json ));
100
- header('Connection: close');
101
-
102
- echo $export_json;
103
- return;
104
- }
105
-
106
- public static function print_notice( $msg, $type = 'error' ){
107
- echo '<div class="notice notice-' . $type . ' is-dismissible"><p>' . $msg . '</p></div>';
108
- }
109
-
110
- }
111
-
112
- Shortcoder_Import::init();
113
-
114
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/metadata.php CHANGED
@@ -4,6 +4,8 @@
4
  *
5
  */
6
 
 
 
7
  class Shortcoder_Metadata{
8
 
9
  public static function init(){
@@ -174,7 +176,7 @@ class Shortcoder_Metadata{
174
  'post_modified_date' => get_the_modified_date()
175
  );
176
 
177
- if( empty( $d[ 'short_url' ] ) ){
178
  $d[ 'short_url' ] = $d[ 'url' ];
179
  }
180
 
4
  *
5
  */
6
 
7
+ if( ! defined( 'ABSPATH' ) ) exit;
8
+
9
  class Shortcoder_Metadata{
10
 
11
  public static function init(){
176
  'post_modified_date' => get_the_modified_date()
177
  );
178
 
179
+ if( $d[ 'short_url' ] == '' ){
180
  $d[ 'short_url' ] = $d[ 'url' ];
181
  }
182
 
includes/updates.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if( ! defined( 'ABSPATH' ) ) exit;
4
+
5
+ class Shortcoder_Updates{
6
+
7
+ public static function init(){
8
+
9
+ add_action( 'admin_init', array( __class__, 'do_update' ) );
10
+
11
+ }
12
+
13
+ public static function do_update(){
14
+
15
+ $previous_version = self::get_previous_version();
16
+ $current_version = SC_VERSION;
17
+
18
+ if( version_compare( $previous_version, $current_version, '>=' ) ){
19
+ return true;
20
+ }
21
+
22
+ if ( get_transient( 'sc_upgrade' ) === 'yes' ) {
23
+ return false;
24
+ }
25
+
26
+ set_transient( 'sc_upgrade', 'yes', MINUTE_IN_SECONDS * 2 );
27
+
28
+ if( version_compare( $previous_version, '5.0', '<' ) ){
29
+ if( !self::do_update_50() ){
30
+ return false;
31
+ }
32
+ }
33
+
34
+ // Register roles everytime plugin is updated.
35
+ self::register_roles();
36
+
37
+ delete_transient( 'sc_upgrade' );
38
+
39
+ update_option( 'shortcoder_version', $current_version );
40
+
41
+ }
42
+
43
+ public static function do_update_50(){
44
+
45
+ $o_scs = get_option( 'shortcoder_data' );
46
+ $n_scs = Shortcoder::get_shortcodes();
47
+
48
+ if( empty( $o_scs ) ){
49
+ return true;
50
+ }
51
+
52
+ foreach( $o_scs as $o_name => $o_props ){
53
+
54
+ if( array_key_exists( 'post_id', $o_props ) || array_key_exists( $o_name, $n_scs ) ){
55
+ continue;
56
+ }
57
+
58
+ if( post_exists( $o_name, '', '', SC_POST_TYPE ) != 0 ){
59
+ continue;
60
+ }
61
+
62
+ $status = ( isset( $o_props[ 'disabled' ] ) && $o_props[ 'disabled' ] == 0 ) ? 'no' : 'yes';
63
+ $disable_admin = ( isset( $o_props[ 'hide_admin' ] ) && $o_props[ 'hide_admin' ] == 0 ) ? 'no' : 'yes';
64
+ $content = isset( $o_props[ 'content' ] ) ? $o_props[ 'content' ] : '';
65
+ $editor = isset( $o_props[ 'editor' ] ) ? $o_props[ 'editor' ] : 'code';
66
+ $tags = isset( $o_props[ 'tags' ] ) ? $o_props[ 'tags' ] : array();
67
+ $devices = isset( $o_props[ 'devices' ] ) ? $o_props[ 'devices' ] : 'all';
68
+
69
+ $post_id = wp_insert_post( array(
70
+ 'post_title' => $o_name,
71
+ 'post_name' => $o_name,
72
+ 'post_content' => $content,
73
+ 'post_type' => SC_POST_TYPE,
74
+ 'post_status' => 'publish',
75
+ 'tax_input' => array(
76
+ 'sc_tag' => $tags
77
+ ),
78
+ 'meta_input' => array(
79
+ '_sc_disable_sc' => $status,
80
+ '_sc_disable_admin' => $disable_admin,
81
+ '_sc_editor' => $editor,
82
+ '_sc_allowed_devices' => $devices,
83
+ '_sc_migrated' => 'yes'
84
+ )
85
+ ));
86
+
87
+ if( $post_id ){
88
+ $o_scs[ $o_name ][ 'post_id' ] = $post_id;
89
+ }else{
90
+ return false;
91
+ }
92
+
93
+ }
94
+
95
+ update_option( 'shortcoder_data', $o_scs );
96
+
97
+ return true;
98
+
99
+ }
100
+
101
+ public static function register_roles(){
102
+
103
+ $capability_type = 'shortcoder';
104
+
105
+ $capabilities = array(
106
+ "edit_{$capability_type}",
107
+ "read_{$capability_type}",
108
+ "delete_{$capability_type}",
109
+ "edit_{$capability_type}s",
110
+ "edit_others_{$capability_type}s",
111
+ "publish_{$capability_type}s",
112
+ "delete_{$capability_type}s",
113
+ "delete_published_{$capability_type}s",
114
+ "delete_others_{$capability_type}s",
115
+ "edit_published_{$capability_type}s",
116
+ );
117
+
118
+ $roles = array( 'administrator' );
119
+
120
+ foreach( $roles as $role_name ){
121
+
122
+ $role = get_role( $role_name );
123
+
124
+ foreach( $capabilities as $cap ){
125
+ $role->add_cap( $cap );
126
+ }
127
+
128
+ }
129
+
130
+ }
131
+
132
+ public static function get_previous_version(){
133
+
134
+ $version = get_option( 'shortcoder_version' );
135
+
136
+ if( $version ){
137
+ return $version;
138
+ }
139
+
140
+ $sc_flags = get_option( 'shortcoder_flags' );
141
+
142
+ if( !$sc_flags ){
143
+ return '0';
144
+ }
145
+
146
+ if( !is_array( $sc_flags ) || !array_key_exists( 'version', $sc_flags ) ){
147
+ return '0';
148
+ }
149
+
150
+ return $sc_flags[ 'version' ];
151
+
152
+ }
153
+
154
+ }
155
+
156
+ Shortcoder_Updates::init();
157
+
158
+ ?>
readme.txt CHANGED
@@ -2,24 +2,25 @@
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, short code, posts, pages, widgets, insert, adsense, ads, snippets,
6
- Donate link: https://www.paypal.me/vaakash/6
7
  License: GPLv2 or later
8
- Requires at least: 4.4.0
9
- Tested up to: 5.2.2
10
- Stable tag: 4.6
 
11
 
12
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
13
 
14
  == Description ==
15
 
16
- 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 exceuted in that place.
17
 
18
  = Create custom shortcodes easily =
19
  1. Give a name for the shortcode
20
- 1. Paste the HTML/Javascript as content
21
  1. Save !
22
- 1. Now insert the shortcode `[sc name="my_shortcode"]` in your post.
23
  1. **Voila !** You got the HTML/Javascript in your post.
24
 
25
  = Features =
@@ -27,78 +28,75 @@ Shortcoder is a plugin which allows to create a custom shortcode and store HTML,
27
  * Create **"custom shortcodes"** easily and use them within WordPress
28
  * Use any kind of **HTML** as Shortcode content.
29
  * Insert: **Custom parameters** in shortcode
30
- * Insert: WordPress parameters in shortcode
31
- * Visual editor for adding shortcode contents.
32
  * Globally disable the shortcode when not needed.
33
- * Can disable the shortcode to admins.
34
-
35
- [youtube="https://www.youtube.com/watch?v=GrlRADfvjII"]
36
 
37
  = An example usage =
38
 
39
  1. Create a shortcode named "adsenseAd" in the Shortcoder admin page.
40
  1. Paste the adsense code in the box given and save it.
41
  1. Use `[sc name="adsenseAd"]` in your posts and pages.
42
- 1. Tada !!! the ad appears in the post.
 
43
 
44
  * Using this idea, shortcodes can be created for frequently used snippets.
45
- * You can also add parameters (like `%%id%%`) inside the snippets, and vary it like `[sc name="youtube" id="GrlRADfvjII"]`
46
- * This plugin will be hugely useful to all !!!
47
 
48
  = Resources =
49
 
50
- * [Documentation](https://www.aakashweb.com/wordpress-plugins/shortcoder/)
51
- * [FAQs](https://www.aakashweb.com/faqs/wordpress-plugins/shortcoder/)
52
- * [Support](https://www.aakashweb.com/forum/)
53
- * [Report Bugs](https://www.aakashweb.com/forum/)
54
 
55
  == Installation ==
56
 
57
  1. Extract the zipped file and upload the folder `Shortcoder` to to `/wp-content/plugins/` directory.
58
  1. Activate the plugin through the `Plugins` menu in WordPress.
59
- 1. Go to the "Shortcoder" admin page. Admin page is under the "Settings" menu.
60
- 1. Enter a shortcode name.
61
- 1. Paste some code in it.
62
- 1. Then use the shortcode `[sc name="name of the shortcode"]` in your post. ex: If "youtube" is the shortcode name, then just use `[sc name="youtube"]` in your posts
63
- 1. That's all !
64
-
65
- You can also insert some parameters within the post. Check this page to [learn more](https://www.aakashweb.com/wordpress-plugins/shortcoder/).
66
 
67
  == Frequently Asked Questions ==
68
 
69
- Please visit the [Plugin homepage](https://www.aakashweb.com/wordpress-plugins/shortcoder/) for lots of FAQ's. Selected are given here.
 
 
 
 
70
 
71
- = I've created a shortcode, how to use it ? =
72
 
73
- For example, consider you made a shortcode "advertisement". Then you should use the shortcode `[sc name="advertisement"]` in your post.
74
 
75
- = How to temporarily disable a shortcode ? =
76
 
77
- Just check the "Temporarily disable this shortcode" in the shortcode admin page to disable it.
78
- Note: When you disable a shortcode, the shortcode will not be executed in the page.
79
 
80
- [More FAQs](https://www.aakashweb.com/docs/shortcoder-doc/)
 
 
81
 
82
  == Screenshots ==
83
 
84
  1. Shortcoder admin page.
85
  2. Editing a shortcode.
86
- 3. Popup to select and insert shortcode into posts.
87
- 4. A shortcode inserted into a post.
88
- 5. The shortcode executed in the post.
 
89
 
90
  [More Screenshots](https://www.aakashweb.com/wordpress-plugins/shortcoder/)
91
 
92
  == Changelog ==
93
 
94
- = 4.6 =
95
- * Fix: Show proper error when shortcoder saving fails.
96
- * Fix: Shortcode metadata throws undefined url error sometimes.
97
- * Fix: Show proper error when Code editor fails to load.
 
98
 
99
- = 4.5 =
100
- * Fix: Copy shortcode box having incorrect width.
101
- * Fix: Codemirror has been updated to latest version.
102
 
103
  = 4.4 =
104
  * New: Insert shortcode automatically adds "closing tag" if the shortcode has enclosed content parameter.
@@ -181,55 +179,8 @@ Note: When you disable a shortcode, the shortcode will not be executed in the pa
181
  * Fix: Insert shortcode window is not loading.
182
  * Fix: Unable to delete the shortcodes
183
 
184
- = 3.4.1 =
185
- * Fixed Shortcoder not working in WordPress 4.4
186
- * Changed the shortcoder syntax from `[sc:the_name]` to `[sc name="the_name"]` permanently in effect of WordPress 4.4 changes.
187
-
188
- = 3.4 =
189
- * New feature: Embedded/Nested shortcodes is now supported.
190
- * New feature: Full fledged native WordPress editor for adding shortcode content with media buttons.
191
- * Bug fix: "duplicate percentage" in content on plugin reactivate.
192
- * Updated admin UI with fixed errors.
193
- * Updated "insert shortcode" interface is revised and some issues are fixed.
194
- * Updated with translatable texts in admin page.
195
- * Minor code revision and changes.
196
-
197
- = 3.3 =
198
- * Fixed bug in loops using `foreach`.
199
- * Fixed several PHP notices.
200
-
201
- = 3.2 =
202
- * Moved the shortcoder admin page to the "Settings" menu.
203
- * Some admin page issues are fixed.
204
-
205
- = 3.1 =
206
- * Changed the "Custom parameter" syntax from %param% to %%param%%
207
- * Code revision.
208
-
209
- = 3.0.1 =
210
- * Added license tag to the readme file.
211
-
212
- = 3.0 =
213
- * Plugin code rewritten from scratch.
214
- * Shortcode syntax is changed.
215
- * Supports any custom parameters.
216
- * Admin interface is redesigned and easy to use.
217
- * Added a tinyMCE button to the editing toolbar for inserting the shortcodes in the post.
218
- * Inbuilt shortcodes are removed.
219
-
220
- = 2.3 =
221
- * Can disable the shortcode to Administrators.
222
- * Admin interface changed.
223
-
224
- = 1.3.1 =
225
- * Changed the folder name's case and some minor bugs.
226
- * Code revision.
227
-
228
- = 1.3 =
229
- * Initial Version with 5 inbuilt shortcodes.
230
-
231
- (Pre made versions are not released)
232
 
233
  == Upgrade Notice ==
234
 
235
- 4.0 is a major upgrade. Entire code is rewritten from scratch.
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.4
10
+ Tested up to: 5.3.2
11
+ Stable tag: 5.0.1
12
 
13
  Create custom "Shortcodes" easily for HTML, JavaScript snippets and use the shortcodes within posts, pages & widgets.
14
 
15
  == Description ==
16
 
17
+ 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.
18
 
19
  = Create custom shortcodes easily =
20
  1. Give a name for the shortcode
21
+ 1. Paste the HTML/JavaScript as content
22
  1. Save !
23
+ 1. Now insert the shortcode `[sc name="my_shortcode"]` in your post/page.
24
  1. **Voila !** You got the HTML/Javascript in your post.
25
 
26
  = Features =
28
  * Create **"custom shortcodes"** easily and use them within WordPress
29
  * Use any kind of **HTML** as Shortcode content.
30
  * Insert: **Custom parameters** in shortcode
31
+ * Insert: **WordPress parameters** in shortcode
32
+ * Multiple editors: Code, Visual and text modes.
33
  * Globally disable the shortcode when not needed.
 
 
 
34
 
35
  = An example usage =
36
 
37
  1. Create a shortcode named "adsenseAd" in the Shortcoder admin page.
38
  1. Paste the adsense code in the box given and save it.
39
  1. Use `[sc name="adsenseAd"]` in your posts and pages.
40
+ 1. Tada !!! the ad code is replaced and it appears in the post.
41
+ 1. Now you can edit the ad code at one place and the code is updated in all the locations where the shortcode is used.
42
 
43
  * Using this idea, shortcodes can be created for frequently used snippets.
44
+ * You can also add [custom parameters](https://www.aakashweb.com/docs/shortcoder-doc/) (like `%%id%%`) inside the snippets, and change it's value like `[sc name="youtube" id="GrlRADfvjII"]`
 
45
 
46
  = Resources =
47
 
48
+ * [Documentation](https://www.aakashweb.com/docs/shortcoder-doc/)
49
+ * [FAQs](https://www.aakashweb.com/docs/shortcoder-doc/)
50
+ * [Support/Report bugs](https://www.aakashweb.com/forum/)
 
51
 
52
  == Installation ==
53
 
54
  1. Extract the zipped file and upload the folder `Shortcoder` to to `/wp-content/plugins/` directory.
55
  1. Activate the plugin through the `Plugins` menu in WordPress.
56
+ 1. Open the admin page from the "Shortcoder" link in the navigation menu.
 
 
 
 
 
 
57
 
58
  == Frequently Asked Questions ==
59
 
60
+ Please visit the [plugin documentation page](https://www.aakashweb.com/docs/shortcoder-doc/) for complete list of FAQs.
61
+
62
+ = What are the allowed characters for shortcode name ? =
63
+
64
+ Allowed characters are alphabets, numbers, hyphens and underscores.
65
 
66
+ = My shortcode is not working in my page builder ! =
67
 
68
+ 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.
69
 
70
+ = My shortcode is not working ! =
71
 
72
+ Please check the following if you notice that the shortcode content is not printed or when the output is not as expected.
 
73
 
74
+ * Please verify if the shortcode content is printed. If shortcode content is not seen printed, check the shortcode settings to see if any option is enabled to restrict where and when shortcode is printed. Also confirm if the shortcode name is correct and there is no duplicate `name` attribute for the shortcode.
75
+ * 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.
76
+ * 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.
77
 
78
  == Screenshots ==
79
 
80
  1. Shortcoder admin page.
81
  2. Editing a shortcode.
82
+ 3. "Insert shortcode" popup to select and insert shortcodes.
83
+ 4. A shortcode inserted into post.
84
+ 5. Shortcoder block for Gutenberg editor.
85
+ 6. Shortcoder executed in the post.
86
 
87
  [More Screenshots](https://www.aakashweb.com/wordpress-plugins/shortcoder/)
88
 
89
  == Changelog ==
90
 
91
+ = 5.0.1 =
92
+ * Fix: Code editor escaping HTML characters.
93
+ * Fix: `get_current_screen()` undefined.
94
+ * Fix: Code editor breaks if there is any other plugin which loads codemirror.
95
+ * Fix: `tools.php` is not found.
96
 
97
+ = 5.0 =
98
+ * New: Brand new version. Plugin rewritten from scratch.
99
+ * New: Shortcoder block for the block editor.
100
 
101
  = 4.4 =
102
  * New: Insert shortcode automatically adds "closing tag" if the shortcode has enclosed content parameter.
179
  * Fix: Insert shortcode window is not loading.
180
  * Fix: Unable to delete the shortcodes
181
 
182
+ (Older changelogs are removed from this list)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
184
  == Upgrade Notice ==
185
 
186
+ Version 5.0 is a major release.
shortcoder.php CHANGED
@@ -1,187 +1,245 @@
1
  <?php
2
  /*
3
  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.6
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
- define( 'SC_VERSION', '4.6' );
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' ) );
15
  define( 'SC_BASE_NAME', plugin_basename( __FILE__ ) );
 
 
 
 
 
 
 
16
 
17
- class Shortcoder{
18
-
19
  public static function init(){
20
 
21
  // Include the required
22
  self::includes();
23
-
24
  add_action( 'plugins_loaded', array( __class__, 'load_text_domain' ) );
25
 
26
- register_activation_hook( __FILE__, array( __class__, 'on_activate' ) );
27
-
28
- add_filter( 'the_content', array( __class__, 'wp_44_workaround' ), 5 );
29
-
30
- // Register the shortcode
31
  add_shortcode( 'sc', array( __class__, 'execute_shortcode' ) );
32
 
33
  }
34
-
35
- public static function list_all(){
36
-
37
- $shortcodes = get_option( 'shortcoder_data' );
38
-
39
- return empty( $shortcodes ) ? array() : $shortcodes;
40
-
41
- }
42
-
43
  public static function includes(){
44
-
 
45
  include_once( SC_PATH . 'includes/metadata.php' );
46
- include_once( SC_PATH . 'includes/import.php' );
47
- include_once( SC_PATH . 'admin/sc-admin.php' );
48
-
 
 
 
49
  }
50
-
51
- public static function execute_shortcode( $atts, $enc_content ) {
52
-
53
- $shortcodes = self::list_all();
54
-
55
  if( empty( $shortcodes ) ){
56
- return '';
57
  }
58
-
59
- // Get the Shortcode name
60
- if(isset($atts[0])){
61
- $sc_name = str_replace(array('"', "'", ":"), '', $atts[0]);
62
- unset($atts[0]);
63
- }else{
64
- // Old version with "name" param support
65
- if(array_key_exists("name", $atts)){
66
- $tVal = $atts['name'];
67
- if(array_key_exists($tVal, $shortcodes)){
68
- $sc_name = $tVal;
69
- unset($atts['name']);
70
- }
71
- }
72
  }
73
-
74
- if(!isset($sc_name)){
75
- return '';
 
 
 
76
  }
77
-
78
- // Check whether shortcoder can execute
79
- if( self::check_conditions( $sc_name ) ){
80
-
81
- $sc_content_final = '';
82
-
83
- // If SC has parameters, then replace it
84
- if( !empty( $atts ) ){
85
-
86
- $keys = array();
87
- $values = array();
88
- $i = 0;
89
-
90
- // Seperate key and value from atts
91
- foreach( $atts as $k => $v ){
92
- if( $k !== 0 ){
93
- $keys[$i] = "%%" . $k . "%%";
94
- $values[$i] = $v;
95
- }
96
- $i++;
97
- }
98
-
99
- // Replace the params
100
- $sc_content = $shortcodes[ $sc_name ][ 'content' ];
101
- $sc_content_rep1 = str_ireplace( $keys, $values, $sc_content );
102
- $sc_content_final = preg_replace( '/%%[^%\s]+%%/', '', $sc_content_rep1 );
103
-
104
- }
105
- else{
106
-
107
- // If the SC has no params, then replace the %%vars%%
108
- $sc_content = $shortcodes[ $sc_name ][ 'content' ];
109
- $sc_content_final = preg_replace( '/%%[^%\s]+%%/', '', $sc_content );
110
-
111
- }
112
-
113
- $sc_content_final = self::replace_wp_params( $sc_content_final, $enc_content );
114
-
115
- $sc_content_final = self::replace_custom_fields( $sc_content_final );
116
-
117
- return do_shortcode( $sc_content_final );
118
-
119
- }else{
120
- return '<!-- Shortcoder conditions not met -->';
121
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  }
123
-
124
- public static function check_conditions( $name ){
125
-
126
- $shortcodes = self::list_all();
127
-
128
- if( array_key_exists( $name, $shortcodes ) ){
129
-
130
- $sc = wp_parse_args( $shortcodes[ $name ], self::defaults() );
131
-
132
- $devices = $sc[ 'devices' ];
133
- if( $devices == 'mobile_only' && !wp_is_mobile() ){
134
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
-
137
- if( $devices == 'desktop_only' && wp_is_mobile() ){
138
- return false;
 
 
 
139
  }
140
-
141
- if( $sc[ 'disabled' ] == 0 ){
142
- if( current_user_can( 'level_10' ) && $sc[ 'hide_admin' ] == 1 ){
143
- return false;
144
- }else{
145
- return true;
146
- }
147
- }else{
148
- return false;
149
  }
150
- }else{
 
 
 
 
 
 
 
 
 
 
151
  return false;
152
  }
153
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  }
155
-
156
- public static function replace_wp_params( $content, $enc_content ){
157
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  $params = self::wp_params_list();
 
 
159
  $all_params = array();
160
-
 
161
  foreach( $params as $group => $group_info ){
162
  $all_params = array_merge( $group_info[ 'params' ], $all_params );
163
  }
164
-
165
- $metadata = Shortcoder_Metadata::metadata();
166
- $to_replace = array();
167
-
168
- $metadata[ 'enclosed_content' ] = $enc_content;
169
-
170
  foreach( $all_params as $id => $name ){
171
  if( array_key_exists( $id, $metadata ) ){
172
  $placeholder = '$$' . $id . '$$';
173
  $to_replace[ $placeholder ] = $metadata[ $id ];
174
  }
175
  }
176
-
177
  $content = strtr( $content, $to_replace );
178
-
179
  return $content;
180
-
181
  }
182
-
183
  public static function replace_custom_fields( $content ){
184
-
185
  global $post;
186
 
187
  preg_match_all('/\$\$[^\s]+\$\$/', $content, $matches );
@@ -211,13 +269,15 @@ class Shortcoder{
211
  }
212
 
213
  return $content;
214
-
215
  }
216
-
217
  public static function wp_params_list(){
 
218
  return apply_filters( 'sc_mod_wp_params', array(
219
  'wp_info' => array(
220
  'name' => __( 'WordPress information', 'shortcoder' ),
 
221
  'params' => array(
222
  'url' => __( 'URL of the post/location', 'shortcoder' ),
223
  'title' => __( 'Title of the post/location', 'shortcoder' ),
@@ -245,6 +305,7 @@ class Shortcoder{
245
  ),
246
  'date_info' => array(
247
  'name' => __( 'Date parameters', 'shortcoder' ),
 
248
  'params' => array(
249
  'day' => __( 'Day', 'shortcoder' ),
250
  'day_lz' => __( 'Day - leading zeros', 'shortcoder' ),
@@ -260,69 +321,21 @@ class Shortcoder{
260
  ),
261
  'sc_cnt' => array(
262
  'name' => __( 'Shortcode enclosed content', 'shortcoder' ),
 
263
  'params' => array(
264
  'enclosed_content' => __( 'Shortcode enclosed content', 'shortcoder' )
265
  )
266
  )
267
  ));
268
- }
269
-
270
- public static function get_tags(){
271
-
272
- $shortcodes = self::list_all();
273
- $all_tags = array();
274
-
275
- foreach( $shortcodes as $id => $opts ){
276
- if( isset( $opts['tags'] ) && !empty( $opts['tags'] ) && is_array($opts['tags']) ){
277
- $all_tags = array_merge( $all_tags, $opts['tags'] );
278
- }
279
- }
280
-
281
- return array_unique($all_tags);
282
-
283
- }
284
-
285
- public static function on_activate(){
286
-
287
- $shortcodes = self::list_all();
288
- $sc_flags = get_option( 'shortcoder_flags' );
289
-
290
- // Move the flag version fix to sc_flags option
291
- if( isset( $shortcodes[ '_version_fix' ] ) ){
292
- unset( $shortcodes['_version_fix'] );
293
- update_option( 'shortcoder_data', $shortcodes );
294
- }
295
-
296
- $sc_flags[ 'version' ] = SC_VERSION;
297
- update_option( 'shortcoder_flags', $sc_flags );
298
 
299
  }
300
-
301
- public static function defaults(){
302
- return array(
303
- 'content' => '',
304
- 'disabled' => 0,
305
- 'hide_admin' => 0,
306
- 'devices' => 'all',
307
- 'editor' => 'text',
308
- 'tags' => array()
309
- );
310
- }
311
-
312
- public static function can_edit_sc(){
313
- return current_user_can( 'manage_options' );
314
- }
315
-
316
- public static function wp_44_workaround( $content ){
317
- return str_replace( '[sc:', '[sc name=', $content );
318
- }
319
-
320
  public static function load_text_domain(){
321
-
322
  load_plugin_textdomain( 'shortcoder', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
323
-
324
  }
325
-
326
  }
327
 
328
  Shortcoder::init();
1
  <?php
2
  /*
3
  Plugin Name: Shortcoder
4
+ Plugin URI: https://www.aakashweb.com/wordpress-plugins/shortcoder/
5
+ Description: Shortcoder plugin allows to create a custom shortcodes for HTML, JavaScript and other snippets. Now the shortcodes can be used in posts/pages and the snippet will be replaced in place.
6
  Author: Aakash Chakravarthy
7
+ Version: 5.0.1
8
  Author URI: https://www.aakashweb.com/
9
  */
10
 
11
+ define( 'SC_VERSION', '5.0.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' ) );
15
  define( 'SC_BASE_NAME', plugin_basename( __FILE__ ) );
16
+ define( 'SC_POST_TYPE', 'shortcoder' );
17
+
18
+ // error_reporting(E_ALL);
19
+
20
+ final class Shortcoder{
21
+
22
+ static public $shortcodes = array();
23
 
 
 
24
  public static function init(){
25
 
26
  // Include the required
27
  self::includes();
28
+
29
  add_action( 'plugins_loaded', array( __class__, 'load_text_domain' ) );
30
 
 
 
 
 
 
31
  add_shortcode( 'sc', array( __class__, 'execute_shortcode' ) );
32
 
33
  }
34
+
 
 
 
 
 
 
 
 
35
  public static function includes(){
36
+
37
+ include_once( SC_PATH . 'includes/updates.php' );
38
  include_once( SC_PATH . 'includes/metadata.php' );
39
+ include_once( SC_PATH . 'admin/admin.php' );
40
+ include_once( SC_PATH . 'admin/form.php' );
41
+ include_once( SC_PATH . 'admin/edit.php' );
42
+ include_once( SC_PATH . 'admin/manage.php' );
43
+ include_once( SC_PATH . 'admin/tools.php' );
44
+
45
  }
46
+
47
+ public static function execute_shortcode( $atts, $enclosed_content = null ){
48
+
49
+ $shortcodes = self::get_shortcodes();
50
+
51
  if( empty( $shortcodes ) ){
52
+ return '<!-- No shortcodes are defined -->';
53
  }
54
+
55
+ $shortcode = self::find_shortcode( $atts, $shortcodes );
56
+
57
+ if( !is_array( $shortcode ) ){
58
+ return $shortcode;
 
 
 
 
 
 
 
 
 
59
  }
60
+
61
+ $sc_content = $shortcode[ 'content' ];
62
+ $sc_settings = $shortcode[ 'settings' ];
63
+
64
+ if( !self::can_display( $shortcode ) ){
65
+ return '<!-- Shortcode does not match the conditions -->';
66
  }
67
+
68
+ $sc_content = self::replace_sc_params( $sc_content, $atts );
69
+ $sc_content = self::replace_wp_params( $sc_content, $enclosed_content );
70
+ $sc_content = self::replace_custom_fields( $sc_content );
71
+
72
+ return $sc_content;
73
+
74
+ }
75
+
76
+ public static function get_shortcodes(){
77
+
78
+ if( !empty( self::$shortcodes ) ){
79
+ return self::$shortcodes;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
81
+
82
+ $shortcodes = array();
83
+ $shortcode_posts = get_posts(array(
84
+ 'post_type' => SC_POST_TYPE,
85
+ 'posts_per_page' => -1,
86
+ 'post_status' => 'publish'
87
+ ));
88
+
89
+ foreach( $shortcode_posts as $index => $post ){
90
+ $shortcodes[ $post->post_name ] = array(
91
+ 'id' => $post->ID,
92
+ 'content' => $post->post_content,
93
+ 'settings' => self::get_sc_settings( $post->ID )
94
+ );
95
+ }
96
+
97
+ self::$shortcodes = $shortcodes;
98
+
99
+ return $shortcodes;
100
+
101
  }
102
+
103
+ public static function default_sc_settings(){
104
+
105
+ return array(
106
+ '_sc_disable_sc' => 'no',
107
+ '_sc_disable_admin' => 'no',
108
+ '_sc_editor' => 'visual',
109
+ '_sc_allowed_devices' => 'all'
110
+ );
111
+
112
+ }
113
+
114
+ public static function get_sc_settings( $post_id ){
115
+
116
+ $meta_vals = get_post_meta( $post_id, '', true );
117
+ $default_vals = self::default_sc_settings();
118
+ $settings = array();
119
+
120
+ foreach( $default_vals as $key => $val ){
121
+ $settings[ $key ] = array_key_exists( $key, $meta_vals ) ? $meta_vals[$key][0] : $val;
122
+ }
123
+
124
+ $settings[ '_sc_title' ] = get_the_title( $post_id );
125
+
126
+ return $settings;
127
+
128
+ }
129
+
130
+ public static function get_sc_tag( $post_id ){
131
+ $post = get_post( $post_id );
132
+ return '[sc name="' . $post->post_name . '"]';
133
+ }
134
+
135
+ public static function find_shortcode( $atts, $shortcodes ){
136
+
137
+ $sc_name = false;
138
+
139
+ // Find by shortcode ID
140
+ if( array_key_exists( 'sc_id', $atts ) ){
141
+ $sc_id = $atts[ 'sc_id' ];
142
+ foreach( $shortcodes as $temp_name => $temp_props ){
143
+ if( $temp_props[ 'id' ] == $sc_id ){
144
+ $sc_name = $temp_name;
145
+ break;
146
+ }
147
  }
148
+ }
149
+
150
+ // If shortcode ID is not passed, then get the shortcode name
151
+ if( !$sc_name ){
152
+ if( !array_key_exists( 'name', $atts ) ){
153
+ return '<!-- Shortcode is missing "name" attribute -->';
154
  }
155
+ $sc_name = $atts[ 'name' ];
156
+ }
157
+
158
+ // Check if the shortcode name exists
159
+ if( !array_key_exists( $sc_name, $shortcodes ) ){
160
+ $sc_name = sanitize_title_with_dashes( $sc_name );
161
+ if( !array_key_exists( $sc_name, $shortcodes ) ){
162
+ return '<!-- Shortcode does not exist -->';
 
163
  }
164
+ }
165
+
166
+ return $shortcodes[ $sc_name ];
167
+
168
+ }
169
+
170
+ public static function can_display( $sc_props ){
171
+
172
+ $settings = $sc_props['settings'];
173
+
174
+ if( $settings[ '_sc_disable_sc' ] == 'yes' ){
175
  return false;
176
  }
177
+
178
+ $devices = $settings[ '_sc_allowed_devices' ];
179
+
180
+ if( $devices == 'mobile_only' && !wp_is_mobile() ){
181
+ return false;
182
+ }
183
+
184
+ if( $devices == 'desktop_only' && wp_is_mobile() ){
185
+ return false;
186
+ }
187
+
188
+ if( current_user_can( 'manage_options' ) && $settings[ '_sc_disable_admin' ] == 'yes' ){
189
+ return false;
190
+ }
191
+
192
+ return true;
193
+
194
  }
195
+
196
+ public static function replace_sc_params( $content, $params ){
197
+
198
+ $keys = array();
199
+ $values = array();
200
+
201
+ foreach( $params as $key => $value ){
202
+ array_push( $keys, '%%' . $key . '%%' );
203
+ array_push( $values, $value );
204
+ }
205
+
206
+ // Replace params which are passed
207
+ $content = str_ireplace( $keys, $values, $content );
208
+
209
+ // Replace params which are not passed
210
+ $content = preg_replace( '/%%[^%\s]+%%/', '', $content );
211
+
212
+ return $content;
213
+
214
+ }
215
+
216
+ public static function replace_wp_params( $content, $enc_content = null ){
217
+
218
  $params = self::wp_params_list();
219
+ $metadata = Shortcoder_Metadata::metadata();
220
+ $metadata[ 'enclosed_content' ] = $enc_content;
221
  $all_params = array();
222
+ $to_replace = array();
223
+
224
  foreach( $params as $group => $group_info ){
225
  $all_params = array_merge( $group_info[ 'params' ], $all_params );
226
  }
227
+
 
 
 
 
 
228
  foreach( $all_params as $id => $name ){
229
  if( array_key_exists( $id, $metadata ) ){
230
  $placeholder = '$$' . $id . '$$';
231
  $to_replace[ $placeholder ] = $metadata[ $id ];
232
  }
233
  }
234
+
235
  $content = strtr( $content, $to_replace );
236
+
237
  return $content;
238
+
239
  }
240
+
241
  public static function replace_custom_fields( $content ){
242
+
243
  global $post;
244
 
245
  preg_match_all('/\$\$[^\s]+\$\$/', $content, $matches );
269
  }
270
 
271
  return $content;
272
+
273
  }
274
+
275
  public static function wp_params_list(){
276
+
277
  return apply_filters( 'sc_mod_wp_params', array(
278
  'wp_info' => array(
279
  'name' => __( 'WordPress information', 'shortcoder' ),
280
+ 'icon' => 'wordpress-alt',
281
  'params' => array(
282
  'url' => __( 'URL of the post/location', 'shortcoder' ),
283
  'title' => __( 'Title of the post/location', 'shortcoder' ),
305
  ),
306
  'date_info' => array(
307
  'name' => __( 'Date parameters', 'shortcoder' ),
308
+ 'icon' => 'calendar-alt',
309
  'params' => array(
310
  'day' => __( 'Day', 'shortcoder' ),
311
  'day_lz' => __( 'Day - leading zeros', 'shortcoder' ),
321
  ),
322
  'sc_cnt' => array(
323
  'name' => __( 'Shortcode enclosed content', 'shortcoder' ),
324
+ 'icon' => 'text',
325
  'params' => array(
326
  'enclosed_content' => __( 'Shortcode enclosed content', 'shortcoder' )
327
  )
328
  )
329
  ));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
330
 
331
  }
332
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  public static function load_text_domain(){
334
+
335
  load_plugin_textdomain( 'shortcoder', FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
336
+
337
  }
338
+
339
  }
340
 
341
  Shortcoder::init();