PluginProbe
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards / 5.5.84
WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards v5.5.84
5.5.84 5.5.83 5.5.82 5.5.81 5.5.80 5.5.79 5.5.77 5.5.76 5.5.75 5.5.73 5.5.72 5.5.22 5.5.23 5.5.29 5.5.3 5.5.31 5.5.32 5.5.34 5.5.35 5.5.36 5.5.37 5.5.4 5.5.40 5.5.41 5.5.42 All 160 releases
wp-data-access / WPDataAccess / Settings / WPDA_Settings_ManageRepository.php

WPDA_Settings_ManageRepository.php in WP Data Access – App Builder for Tables, Forms, Charts, Maps & Dashboards 5.5.84, at WPDataAccess/Settings/WPDA_Settings_ManageRepository.php

1,299 lines 54.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPDataAccess\Settings {
4
5 use WPDataAccess\Plugin_Table_Models\WPDA_App_Apps_Model;
6 use WPDataAccess\Plugin_Table_Models\WPDA_App_Container_Model;
7 use WPDataAccess\Plugin_Table_Models\WPDA_App_Model;
8 use WPDataAccess\Plugin_Table_Models\WPDA_CSV_Uploads_Model;
9 use WPDataAccess\Plugin_Table_Models\WPDA_Design_Table_Model;
10 use WPDataAccess\Plugin_Table_Models\WPDA_Logging_Model;
11 use WPDataAccess\Plugin_Table_Models\WPDA_Media_Model;
12 use WPDataAccess\Plugin_Table_Models\WPDA_Publisher_Model;
13 use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model;
14 use WPDataAccess\Plugin_Table_Models\WPDA_User_Menus_Model;
15 use WPDataAccess\Plugin_Table_Models\WPDP_Page_Model;
16 use WPDataAccess\Plugin_Table_Models\WPDP_Project_Design_Table_Model;
17 use WPDataAccess\Plugin_Table_Models\WPDP_Project_Model;
18 use WPDataAccess\Utilities\WPDA_Message_Box;
19 use WPDataAccess\Utilities\WPDA_Repository;
20 use WPDataAccess\Utilities\WPDA_Restore_Repository;
21 use WPDataAccess\WPDA;
22
23 class WPDA_Settings_ManageRepository extends WPDA_Settings {
24
25 public function __construct( $current_tab ) {
26 parent::__construct( $current_tab );
27
28 // Recreation of repository must be performed before checking the availability of menu items (done next).
29 if ( isset( $_REQUEST['repos'] ) && 'true' === sanitize_text_field( wp_unslash( $_REQUEST['repos'] ) ) ) {
30 // Security check.
31 $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay.
32 if ( ! wp_verify_nonce( $wp_nonce, 'wpda-settings-recreate-repository-' . WPDA::get_current_user_login() ) ) {
33 wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) );
34 }
35
36 // Recreate repository.
37 $wpda_repository = new WPDA_Repository();
38 $wpda_repository->recreate();
39 WPDA::set_option( WPDA::OPTION_WPDA_SETUP_ERROR ); // Set to default.
40
41 $msg = new WPDA_Message_Box(
42 array(
43 'message_text' => __( 'Repository recreation completed', 'wp-data-access' ),
44 )
45 );
46 $msg->box();
47 }
48 }
49
50 /**
51 * Counts the number of rows in a backup table. The table is queried from the MySQL meta data and cannot be
52 * entered by a user. No SQL injection checks necessary.
53 */
54 protected function count_repository_backup_table( $table_name ) {
55 global $wpdb;
56
57 $suppress = $wpdb->suppress_errors( true );
58 $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
59 $wpdb->prepare(
60 'select 1 from `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders
61 array(
62 WPDA::remove_backticks( $table_name ),
63 )
64 )
65 );
66 $wpdb->suppress_errors( $suppress );
67
68 return $wpdb->num_rows;
69 }
70
71 /**
72 * Add repository tab content
73 *
74 * See class documentation for flow explanation.
75 *
76 * @since 1.0.0
77 */
78 protected function add_content() {
79
80 global $wpdb;
81
82 if ( isset( $_REQUEST['action'] ) ) {
83 $action = sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ); // input var okay.
84
85 // Security check.
86 $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay.
87 if ( ! wp_verify_nonce( $wp_nonce, 'wpda-repository-settings-' . WPDA::get_current_user_login() ) ) {
88 wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) );
89 }
90
91 if ( 'save' === $action ) {
92 // Save changes.
93 WPDA::set_option(
94 WPDA::OPTION_MR_KEEP_BACKUP_TABLES,
95 isset( $_REQUEST['keep_backup_tables'] ) ?
96 sanitize_text_field( wp_unslash( $_REQUEST['keep_backup_tables'] ) ) :
97 'off' // input var okay.
98 );
99 WPDA::set_option(
100 WPDA::OPTION_MR_BACKUP_TABLES_KEPT,
101 isset( $_REQUEST['backup_tables_kept'] ) ?
102 sanitize_text_field( wp_unslash( $_REQUEST['backup_tables_kept'] ) ) :
103 WPDA::OPTION_MR_BACKUP_TABLES_KEPT_DEFAULT // input var okay.
104 );
105 } elseif ( 'setdefaults' === $action ) {
106 // Set back to default values.
107 WPDA::set_option( WPDA::OPTION_MR_KEEP_BACKUP_TABLES );
108 WPDA::set_option( WPDA::OPTION_MR_BACKUP_TABLES_KEPT );
109 }
110
111 $msg = new WPDA_Message_Box(
112 array(
113 'message_text' => __( 'Settings saved', 'wp-data-access' ),
114 )
115 );
116 $msg->box();
117
118 }
119
120 $keep_backup_tables = WPDA::get_option( WPDA::OPTION_MR_KEEP_BACKUP_TABLES );
121 $backup_tables_kept = WPDA::get_option( WPDA::OPTION_MR_BACKUP_TABLES_KEPT );
122
123 // Check table wp_wpda_app.
124 $app_table_name = WPDA_App_Model::get_base_table_name();
125 $app_table_name_exists = WPDA_App_Model::table_exists();
126
127 // Check table wp_wpda_app_container.
128 $app_container_table_name = WPDA_App_Container_Model::get_base_table_name();
129 $app_container_table_name_exists = WPDA_App_Container_Model::table_exists();
130
131 // Check table wp_wpda_app_apps.
132 $app_apps_table_name = WPDA_App_Apps_Model::get_base_table_name();
133 $app_apps_table_name_exists = WPDA_App_Apps_Model::table_exists();
134
135 // Check table wp_wpda_menus.
136 $menus_table_name = WPDA_User_Menus_Model::get_base_table_name();
137 $menus_table_name_exists = WPDA_User_Menus_Model::table_exists();
138
139 // Check table wp_wpda_table_design.
140 $design_table_name = WPDA_Design_Table_Model::get_base_table_name();
141 $design_table_name_exists = WPDA_Design_Table_Model::table_exists();
142
143 // Check table wp_wpda_logging
144 $logging_table_name = WPDA_Logging_Model::get_base_table_name();
145 $logging_table_exists = WPDA_Logging_Model::table_exists();
146
147 // Check table wp_wpda_media
148 $media_table_name = WPDA_Media_Model::get_base_table_name();
149 $media_table_exists = WPDA_Media_Model::table_exists();
150
151 // Check data projects tables
152 $data_projects_project_name = WPDP_Project_Model::get_base_table_name();
153 $data_projects_project_name_exists = WPDP_Project_Model::table_exists();
154
155 // Check data project page table.
156 $data_projects_page_name = WPDP_Page_Model::get_base_table_name();
157 $data_projects_page_name_exists = WPDP_Page_Model::table_exists();
158
159 // Check data project tables table
160 $data_projects_table_name = WPDP_Project_Design_Table_Model::get_base_table_name();
161 $data_projects_table_name_exists = WPDP_Project_Design_Table_Model::table_exists();
162
163 // Check data tables table.
164 $data_publication_table_name = WPDA_Publisher_Model::get_base_table_name();
165 $data_publication_table_name_exists = WPDA_Publisher_Model::table_exists();
166
167 // Check table settings tablewp_wpda_project_
168 $table_settings_table_name = WPDA_Table_Settings_Model::get_base_table_name();
169 $table_settings_table_exists = WPDA_Table_Settings_Model::table_exists();
170
171 // Check CSV import table
172 $csv_import_table_name = WPDA_CSV_Uploads_Model::get_base_table_name();
173 $csv_import_table_exists = WPDA_CSV_Uploads_Model::table_exists();
174
175 $table = __( 'Table', 'wp-data-access' );
176 $found = __( 'found', 'wp-data-access' );
177 $not_found = __( 'not found', 'wp-data-access' );
178 $bck_postfix = WPDA_Restore_Repository::BACKUP_TABLE_EXTENSION;
179 $query = '
180 select table_name AS table_name from information_schema.tables
181 where table_schema = %s
182 and (
183 table_name like %s
184 or table_name like %s
185 or table_name like %s
186 or table_name like %s
187 or table_name like %s
188 or table_name like %s
189 or table_name like %s
190 or table_name like %s
191 or table_name like %s
192 or table_name like %s
193 or table_name like %s
194 or table_name like %s
195 or table_name like %s
196 )
197 order by 1 desc';
198
199 if ( isset( $_REQUEST['create_backup'] ) && 'true' === $_REQUEST['create_backup'] ) {
200 // Security check
201 $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay.
202 if ( ! wp_verify_nonce( $wp_nonce, 'wpda-settings-create_backup-repository-' . WPDA::get_current_user_login() ) ) {
203 wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) );
204 }
205
206 $wpda_repository = new WPDA_Repository();
207 $wpda_repository->create_new_backup();
208 } elseif ( isset( $_REQUEST['remove_one_backup'] ) && 'true' === $_REQUEST['remove_one_backup'] ) {
209 // Security check
210 $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay.
211 if ( ! wp_verify_nonce( $wp_nonce, 'wpda-settings-remove_backup-repository-' . WPDA::get_current_user_login() ) ) {
212 wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) );
213 }
214
215 if ( isset( $_REQUEST['backup_date'] ) ) {
216 $backup_date = sanitize_text_field( wp_unslash( $_REQUEST['backup_date'] ) ); // input var okay.
217
218 // Remove specific repository backup set
219 $repository = new WPDA_Repository();
220 $repository->remove_backup( $backup_date );
221
222 $msg = new WPDA_Message_Box(
223 array(
224 'message_text' => __( 'Repository backup tables dropped', 'wp-data-access' ),
225 )
226 );
227 $msg->box();
228 }
229 } elseif ( isset( $_REQUEST['remove_backup'] ) && 'true' === $_REQUEST['remove_backup'] ) {
230 $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay.
231 if ( ! wp_verify_nonce( $wp_nonce, 'wpda-settings-remove_backup-repository-' . WPDA::get_current_user_login() ) ) {
232 wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) );
233 }
234
235 // Remove all repository backups
236 $backup_tables = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- plugin table
237 $wpdb->prepare(
238 $query, // phpcs:ignore WordPress.DB.PreparedSQL
239 array(
240 $wpdb->dbname,
241 "$menus_table_name{$bck_postfix}%",
242 "$design_table_name{$bck_postfix}%",
243 "$table_settings_table_name{$bck_postfix}%",
244 "$logging_table_name{$bck_postfix}%",
245 "$media_table_name{$bck_postfix}%",
246 "$data_publication_table_name{$bck_postfix}%",
247 "$csv_import_table_name{$bck_postfix}%",
248 "$data_projects_project_name{$bck_postfix}%",
249 "$data_projects_page_name{$bck_postfix}%",
250 "$data_projects_table_name{$bck_postfix}%",
251 "$app_table_name{$bck_postfix}%",
252 "$app_container_table_name{$bck_postfix}%",
253 "$app_apps_table_name{$bck_postfix}%",
254 )
255 ),
256 'ARRAY_N'
257 );
258 foreach ( $backup_tables as $backup_table ) {
259 $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugin table
260 $wpdb->prepare(
261 'drop table `%1s`', // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders, WordPress.DB.DirectDatabaseQuery.SchemaChange
262 array(
263 WPDA::remove_backticks( $backup_table[0] ),
264 )
265 )
266 );
267 }
268
269 $msg = new WPDA_Message_Box(
270 array(
271 'message_text' => __( 'Repository backup tables dropped', 'wp-data-access' ),
272 )
273 );
274 $msg->box();
275 } elseif ( isset( $_REQUEST['restore_backup'] ) ) {
276 if ( isset( $_REQUEST['restore_date'] ) ) {
277 $wp_nonce = isset( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_wpnonce'] ) ) : ''; // input var okay.
278 if ( ! wp_verify_nonce( $wp_nonce, 'wpda-settings-restore_backup-repository-' . WPDA::get_current_user_login() ) ) {
279 wp_die( esc_attr__( 'ERROR: Not authorized', 'wp-data-access' ) );
280 }
281
282 // Start repository restore procedure
283 $restore_date = sanitize_text_field( wp_unslash( $_REQUEST['restore_date'] ) ); // input var okay.
284 $restore = new WPDA_Restore_Repository();
285 $repository_tables = $restore->restore( $restore_date );
286 }
287 }
288
289 // Count backup tables rows
290 if ( $app_table_name_exists ) {
291 $no_app_items = WPDA_App_Model::count(); // phpcs:ignore -- 8.1 proof
292 } else {
293 $no_app_items = 0;
294 }
295 if ( $app_container_table_name_exists ) {
296 $no_app_container_items = WPDA_App_Container_Model::count(); // phpcs:ignore -- 8.1 proof
297 } else {
298 $no_app_container_items = 0;
299 }
300 if ( $app_apps_table_name_exists ) {
301 $no_app_apps_items = WPDA_App_Apps_Model::count(); // phpcs:ignore -- 8.1 proof
302 } else {
303 $no_app_apps_items = 0;
304 }
305 if ( $menus_table_name_exists ) {
306 $no_menu_items = WPDA_User_Menus_Model::count(); // phpcs:ignore -- 8.1 proof
307 } else {
308 $no_menu_items = 0;
309 }
310 if ( $design_table_name_exists ) {
311 $no_table_designs = WPDA_Design_Table_Model::count(); // phpcs:ignore -- 8.1 proof
312 } else {
313 $no_table_designs = 0;
314 }
315 if ( $logging_table_exists ) {
316 $no_logs = WPDA_Logging_Model::count(); // phpcs:ignore -- 8.1 proof
317 } else {
318 $no_logs = 0;
319 }
320 if ( $media_table_exists ) {
321 $no_media = WPDA_Media_Model::count(); // phpcs:ignore -- 8.1 proof
322 } else {
323 $no_media = 0;
324 }
325 if ( $data_projects_project_name_exists ) {
326 $no_projects = WPDP_Project_Model::count(); // phpcs:ignore -- 8.1 proof
327 } else {
328 $no_projects = 0;
329 }
330 if ( $data_projects_page_name_exists ) {
331 $no_pages = WPDP_Page_Model::count(); // phpcs:ignore -- 8.1 proof
332 } else {
333 $no_pages = 0;
334 }
335 if ( $data_projects_table_name_exists ) {
336 $no_project_table_designs = WPDP_Project_Design_Table_Model::count(); // phpcs:ignore -- 8.1 proof
337 } else {
338 $no_project_table_designs = 0;
339 }
340 if ( $data_publication_table_name_exists ) {
341 $no_data_publication = WPDA_Publisher_Model::count(); // phpcs:ignore -- 8.1 proof
342 } else {
343 $no_data_publication = 0;
344 }
345 if ( $table_settings_table_exists ) {
346 $no_table_settings = WPDA_Table_Settings_Model::count(); // phpcs:ignore -- 8.1 proof
347 } else {
348 $no_table_settings = 0;
349 }
350 if ( $csv_import_table_exists ) {
351 $no_csv_import = WPDA_CSV_Uploads_Model::count(); // phpcs:ignore -- 8.1 proof
352 } else {
353 $no_csv_import = 0;
354 }
355
356 // Count backup tables
357 $backup_tables = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter -- plugin tables
358 $wpdb->prepare(
359 $query, // phpcs:ignore WordPress.DB.PreparedSQL
360 array(
361 $wpdb->dbname,
362 "$menus_table_name{$bck_postfix}%",
363 "$design_table_name{$bck_postfix}%",
364 "$table_settings_table_name{$bck_postfix}%",
365 "$logging_table_name{$bck_postfix}%",
366 "$media_table_name{$bck_postfix}%",
367 "$data_publication_table_name{$bck_postfix}%",
368 "$csv_import_table_name{$bck_postfix}%",
369 "$data_projects_project_name{$bck_postfix}%",
370 "$data_projects_page_name{$bck_postfix}%",
371 "$data_projects_table_name{$bck_postfix}%",
372 "$app_table_name{$bck_postfix}%",
373 "$app_container_table_name{$bck_postfix}%",
374 "$app_apps_table_name{$bck_postfix}%",
375 )
376 ),
377 'ARRAY_N'
378 );
379 $no_backup_tables = $wpdb->num_rows;
380
381 $wpnonce_create_backup = wp_create_nonce( 'wpda-settings-create_backup-repository-' . WPDA::get_current_user_login() );
382 $wpnonce_remove_backup = wp_create_nonce( 'wpda-settings-remove_backup-repository-' . WPDA::get_current_user_login() );
383 $wpnonce_restore_backup = wp_create_nonce( 'wpda-settings-restore_backup-repository-' . WPDA::get_current_user_login() );
384
385 if ( isset( $repository_tables ) ) {
386 // Show restore results
387 $output_restore_data = '';
388 foreach ( $repository_tables as $key => $repository_table ) {
389 $rows = false === $repository_table['rows'] ? '0' : $repository_table['rows'];
390 $output_restore_data .= '
391 <tr>
392 <td>' . esc_attr( $key ) . '</td>
393 <td>' . esc_attr( $rows ) . '</td>
394 <td>' . esc_attr( $repository_table['errors'] ) . '</td>
395 </tr>
396 ';
397 }
398 $output_restore = "
399 <h3>Repository Restore Results</h3>
400 <table class='wpda-repository-restore'>
401 <thead>
402 <tr>
403 <th>Repository table name</th>
404 <th>Rows imported</th>
405 <th>Error messages</th>
406 </tr>
407 </thead>
408 <tbody>
409 {$output_restore_data}
410 </tbody>
411 </table>
412 ";
413 $msgbox = new WPDA_Message_Box(
414 array(
415 'message_text' => 'custom',
416 )
417 );
418 $msgbox->custom_box( $output_restore );
419 }
420
421 $wpnonce_download_backup = wp_create_nonce( 'wpda-export-' . WPDA::get_current_user_login() );
422 ?>
423 <form id="wpda-download-actual-respository"
424 method="post"
425 action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?action=wpda_export"
426 target="_blank"
427 style="display: none"
428 >
429 <input type="hidden" name="type" value="table">
430 <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $wpnonce_download_backup ); ?>">
431 <input type="hidden" name="show_create" value="off">
432 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $app_table_name ); ?>">
433 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $app_container_table_name ); ?>">
434 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $app_apps_table_name ); ?>">
435 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $table_settings_table_name ); ?>">
436 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $media_table_name ); ?>">
437 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $design_table_name ); ?>">
438 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $data_projects_project_name ); ?>">
439 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $data_projects_page_name ); ?>">
440 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $data_projects_table_name ); ?>">
441 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $data_publication_table_name ); ?>">
442 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $menus_table_name ); ?>">
443 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $csv_import_table_name ); ?>">
444 <input type="hidden" name="table_names[]" value="<?php echo esc_attr( $logging_table_name ); ?>">
445 <input type="submit">
446 </form>
447 <form id="wpda-download-backup"
448 method="post"
449 action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?action=wpda_export"
450 target="_blank"
451 style="display: none"
452 >
453 <input type="hidden" name="type" value="table">
454 <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $wpnonce_download_backup ); ?>">
455 <input type="hidden" name="show_create" value="off">
456 <input type="hidden" name="table_names[]" id="app_table_name">
457 <input type="hidden" name="table_names[]" id="app_container_table_name">
458 <input type="hidden" name="table_names[]" id="app_apps_table_name">
459 <input type="hidden" name="table_names[]" id="table_settings_table_name">
460 <input type="hidden" name="table_names[]" id="media_table_name">
461 <input type="hidden" name="table_names[]" id="design_table_name">
462 <input type="hidden" name="table_names[]" id="data_projects_project_name">
463 <input type="hidden" name="table_names[]" id="data_projects_page_name">
464 <input type="hidden" name="table_names[]" id="data_projects_table_name">
465 <input type="hidden" name="table_names[]" id="data_publication_table_name">
466 <input type="hidden" name="table_names[]" id="menus_table_name">
467 <input type="hidden" name="table_names[]" id="csv_import_table_name">
468 <input type="hidden" name="table_names[]" id="logging_table_name">
469 <input type="submit">
470 </form>
471 <form id="wpda-remove-backup"
472 method="post"
473 action="<?php esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->page ); ?>&tab=repository"
474 style="display: none"
475 >
476 <input type="hidden" name="backup_date" id="remove_backup_date">
477 <input type="hidden" name="remove_one_backup" value="true">
478 <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $wpnonce_remove_backup ); ?>">
479 <input type="submit">
480 </form>
481 <form id="wpda-create-backup"
482 method="post"
483 action="<?php esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->page ); ?>&tab=repository"
484 style="display: none"
485 >
486 <input type="hidden" name="create_backup" value="true">
487 <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $wpnonce_create_backup ); ?>">
488 <input type="submit">
489 </form>
490 <form id="wpda-remove-all-backups"
491 method="post"
492 action="<?php esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->page ); ?>&tab=repository"
493 style="display: none"
494 >
495 <input type="hidden" name="remove_backup" value="true">
496 <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $wpnonce_remove_backup ); ?>">
497 <input type="submit">
498 </form>
499 <form id="wpda-restore-respository"
500 method="post"
501 action="<?php esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->page ); ?>&tab=repository"
502 style="display: none"
503 >
504 <input type="hidden" name="wpda_app" id="restore_app_table_name">
505 <input type="hidden" name="wpda_app_container" id="restore_app_container_table_name">
506 <input type="hidden" name="wpda_app_apps" id="restore_app_apps_table_name">
507 <input type="hidden" name="wpda_table_settings" id="restore_table_settings_table_name">
508 <input type="hidden" name="wpda_media" id="restore_media_table_name">
509 <input type="hidden" name="wpda_table_design" id="restore_design_table_name">
510 <input type="hidden" name="wpda_project" id="restore_data_projects_project_name">
511 <input type="hidden" name="wpda_project_page" id="restore_data_projects_page_name">
512 <input type="hidden" name="wpda_project_table" id="restore_data_projects_table_name">
513 <input type="hidden" name="wpda_publisher" id="restore_data_publication_table_name">
514 <input type="hidden" name="wpda_menus" id="restore_menus_table_name">
515 <input type="hidden" name="wpda_csv_uploads" id="restore_csv_import_table_name">
516 <input type="hidden" name="wpda_logging" id="restore_logging_table_name">
517 <input type="hidden" name="restore_date" id="restore_date">
518 <input type="hidden" name="restore_backup" value="true">
519 <input type="hidden" name="_wpnonce" value="<?php echo esc_attr( $wpnonce_restore_backup ); ?>">
520 <input type="submit">
521 </form>
522 <form id="wpda_settings_repository" method="post"
523 action="<?php esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->page ); ?>&tab=repository">
524 <table class="wpda-table-settings">
525
526 <tr>
527 <th>
528 <?php esc_html_e( 'On Plugin Update', 'wp-data-access' ); ?>
529 </th>
530 <td>
531 <label>
532 <input type="checkbox" name="keep_backup_tables"
533 <?php echo 'on' === $keep_backup_tables ? 'checked' : ''; ?>>
534 <strong><?php esc_html_e( 'Keep backup of repository tables', 'wp-data-access' ); ?></strong>
535 <?php esc_html_e( '(creates backup tables on plugin updates)', 'wp-data-access' ); ?>
536 </label>
537 <br/>
538 <label style="display: inline-block; margin-top: 5px">
539 <strong>Max backups saved:</strong>&nbsp;
540 <input type="number" name="backup_tables_kept" value="<?php echo esc_attr( $backup_tables_kept ); ?>" />
541 </label>
542 <br/><br/>
543 <a href="javascript:void(0)"
544 class="button"
545 onclick="jQuery('#wpda-download-actual-respository').submit()"
546 >
547 <?php esc_html_e( 'Download actual repository tables', 'wp-data-access' ); ?>
548 </a>
549 <div style="width: fit-content">
550 <?php
551 if ( $no_backup_tables > 0 ) {
552 ?>
553 <table class="wpda-table-backup">
554 <tr>
555 <th style="vertical-align: bottom">Current repository backups</th>
556 <th class="wpda-repository-column"></th>
557 <th class="wpda-repository-column"></th>
558 <th class="wpda-repository-column"></th>
559 <th class="wpda-repository-column"><span>Apps</span></th>
560 <th class="wpda-repository-column"><span>App Containers</span></th>
561 <th class="wpda-repository-column"><span>App Apps</span></th>
562 <th class="wpda-repository-column"><span>Table Settings</span></th>
563 <th class="wpda-repository-column"><span>Media Columns</span></th>
564 <th class="wpda-repository-column"><span>Data Designer</span></th>
565 <th class="wpda-repository-column"><span>Data Projects</span></th>
566 <th class="wpda-repository-column"><span>Project Pages</span></th>
567 <th class="wpda-repository-column"><span>Project Templates</span></th>
568 <th class="wpda-repository-column"><span>Data Tables</span></th>
569 <th class="wpda-repository-column"><span>Data Menus</span></th>
570 <th class="wpda-repository-column"><span>CSV Uploads</span></th>
571 <th class="wpda-repository-column"><span>Data Logging</span></th>
572 </tr>
573 <?php
574 foreach ( $backup_tables as $backup_table ) {
575 if (
576 strtolower( "{$data_projects_page_name}{$bck_postfix}" ) ===
577 strtolower( substr( $backup_table[0], 0, strlen( "{$data_projects_page_name}{$bck_postfix}" ) ) )
578 ) {
579 $backup_date = substr( $backup_table[0], 25 + strlen( $wpdb->prefix ) );
580 $display_date =
581 substr( $backup_date, 0, 4 ) . '-' .
582 substr( $backup_date, 4, 2 ) . '-' .
583 substr( $backup_date, 6, 2 ) . ' ' .
584 substr( $backup_date, 8, 2 ) . ':' .
585 substr( $backup_date, 10, 2 ) . ':' .
586 substr( $backup_date, 12, 2 );
587 ?>
588 <tr data-backup-date="<?php echo esc_attr( $backup_date ); ?>">
589 <td>
590 <span>
591 Repository backup <?php echo esc_attr( $display_date ); ?>
592 </span>
593 </td>
594 <td>
595 <span class="dashicons dashicons-download wpda_tooltip"
596 title="Download backup: <?php echo esc_attr( $display_date ); ?>"
597 onclick="backup_respository_tables('<?php echo "{$app_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$app_container_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$app_apps_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$table_settings_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$media_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$design_table_name}{$bck_postfix}{$backup_date}"; ?>', '<?php echo "{$data_projects_project_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$data_projects_page_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$data_projects_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$data_publication_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$menus_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$csv_import_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>', '<?php echo "{$logging_table_name}{$bck_postfix}{$backup_date}"; // phpcs:ignore WordPress.Security.EscapeOutput ?>')"
598 >
599 </span>
600 </td>
601 <td>
602 <span class="dashicons dashicons-upload wpda_tooltip"
603 title="Restore backup: <?php echo esc_attr( $display_date ); ?>"
604 onclick="jQuery('.wpda-restore-repository-backup-selected').removeClass('wpda-restore-repository-backup-selected'); jQuery(this).closest('tr').addClass('wpda-restore-repository-backup-selected'); jQuery('#wpda-restore-repository-backup').show();"
605 >
606 </span>
607 </td>
608 <td>
609 <span class="dashicons dashicons-trash wpda_tooltip"
610 title="Remove repository backup: <?php echo esc_attr( $display_date ); ?>"
611 onclick="if (confirm('Remove backup?')) { jQuery('#remove_backup_date').val('<?php echo esc_attr( $backup_date ); ?>'); jQuery('#wpda-remove-backup').submit(); }"
612 >
613 </span>
614 </td>
615 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $app_table_name . $bck_postfix . $backup_date ) ); ?></td>
616 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $app_container_table_name . $bck_postfix . $backup_date ) ); ?></td>
617 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $app_apps_table_name . $bck_postfix . $backup_date ) ); ?></td>
618 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $table_settings_table_name . $bck_postfix . $backup_date ) ); ?></td>
619 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $media_table_name . $bck_postfix . $backup_date ) ); ?></td>
620 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $design_table_name . $bck_postfix . $backup_date ) ); ?></td>
621 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $data_projects_project_name . $bck_postfix . $backup_date ) ); ?></td>
622 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $data_projects_page_name . $bck_postfix . $backup_date ) ); ?></td>
623 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $data_projects_table_name . $bck_postfix . $backup_date ) ); ?></td>
624 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $data_publication_table_name . $bck_postfix . $backup_date ) ); ?></td>
625 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $menus_table_name . $bck_postfix . $backup_date ) ); ?></td>
626 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $csv_import_table_name . $bck_postfix . $backup_date ) ); ?></td></td>
627 <td class="wpda-repository-column"><?php echo esc_attr( $this->count_repository_backup_table( $logging_table_name . $bck_postfix . $backup_date ) ); ?></td>
628 </tr>
629 <?php
630 }
631 }
632 ?>
633 </table>
634 <?php
635 $replace_title = __( 'CAREFULL This will truncate your actual repository table before restoring the selected version. Make a backup first!', 'wp-data-access' );
636 $add_title = __( 'IMPORTANT This option fails for which existing rows.', 'wp-data-access' );
637 ?>
638 <div id="wpda-restore-repository-backup" style="display: none; margin-top: 10px;">
639 <fieldset class="wpda_fieldset wpda-restore-repository-backup" style="box-sizing: border-box; width: 100%;">
640 <legend>
641 Restore repository backup
642 </legend>
643 <table class="wpda-restore-repository-backup">
644 <tr>
645 <td>Apps</td>
646 <th>
647 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
648 <input type="radio" name="restore_app_table_name" value="replace"/>
649 Replace
650 </label>
651 </th>
652 <th>
653 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
654 <input type="radio" name="restore_app_table_name" value="add"/>
655 Add
656 </label>
657 </th>
658 <th>
659 <label>
660 <input type="radio" name="restore_app_table_name" value="noaction" checked/>
661 No action
662 </label>
663 </th>
664 </tr>
665 <tr>
666 <td>App Containers</td>
667 <th>
668 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
669 <input type="radio" name="restore_app_container_table_name" value="replace"/>
670 Replace
671 </label>
672 </th>
673 <th>
674 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
675 <input type="radio" name="restore_app_container_table_name" value="add"/>
676 Add
677 </label>
678 </th>
679 <th>
680 <label>
681 <input type="radio" name="restore_app_container_table_name" value="noaction" checked/>
682 No action
683 </label>
684 </th>
685 </tr>
686 <tr>
687 <td>App Apps</td>
688 <th>
689 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
690 <input type="radio" name="restore_app_apps_table_name" value="replace"/>
691 Replace
692 </label>
693 </th>
694 <th>
695 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
696 <input type="radio" name="restore_app_apps_table_name" value="add"/>
697 Add
698 </label>
699 </th>
700 <th>
701 <label>
702 <input type="radio" name="restore_app_apps_table_name" value="noaction" checked/>
703 No action
704 </label>
705 </th>
706 </tr>
707 <tr>
708 <td>Table Settings</td>
709 <th>
710 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
711 <input type="radio" name="restore_table_settings_table_name" value="replace"/>
712 Replace
713 </label>
714 </th>
715 <th>
716 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
717 <input type="radio" name="restore_table_settings_table_name" value="add"/>
718 Add
719 </label>
720 </th>
721 <th>
722 <label>
723 <input type="radio" name="restore_table_settings_table_name" value="noaction" checked/>
724 No action
725 </label>
726 </th>
727 </tr>
728 <tr>
729 <td>Media Columns</td>
730 <th>
731 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
732 <input type="radio" name="restore_media_table_name" value="replace"/>
733 Replace
734 </label>
735 </th>
736 <th>
737 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
738 <input type="radio" name="restore_media_table_name" value="add"/>
739 Add
740 </label>
741 </th>
742 <th>
743 <label>
744 <input type="radio" name="restore_media_table_name" value="noaction" checked/>
745 No action
746 </label>
747 </th>
748 </tr>
749 <tr>
750 <td>Data Designer</td>
751 <th>
752 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
753 <input type="radio" name="restore_design_table_name" value="replace"/>
754 Replace
755 </label>
756 </th>
757 <th>
758 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
759 <input type="radio" name="restore_design_table_name" value="add"/>
760 Add
761 </label>
762 </th>
763 <th>
764 <label>
765 <input type="radio" name="restore_design_table_name" value="noaction" checked/>
766 No action
767 </label>
768 </th>
769 </tr>
770 <tr>
771 <td>Data Projects (incl pages)</td>
772 <th>
773 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
774 <input type="radio" name="restore_data_projects_project_name" value="replace"/>
775 Replace
776 </label>
777 </th>
778 <th>
779 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
780 <input type="radio" name="restore_data_projects_project_name" value="add"/>
781 Add
782 </label>
783 </th>
784 <th>
785 <label>
786 <input type="radio" name="restore_data_projects_project_name" value="noaction" checked/>
787 No action
788 </label>
789 </th>
790 </tr>
791 <tr>
792 <td>Project Templates</td>
793 <th>
794 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
795 <input type="radio" name="restore_data_projects_table_name" value="replace"/>
796 Replace
797 </label>
798 </th>
799 <th>
800 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
801 <input type="radio" name="restore_data_projects_table_name" value="add"/>
802 Add
803 </label>
804 </th>
805 <th>
806 <label>
807 <input type="radio" name="restore_data_projects_table_name" value="noaction" checked/>
808 No action
809 </label>
810 </th>
811 </tr>
812 <tr>
813 <td>Data Tables</td>
814 <th>
815 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
816 <input type="radio" name="restore_data_publication_table_name" value="replace"/>
817 Replace
818 </label>
819 </th>
820 <th>
821 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
822 <input type="radio" name="restore_data_publication_table_name" value="add"/>
823 Add
824 </label>
825 </th>
826 <th>
827 <label>
828 <input type="radio" name="restore_data_publication_table_name" value="noaction" checked/>
829 No action
830 </label>
831 </th>
832 </tr>
833 <tr>
834 <td>Data Menus</td>
835 <th>
836 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
837 <input type="radio" name="restore_menus_table_name" value="replace"/>
838 Replace
839 </label>
840 </th>
841 <th>
842 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
843 <input type="radio" name="restore_menus_table_name" value="add"/>
844 Add
845 </label>
846 </th>
847 <th>
848 <label>
849 <input type="radio" name="restore_menus_table_name" value="noaction" checked/>
850 No action
851 </label>
852 </th>
853 </tr>
854 <tr>
855 <td>CSV Uploads</td>
856 <th>
857 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
858 <input type="radio" name="restore_csv_import_table_name" value="replace"/>
859 Replace
860 </label>
861 </th>
862 <th>
863 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
864 <input type="radio" name="restore_csv_import_table_name" value="add"/>
865 Add
866 </label>
867 </th>
868 <th>
869 <label>
870 <input type="radio" name="restore_csv_import_table_name" value="noaction" checked/>
871 No action
872 </label>
873 </th>
874 </tr>
875 <tr>
876 <td>Data Logging</td>
877 <th>
878 <label title="<?php echo esc_attr( $replace_title ); ?>" class="wpda_tooltip">
879 <input type="radio" name="restore_logging_table_name" value="replace"/>
880 Replace
881 </label>
882 </th>
883 <th>
884 <label title="<?php echo esc_attr( $add_title ); ?>" class="wpda_tooltip">
885 <input type="radio" name="restore_logging_table_name" value="add"/>
886 Add
887 </label>
888 </th>
889 <th>
890 <label>
891 <input type="radio" name="restore_logging_table_name" value="noaction" checked/>
892 No action
893 </label>
894 </th>
895 </tr>
896 </table>
897 <div style="padding-top: 10px; text-align: center;">
898 <a href="javascript:void(0)"
899 class="button"
900 onclick="jQuery('.wpda-restore-repository-backup-selected').removeClass('wpda-restore-repository-backup-selected'); jQuery('#wpda-restore-repository-backup').hide();"
901 >
902 <?php esc_html_e( 'Cancel', 'wp-data-access' ); ?>
903 </a>
904 <a href="javascript:void(0)"
905 class="button"
906 onclick="restore_respository_tables()"
907 >
908 <?php esc_html_e( 'Restore', 'wp-data-access' ); ?>
909 </a>
910 </div>
911 </fieldset>
912 </div>
913 <?php
914 }
915 ?>
916 </div>
917 <div class="wpda-spacer"></div>
918 <a href="javascript:void(0)"
919 class="button"
920 onclick=" if (confirm('<?php esc_html_e( 'Backup repository tables?', 'wp-data-access' ); ?>')) { jQuery('#wpda-create-backup').submit(); }"
921 >
922 <?php esc_html_e( 'Create new repository backup', 'wp-data-access' ); ?>
923 </a>
924 <a href="javascript:void(0)"
925 class="button <?php echo 0 === $no_backup_tables ? 'disabled' : ''; ?>"
926 onclick="if (confirm('<?php echo esc_attr__( 'Delete all backup tables?', 'wp-data-access' ) . '\n' . esc_attr__( 'This action cannot be undone.', 'wp-data-access' ) . '\n' . esc_attr__( '\\\'Cancel\\\' to stop, \\\'OK\\\' to delete.', 'wp-data-access' ); ?>')) { jQuery('#wpda-remove-all-backups').submit(); }"
927 >
928 <?php echo esc_attr__( 'Delete all (', 'wp-data-access' ) . esc_attr( $no_backup_tables ) . esc_attr__( ') repository backup tables', 'wp-data-access' ); ?>
929 </a>
930 </td>
931 </tr>
932
933 <tr>
934 <th>
935 <?php esc_html_e( 'Apps', 'wp-data-access' ); ?>
936 </th>
937 <td>
938 <span class="dashicons <?php echo $app_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
939 <?php echo esc_attr( $table ); ?>
940 <strong><?php echo esc_attr( $app_table_name ); ?></strong>
941 <?php echo $app_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
942 <?php
943 if ( $app_table_name_exists ) {
944 ?>
945 <br/><br/>
946 <span class="dashicons dashicons-yes"></span>
947 <strong>
948 <?php echo esc_attr( $no_app_items ); ?>
949 <?php esc_html_e( 'apps defined in repository', 'wp-data-access' ); ?>
950 </strong>
951 <?php
952 }
953 ?>
954 </td>
955 </tr>
956
957 <tr>
958 <th>
959 <?php esc_html_e( 'App Containers', 'wp-data-access' ); ?>
960 </th>
961 <td>
962 <span class="dashicons <?php echo $app_container_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
963 <?php echo esc_attr( $table ); ?>
964 <strong><?php echo esc_attr( $app_container_table_name ); ?></strong>
965 <?php echo $app_container_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
966 <?php
967 if ( $app_container_table_name_exists ) {
968 ?>
969 <br/><br/>
970 <span class="dashicons dashicons-yes"></span>
971 <strong>
972 <?php echo esc_attr( $no_app_container_items ); ?>
973 <?php esc_html_e( 'apps containers defined in repository', 'wp-data-access' ); ?>
974 </strong>
975 <?php
976 }
977 ?>
978 </td>
979 </tr>
980
981 <tr>
982 <th>
983 <?php esc_html_e( 'App Apps', 'wp-data-access' ); ?>
984 </th>
985 <td>
986 <span class="dashicons <?php echo $app_apps_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
987 <?php echo esc_attr( $table ); ?>
988 <strong><?php echo esc_attr( $app_apps_table_name ); ?></strong>
989 <?php echo $app_apps_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
990 <?php
991 if ( $app_apps_table_name_exists ) {
992 ?>
993 <br/><br/>
994 <span class="dashicons dashicons-yes"></span>
995 <strong>
996 <?php echo esc_attr( $no_app_apps_items ); ?>
997 <?php esc_html_e( 'app apps defined in repository', 'wp-data-access' ); ?>
998 </strong>
999 <?php
1000 }
1001 ?>
1002 </td>
1003 </tr>
1004
1005 <tr>
1006 <th>
1007 <?php esc_html_e( 'Table Settings', 'wp-data-access' ); ?>
1008 </th>
1009 <td>
1010 <span class="dashicons <?php echo $table_settings_table_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1011 <?php echo esc_attr( $table ); ?>
1012 <strong><?php echo esc_attr( $table_settings_table_name ); ?></strong>
1013 <?php echo $table_settings_table_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1014 <?php
1015 if ( $table_settings_table_exists ) {
1016 ?>
1017 <br/><br/>
1018 <span class="dashicons dashicons-yes"></span>
1019 <strong>
1020 <?php echo esc_attr( $no_table_settings ); ?>
1021 <?php esc_html_e( 'table settings defined in repository', 'wp-data-access' ); ?>
1022 </strong>
1023 <?php
1024 }
1025 ?>
1026 </td>
1027 </tr>
1028
1029 <tr>
1030 <th>
1031 <?php esc_html_e( 'Manage Media', 'wp-data-access' ); ?>
1032 </th>
1033 <td>
1034 <span class="dashicons <?php echo $media_table_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1035 <?php echo esc_attr( $table ); ?>
1036 <strong><?php echo esc_attr( $media_table_name ); ?></strong>
1037 <?php echo $media_table_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1038 <?php
1039 if ( $media_table_exists ) {
1040 ?>
1041 <br/><br/>
1042 <span class="dashicons dashicons-yes"></span>
1043 <strong>
1044 <?php echo esc_attr( $no_media ); ?>
1045 <?php esc_html_e( 'media columns defined in repository', 'wp-data-access' ); ?>
1046 </strong>
1047 <?php
1048 }
1049 ?>
1050 </td>
1051 </tr>
1052
1053 <tr>
1054 <th>
1055 Data Designer
1056 </th>
1057 <td>
1058 <span class="dashicons <?php echo $design_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1059 <?php echo esc_attr( $table ); ?>
1060 <strong><?php echo esc_attr( $design_table_name ); ?></strong>
1061 <?php echo $design_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1062 <?php
1063 if ( $design_table_name_exists ) {
1064 ?>
1065 <br/><br/>
1066 <span class="dashicons dashicons-yes"></span>
1067 <strong>
1068 <?php echo esc_attr( $no_table_designs ); ?>
1069 <?php esc_html_e( 'table designs in repository', 'wp-data-access' ); ?>
1070 </strong>
1071 <?php
1072 }
1073 ?>
1074 </td>
1075 </tr>
1076
1077 <tr>
1078 <th>
1079 Data Projects
1080 </th>
1081 <td>
1082 <span class="dashicons <?php echo $design_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1083 <?php echo esc_attr( $table ); ?>
1084 <strong><?php echo esc_attr( $data_projects_project_name ); ?></strong>
1085 <?php echo $design_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1086 <strong>( = Data Projects )</strong>
1087 <br/>
1088 <span class="dashicons <?php echo $design_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1089 <?php echo esc_attr( $table ); ?>
1090 <strong><?php echo esc_attr( $data_projects_page_name ); ?></strong>
1091 <?php echo $design_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1092 <strong>( = Project Pages )</strong>
1093 <br/>
1094 <span class="dashicons <?php echo $design_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1095 <?php echo esc_attr( $table ); ?>
1096 <strong><?php echo esc_attr( $data_projects_table_name ); ?></strong>
1097 <?php echo $design_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1098 <strong>( = Project Templates )</strong>
1099 <br/>
1100 <?php
1101 if ( $data_projects_project_name_exists ) {
1102 ?>
1103 <br/>
1104 <span class="dashicons dashicons-yes"></span>
1105 <strong>
1106 <?php echo esc_attr( $no_projects ); ?>
1107 <?php esc_html_e( 'data projects in repository', 'wp-data-access' ); ?>
1108 </strong>
1109 <?php
1110 }
1111 if ( $data_projects_page_name_exists ) {
1112 ?>
1113 <br/>
1114 <span class="dashicons dashicons-yes"></span>
1115 <strong>
1116 <?php echo esc_attr( $no_pages ); ?>
1117 <?php esc_html_e( 'project pages in repository', 'wp-data-access' ); ?>
1118 </strong>
1119 <?php
1120 }
1121 if ( $data_projects_table_name_exists ) {
1122 ?>
1123 <br/>
1124 <span class="dashicons dashicons-yes"></span>
1125 <strong>
1126 <?php echo esc_attr( $no_project_table_designs ); ?>
1127 <?php esc_html_e( 'project tables in repository', 'wp-data-access' ); ?>
1128 </strong>
1129 <?php
1130 }
1131 ?>
1132 </td>
1133 </tr>
1134
1135 <tr>
1136 <th>
1137 Data Tables
1138 </th>
1139 <td>
1140 <span class="dashicons <?php echo $data_publication_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1141 <?php echo esc_attr( $table ); ?>
1142 <strong><?php echo esc_attr( $data_publication_table_name ); ?></strong>
1143 <?php echo $data_publication_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1144 <?php
1145 if ( $data_publication_table_name_exists ) {
1146 ?>
1147 <br/><br/>
1148 <span class="dashicons dashicons-yes"></span>
1149 <strong>
1150 <?php echo esc_attr( $no_data_publication ); ?>
1151 <?php esc_html_e( 'data tables in repository', 'wp-data-access' ); ?>
1152 </strong>
1153 <?php
1154 }
1155 ?>
1156 </td>
1157 </tr>
1158
1159 <tr>
1160 <th>
1161 Data Menus
1162 </th>
1163 <td>
1164 <span class="dashicons <?php echo $menus_table_name_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1165 <?php echo esc_attr( $table ); ?>
1166 <strong><?php echo esc_attr( $menus_table_name ); ?></strong>
1167 <?php echo $menus_table_name_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1168 <?php
1169 if ( $menus_table_name_exists ) {
1170 ?>
1171 <br/><br/>
1172 <span class="dashicons dashicons-yes"></span>
1173 <strong>
1174 <?php echo esc_attr( $no_menu_items ); ?>
1175 <?php esc_html_e( 'menus in repository', 'wp-data-access' ); ?>
1176 </strong>
1177 <?php
1178 }
1179 ?>
1180 </td>
1181 </tr>
1182
1183 <tr>
1184 <th>
1185 <?php esc_html_e( 'CSV Uploads', 'wp-data-access' ); ?>
1186 </th>
1187 <td>
1188 <span class="dashicons <?php echo $csv_import_table_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1189 <?php echo esc_attr( $table ); ?>
1190 <strong><?php echo esc_attr( $csv_import_table_name ); ?></strong>
1191 <?php echo $csv_import_table_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1192 <?php
1193 if ( $csv_import_table_exists ) {
1194 ?>
1195 <br/><br/>
1196 <span class="dashicons dashicons-yes"></span>
1197 <strong>
1198 <?php echo esc_attr( $no_csv_import ); ?>
1199 <?php esc_html_e( 'menus in repository', 'wp-data-access' ); ?>
1200 </strong>
1201 <?php
1202 }
1203 ?>
1204 </td>
1205 </tr>
1206
1207 <tr>
1208 <th>
1209 Data Logging
1210 </th>
1211 <td>
1212 <span class="dashicons <?php echo $logging_table_exists ? 'dashicons-yes' : 'dashicons-no'; ?>"></span>
1213 <?php echo esc_attr( $table ); ?>
1214 <strong><?php echo esc_attr( $logging_table_name ); ?></strong>
1215 <?php echo $logging_table_exists ? esc_attr( $found ) : esc_attr( $not_found ); ?>
1216 <?php
1217 if ( $logging_table_exists ) {
1218 ?>
1219 <br/><br/>
1220 <span class="dashicons dashicons-yes"></span>
1221 <strong>
1222 <?php echo esc_attr( $no_logs ); ?>
1223 <?php esc_html_e( 'logging rows in repository', 'wp-data-access' ); ?>
1224 </strong>
1225 <?php
1226 }
1227 ?>
1228 </td>
1229 </tr>
1230
1231 </table>
1232 <div class="wpda-table-settings-button">
1233 <input type="hidden" name="action" value="save"/>
1234 <button type="submit" class="button button-primary">
1235 <i class="fas fa-check wpda_icon_on_button"></i>
1236 <?php esc_html_e( 'Save Manage Respository Settings', 'wp-data-access' ); ?>
1237 </button>
1238 <a href="javascript:void(0)"
1239 onclick="if (confirm('<?php esc_html_e( 'Reset to defaults?', 'wp-data-access' ); ?>')) {
1240 jQuery('input[name=\'action\']').val('setdefaults');
1241 jQuery('#wpda_settings_repository').trigger('submit');
1242 }"
1243 class="button button-secondary">
1244 <i class="fas fa-times-circle wpda_icon_on_button"></i>
1245 <?php esc_html_e( 'Reset Manage Repository Settings To Defaults', 'wp-data-access' ); ?>
1246 </a>
1247 <?php
1248 $wpnonce_recreate = wp_create_nonce( 'wpda-settings-recreate-repository-' . WPDA::get_current_user_login() );
1249 ?>
1250 <a href="<?php esc_url( admin_url( 'admin.php' ) ); ?>?page=<?php echo esc_attr( $this->page ); ?>&tab=repository&repos=true&_wpnonce=<?php echo esc_attr( $wpnonce_recreate ); ?>"
1251 class="button button-secondary">
1252 <i class="fas fa-redo wpda_icon_on_button"></i>
1253 <?php esc_html_e( 'Recreate', 'wp-data-access' ); ?> WP Data Access
1254 <?php esc_html_e( 'Repository', 'wp-data-access' ); ?>
1255 </a>
1256 </div>
1257 <?php wp_nonce_field( 'wpda-repository-settings-' . WPDA::get_current_user_login(), '_wpnonce', false ); ?>
1258 </form>
1259
1260 <div class="wpda-table-settings-button">
1261
1262 <?php
1263
1264 $repository_valid = true;
1265
1266 // Check if repository should be recreated.
1267 if (
1268 ! $menus_table_name_exists ||
1269 ! $design_table_name_exists ||
1270 ! $data_projects_project_name_exists ||
1271 ! $data_projects_page_name_exists ||
1272 ! $data_projects_table_name_exists ||
1273 ! $data_publication_table_name_exists
1274 ) {
1275 ?>
1276 <p><strong><?php esc_html_e( 'Your repository has errors!', 'wp-data-access' ); ?></strong></p>
1277 <p>
1278 <?php esc_html_e( 'Recreate the WP Data Access repository to solve this problem.', 'wp-data-access' ); ?>
1279 <?php esc_html_e( 'Please leave your comments on the support forum if the problem remains.', 'wp-data-access' ); ?>
1280 (<a href="https://wordpress.org/support/plugin/wp-data-access/" target="_blank">go to forum</a>)
1281 </p>
1282 <?php
1283
1284 $repository_valid = false;
1285 }
1286
1287 ?>
1288
1289
1290 </div>
1291
1292 <?php
1293
1294 }
1295
1296 }
1297
1298 }
1299