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

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