PluginProbe
Snippet Shortcodes / 2.0.1
Snippet Shortcodes v2.0.1
5.2.1 5.2 5.1.8 5.1.6 5.1.7 5.1.5 trunk 1.0 1.1 1.2 1.3 1.3.1 1.4 1.5 1.5.1 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.8 2.0 2.0.1 All 74 releases
shortcode-variables / includes / pages / pages.edit.php

pages.edit.php in Snippet Shortcodes 2.0.1, at includes/pages/pages.edit.php

88 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined('ABSPATH') or die('Jog on!');
4
5 function sh_cd_pages_your_shortcodes_edit( $action = 'add' ) {
6
7 if ( false === in_array( $action, [ 'add', 'edit', 'save' ] ) ) {
8 return;
9 }
10
11 if ( false === current_user_can( 'manage_options' ) ) {
12 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
13 }
14
15 // Saving / Inserting a shortcode?
16 if ( $action == 'save' ) {
17
18 $save_result = sh_cd_shortcodes_save_post();
19
20 $message = ( true === $save_result ) ? 'Your shortcode has been saved!' : 'There was an error saving your shortcode!';
21
22 sh_cd_message_display( $message, ! $save_result );
23 }
24
25 // Load
26 $shortcode = ( false === empty( $_GET['id'] ) ) ?
27 sh_cd_db_shortcodes_by_id( (int) $_GET['id'] ) :
28 sh_cd_get_values_from_post( [ 'id', 'slug', 'data', 'disabled' ] );
29
30 $shortcode['data'] = stripslashes( $shortcode['data'] );
31
32 ?>
33
34 <div class="wrap">
35 <div id="icon-options-general" class="icon32"></div>
36 <div id="poststuff">
37 <div id="post-body" class="metabox-holder columns-3">
38 <div id="post-body-content">
39 <div class="meta-box-sortables ui-sortable">
40 <div class="postbox">
41 <h3 class="hndle"><span>Add / Edit a shortcode</span></h3>
42 <div style="padding: 0px 15px 0px 15px">
43 <?php
44
45 if ( true === $save_result ) :
46
47 printf('<p>Your shortcode has been saved successfully. <a href="%s">Return to all shortcodes</a>.',
48 sh_cd_link_your_shortcodes() );
49
50 else:
51 ?>
52 <form method="post" action="<?php echo sh_cd_link_your_shortcodes() . '&action=save'; ?>">
53 <input type="hidden" id="id" name="id" value="<?php echo esc_attr( $shortcode['id'] ); ?>" />
54 <h4>Slug</h4>
55 <p><small>Specify the unique identifier for this shortcode.</small></p>
56 <input type="text" required class="regular-text" size="100" id="slug" name="slug"
57 <?php echo ( ('edit' === $action) ? ' disabled' : ''); ?> placeholder="Slug"
58 value="<?php echo esc_attr( $shortcode['slug'] )?>" />
59 <?php if ('edit' == $action): ?>
60 <p><small>Note: You can not edit a slug name. Editing a slug name may cause issues throughout your site. Please delete this shortcode and create another.</small></p>
61 <?php endif; ?>
62 <h4>Shortcode content</h4>
63 <p><small>Specify the text, HTML, media, data, etc that should be rendered wherever the shortcode is placed.</small></p>
64 <?php wp_editor( $shortcode['data'], 'data', [ 'textarea_name' => 'data' ] ); ?>
65 <h4>Disable?</h4>
66 <p>If disabled, nothing will be rendered where the shortcode has been placed.</p>
67 <select id="disabled" name="disabled">
68 <option value="0" <?php selected( $shortcode['disabled'], 0 ); ?>>No</option>
69 <option value="1" <?php selected( $shortcode['disabled'], 1 ); ?>>Yes</option>
70 </select>
71 <div class="sh-cd-button-row">
72 <a class="comment-submit button" href="<?php echo sh_cd_link_your_shortcodes(); ?>">Cancel</a>
73 <input name="submit_button" type="submit" value="Save Shortcode" class="comment-submit button button-primary">
74 </div>
75 </form>
76 <?php endif; ?>
77 </div>
78 </div>
79 </div>
80 </div>
81 </div>
82 <br class="clear">
83 </div>
84 </div>
85 <?php
86 }
87
88