PluginProbe
Snippet Shortcodes / 4.2.3
Snippet Shortcodes v4.2.3
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 4.2.3, at includes/pages/page.list.php

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