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

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