PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.3.6
Pods – Custom Content Types and Fields v3.3.6
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-tools.php
pods / ui / admin Last commit date
callouts 4 months ago upgrade 4 months ago widgets 4 months ago components-admin.php 4 months 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-tools.php
216 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\Repair;
16
17 global $wpdb;
18
19 $pods_api = pods_api();
20
21 $all_pods = $pods_api->load_pods();
22
23 if ( isset( $_POST['_wpnonce'] ) && false !== wp_verify_nonce( $_POST['_wpnonce'], 'pods-settings' ) ) {
24 if ( isset( $_POST['pods_repair_pod'] ) || isset( $_POST['pods_repair_pod_preview'] ) ) {
25 $pod_name = pods_v( 'pods_field_repair_pod', 'post' );
26
27 if ( is_array( $pod_name ) ) {
28 $pod_name = $pod_name[0];
29 }
30
31 $pod_name = sanitize_text_field( $pod_name );
32
33 if ( empty( $pod_name ) ) {
34 pods_message( __( 'No Pod selected.', 'pods' ), 'error' );
35 } else {
36 if ( '__all_pods' === $pod_name ) {
37 $pods_to_repair = [];
38
39 foreach ( $all_pods as $pod ) {
40 if ( 'post_type' !== $pod->get_object_storage_type() ) {
41 continue;
42 }
43
44 $pods_to_repair[] = $pod->get_name();
45 }
46 } else {
47 $pods_to_repair = [ $pod_name ];
48 }
49
50 foreach ( $pods_to_repair as $pod_to_repair ) {
51 $pod = $pods_api->load_pod( [ 'name' => $pod_to_repair ], false );
52
53 if ( empty( $pod ) ) {
54 pods_message( __( 'Pod not found.', 'pods' ) . ' (' . $pod_to_repair . ')', 'error' );
55 } else {
56 $tool = pods_container( Repair::class );
57
58 $mode = 'full';
59
60 if ( ! empty( $_POST['pods_repair_pod_preview'] ) ) {
61 $mode = 'preview';
62 }
63
64 $results = $tool->repair_groups_and_fields_for_pod( $pod, $mode );
65
66 pods_message( $results['message_html'] );
67 }
68 }
69 }
70 } elseif ( isset( $_POST['pods_repair_pods'] ) || isset( $_POST['pods_repair_pods_preview'] ) ) {
71 $tool = pods_container( Repair::class );
72
73 $mode = 'full';
74
75 if ( ! empty( $_POST['pods_repair_pods_preview'] ) ) {
76 $mode = 'preview';
77 }
78
79 $results = $tool->repair_pods( $mode );
80
81 pods_message( $results['message_html'] );
82 } elseif ( isset( $_POST['pods_recreate_tables'] ) ) {
83 pods_upgrade()->delta_tables();
84
85 pods_redirect( pods_query_arg( array( 'pods_recreate_tables_success' => 1 ), array( 'page', 'tab' ) ) );
86 }
87 } elseif ( 1 === (int) pods_v( 'pods_recreate_tables_success' ) ) {
88 pods_message( 'Pods tables have been recreated.' );
89 }
90 ?>
91
92 <h3><?php esc_html_e( 'Repair Pod, Groups, and Fields', 'pods' ); ?></h3>
93
94 <p><?php esc_html_e( 'This tool will attempt to repair a Pod, Groups, and Fields. When the tool runs you will be provided with a complete list of repairs made.', 'pods' ); ?></p>
95
96 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
97
98 <ul class="ul-disc">
99 <li><?php esc_html_e( 'If the Pod has Fields but no Groups yet, the first Group will be automatically created', 'pods' ); ?></li>
100 <li><?php esc_html_e( 'All Groups with conflicting names will be renamed to prevent conflicts with other registered Groups', 'pods' ); ?></li>
101 <li><?php esc_html_e( 'All Fields with conflicting names will be renamed to prevent conflicts with other registered Fields', 'pods' ); ?></li>
102 <li><?php esc_html_e( 'All orphaned Fields that belong to a Group that no longer exists will be auto-assigned to the first available Group', 'pods' ); ?></li>
103 <li><?php esc_html_e( 'All orphaned Fields that do not belong to a Group will be auto-assigned to the first available Group', 'pods' ); ?></li>
104 <li><?php esc_html_e( 'All Fields that have an invalid Field type set will be changed to Plain Text', 'pods' ); ?></li>
105 <li><?php esc_html_e( 'All Fields that have invalid arguments set will have those arguments removed (conditional logic saved with serialized data and other arguments not intended for the DB used by early Pods 2.x releases)', 'pods' ); ?></li>
106 </ul>
107
108 <?php
109 $repair_pods = [];
110
111 foreach ( $all_pods as $pod ) {
112 if ( 'post_type' !== $pod->get_object_storage_type() ) {
113 continue;
114 }
115
116 $repair_pods[ $pod->get_name() ] = sprintf(
117 '%1$s (%2$s)',
118 $pod->get_label(),
119 $pod->get_name()
120 );
121 }
122
123 asort( $repair_pods );
124
125 $repair_pods['__all_pods'] = '-- ' . __( 'Run Repair for All Pods', 'pods' ) . ' (' . __( 'Warning: This may be slow on large configurations', 'pods' ) . ') --';
126 ?>
127
128 <?php if ( 1 < count( $repair_pods ) ) : ?>
129 <table class="form-table pods-manage-field">
130 <?php
131 $fields = [
132 'repair_pod' => [
133 'name' => 'repair_pod',
134 'label' => __( 'Pod', 'pods' ),
135 'type' => 'pick',
136 'pick_format_type' => 'single',
137 'pick_format_single' => 'autocomplete',
138 'data' => $repair_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 be making a few repairs to your configuration that should not be destructive to your data but you should be always have a backup just in case.', 'pods' );
158 ?>
159 <input type="submit" class="button button-primary" name="pods_repair_pod"
160 value=" <?php esc_attr_e( 'Repair Pod, Groups, and Fields', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
161 <input type="submit" class="button button-secondary" name="pods_repair_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 repair.', 'pods' ); ?></em></p>
166 <?php endif; ?>
167
168 <hr />
169
170 <h3><?php esc_html_e( 'Repair Pod configurations', 'pods' ); ?></h3>
171
172 <p><?php esc_html_e( 'This will repair pod configurations themselves.', 'pods' ); ?></p>
173 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
174 <ul class='ul-disc'>
175 <li><?php esc_html_e( 'All Pods with conflicting names will be renamed to prevent conflicts with other registered Pods', 'pods' ); ?></li>
176 </ul>
177
178 <p class='submit'>
179 <?php
180 $confirm = esc_html__( 'Are you sure you want to do this?', 'pods' )
181 . "\n\n" . esc_html__( 'This is a good time to make sure you have a backup.', 'pods' )
182 . "\n\n" . esc_html__( 'We will be making a few repairs to your configuration that should not be destructive to your data but you should be always have a backup just in case.', 'pods' );
183 ?>
184 <input type="submit" class="button button-primary" name="pods_repair_pods"
185 value=" <?php esc_attr_e( 'Repair Pod configurations', 'pods' ); ?> "
186 onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );"/>
187 <input type="submit" class="button button-secondary" name="pods_repair_pods_preview"
188 value=" <?php esc_attr_e( 'Preview (no changes will be made)', 'pods' ); ?> "/>
189 </p>
190
191 <hr />
192
193 <?php
194 $relationship_table = $wpdb->prefix . 'podsrel';
195 ?>
196
197 <h3><?php esc_html_e( 'Recreate missing tables', 'pods' ); ?></h3>
198
199 <p><?php esc_html_e( 'This will recreate missing tables if there are any that do not exist.', 'pods' ); ?></p>
200 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
201 <ul>
202 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php
203 // translators: %s is the name of the wp_podsrel table in the database.
204 printf( esc_html__( '%s will remain untouched if it already exists', 'pods' ), esc_html( $relationship_table ) );
205 ?></li>
206 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'CREATE', 'pods' ); ?>:</strong> <?php
207 // translators: %s is the name of the wp_podsrel table in the database.
208 printf( esc_html__( '%s will be created if it does not exist', 'pods' ), esc_html( $relationship_table ) );
209 ?></li>
210 </ul>
211
212 <p class="submit">
213 <?php $confirm = __( 'Are you sure you want to do this?', 'pods' ); ?>
214 <input type="submit" class="button button-primary" name="pods_recreate_tables" value=" <?php esc_attr_e( 'Recreate missing tables', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
215 </p>
216