PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.0.10.5
Pods – Custom Content Types and Fields v3.0.10.5
2.7.31.4 2.8.23.5 2.9.19.5 3.0.10.5 3.1.4.3 3.2.8.4 3.3.9.2 2.8.23.4 2.9.19.4 3.0.10.4 3.1.4.2 3.2.8.3 3.3.9.1 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 1 day ago upgrade 1 day ago widgets 1 day ago components-admin.php 1 day ago help-addons-row.php 1 day ago help-addons.php 1 day ago help.php 1 day ago postbox-header.php 1 day ago settings-reset.php 1 day ago settings-settings.php 1 day ago settings-tools.php 1 day ago settings.php 1 day ago setup-add.php 1 day ago setup-edit.php 1 day ago shortcode.php 1 day ago view.php 1 day ago
settings-tools.php
174 lines
1 <?php
2
3 use Pods\Tools\Repair;
4
5 // Don't load directly.
6 if ( ! defined( 'ABSPATH' ) || ! pods_is_admin( 'pods_settings' ) ) {
7 die( '-1' );
8 }
9
10 global $wpdb;
11
12 $pods_api = pods_api();
13
14 $all_pods = $pods_api->load_pods();
15
16 if ( isset( $_POST['_wpnonce'] ) && false !== wp_verify_nonce( $_POST['_wpnonce'], 'pods-settings' ) ) {
17 if ( isset( $_POST['pods_repair_pod'] ) || isset( $_POST['pods_repair_pod_preview'] ) ) {
18 $pod_name = pods_v( 'pods_field_repair_pod', 'post' );
19
20 if ( is_array( $pod_name ) ) {
21 $pod_name = $pod_name[0];
22 }
23
24 $pod_name = sanitize_text_field( $pod_name );
25
26 if ( empty( $pod_name ) ) {
27 pods_message( __( 'No Pod selected.', 'pods' ), 'error' );
28 } else {
29 if ( '__all_pods' === $pod_name ) {
30 $pods_to_repair = [];
31
32 foreach ( $all_pods as $pod ) {
33 if ( 'post_type' !== $pod->get_object_storage_type() ) {
34 continue;
35 }
36
37 $pods_to_repair[] = $pod->get_name();
38 }
39 } else {
40 $pods_to_repair = [ $pod_name ];
41 }
42
43 foreach ( $pods_to_repair as $pod_to_repair ) {
44 $pod = $pods_api->load_pod( [ 'name' => $pod_to_repair ], false );
45
46 if ( empty( $pod ) ) {
47 pods_message( __( 'Pod not found.', 'pods' ) . ' (' . $pod_to_repair . ')', 'error' );
48 } else {
49 $tool = pods_container( Repair::class );
50
51 $mode = 'full';
52
53 if ( ! empty( $_POST['pods_repair_pod_preview'] ) ) {
54 $mode = 'preview';
55 }
56
57 $results = $tool->repair_groups_and_fields_for_pod( $pod, $mode );
58
59 pods_message( $results['message_html'] );
60 }
61 }
62 }
63 } elseif ( isset( $_POST['pods_recreate_tables'] ) ) {
64 pods_upgrade()->delta_tables();
65
66 pods_redirect( pods_query_arg( array( 'pods_recreate_tables_success' => 1 ), array( 'page', 'tab' ) ) );
67 }
68 } elseif ( 1 === (int) pods_v( 'pods_recreate_tables_success' ) ) {
69 pods_message( 'Pods tables have been recreated.' );
70 }
71 ?>
72
73 <h3><?php esc_html_e( 'Repair Pod, Groups, and Fields', 'pods' ); ?></h3>
74
75 <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>
76
77 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
78
79 <ul class="ul-disc">
80 <li><?php esc_html_e( 'If the Pod has Fields but no Groups yet, the first Group will be automatically created', 'pods' ); ?></li>
81 <li><?php esc_html_e( 'All Groups with conflicting names will be renamed to prevent conflicts with other registered Groups', 'pods' ); ?></li>
82 <li><?php esc_html_e( 'All Fields with conflicting names will be renamed to prevent conflicts with other registered Fields', 'pods' ); ?></li>
83 <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>
84 <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>
85 <li><?php esc_html_e( 'All Fields that have an invalid Field type set will be changed to Plain Text', 'pods' ); ?></li>
86 <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>
87 </ul>
88
89 <?php
90 $repair_pods = [];
91
92 foreach ( $all_pods as $pod ) {
93 if ( 'post_type' !== $pod->get_object_storage_type() ) {
94 continue;
95 }
96
97 $repair_pods[ $pod->get_name() ] = sprintf(
98 '%1$s (%2$s)',
99 $pod->get_label(),
100 $pod->get_name()
101 );
102 }
103
104 asort( $repair_pods );
105
106 $repair_pods['__all_pods'] = '-- ' . __( 'Run Repair for All Pods', 'pods' ) . ' (' . __( 'Warning: This may be slow on large configurations', 'pods' ) . ') --';
107 ?>
108
109 <?php if ( 1 < count( $repair_pods ) ) : ?>
110 <table class="form-table pods-manage-field">
111 <?php
112 $fields = [
113 'repair_pod' => [
114 'name' => 'repair_pod',
115 'label' => __( 'Pod', 'pods' ),
116 'type' => 'pick',
117 'pick_format_type' => 'single',
118 'pick_format_single' => 'autocomplete',
119 'data' => $repair_pods,
120 ],
121 ];
122
123 $field_prefix = 'pods_field_';
124 $field_row_classes = '';
125 $id = '';
126 $value_callback = static function( $field_name, $id, $field, $pod ) use ( $field_prefix ) {
127 return pods_v( $field_prefix . $field_name, 'post', '' );
128 };
129
130 pods_view( PODS_DIR . 'ui/forms/table-rows.php', compact( array_keys( get_defined_vars() ) ) );
131 ?>
132 </table>
133
134 <p class="submit">
135 <?php
136 $confirm = esc_html__( 'Are you sure you want to do this?', 'pods' )
137 . "\n\n" . esc_html__( 'This is a good time to make sure you have a backup.', 'pods' )
138 . "\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' );
139 ?>
140 <input type="submit" class="button button-primary" name="pods_repair_pod"
141 value=" <?php esc_attr_e( 'Repair Pod, Groups, and Fields', 'pods' ); ?> " onclick="return confirm( '<?php echo esc_js( $confirm ); ?>' );" />
142 <input type="submit" class="button button-secondary" name="pods_repair_pod_preview"
143 value=" <?php esc_attr_e( 'Preview (no changes will be made)', 'pods' ); ?> " />
144 </p>
145 <?php else : ?>
146 <p><em><?php esc_html_e( 'No Pods available to repair.', 'pods' ); ?></em></p>
147 <?php endif; ?>
148
149 <hr />
150
151 <?php
152 $relationship_table = $wpdb->prefix . 'podsrel';
153 ?>
154
155 <h3><?php esc_html_e( 'Recreate missing tables', 'pods' ); ?></h3>
156
157 <p><?php esc_html_e( 'This will recreate missing tables if there are any that do not exist.', 'pods' ); ?></p>
158 <h4><?php esc_html_e( 'What you can expect', 'pods' ); ?></h4>
159 <ul>
160 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'KEEP', 'pods' ); ?>:</strong> <?php
161 // translators: %s is the name of the wp_podsrel table in the database.
162 printf( esc_html__( '%s will remain untouched if it already exists', 'pods' ), esc_html( $relationship_table ) );
163 ?></li>
164 <li>🆗 &nbsp;&nbsp;<strong><?php esc_html_e( 'CREATE', 'pods' ); ?>:</strong> <?php
165 // translators: %s is the name of the wp_podsrel table in the database.
166 printf( esc_html__( '%s will be created if it does not exist', 'pods' ), esc_html( $relationship_table ) );
167 ?></li>
168 </ul>
169
170 <p class="submit">
171 <?php $confirm = __( 'Are you sure you want to do this?', 'pods' ); ?>
172 <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 ); ?>' );" />
173 </p>
174