class-ai1wm-export-archive.php
1 year ago
class-ai1wm-export-clean.php
1 year ago
class-ai1wm-export-compatibility.php
1 year ago
class-ai1wm-export-config-file.php
1 year ago
class-ai1wm-export-config.php
1 year ago
class-ai1wm-export-content.php
1 year ago
class-ai1wm-export-database-file.php
1 year ago
class-ai1wm-export-database.php
1 year ago
class-ai1wm-export-download.php
1 year ago
class-ai1wm-export-enumerate-content.php
1 year ago
class-ai1wm-export-enumerate-media.php
1 year ago
class-ai1wm-export-enumerate-plugins.php
1 year ago
class-ai1wm-export-enumerate-tables.php
1 year ago
class-ai1wm-export-enumerate-themes.php
1 year ago
class-ai1wm-export-init.php
1 year ago
class-ai1wm-export-media.php
1 year ago
class-ai1wm-export-plugins.php
1 year ago
class-ai1wm-export-themes.php
1 year ago
class-ai1wm-export-enumerate-tables.php
100 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Copyright (C) 2014-2025 ServMask Inc. |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | * Attribution: This code is part of the All-in-One WP Migration plugin, developed by |
| 19 | * |
| 20 | * ███████╗███████╗██████╗ ██╗ ██╗███╗ ███╗ █████╗ ███████╗██╗ ██╗ |
| 21 | * ██╔════╝██╔════╝██╔══██╗██║ ██║████╗ ████║██╔══██╗██╔════╝██║ ██╔╝ |
| 22 | * ███████╗█████╗ ██████╔╝██║ ██║██╔████╔██║███████║███████╗█████╔╝ |
| 23 | * ╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██║╚██╔╝██║██╔══██║╚════██║██╔═██╗ |
| 24 | * ███████║███████╗██║ ██║ ╚████╔╝ ██║ ╚═╝ ██║██║ ██║███████║██║ ██╗ |
| 25 | * ╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ |
| 26 | */ |
| 27 | |
| 28 | if ( ! defined( 'ABSPATH' ) ) { |
| 29 | die( 'Kangaroos cannot jump here' ); |
| 30 | } |
| 31 | |
| 32 | class Ai1wm_Export_Enumerate_Tables { |
| 33 | |
| 34 | public static function execute( $params ) { |
| 35 | // Set exclude database |
| 36 | if ( isset( $params['options']['no_database'] ) ) { |
| 37 | return $params; |
| 38 | } |
| 39 | |
| 40 | // Get total tables count |
| 41 | if ( isset( $params['total_tables_count'] ) ) { |
| 42 | $total_tables_count = (int) $params['total_tables_count']; |
| 43 | } else { |
| 44 | $total_tables_count = 1; |
| 45 | } |
| 46 | |
| 47 | // Set progress |
| 48 | Ai1wm_Status::info( __( 'Gathering database tables...', 'all-in-one-wp-migration' ) ); |
| 49 | |
| 50 | // Get database client |
| 51 | $db_client = Ai1wm_Database_Utility::create_client(); |
| 52 | |
| 53 | // Include table prefixes |
| 54 | if ( ai1wm_table_prefix() ) { |
| 55 | $db_client->add_table_prefix_filter( ai1wm_table_prefix() ); |
| 56 | |
| 57 | // Include table prefixes (Webba Booking and CiviCRM) |
| 58 | foreach ( array( 'wbk_', 'civicrm_' ) as $table_name ) { |
| 59 | $db_client->add_table_prefix_filter( $table_name ); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | // Create tables list file |
| 64 | $tables_list = ai1wm_open( ai1wm_tables_list_path( $params ), 'w' ); |
| 65 | |
| 66 | // Exclude selected db tables |
| 67 | $excluded_db_tables = array(); |
| 68 | if ( isset( $params['options']['exclude_db_tables'], $params['excluded_db_tables'] ) ) { |
| 69 | $excluded_db_tables = explode( ',', $params['excluded_db_tables'] ); |
| 70 | } |
| 71 | |
| 72 | // Write table line |
| 73 | foreach ( $db_client->get_tables() as $table_name ) { |
| 74 | if ( ! in_array( $table_name, $excluded_db_tables ) && ai1wm_putcsv( $tables_list, array( $table_name ) ) ) { |
| 75 | $total_tables_count++; |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | // Include selected db tables |
| 80 | if ( isset( $params['options']['include_db_tables'] ) && ! empty( $params['included_db_tables'] ) ) { |
| 81 | foreach ( explode( ',', $params['included_db_tables'] ) as $table_name ) { |
| 82 | if ( ai1wm_putcsv( $tables_list, array( $table_name ) ) ) { |
| 83 | $total_tables_count++; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // Set progress |
| 89 | Ai1wm_Status::info( __( 'Database tables gathered.', 'all-in-one-wp-migration' ) ); |
| 90 | |
| 91 | // Set total tables count |
| 92 | $params['total_tables_count'] = $total_tables_count; |
| 93 | |
| 94 | // Close the tables list file |
| 95 | ai1wm_close( $tables_list ); |
| 96 | |
| 97 | return $params; |
| 98 | } |
| 99 | } |
| 100 |