PluginProbe
Snippet Shortcodes / 5.0a
Snippet Shortcodes v5.0a
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 / page.list.php

page.list.php in Snippet Shortcodes 5.0a, at includes/pages/page.list.php

250 lines 10.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 /**
6 * Determine which page to show
7 */
8 function sh_cd_pages_your_shortcodes() {
9
10 $action = ( false === empty( $_GET['action'] ) ) ? $_GET['action'] : NULL;
11
12 $action = ( 'save' === $action && true === empty( $_POST ) ) ? '' : $action;
13
14 $save_result = NULL;
15
16 // Do we have a save event?
17 if ( 'save' === $action ) {
18
19 check_admin_referer( 'save-shortcode' );
20
21 $save_result = false;
22
23 if ( false === empty( $_POST[ 'id'] ) ||
24 false === sh_cd_reached_free_limit() ) {
25 $save_result = sh_cd_shortcodes_save_post();
26
27 // Success?
28 if ( true === $save_result ) {
29 $action = 'list';
30 }
31 }
32 }
33
34 switch ( $action ) {
35
36 case 'add':
37 case 'edit':
38 case 'save':
39 sh_cd_pages_your_shortcodes_edit( $action, $save_result );
40 break;
41 default:
42 sh_cd_pages_your_shortcodes_list( $action, $save_result );
43 }
44
45 }
46
47 /**
48 * Display all shortcodes
49 * @param null $action
50 * @param null $save_result
51 */
52 function sh_cd_pages_your_shortcodes_list($action = NULL, $save_result = NULL) {
53
54 sh_cd_permission_check();
55
56 // Cloning a shortcode?
57 if ( 'clone' === $action && false === empty( $_GET['id'] ) ) {
58 sh_cd_clone( (int) $_GET['id'] );
59 }
60
61 if ( true == $save_result ) {
62 sh_cd_message_display( __( 'Your shortcode has been saved!', SH_CD_SLUG ) );
63 }
64
65 ?>
66 <div class="wrap">
67 <div id="icon-options-general" class="icon32"></div>
68 <div id="poststuff">
69 <div id="post-body" class="metabox-holder columns-3">
70 <div id="post-body-content">
71 <div class="meta-box-sortables ui-sortable">
72 <div class="postbox">
73 <h3 class="postbox-header">
74 <span>
75 <?php echo __( 'Your Snippet Shortcodes', SH_CD_SLUG ); ?>
76 </span>
77 </h3>
78 <div style="padding: 0px 15px 0px 15px">
79 <table width="100%" style="margin-top: 10px">
80 <tr>
81 <td class="yk-ss-shortcode-stats">
82 <?php
83
84 if ( false === sh_cd_is_premium() ) {
85 printf( '%s %d %s %d %s. <i class="fa-regular fa-star"></i> <a href="%s">%s</a>',
86 __( 'Used', SH_CD_SLUG ),
87 sh_cd_db_shortcodes_count(),
88 __( 'of', SH_CD_SLUG ),
89 sh_cd_get_free_limit(),
90 __( 'shortcodes', SH_CD_SLUG ),
91 sh_cd_license_upgrade_link(),
92 __( 'Go unlimited!', SH_CD_SLUG )
93 );
94 }
95
96 ?>
97 </td>
98 <td align="right">
99 <?php
100 if ( false === sh_cd_is_premium() ) {
101 sh_cd_upgrade_button( 'sh-cd-hide', sh_cd_license_upgrade_link() );
102 }
103
104 sc_cd_display_add_button();
105 ?>
106 </td>
107 </tr>
108 </table>
109 <p style="text-align: right">
110
111 </p>
112
113 <table class="widefat sh-cd-table" width="100%">
114 <tr class="row-title">
115 <th class="row-title" width="20%"><?php echo __( 'Shortcode', SH_CD_SLUG ); ?></th>
116 <th width="*"><?php echo __( 'Content', SH_CD_SLUG ); ?></th>
117 <th width="60px" align="middle"><?php echo __( 'Global', SH_CD_SLUG ); ?></th>
118 <th width="60px" align="middle"><?php echo __( 'Enabled', SH_CD_SLUG ); ?></th>
119 <th width="70px" align="middle"><?php echo __( 'Options', SH_CD_SLUG ); ?></th>
120 </tr>
121 <?php
122
123 printf( '<tr class="sh-cd-hide" id="sh-cd-add-inline">
124 <td>
125 <input type="text" maxlength="100" placeholder="%1$s" class="sh-cd-slug-validation" id="sh-cd-add-inline-slug" title="Only letters, numbers, dashes and underscores are allowed." />
126 <p class="sh-cd-shortcode-slug sh-cd-hide">
127 <span id="sh-cd-test-shortcode-slug">[%6$s slug="<span id="sh-cd-shortcode-slug-preview"></span>"]</span>
128 <i class="far fa-copy sh-cd-copy-trigger" data-clipboard-text="[%6$s: slug=&quot;&quot;]"></i>
129 </p>
130 </td>
131 <td align="right">
132 <textarea class="large-text inline-text-shortcode" id="sh-cd-add-inline-text"></textarea>
133 <label for="sh-cd-add-inline-clear" >%3$s </label><input type="checkbox" id="sh-cd-add-inline-clear" value="true" checked="checked" />
134 </td>
135 <td align="middle"><input type="checkbox" id="sh-cd-add-inline-global" value="true" /></td>
136 <td align="middle"><input type="checkbox" id="sh-cd-add-inline-enabled" value="true" checked="checked" /></td>
137 <td width="100">
138 <a class="button button-small sh-cd-inline-add-button" id="sh-cd-add-button" %5$s><i class="fas fa-save"></i> %2$s</a>
139 </td>
140 </tr>
141 <tr class="sh-cd-hide" id="sh-cd-add-inline-results">
142 <td></td>
143 <td cospan="4">
144 <p>%4$s</p>
145 </td>
146 </tr>
147
148 ',
149 __( 'Slug', SH_CD_SLUG ),
150 __( 'Add', SH_CD_SLUG ),
151 __( 'Clear form after save', SH_CD_SLUG ),
152 __( 'Your Shortcode has been added. Please refresh the page to edit it.', SH_CD_SLUG ),
153 ( false === sh_cd_is_premium() ) ? ' disabled="disabled"' : '',
154 SH_CD_SHORTCODE
155 );
156
157 $current_shortcodes = sh_cd_db_shortcodes_all();
158
159 if ( false === empty( $current_shortcodes ) ) {
160
161 $class = '';
162 $link = sh_cd_link_your_shortcodes();
163 $i = 0;
164 $limit_reached = sh_cd_reached_free_limit();
165
166 foreach ( $current_shortcodes as $shortcode ) {
167
168 $class = ($class == 'alternate') ? '' : 'alternate';
169
170 $id = (int) $shortcode['id'];
171
172 printf( '<tr class="%1$s yk-ss-row-%3$s sh-cd-shortcode-row" id="sh-cd-row-%8$s">
173 <td><a href="%2$s" class="slug-link">[%4$s slug="%3$s"]</a> <i class="far fa-copy sh-cd-copy-trigger sh-cd-tooltip" data-clipboard-text="[%4$s slug=&quot;%3$s&quot;]" title="%20$s"></i></td>
174 <td align="right">
175 <textarea class="large-text inline-text-shortcode sh-cd-toggle-%13$s" id="sh-cd-text-area-%8$d" data-id="%8$d" %13$s>%5$s</textarea>
176 <a class="button button-small sh-cd-inline-save-button sh-cd-toggle-%13$s" id="sh-cd-save-button-%8$d" data-id="%8$d" %13$s><i class="fas fa-save"></i> %11$s</a>
177 </td>
178 <td align="middle"><a class="button button-small toggle-multisite sh-cd-toggle-%13$s sh-cd-tooltip" id="sc-cd-multisite-%8$s" data-id="%8$s" %13$s title="%19$s"><i class="fa-solid %10$s"></i></a></td>
179 <td align="middle"><a class="button button-small toggle-disable sh-cd-toggle-%13$s sh-cd-tooltip" id="sc-cd-toggle-%8$s" data-id="%8$s" %13$s title="%18$s"><i class="fa-solid %6$s"></i></a></td>
180 <td width="100">
181 <a class="button button-small sh-cd-toggle-%13$s sh-cd-tooltip" %13$s href="%9$s" title="%17$s"><i class="far fa-clone"></i></a>
182 <a class="button button-small edit-shortcode sh-cd-tooltip" href="%2$s" title="%15$s"><i class="far fa-edit"></i></a>
183 <a id="delete-%8$s" class="button button-small delete-shortcode sh-cd-tooltip" data-id="%8$s" title="%16$s"><i class="fas fa-trash-alt"></i></a>
184 </td>
185 </tr>',
186 $class,
187 $link . '&action=edit&id=' . $id,
188 esc_html( $shortcode['slug'] ),
189 SH_CD_SHORTCODE,
190 ( true === sh_cd_is_premium() ) ? esc_html( stripslashes( $shortcode['data'] ) ) : __( 'Upgrade for inline editing and toggles.', SH_CD_SLUG ),
191 ( 1 === (int) $shortcode['disabled'] ) ? 'fa-times' : 'fa-check',
192 $link . '&action=delete&id=' . $id,
193 $id,
194 ( true === sh_cd_is_premium() ) ? $link . '&action=clone&id=' . $id : sh_cd_license_upgrade_link(),
195 ( 1 === (int) $shortcode['multisite'] ) ? 'fa-check' : 'fa-times',
196 __( 'Save', SH_CD_SLUG ),
197 __( 'Are you sure you want to delete this shortcode?', SH_CD_SLUG ),
198 ( false === sh_cd_is_premium() ) ? 'disabled' : '',
199 ( true === $limit_reached && $i > sh_cd_get_free_limit() ) ? 'disabled' : '',
200 __( 'Use the full Visual or Code editor to edit this shortcode.', SH_CD_SLUG ),
201 __( 'Permanently delete and remove this shortcode.', SH_CD_SLUG ),
202 __( 'Clone this shortcode to create an identical copy for editing', SH_CD_SLUG ),
203 __( 'Enable or disable a shortcode. When enabled, the shortcode will not be rendered on the website\'s public facing side.', SH_CD_SLUG ),
204 __( 'Enable this shortcode for use across all sites within your WordPress multisite network.', SH_CD_SLUG ),
205 __( 'Copy to clipboard', SH_CD_SLUG )
206 );
207
208 $i++;
209 }
210 }
211 else {
212 printf( '<tr><td colspan="5" align="center">%1$s. <a href="%2$s">%3$s</a></td></tr>',
213 __( 'You haven\'t created any shortcodes yet', SH_CD_SLUG ),
214 sh_cd_link_your_shortcodes_add(),
215 __( 'Add one now!', SH_CD_SLUG )
216 );
217 }
218 ?>
219 </table>
220 <br clear="all" />
221 </div>
222 </div>
223 </div>
224 </div>
225 </div>
226 </div>
227 </div>
228 <?php
229 }
230
231 /**
232 * Render button for adding a shortcode
233 *
234 * @param bool $show_quick_add
235 */
236 function sc_cd_display_add_button( $show_quick_add = true ) {
237
238 $limit_reached = sh_cd_reached_free_limit();
239
240 if ( true === $show_quick_add ) {
241 printf( '&nbsp;<a class="button-primary sh-cd-button button-add-inline yk-ss-button-add-quick-editor"><i class="fa-solid fa-plus"></i> %1$s</a>', __( 'Quick Add', SH_CD_SLUG ) );
242 }
243
244 printf( '&nbsp;<a class="button-primary sh-cd-button yk-ss-button-add-full-editor sh-cd-tooltip" title="%3$s" href="%1$s"><i class="fa-solid fa-file-code"></i> %2$s</a>',
245 ( false === $limit_reached ) ? sh_cd_link_your_shortcodes_add() : sh_cd_license_upgrade_link(),
246 ( false === $limit_reached ) ? __( 'Add via full editor', SH_CD_SLUG ) : __( 'You must upgrade to add more shortcodes', SH_CD_SLUG ),
247 __( 'Use the full Visual or Code editor to add a new shortcode.', SH_CD_SLUG )
248 );
249 }
250