PluginProbe
Snippet Shortcodes / 1.7
Snippet Shortcodes v1.7
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.7, at includes/pages.php

277 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="1" <?php selected( $shortcode->disabled, 1 ); ?>><?php echo __('Yes'); ?></option>
111 <option value="0" <?php selected( $shortcode->disabled, 0 ); ?>><?php echo __('No'); ?></option>
112 </select>
113
114 <?php echo submit_button( $button_text . __(' Shortcode') ); ?>
115
116 </form>
117 </div>
118 </div>
119
120 <?php
121 }
122 else
123 {?>
124 <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>
125 <br /><br />
126
127
128 <div class="postbox">
129 <h3 class="hndle"><span><?php _e( 'Existing Shortcodes' ); ?> </span></h3>
130 <div style="padding: 0px 15px 0px 15px">
131 <br />
132 <table class="widefat" width="100%">
133 <tr class="row-title">
134 <th class="row-title" width="15%"><?php echo __('Slug'); ?></th>
135 <th width="20%"><?php echo __('Shortcode to embed'); ?></th>
136 <th width="*"><?php echo __('Shortcode Value'); ?></th>
137 <th width="5%"><?php echo __('Disabled'); ?></th>
138 <th width="15%"><?php echo __('Options'); ?></th>
139 </tr>
140 <?php
141
142 $current_shortcodes = sh_cd_get_all_shortcodes();
143
144 if ($current_shortcodes)
145 {
146
147 $class = '';
148
149 foreach ($current_shortcodes as $shortcode):
150
151 $class = ($class == 'alternate') ? '' : 'alternate';
152
153 $edit_link = admin_url('admin.php?page=sh-cd-shortcode-variables-user-defined&action=edit&id=' . $shortcode->id);
154 $delete_link = admin_url('admin.php?page=sh-cd-shortcode-variables-user-defined&action=delete&id=' . $shortcode->id);
155 ?>
156 <tr class="<?php echo $class; ?>">
157 <td><a href="<?php echo $edit_link; ?>"><?php echo $shortcode->slug; ?></a></td>
158 <td>[<?php echo SH_CD_SHORTCODE; ?> slug="<?php echo $shortcode->slug; ?>"]</td>
159 <td><textarea class="large-text"><?php echo esc_html(stripslashes($shortcode->data)); ?></textarea></td>
160 <td><?php echo (0 == $shortcode->disabled) ? __('No') : __('Yes'); ?></td>
161 <td>
162 <a class="button button-small" href="<?php echo $edit_link; ?>"><?php echo __('Edit'); ?></a>
163 <a class="button button-small" href="<?php echo $delete_link; ?>" class="remove-confirm" ><?php echo __('Delete'); ?></a>
164 </td>
165 </tr>
166 <?php endforeach;
167
168 }
169 else
170 {?>
171 <tr>
172 <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>
173 </tr>
174 <?php
175 }
176 ?>
177 </table>
178 <br />
179 </div>
180 </div>
181 <?php
182
183
184
185 }
186 ?>
187
188
189 </div>
190 <!-- .meta-box-sortables .ui-sortable -->
191
192 </div>
193 <!-- post-body-content -->
194
195 </div>
196 <!-- #post-body .metabox-holder .columns-2 -->
197
198 <br class="clear">
199 </div>
200 <!-- #poststuff -->
201
202 </div> <?php
203
204 sh_cd_create_dialog_jquery_code(__('Are you sure?'), __('Are you sure you wish to delete this shortcode?'), 'remove-confirm');
205
206 }
207
208
209 function sh_cd_premade_shortcodes_page() {
210
211 ?>
212
213 <div class="wrap">
214
215 <div id="icon-options-general" class="icon32"></div>
216
217 <div id="poststuff">
218
219 <div id="post-body" class="metabox-holder columns-3">
220
221 <!-- main content -->
222 <div id="post-body-content">
223
224 <div class="meta-box-sortables ui-sortable">
225 <div class="postbox">
226 <h3 class="hndle"><span><?php _e( 'Pre-made Shortcode Variables' ); ?> </span></h3>
227 <div style="padding: 0px 15px 0px 15px">
228 <p><?php echo __('Below is a list of premade shortcode variables that you can use throughout your website.'); ?></p>
229 <br />
230 <table class="widefat" width="100%">
231 <tr class="row-title">
232 <th class="row-title" width="30%"><?php echo __('Shortcode to embed'); ?></th>
233 <th width="*"><?php echo __('Description'); ?></th>
234
235 </tr>
236 <?php
237
238 $premade_shortcodes = sh_cd_shortcode_presets();
239
240 $class = '';
241
242 foreach ($premade_shortcodes as $key => $description):
243
244 $class = ($class == 'alternate') ? '' : 'alternate';
245
246 $shortcode = '[' . SH_CD_SHORTCODE. ' slug="' . $key . '"]';
247
248 ?>
249 <tr class="<?php echo $class; ?>">
250 <td><?php echo $shortcode; ?></td>
251 <td><?php echo $description; ?></td>
252 </tr>
253 <?php endforeach; ?>
254 </table>
255 <br />
256 <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>
257 </div>
258 </div>
259
260
261 </div>
262 <!-- .meta-box-sortables .ui-sortable -->
263
264 </div>
265 <!-- post-body-content -->
266
267 </div>
268 <!-- #post-body .metabox-holder .columns-2 -->
269
270 <br class="clear">
271 </div>
272 <!-- #poststuff -->
273
274 </div> <?php
275
276 }
277