PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / trunk
Pods – Custom Content Types and Fields vtrunk
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 4 months ago upgrade 4 months ago widgets 4 months ago components-admin.php 1 month ago help-addons-row.php 4 months ago help-addons.php 4 months ago help.php 4 months ago postbox-header.php 4 months ago settings-reset.php 4 months ago settings-settings.php 4 months ago settings-tools.php 4 months ago settings.php 4 months ago setup-add.php 4 months ago setup-edit.php 4 months ago shortcode.php 4 months ago view.php 4 months ago
settings-reset.php
294 lines
1 <?php
2
3 // Don't load directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 die( '-1' );
6 }
7
8 // phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
9
10 // Prevent non-admins.
11 if ( ! pods_is_admin( 'pods_settings' ) ) {
12 die( '-1' );
13 }
14
15 use Pods\Tools\Reset;
16
17 /** @var $pods_init PodsInit */
18 global $pods_init, $wpdb;
19
20 $relationship_table = $wpdb->prefix . 'podsrel';
21
22 $excluded_pod_types_from_reset = [
23 'user',
24 'media',
25 ];
26
27 $pods_api = pods_api();
28
29 if ( isset( $_POST['_wpnonce'] ) && false !== wp_verify_nonce( $_POST['_wpnonce'], 'pods-settings' ) ) {
30 if ( isset( $_POST['pods_cleanup_1x'] ) ) {
31 pods_upgrade( '2.0.0' )->cleanup();
32
33 pods_redirect( pods_query_arg( array( 'pods_cleanup_1x_success' => 1 ), array( 'page', 'tab' ) ) );
34 } elseif ( isset( $_POST['pods_reset_pod'] ) || isset( $_POST['pods_reset_pod_preview'] ) ) {
35 $pod_name = pods_v( 'pods_field_reset_pod', 'post' );
36
37 if ( is_array( $pod_name ) ) {
38 $pod_name = $pod_name[0];
39 }
40
41 $pod_name = sanitize_text_field( $pod_name );
42
43 if ( empty( $pod_name ) ) {
44 pods_message( __( 'No Pod specified.', 'pods' ), 'error' );
45 } else {
46 $pod = $pods_api->load_pod( [ 'name' => $pod_name ], false );
47
48 if ( empty( $pod ) ) {
49 pods_message( __( 'Pod not found.', 'pods' ), 'error' );
50 } else {
51 $tool = pods_container( Reset::class );
52
53 $mode = 'full';
54
55 if ( ! empty( $_POST['pods_reset_pod_preview'] ) ) {
56 $mode = 'preview';
57 }
58
59 $results = $tool->delete_all_content_for_pod( $pod, $mode );
60
61 pods_message( $results['message_html'] );
62 }
63 }
64 } elseif ( isset( $_POST['pods_reset'] ) ) {
65 $pods_init->reset();
66 $pods_init->setup();
67
68 pods_redirect( pods_query_arg( array( 'pods_reset_success' => 1 ), array( 'page', 'tab' ) ) );
69 } elseif ( isset( $_POST['pods_reset_deactivate'] ) ) {
70 $pods_init->reset();
71
72 deactivate_plugins( PODS_DIR . 'init.php' );
73
74 pods_redirect( 'index.php' );
75 }
76 } elseif ( 1 === (int) pods_v( 'pods_reset_success' ) ) {
77 pods_message( 'Pods settings and data have been reset.' );
78 } elseif ( 1 === (int) pods_v( 'pods_cleanup_1x_success' ) ) {
79 pods_message( 'Pods 1.x data has been deleted.' );
80 }
81
82 // Monday Mode
83 $monday_mode = (
84 1 === (int) pods_v( 'pods_monday_mode', 'get', 0, true )
85 || (
86 1 === (int) date_i18n( 'N' )
87 && (int) date_i18n( 'H' ) < 12
88 )
89 );
90
91 if ( pods_v_sanitized( 'pods_reset_weekend', 'post', pods_v_sanitized( 'pods_reset_weekend', 'get', 0, null, true ), null, true ) ) {
92 $html = '<br /><br /><iframe width="480" height="360" src="https://www.youtube-nocookie.com/embed/2yJgwwDcgV8?autoplay=1" frameborder="0" allowfullscreen></iframe>';
93
94 if ( $monday_mode ) {
95 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 );
96 } else {
97 pods_message( 'Oops, sorry! You can only reset the weekend on a Monday morning but enjoy the video below..' . $html, 'error' );
98 }
99 }
100
101 // Please Note:
102 $please_note = __( 'Please Note:', 'pods' );
103
104 $all_pods = $pods_api->load_pods();
105 ?>
106 <h3><?php esc_html_e( 'Delete all content for a Pod', 'pods' ); ?></h3>
107
108 <p><?php esc_html_e( 'This will delete ALL stored content in the database for your Pod.', 'pods' ); ?></p>
109
110 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
111
112 <ul>
113 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Your Pod configuration will remain', 'pods' ); ?></li>
114 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Your Group configurations will remain', 'pods' ); ?></li>
115 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Your Field configurations will remain', 'pods' ); ?></li>
116 <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>
117 <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>
118 <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>
119 <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>
120 </ul>
121
122 <?php
123 $reset_pods = [];
124
125 foreach ( $all_pods as $pod ) {
126 if ( in_array( $pod->get_type(), $excluded_pod_types_from_reset, true ) ) {
127 continue;
128 }
129
130 $pod_name = $pod->get_name();
131
132 $reset_pods[ $pod_name ] = sprintf(
133 '%1$s (%2$s)',
134 $pod->get_label(),
135 $pod_name
136 );
137 }
138
139 asort( $reset_pods );
140 ?>
141
142 <?php if ( ! empty( $reset_pods ) ) : ?>
143 <table class="form-table pods-manage-field">
144 <?php
145 $fields = [
146 'reset_pod' => [
147 'name' => 'reset_pod',
148 'label' => __( 'Pod', 'pods' ),
149 'type' => 'pick',
150 'pick_format_type' => 'single',
151 'pick_format_single' => 'autocomplete',
152 'data' => $reset_pods,
153 ],
154 ];
155
156 $field_prefix = 'pods_field_';
157 $field_row_classes = '';
158 $id = '';
159 $value_callback = static function( $field_name, $id, $field, $pod ) use ( $field_prefix ) {
160 return pods_v( $field_prefix . $field_name, 'post', '' );
161 };
162
163 pods_view( PODS_DIR . 'ui/forms/table-rows.php', compact( array_keys( get_defined_vars() ) ) );
164 ?>
165 </table>
166
167 <p class="submit">
168 <?php
169 $confirm = esc_html__( 'Are you sure you want to do this?', 'pods' )
170 . "\n\n" . esc_html__( 'This is a good time to make sure you have a backup.', 'pods' )
171 . "\n\n" . esc_html__( 'We will delete ALL of the content for the Pod you selected.', 'pods' );
172 ?>
173 <input type="submit" class="button button-primary" name="pods_reset_pod"
174 value=" <?php esc_attr_e( 'Delete Pod Content', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
175 <input type="submit" class="button button-secondary" name="pods_reset_pod_preview"
176 value=" <?php esc_attr_e( 'Preview (no changes will be made)', 'pods' ); ?> " />
177 </p>
178 <?php else : ?>
179 <p><em><?php esc_html_e( 'No Pods available to reset.', 'pods' ); ?></em></p>
180 <?php endif; ?>
181
182 <hr />
183
184 <?php
185 $old_version = get_option( 'pods_version' );
186
187 if ( ! empty( $old_version ) ) {
188 ?>
189 <h3><?php esc_html_e( 'Delete Pods 1.x data', 'pods' ); ?></h3>
190
191 <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>
192
193 <p class="submit">
194 <?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' ); ?>
195 <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 ); ?>' );" />
196 </p>
197
198 <hr />
199
200 <h3><?php esc_html_e( 'Reset Pods 2.x', 'pods' ); ?></h3>
201
202 <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>
203 <p><?php echo sprintf( '<strong>%1$s</strong>', esc_html( $please_note ) ) . esc_html__( '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>
204
205 <p class="submit">
206 <?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' ); ?>
207 <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 ); ?>' );" />
208 </p>
209
210 <hr />
211
212 <h3><?php esc_html_e( 'Deactivate and Delete Pods 2.x data', 'pods' ); ?></h3>
213
214 <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>
215 <p><?php esc_html_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>
216
217 <p class="submit">
218 <?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' ); ?>
219 <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 ); ?>' );" />
220 </p>
221 <?php
222 } else {
223 ?>
224 <h3><?php esc_html_e( 'Reset Pods entirely', 'pods' ); ?></h3>
225
226 <p><?php esc_html_e( 'This will reset Pods settings, remove all of your Pod configurations, and perform a fresh install.', 'pods' ); ?></p>
227 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
228 <ul>
229 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All posts will remain', 'pods' ); ?></li>
230 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All terms will remain', 'pods' ); ?></li>
231 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All media will remain', 'pods' ); ?></li>
232 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All users will remain', 'pods' ); ?></li>
233 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All custom field values will remain', 'pods' ); ?></li>
234 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'Pods plugin will remain activated', 'pods' ); ?></li>
235 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'Pods settings will be reset to defaults', 'pods' ); ?></li>
236 <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>
237 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php
238 // translators: %s is the name of the wp_podsrel table in the database.
239 printf( esc_html__( 'Relationship table (%s) will be deleted (and all of the relationships)', 'pods' ), esc_html( $relationship_table ) );
240 ?></li>
241 <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>
242 </ul>
243
244 <p class="submit">
245 <?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' ); ?>
246 <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 ); ?>' );" />
247 </p>
248
249 <hr />
250
251 <h3><?php esc_html_e( 'Deactivate and Delete Pods data', 'pods' ); ?></h3>
252
253 <p><?php esc_html_e( 'This will delete Pods settings, data, and deactivate itself once done.', 'pods' ); ?></p>
254 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
255 <ul>
256 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All posts will remain', 'pods' ); ?></li>
257 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All terms will remain', 'pods' ); ?></li>
258 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All media will remain', 'pods' ); ?></li>
259 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All users will remain', 'pods' ); ?></li>
260 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php esc_html_e( 'All custom field values will remain', 'pods' ); ?></li>
261 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DEACTIVATE', 'pods' ); ?>:</strong> <?php esc_html_e( 'Pods plugin will be deactivated', 'pods' ); ?></li>
262 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php esc_html_e( 'Pods settings will be reset to defaults', 'pods' ); ?></li>
263 <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>
264 <li> &nbsp;&nbsp;<strong><?php esc_html_e( 'DELETE', 'pods' ); ?>:</strong> <?php
265 // translators: %s is the name of the wp_podsrel table in the database.
266 printf( esc_html__( 'Relationship table (%s) will be deleted (and all of the relationships)', 'pods' ), esc_html( $relationship_table ) );
267 ?></li>
268 <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>
269 </ul>
270
271 <p class="submit">
272 <?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' ); ?>
273 <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 ); ?>' );" />
274 </p>
275 <?php
276 }//end if
277
278 if ( $monday_mode ) {
279 ?>
280 <hr />
281
282 <h3><?php esc_html_e( 'Reset Weekend', 'pods' ); ?></h3>
283
284 <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>
285 <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>
286
287 <p class="submit">
288 <?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' ); ?>
289 <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 ); ?>' );" />
290 </p>
291 <?php
292 }
293 ?>
294