PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.2.2
Pods – Custom Content Types and Fields v3.2.2
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / ui / admin / settings-reset.php
pods / ui / admin Last commit date
callouts 2 years ago upgrade 2 years ago widgets 2 years ago components-admin.php 2 years ago help-addons-row.php 2 years ago help-addons.php 2 years ago help.php 2 years ago postbox-header.php 2 years ago settings-reset.php 2 years ago settings-settings.php 2 years ago settings-tools.php 2 years ago settings.php 2 years ago setup-add.php 2 years ago setup-edit.php 2 years ago shortcode.php 2 years ago view.php 2 years ago
settings-reset.php
280 lines
1 <?php
2 use Pods\Tools\Reset;
3
4 // Don't load directly.
5 if ( ! defined( 'ABSPATH' ) || ! pods_is_admin( 'pods_settings' ) ) {
6 die( '-1' );
7 }
8
9 /** @var $pods_init PodsInit */
10 global $pods_init, $wpdb;
11
12 $relationship_table = $wpdb->prefix . 'podsrel';
13
14 $excluded_pod_types_from_reset = [
15 'user',
16 'media',
17 ];
18
19 $pods_api = pods_api();
20
21 if ( isset( $_POST['_wpnonce'] ) && false !== wp_verify_nonce( $_POST['_wpnonce'], 'pods-settings' ) ) {
22 if ( isset( $_POST['pods_cleanup_1x'] ) ) {
23 pods_upgrade( '2.0.0' )->cleanup();
24
25 pods_redirect( pods_query_arg( array( 'pods_cleanup_1x_success' => 1 ), array( 'page', 'tab' ) ) );
26 } elseif ( isset( $_POST['pods_reset_pod'] ) || isset( $_POST['pods_reset_pod_preview'] ) ) {
27 $pod_name = pods_v( 'pods_field_reset_pod', 'post' );
28
29 if ( is_array( $pod_name ) ) {
30 $pod_name = $pod_name[0];
31 }
32
33 $pod_name = sanitize_text_field( $pod_name );
34
35 if ( empty( $pod_name ) ) {
36 pods_message( __( 'No Pod specified.', 'pods' ), 'error' );
37 } else {
38 $pod = $pods_api->load_pod( [ 'name' => $pod_name ], false );
39
40 if ( empty( $pod ) ) {
41 pods_message( __( 'Pod not found.', 'pods' ), 'error' );
42 } else {
43 $tool = pods_container( Reset::class );
44
45 $mode = 'full';
46
47 if ( ! empty( $_POST['pods_reset_pod_preview'] ) ) {
48 $mode = 'preview';
49 }
50
51 $results = $tool->delete_all_content_for_pod( $pod, $mode );
52
53 pods_message( $results['message_html'] );
54 }
55 }
56 } elseif ( isset( $_POST['pods_reset'] ) ) {
57 $pods_init->reset();
58 $pods_init->setup();
59
60 pods_redirect( pods_query_arg( array( 'pods_reset_success' => 1 ), array( 'page', 'tab' ) ) );
61 } elseif ( isset( $_POST['pods_reset_deactivate'] ) ) {
62 $pods_init->reset();
63
64 deactivate_plugins( PODS_DIR . 'init.php' );
65
66 pods_redirect( 'index.php' );
67 }
68 } elseif ( 1 === (int) pods_v( 'pods_reset_success' ) ) {
69 pods_message( 'Pods settings and data have been reset.' );
70 } elseif ( 1 === (int) pods_v( 'pods_cleanup_1x_success' ) ) {
71 pods_message( 'Pods 1.x data has been deleted.' );
72 }
73
74 // Monday Mode
75 $monday_mode = pods_v( 'pods_monday_mode', 'get', 0, true );
76
77 if ( pods_v_sanitized( 'pods_reset_weekend', 'post', pods_v_sanitized( 'pods_reset_weekend', 'get', 0, null, true ), null, true ) ) {
78 if ( $monday_mode ) {
79 $html = '<br /><br /><iframe width="480" height="360" src="https://www.youtube-nocookie.com/embed/QH2-TGUlwu4?autoplay=1" frameborder="0" allowfullscreen></iframe>';
80 pods_message( 'The weekend has been reset and you have been sent back to Friday night. Unfortunately due to a tear in the fabric of time, you slipped back to Monday. We took video of the whole process and you can see it below..' . $html );
81 } else {
82 $html = '<br /><br /><iframe width="480" height="360" src="https://www.youtube-nocookie.com/embed/QH2-TGUlwu4?autoplay=1" frameborder="0" allowfullscreen></iframe>';
83 pods_message( 'Oops, sorry! You can only reset the weekend on a Monday before the end of the work day. Somebody call the Waaambulance!' . $html, 'error' );
84 }
85 }
86
87 // Please Note:
88 $please_note = __( 'Please Note:' );
89
90 $all_pods = $pods_api->load_pods();
91 ?>
92 <h3><?php esc_html_e( 'Delete all content for a Pod', 'pods' ); ?></h3>
93
94 <p><?php esc_html_e( 'This will delete ALL stored content in the database for your Pod.', 'pods' ); ?></p>
95
96 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
97
98 <ul>
99 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Your Pod configuration will remain', 'pods' ); ?></li>
100 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Your Group configurations will remain', 'pods' ); ?></li>
101 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Your Field configurations will remain', 'pods' ); ?></li>
102 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Previously uploaded media will remain in the Media Library but will no longer be attached to their corresponding posts', 'pods' ); ?></li>
103 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'All items for this Pod stored will be deleted from the database', 'pods' ); ?></li>
104 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'All custom fields for the items stored will be deleted from the database', 'pods' ); ?></li>
105 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'All files and relationships for the items stored will be deleted from the database', 'pods' ); ?></li>
106 </ul>
107
108 <?php
109 $reset_pods = [];
110
111 foreach ( $all_pods as $pod ) {
112 if ( in_array( $pod->get_type(), $excluded_pod_types_from_reset, true ) ) {
113 continue;
114 }
115
116 $pod_name = $pod->get_name();
117
118 $reset_pods[ $pod_name ] = sprintf(
119 '%1$s (%2$s)',
120 $pod->get_label(),
121 $pod_name
122 );
123 }
124
125 asort( $reset_pods );
126 ?>
127
128 <?php if ( ! empty( $reset_pods ) ) : ?>
129 <table class="form-table pods-manage-field">
130 <?php
131 $fields = [
132 'reset_pod' => [
133 'name' => 'reset_pod',
134 'label' => __( 'Pod', 'pods' ),
135 'type' => 'pick',
136 'pick_format_type' => 'single',
137 'pick_format_single' => 'autocomplete',
138 'data' => $reset_pods,
139 ],
140 ];
141
142 $field_prefix = 'pods_field_';
143 $field_row_classes = '';
144 $id = '';
145 $value_callback = static function( $field_name, $id, $field, $pod ) use ( $field_prefix ) {
146 return pods_v( $field_prefix . $field_name, 'post', '' );
147 };
148
149 pods_view( PODS_DIR . 'ui/forms/table-rows.php', compact( array_keys( get_defined_vars() ) ) );
150 ?>
151 </table>
152
153 <p class="submit">
154 <?php
155 $confirm = esc_html__( 'Are you sure you want to do this?', 'pods' )
156 . "\n\n" . esc_html__( 'This is a good time to make sure you have a backup.', 'pods' )
157 . "\n\n" . esc_html__( 'We will delete ALL of the content for the Pod you selected.', 'pods' );
158 ?>
159 <input type="submit" class="button button-primary" name="pods_reset_pod"
160 value=" <?php esc_attr_e( 'Delete Pod Content', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
161 <input type="submit" class="button button-secondary" name="pods_reset_pod_preview"
162 value=" <?php esc_attr_e( 'Preview (no changes will be made)', 'pods' ); ?> " />
163 </p>
164 <?php else : ?>
165 <p><em><?php esc_html_e( 'No Pods available to reset.', 'pods' ); ?></em></p>
166 <?php endif; ?>
167
168 <hr />
169
170 <?php
171 $old_version = get_option( 'pods_version' );
172
173 if ( ! empty( $old_version ) ) {
174 ?>
175 <h3><?php esc_html_e( 'Delete Pods 1.x data', 'pods' ); ?></h3>
176
177 <p><?php esc_html_e( 'This will delete all of your Pods 1.x data, it\'s only recommended if you\'ve verified your data has been properly migrated into Pods 2.x.', 'pods' ); ?></p>
178
179 <p class="submit">
180 <?php $confirm = __( "Are you sure you want to do this?\n\nThis is a good time to make sure you have a backup.\n\nWe are deleting ALL of the data that surrounds 1.x, resetting it to a clean first install.", 'pods' ); ?>
181 <input type="submit" class="button button-primary" name="pods_cleanup_1x" value=" <?php esc_attr_e( 'Delete Pods 1.x settings and data', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
182 </p>
183
184 <hr />
185
186 <h3><?php esc_html_e( 'Reset Pods 2.x', 'pods' ); ?></h3>
187
188 <p><?php esc_html_e( 'This does not delete any Pods 1.x data, it simply resets the Pods 2.x settings, removes all of it\'s data, and performs a fresh install.', 'pods' ); ?></p>
189 <p><?php echo sprintf( '<strong>%1$s</strong>', $please_note ) . __( 'This does not remove any items from any Post Types, Taxonomies, Media, Users, or Comments data you have added/modified. Any custom fields stored using the table storage component, content in Advanced Content Types, and relationships between posts will be lost.', 'pods' ); ?></p>
190
191 <p class="submit">
192 <?php $confirm = __( "Are you sure you want to do this?\n\nThis is a good time to make sure you have a backup. We are deleting all of the data that surrounds 2.x, resetting it to a clean first install.", 'pods' ); ?>
193 <input type="submit" class="button button-primary" name="pods_reset" value=" <?php esc_attr_e( 'Reset Pods 2.x settings and data', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
194 </p>
195
196 <hr />
197
198 <h3><?php esc_html_e( 'Deactivate and Delete Pods 2.x data', 'pods' ); ?></h3>
199
200 <p><?php esc_html_e( 'This will delete Pods 2.x settings, data, and deactivate itself once done. Your database will be as if Pods 2.x never existed.', 'pods' ); ?></p>
201 <p><?php _e( '<strong>Please Note:</strong> This does not remove any items from any Post Types, Taxonomies, Media, Users, or Comments data you have added/modified.', 'pods' ); ?></p>
202
203 <p class="submit">
204 <?php $confirm = __( "Are you sure you want to do this?\n\nThis is a good time to make sure you have a backup.\n\nWe are deleting ALL of the data that surrounds 2.x with no turning back.", 'pods' ); ?>
205 <input type="submit" class="button button-primary" name="pods_reset_deactivate" value=" <?php esc_attr_e( 'Deactivate and Delete Pods 2.x data', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
206 </p>
207 <?php
208 } else {
209 ?>
210 <h3><?php esc_html_e( 'Reset Pods entirely', 'pods' ); ?></h3>
211
212 <p><?php esc_html_e( 'This will reset Pods settings, remove all of your Pod configurations, and perform a fresh install.', 'pods' ); ?></p>
213 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
214 <ul>
215 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All posts will remain', 'pods' ); ?></li>
216 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All terms will remain', 'pods' ); ?></li>
217 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All media will remain', 'pods' ); ?></li>
218 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All users will remain', 'pods' ); ?></li>
219 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All custom field values will remain', 'pods' ); ?></li>
220 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Pods plugin will remain activated', 'pods' ); ?></li>
221 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'Pods settings will be reset to defaults', 'pods' ); ?></li>
222 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'All Pod configurations will be deleted including Custom Post Types, Custom Taxonomies, Custom Settings Pages, and all custom field configurations', 'pods' ); ?></li>
223 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php
224 // translators: %s is the name of the wp_podsrel table in the database.
225 printf( esc_html__( 'Relationship table (%s) will be deleted (and all of the relationships)', 'pods' ), esc_html( $relationship_table ) );
226 ?></li>
227 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'Advanced Content Type tables will be deleted (and all of their data)', 'pods' ); ?></li>
228 </ul>
229
230 <p class="submit">
231 <?php $confirm = __( "Are you sure you want to do this?\n\nThis is a good time to make sure you have a backup.\n\nWe are deleting ALL of the data that surrounds Pods, resetting it to a clean, first install.", 'pods' ); ?>
232 <input type="submit" class="button button-primary" name="pods_reset" value="<?php esc_attr_e( 'Reset Pods settings and data', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
233 </p>
234
235 <hr />
236
237 <h3><?php esc_html_e( 'Deactivate and Delete Pods data', 'pods' ); ?></h3>
238
239 <p><?php esc_html_e( 'This will delete Pods settings, data, and deactivate itself once done.', 'pods' ); ?></p>
240 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
241 <ul>
242 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All posts will remain', 'pods' ); ?></li>
243 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All terms will remain', 'pods' ); ?></li>
244 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All media will remain', 'pods' ); ?></li>
245 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All users will remain', 'pods' ); ?></li>
246 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All custom field values will remain', 'pods' ); ?></li>
247 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DEACTIVATE', 'pods' ); ?>:</strong> <?php esc_html_e( 'Pods plugin will be deactivated', 'pods' ); ?></li>
248 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'Pods settings will be reset to defaults', 'pods' ); ?></li>
249 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'All Pod configurations will be deleted including Custom Post Types, Custom Taxonomies, Custom Settings Pages, and all custom field configurations', 'pods' ); ?></li>
250 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php
251 // translators: %s is the name of the wp_podsrel table in the database.
252 printf( esc_html__( 'Relationship table (%s) will be deleted (and all of the relationships)', 'pods' ), esc_html( $relationship_table ) );
253 ?></li>
254 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'Advanced Content Type tables will be deleted (and all of their data)', 'pods' ); ?></li>
255 </ul>
256
257 <p class="submit">
258 <?php $confirm = __( "Are you sure you want to do this?\n\nThis is a good time to make sure you have a backup.\n\nWe are deleting ALL of the data that surrounds with no turning back.", 'pods' ); ?>
259 <input type="submit" class="button button-primary" name="pods_reset_deactivate" value=" <?php esc_attr_e( 'Deactivate and Delete Pods data', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
260 </p>
261 <?php
262 }//end if
263
264 if ( $monday_mode ) {
265 ?>
266 <hr />
267
268 <h3><?php esc_html_e( 'Reset Weekend', 'pods' ); ?></h3>
269
270 <p><?php esc_html_e( 'This feature has been exclusively built for Pods to help developers suffering from "Monday", and allows them to reset the weekend.', 'pods' ); ?></p>
271 <p><?php esc_html_e( "By resetting the weekend, you will be sent back to Friday night and the weekend you've just spent will be erased. You will retain all of your memories of the weekend, and be able to relive it in any way you wish.", 'pods' ); ?></p>
272
273 <p class="submit">
274 <?php $confirm = __( "Are you sure you want to Reset your Weekend?\n\nThere is no going back, you cannot reclaim anything you've gained throughout your weekend.\n\nYou are about to be groundhoggin' it", 'pods' ); ?>
275 <input type="submit" class="button button-primary" name="pods_reset_weekend" value=" reset_weekend( '<?php echo esc_js( date_i18n( 'Y-m-d', strtotime( '-3 days' ) ) ); ?> 19:00:00' ); " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
276 </p>
277 <?php
278 }
279 ?>
280