PluginProbe
Snippet Shortcodes / 1.8
Snippet Shortcodes v1.8
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.php

pages.php in Snippet Shortcodes 1.8, at includes/pages.php

278 lines 8.9 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_user_defined_page() {
6
7 wp_enqueue_style('sh-cd-style', plugins_url( 'css/sh-cd.css', __FILE__ ));
8
9 if ( !current_user_can( 'manage_options' ) ) {
10 wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
11 }
12 echo '<h1>' . SH_CD_PLUGIN_NAME . '</h1>';
13
14
15 $this_page = get_permalink();
16
17 $action = (isset($_GET['action']) ? $_GET['action'] : 'view-all');
18
19
20 if ($action == 'save')
21 {
22 $slug = (isset($_POST['slug']) ? $_POST['slug'] : '');
23 $value = (isset($_POST['value']) ? $_POST['value'] : '');
24 $id = ((isset($_POST['existing-id']) && is_numeric($_POST['existing-id'])) ? $_POST['existing-id'] : false);
25 $disabled = (isset($_POST['is-disabled']) && '1' == $_POST['is-disabled']) ? true : false;
26
27 if(sh_cd_save_shortcode($slug, $value, $disabled, $id))
28 {
29 sh_cd_display_message('Shortcode has been saved');
30 }
31 else
32 {
33 sh_cd_display_message('There was an error saving your shortcode', true);
34 }
35 }
36 elseif($action == 'delete')
37 {
38 if(sh_cd_delete_shortcode($_GET['id']))
39 {
40 sh_cd_display_message('Shortcode has been deleted!');
41 }
42 else
43 {
44 sh_cd_display_message('There was an error deleting your shortcode', true);
45 }
46 }
47
48 ?>
49
50 <div class="wrap">
51
52 <div id="icon-options-general" class="icon32"></div>
53
54 <div id="poststuff">
55
56 <div id="post-body" class="metabox-holder columns-3">
57
58 <!-- main content -->
59 <div id="post-body-content">
60
61 <div class="meta-box-sortables ui-sortable">
62
63 <?php
64
65 if ($action == 'add' || $action == 'edit')
66 {
67
68
69 $title = 'Add Shortcode';
70 $slug = '';
71 $value = '';
72 $button_text = 'Add';
73 $existing_id = false;
74
75 if ($action == 'edit')
76 {
77 $title = 'Edit Shortcode';
78 $button_text = 'Save';
79 $existing_id = $_GET['id'];
80
81 // Get Shortcode from DB
82 $shortcode = sh_cd_get_shortcode($existing_id);
83 $slug = $shortcode->slug;
84 $value = stripslashes($shortcode->data);
85 }
86
87 $settings = array( 'textarea_name' => 'value' );
88
89
90 ?>
91 <a class="button-secondary" href="<?php echo admin_url('admin.php?page=sh-cd-shortcode-variables-user-defined'); ?>"><?php esc_attr_e( 'Cancel' ); ?></a>
92 <br /><br />
93 <div class="postbox">
94 <h3 class="hndle"><span><?php echo _e($title); ?> </span></h3>
95 <div style="padding: 0px 15px 0px 15px">
96
97 <form method="post" action="<?php echo admin_url('admin.php?page=sh-cd-shortcode-variables-user-defined&action=save'); ?>">
98 <input type="hidden" id="existing-id" name="existing-id" value="<?php echo ((!empty($existing_id)) ? $existing_id : ''); ?>" />
99 <p><?php echo __('Slug'); ?>:</p>
100 <input type="text" class="regular-text" size="100" id="slug" name="slug" <?php echo (('edit' == $action) ? ' disabled' : ''); ?> placeholder="<?php echo __('Slug'); ?>" <?php echo ((!empty($slug)) ? "value=\"$slug\"" : ""); ?>/>
101 <?php if ('edit' == $action): ?>
102 <p><small><?php echo __('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>
103 <?php endif; ?>
104 <p><?php echo __('Shortcode data / Value:'); ?></p>
105 <!--<textarea id="value" name="value" cols="80" rows="10" class="large-text"><?php echo $value; ?></textarea><br>-->
106 <?php wp_editor( $value, 'value', $settings ); ?>
107 <p><?php echo __('Disable variable? If disabled, nothing will be rendered where the shortcode has been placed.'); ?>:</p>
108
109 <select id="is-disabled" name="is-disabled">
110 <option value="0" <?php selected( $shortcode->disabled, 0 ); ?>><?php echo __('No'); ?></option>
111 <option value="1" <?php selected( $shortcode->disabled, 1 ); ?>><?php echo __('Yes'); ?></option>
112
113 </select>
114
115 <?php echo submit_button( $button_text . __(' Shortcode') ); ?>
116
117 </form>
118 </div>
119 </div>
120
121 <?php
122 }
123 else
124 {?>
125 <a class="button-primary" href="<?php echo admin_url('admin.php?page=sh-cd-shortcode-variables-user-defined&action=add'); ?>"><?php esc_attr_e( 'Add a new Shortcode' ); ?></a>
126 <br /><br />
127
128
129 <div class="postbox">
130 <h3 class="hndle"><span><?php _e( 'Existing Shortcodes' ); ?> </span></h3>
131 <div style="padding: 0px 15px 0px 15px">
132 <br />
133 <table class="widefat" width="100%">
134 <tr class="row-title">
135 <th class="row-title" width="15%"><?php echo __('Slug'); ?></th>
136 <th width="20%"><?php echo __('Shortcode to embed'); ?></th>
137 <th width="*"><?php echo __('Shortcode Value'); ?></th>
138 <th width="5%"><?php echo __('Disabled'); ?></th>
139 <th width="15%"><?php echo __('Options'); ?></th>
140 </tr>
141 <?php
142
143 $current_shortcodes = sh_cd_get_all_shortcodes();
144
145 if ($current_shortcodes)
146 {
147
148 $class = '';
149
150 foreach ($current_shortcodes as $shortcode):
151
152 $class = ($class == 'alternate') ? '' : 'alternate';
153
154 $edit_link = admin_url('admin.php?page=sh-cd-shortcode-variables-user-defined&action=edit&id=' . $shortcode->id);
155 $delete_link = admin_url('admin.php?page=sh-cd-shortcode-variables-user-defined&action=delete&id=' . $shortcode->id);
156 ?>
157 <tr class="<?php echo $class; ?>">
158 <td><a href="<?php echo $edit_link; ?>"><?php echo $shortcode->slug; ?></a></td>
159 <td>[<?php echo SH_CD_SHORTCODE; ?> slug="<?php echo $shortcode->slug; ?>"]</td>
160 <td><textarea class="large-text"><?php echo esc_html(stripslashes($shortcode->data)); ?></textarea></td>
161 <td><?php echo (0 == $shortcode->disabled) ? __('No') : __('Yes'); ?></td>
162 <td>
163 <a class="button button-small" href="<?php echo $edit_link; ?>"><?php echo __('Edit'); ?></a>
164 <a class="button button-small" href="<?php echo $delete_link; ?>" class="remove-confirm" ><?php echo __('Delete'); ?></a>
165 </td>
166 </tr>
167 <?php endforeach;
168
169 }
170 else
171 {?>
172 <tr>
173 <td colspan="4" align="center"><?php echo __('You haven\'t created any shortcodes yet. <a href="' . admin_url('admin.php?page=sh-cd-shortcode-variables-user-defined&action=add') . '">Add one now!</a>'); ?></td>
174 </tr>
175 <?php
176 }
177 ?>
178 </table>
179 <br />
180 </div>
181 </div>
182 <?php
183
184
185
186 }
187 ?>
188
189
190 </div>
191 <!-- .meta-box-sortables .ui-sortable -->
192
193 </div>
194 <!-- post-body-content -->
195
196 </div>
197 <!-- #post-body .metabox-holder .columns-2 -->
198
199 <br class="clear">
200 </div>
201 <!-- #poststuff -->
202
203 </div> <?php
204
205 sh_cd_create_dialog_jquery_code(__('Are you sure?'), __('Are you sure you wish to delete this shortcode?'), 'remove-confirm');
206
207 }
208
209
210 function sh_cd_premade_shortcodes_page() {
211
212 ?>
213
214 <div class="wrap">
215
216 <div id="icon-options-general" class="icon32"></div>
217
218 <div id="poststuff">
219
220 <div id="post-body" class="metabox-holder columns-3">
221
222 <!-- main content -->
223 <div id="post-body-content">
224
225 <div class="meta-box-sortables ui-sortable">
226 <div class="postbox">
227 <h3 class="hndle"><span><?php _e( 'Pre-made Shortcode Variables' ); ?> </span></h3>
228 <div style="padding: 0px 15px 0px 15px">
229 <p><?php echo __('Below is a list of premade shortcode variables that you can use throughout your website.'); ?></p>
230 <br />
231 <table class="widefat" width="100%">
232 <tr class="row-title">
233 <th class="row-title" width="30%"><?php echo __('Shortcode to embed'); ?></th>
234 <th width="*"><?php echo __('Description'); ?></th>
235
236 </tr>
237 <?php
238
239 $premade_shortcodes = sh_cd_shortcode_presets();
240
241 $class = '';
242
243 foreach ($premade_shortcodes as $key => $description):
244
245 $class = ($class == 'alternate') ? '' : 'alternate';
246
247 $shortcode = '[' . SH_CD_SHORTCODE. ' slug="' . $key . '"]';
248
249 ?>
250 <tr class="<?php echo $class; ?>">
251 <td><?php echo $shortcode; ?></td>
252 <td><?php echo $description; ?></td>
253 </tr>
254 <?php endforeach; ?>
255 </table>
256 <br />
257 <p><?php echo __('<strong> Suggestion?</strong> Got an idea for a premade tag? If so, email me at: ') . '<a href="mailto:email@yeken.uk">email@yeken.uk</a>'; ?> </p>
258 </div>
259 </div>
260
261
262 </div>
263 <!-- .meta-box-sortables .ui-sortable -->
264
265 </div>
266 <!-- post-body-content -->
267
268 </div>
269 <!-- #post-body .metabox-holder .columns-2 -->
270
271 <br class="clear">
272 </div>
273 <!-- #poststuff -->
274
275 </div> <?php
276
277 }
278