PluginProbe
Snippet Shortcodes / 5.1.6
Snippet Shortcodes v5.1.6
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.1.6, at includes/pages/page.list.php

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