PluginProbe
Snippet Shortcodes / 3.4.1
Snippet Shortcodes v3.4.1
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 / pages.list.php

pages.list.php in Snippet Shortcodes 3.4.1, at includes/pages/pages.list.php

187 lines 7.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 $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 if ( false === current_user_can( 'manage_options' ) ) {
51 wp_die( __( 'You do not have sufficient permissions to access this page.', SH_CD_SLUG ) );
52 }
53
54 $is_premium = sh_cd_license_is_premium();
55
56 // Cloning a shortcode?
57 if ( 'clone' === $action && false === empty( $_GET['id'] ) ) {
58
59 sh_cd_clone( (int) $_GET['id'] );
60
61 }
62
63 // Deleting a shortcode?
64 if( 'delete' === $action && false === empty( $_GET['id'] ) ) {
65
66 $result = sh_cd_db_shortcodes_delete( (int) $_GET['id'] );
67
68 $message = ( true === $result ) ? __( 'Your shortcode has been deleted!', SH_CD_SLUG ) : __( 'There was an error deleting your shortcode!', SH_CD_SLUG );
69
70 sh_cd_message_display( $message, ! $result );
71 }
72
73 if ( true == $save_result ) {
74 sh_cd_message_display( __( 'Your shortcode has been saved!', SH_CD_SLUG ) );
75 }
76
77 ?>
78 <div class="wrap">
79 <div id="icon-options-general" class="icon32"></div>
80 <div id="poststuff">
81 <div id="post-body" class="metabox-holder columns-3">
82 <div id="post-body-content">
83 <div class="meta-box-sortables ui-sortable">
84 <div class="postbox">
85 <div class="postbox-header">
86 <h2 class="hndle"><span><?php echo __( 'Your existing Snippet Shortcodes', SH_CD_SLUG ); ?></span></h2>
87 </div>
88 <div style="padding: 0px 15px 0px 15px">
89 <p style="text-align: right">
90 <?php
91 if ( false === $is_premium ) {
92 sh_cd_upgrade_button( 'sh-cd-hide', sh_cd_license_upgrade_link() );
93 }
94
95 sc_cd_display_add_button();
96 ?>
97 </p>
98 <table class="widefat sh-cd-table" width="100%">
99 <tr class="row-title">
100 <th class="row-title" width="20%"><?php echo __( 'Shortcode', SH_CD_SLUG ); ?></th>
101 <th width="*"><?php echo __( 'Shortcode content', SH_CD_SLUG ); ?></th>
102 <th width="60px" align="middle"><?php echo __( 'Global', SH_CD_SLUG ); ?></th>
103 <th width="60px" align="middle"><?php echo __( 'Enabled', SH_CD_SLUG ); ?></th>
104 <th width="70px" align="middle"><?php echo __( 'Options', SH_CD_SLUG ); ?></th>
105 </tr>
106 <?php
107
108 $current_shortcodes = sh_cd_db_shortcodes_all();
109
110 if ( false === empty( $current_shortcodes ) ) {
111
112 $class = '';
113
114 $link = sh_cd_link_your_shortcodes();
115
116 foreach ( $current_shortcodes as $shortcode ) {
117
118 $class = ($class == 'alternate') ? '' : 'alternate';
119
120 $id = (int) $shortcode['id'];
121
122 printf( '<tr class="%1$s">
123 <td><a href="%2$s">[%4$s slug="%3$s"]</a></td>
124 <td align="right">
125 <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>
126 <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>
127 </td>
128 <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>
129 <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>
130 <td width="100">
131 <a class="button button-small sh-cd-toggle-%13$s" %13$s href="%9$s"><i class="far fa-clone"></i></a>
132 <a class="button button-small" href="%2$s"><i class="far fa-edit"></i></a>
133 <a class="button button-small" href="%7$s" onclick="return confirm(\'%12$s\');"><i class="fas fa-trash-alt"></i></a>
134 </td>
135 </tr>',
136 $class,
137 $link . '&action=edit&id=' . $id,
138 esc_html( $shortcode['slug'] ),
139 SH_CD_SHORTCODE,
140 ( true === $is_premium ) ? esc_html( stripslashes( $shortcode['data'] ) ) : __( 'Upgrade for inline editing and toggles.', SH_CD_SLUG ),
141 ( 1 === (int) $shortcode['disabled'] ) ? 'fa-times' : 'fa-check',
142 $link . '&action=delete&id=' . $id,
143 $id,
144 ( true === $is_premium ) ? $link . '&action=clone&id=' . $id : sh_cd_license_upgrade_link(),
145 ( 1 === (int) $shortcode['multisite'] ) ? 'fa-check' : 'fa-times',
146 __( 'Save', SH_CD_SLUG ),
147 __( 'Are you sure you want to delete this shortcode?', SH_CD_SLUG ),
148 ( false === $is_premium ) ? 'disabled' : ''
149 );
150 }
151 }
152 else {
153 printf( '<tr><td colspan="5" align="center">%1$s. <a href="%2$s">%3$s</a></td></tr>',
154 __( 'You haven\'t created any shortcodes yet', SH_CD_SLUG ),
155 sh_cd_link_your_shortcodes_add(),
156 __( 'Add one now!', SH_CD_SLUG )
157 );
158 }
159 ?>
160 </table>
161 <p style="text-align: right">
162 <?php sc_cd_display_add_button(); ?>
163 </p>
164 <br clear="all" />
165 </div>
166 </div>
167 </div>
168 </div>
169 </div>
170 </div>
171 </div>
172 <?php
173 }
174
175 /**
176 * Render button for adding a shortcode
177 */
178 function sc_cd_display_add_button() {
179
180 $limit_reached = sh_cd_reached_free_limit();
181
182 printf( '&nbsp;<a class="button-primary" href="%1$s">%2$s</a>',
183 ( false === $limit_reached ) ? sh_cd_link_your_shortcodes_add() : sh_cd_license_upgrade_link(),
184 ( false === $limit_reached ) ? __( 'Add a new Snippet Shortcode', SH_CD_SLUG ) : __( 'You must upgrade to add more shortcodes', SH_CD_SLUG )
185 );
186 }
187