PluginProbe ʕ •ᴥ•ʔ
Shortcoder — Create Shortcodes for Anything / 4.6
Shortcoder — Create Shortcodes for Anything v4.6
trunk 3.0 3.0.1 3.1 3.2 3.3 3.4 3.4.1 4.0 4.0.1 4.0.2 4.0.3 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.3 4.4 4.5 4.6 5.0 5.0.1 5.0.2 5.0.3 5.0.4 5.1 5.2 5.2.1 5.3 5.3.1 5.3.2 5.3.3 5.3.4 5.4 5.5 5.6 5.7 5.8 6.0 6.1 6.2 6.3 6.3.1 6.3.2 6.4 6.5 6.5.1 6.5.2 6.5.3
shortcoder / admin / sc-admin.php
shortcoder / admin Last commit date
css 6 years ago images 6 years ago js 6 years ago sc-admin.php 6 years ago sc-insert.php 6 years ago
sc-admin.php
651 lines
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 ?>