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

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

169 lines 7.7 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 printf( '<h1>%s</h1>', __( 'Your Snippet Shortcodes', SH_CD_SLUG ) );
11
12 $action = ( false === empty( $_GET['action'] ) ) ? $_GET['action'] : NULL;
13
14 $save_result = NULL;
15
16 // Do we have a save event?
17 if ( 'save' === $action ) {
18
19 $save_result = sh_cd_shortcodes_save_post();
20
21 // Success?
22 if ( true === $save_result ) {
23 $action = 'list';
24 }
25 }
26
27 switch ( $action ) {
28
29 case 'add':
30 case 'edit':
31 case 'save':
32 sh_cd_pages_your_shortcodes_edit( $action, $save_result );
33 break;
34 default:
35 sh_cd_pages_your_shortcodes_list( $action, $save_result );
36 }
37
38 }
39
40 /**
41 * Display all shortcodes
42 * @param null $action
43 * @param null $save_result
44 */
45 function sh_cd_pages_your_shortcodes_list($action = NULL, $save_result = NULL) {
46
47 if ( false === current_user_can( 'manage_options' ) ) {
48 wp_die( __( 'You do not have sufficient permissions to access this page.', SH_CD_SLUG ) );
49 }
50
51 // Cloning a shortcode?
52 if ( 'clone' === $action && false === empty( $_GET['id'] ) ) {
53
54 sh_cd_clone( (int) $_GET['id'] );
55
56 }
57
58 // Deleting a shortcode?
59 if( 'delete' === $action && false === empty( $_GET['id'] ) ) {
60
61 $result = sh_cd_db_shortcodes_delete( (int) $_GET['id'] );
62
63 $message = ( true === $result ) ? __( 'Your shortcode has been deleted!', SH_CD_SLUG ) : __( 'There was an error deleting your shortcode!', SH_CD_SLUG );
64
65 sh_cd_message_display( $message, ! $result );
66 }
67
68 if ( true == $save_result ) {
69 sh_cd_message_display( __( 'Your shortcode has been saved!', SH_CD_SLUG ) );
70 }
71
72 ?>
73
74 <div class="wrap">
75 <div id="icon-options-general" class="icon32"></div>
76 <div id="poststuff">
77 <div id="post-body" class="metabox-holder columns-3">
78 <div id="post-body-content">
79 <div class="meta-box-sortables ui-sortable">
80 <div class="postbox">
81 <h3 class="hndle"><span><?php echo __( 'Your existing Snippet Shortcodes', SH_CD_SLUG ); ?></span></h3>
82 <div style="padding: 0px 15px 0px 15px">
83 <p style="text-align: right">
84 <a class="button-primary" href="<?php echo sh_cd_link_your_shortcodes_add() ?>"><?php echo __( 'Add a new Snippet Shortcode', SH_CD_SLUG ); ?></a>
85 </p>
86 <p style="text-align: right">
87 <?php
88
89 sh_cd_upgrade_button( 'sh-cd-hide', sh_cd_license_upgrade_link() );
90
91 ?>
92 </p>
93 <table class="widefat sh-cd-table" width="100%">
94 <tr class="row-title">
95 <th class="row-title" width="15%"><?php echo __( 'Slug', SH_CD_SLUG ); ?></th>
96 <th width="20%"><?php echo __( 'Shortcode', SH_CD_SLUG ); ?></th>
97 <th width="*"><?php echo __( 'Shortcode content', SH_CD_SLUG ); ?></th>
98 <th width="60px" align="middle"><?php echo __( 'Global', SH_CD_SLUG ); ?></th>
99 <th width="60px" align="middle"><?php echo __( 'Enabled', SH_CD_SLUG ); ?></th>
100 <th width="70px" align="middle"><?php echo __( 'Options', SH_CD_SLUG ); ?></th>
101 </tr>
102 <?php
103
104 $current_shortcodes = sh_cd_db_shortcodes_all();
105
106 if ( false === empty( $current_shortcodes ) ) {
107
108 $class = '';
109
110 $link = sh_cd_link_your_shortcodes();
111
112 foreach ( $current_shortcodes as $shortcode ) {
113
114 $class = ($class == 'alternate') ? '' : 'alternate';
115
116 $id = (int) $shortcode['id'];
117
118 printf(
119 '<tr class="%1$s">
120 <td><a href="%2$s">%3$s</a></td>
121 <td>[%4$s slug="%3$s"]</td>
122 <td align="right">
123 <textarea class="large-text inline-text-shortcode" id="sh-cd-text-area-%8$d" data-id="%8$d">%5$s</textarea>
124 <a class="button button-small sh-cd-inline-save-button" id="sh-cd-save-button-%8$d" data-id="%8$d"><i class="fas fa-save"></i> %11$s</a>
125 </td>
126 <td align="middle"><a class="button button-small toggle-multisite" id="sc-cd-multisite-%8$s" data-id="%8$s"><i class="fas %10$s"></i></a></td>
127 <td align="middle"><a class="button button-small toggle-disable" id="sc-cd-toggle-%8$s" data-id="%8$s"><i class="fas %6$s"></i></a></td>
128 <td width="100">
129 <a class="button button-small" href="%9$s"><i class="far fa-clone"></i></a>
130 <a class="button button-small" href="%2$s"><i class="far fa-edit"></i></a>
131 <a class="button button-small" href="%7$s" onclick="return confirm(\'%12$s\');"><i class="fas fa-trash-alt"></i></a>
132 </td>
133 </tr>',
134 $class,
135 $link . '&action=edit&id=' . $id,
136 esc_html( $shortcode['slug'] ),
137 SH_CD_SHORTCODE,
138 esc_html( stripslashes( $shortcode['data'] ) ),
139 ( 1 === (int) $shortcode['disabled'] ) ? 'fa-times' : 'fa-check',
140 $link . '&action=delete&id=' . $id,
141 $id,
142 ( true === sh_cd_license_is_premium() ) ? $link . '&action=clone&id=' . $id : sh_cd_license_upgrade_link(),
143 ( 1 === (int) $shortcode['multisite'] ) ? 'fa-check' : 'fa-times',
144 __( 'Save', SH_CD_SLUG ),
145 __( 'Are you sure you want to delete this shortcode?', SH_CD_SLUG )
146 );
147 }
148 }
149 else {
150 printf( '<tr><td colspan="5" align="center">%1$s. <a href="%2$s">%3$s</a></td></tr>',
151 __( 'You haven\'t created any shortcodes yet', SH_CD_SLUG ),
152 sh_cd_link_your_shortcodes_add(),
153 __( 'Add one now!', SH_CD_SLUG )
154 );
155 }
156 ?>
157 </table>
158 <br clear="all" />
159 </div>
160 </div>
161 </div>
162 </div>
163 </div>
164 </div>
165 </div>
166 <?php
167 }
168
169