run(); add_action('after_setup_theme', [$this, 'after_setup_theme']); add_action('plugins_loaded', [$this, 'plugins_loaded']); add_action('init', [$this, 'init']); } function run() { // } /** * Centralized security check for all tools in init(). * - Ensures only administrators can access. * - Verifies nonce on POST requests, but ONLY when an adminz_* GET param * is active — so regular WP POST requests (Media, AJAX...) are not affected. * * Each form in a tool must include: wp_nonce_field('adminz_tool') */ function check_security() { // 1. Role check if (!current_user_can('administrator')) { return false; } // 2. CSRF check: only when this is an adminz tool request $is_adminz_tool = !empty(array_filter( array_keys($_GET ?? []), fn($k) => str_starts_with($k, 'adminz_') )); if ($is_adminz_tool && $_SERVER['REQUEST_METHOD'] === 'POST') { $nonce = $_POST['_wpnonce'] ?? ''; if (!wp_verify_nonce($nonce, 'adminz_tool')) { wp_die('Security check failed. Invalid or expired nonce.', 403); } } return true; } function after_setup_theme() { // if (current_user_can('administrator')) { if (($_GET['adminz_test_hooks'] ?? '') == 'flatsome') { $hooks = require_once(ADMINZ_DIR . "includes/file/flatsome_hooks.php"); foreach ($hooks as $hook) { add_action($hook, function () use ($hook) { echo do_shortcode('[adminz_test content="' . $hook . '"]'); }); } } } } function plugins_loaded() { // if (current_user_can('administrator')) { if (($_GET['adminz_test_hooks'] ?? '') == 'woocommerce') { $hooks = require_once(ADMINZ_DIR . "includes/file/woocommerce_hooks.php"); foreach ($hooks as $hook) { add_action($hook, function () use ($hook) { echo do_shortcode('[adminz_test content="' . $hook . '"]'); }); } } } } function init() { if (!$this->check_security()) { return; } // ========================= SERVER TOOLS ========================= // if ($_GET['adminz_server_tool'] ?? '') { switch ($_GET['adminz_server_tool']) { case 'serverinfo': echo "

::: Server Information ====================

"; echo ""; echo ""; // Thông tin cơ bản echo ""; echo ""; echo ""; echo ""; echo ""; // Thông tin MySQL (nếu có) if (defined('DB_HOST') && defined('DB_USER') && defined('DB_PASSWORD')) { $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD); if ($link) { echo ""; mysqli_close($link); } else { echo ""; } } else { echo ""; } // Thông tin PHP Configuration echo ""; echo ""; echo ""; echo ""; // Thông tin thời gian hoạt động của server (nếu có) if (function_exists('shell_exec')) { $uptime = @shell_exec('uptime'); if ($uptime) { echo ""; } else { echo ""; } } else { echo ""; } // Thông tin về thư mục gốc của WordPress echo ""; echo ""; // Thông tin về phiên bản WordPress echo ""; echo "
KeyValue
PHP Version" . phpversion() . "
Server Software" . $_SERVER['SERVER_SOFTWARE'] . "
Operating System" . php_uname() . "
Server IP" . $_SERVER['SERVER_ADDR'] . "
Client IP" . $_SERVER['REMOTE_ADDR'] . "
MySQL Version" . mysqli_get_server_info($link) . "
MySQL VersionUnable to connect to MySQL
MySQL VersionMySQL constants not defined
PHP Memory Limit" . ini_get('memory_limit') . "
PHP Max Execution Time" . ini_get('max_execution_time') . " seconds
PHP Upload Max Filesize" . ini_get('upload_max_filesize') . "
PHP Post Max Size" . ini_get('post_max_size') . "
Server Uptime{$uptime}
Server UptimeUnable to retrieve uptime
Server Uptimeshell_exec not enabled
WordPress Root Directory" . ABSPATH . "
WordPress Content Directory" . WP_CONTENT_DIR . "
WordPress Version" . get_bloginfo('version') . "
"; break; case 'serverspeed': echo ""; echo "

::: Server Speed ====================

"; echo ""; // 3. PHP Execution Speed $start_time = microtime(true); for ($i = 0; $i < 1000000; $i++) { md5($i); } $execution_time = microtime(true) - $start_time; $phpScore = max(1, 10 - ($execution_time * 10)); echo ""; // 4. Disk I/O Speed $file = sys_get_temp_dir() . '/speedtest.tmp'; $start_time = microtime(true); file_put_contents($file, str_repeat('A', 1024 * 1024 * 10)); // 10MB $write_time = microtime(true) - $start_time; $start_time = microtime(true); file_get_contents($file); $read_time = microtime(true) - $start_time; unlink($file); $diskScore = max(1, 10 - (($write_time + $read_time) * 5)); echo ""; // 5. MySQL Query Speed if (defined('DB_HOST') && defined('DB_USER') && defined('DB_PASSWORD') && defined('DB_NAME')) { $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if ($link) { $start_time = microtime(true); $result = mysqli_query($link, "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES"); $query_time = microtime(true) - $start_time; $mysqlScore = max(1, 10 - ($query_time * 10)); echo ""; mysqli_close($link); } } // 6. Network Latency $start_time = microtime(true); @file_get_contents("https://www.google.com"); $network_time = microtime(true) - $start_time; $networkScore = max(1, 10 - ($network_time * 10)); echo ""; echo "
Thông sốGiá trịĐánh giá (1-10)
PHP Execution Speed{$execution_time} seconds" . round($phpScore) . "
Disk I/O SpeedWrite: {$write_time}s | Read: {$read_time}s" . round($diskScore) . "
MySQL Query Speed{$query_time} seconds" . round($mysqlScore) . "
Network Latency{$network_time} seconds" . round($networkScore) . "
"; break; case 'phpinfo': phpinfo(); break; case 'phpextensions': echo "

::: PHP Extensions ====================

"; $extensions = get_loaded_extensions(); echo ""; echo ""; foreach ($extensions as $extension) { echo ""; } echo "
Extension
{$extension}
"; break; case 'cacheinfo': echo "

::: Cache Information ====================

"; // Kiểm tra OPcache if (function_exists('opcache_get_status')) { echo "

::: OPcache Information ==============================

"; $opcacheStatus = opcache_get_status(); echo ""; echo ""; foreach ($opcacheStatus as $key => $value) { echo ""; } echo "
KeyValue
{$key}
" . print_r($value, true) . "
"; } else { echo "::: OPcache is not enabled. =====================
"; } // Kiểm tra APCu cache (nếu có) if (function_exists('apcu_cache_info')) { echo "

::: APCu Cache Information ==============================

"; $apcuCacheInfo = apcu_cache_info(true); echo ""; echo ""; foreach ($apcuCacheInfo as $key => $value) { echo ""; } echo "
KeyValue
{$key}
" . print_r($value, true) . "
"; } else { echo "::: APCu is not enabled. =====================
"; } // Kiểm tra Memcached (nếu có) if (class_exists('Memcached')) { echo "

::: Memcached Information ==============================

"; $memcached = new \Memcached(); $memcached->addServer( $_GET['memcached_host'] ?? 'localhost', $_GET['memcached_port'] ?? 11211 ); $stats = $memcached->getStats(); echo ""; echo ""; foreach ($stats as $key => $value) { echo ""; } echo "
KeyValue
{$key}
" . print_r($value, true) . "
"; } else { echo "::: Memcached is not enabled. =====================
"; } // Kiểm tra Redis (nếu có) if (class_exists('Redis')) { echo "

::: Redis Information ==============================

"; $redis = new \Redis(); $redis->connect( $_GET['redis_host'] ?? 'localhost', $_GET['redis_port'] ?? 6379 ); $redisInfo = $redis->info(); echo ""; echo ""; foreach ($redisInfo as $key => $value) { echo ""; } echo "
KeyValue
{$key}
" . print_r($value, true) . "
"; } else { echo "::: Redis is not enabled. =====================
"; } // Kiểm tra Object Cache của WordPress (nếu có) if (function_exists('wp_using_ext_object_cache') && wp_using_ext_object_cache()) { echo "

::: WordPress Object Cache Information ==============================

"; global $wp_object_cache; if (isset($wp_object_cache)) { echo ""; echo ""; foreach ($wp_object_cache->cache as $key => $value) { echo ""; } echo "
KeyValue
{$key}
" . print_r($value, true) . "
"; } else { echo "::: WordPress Object Cache is not available. =====================
"; } } else { echo "::: WordPress is not using an external object cache. =====================
"; } break; case 'resetcache': echo "

Reset Cache

"; // Reset OPcache if (function_exists('opcache_reset')) { if (opcache_reset()) { echo "OPcache reset successfully.
"; } else { echo "Failed to reset OPcache.
"; } } else { echo "OPcache is not enabled.
"; } // Reset Memcached Cache if (class_exists('Memcached')) { $memcached = new \Memcached(); $memcachedHost = isset($_GET['memcached_host']) ? $_GET['memcached_host'] : 'localhost'; $memcachedPort = isset($_GET['memcached_port']) ? (int) $_GET['memcached_port'] : 11211; $memcached->addServer($memcachedHost, $memcachedPort); if ($memcached->flush()) { echo "Memcached cache reset successfully.
"; } else { echo "Failed to reset Memcached cache.
"; } } else { echo "Memcached is not enabled.
"; } // Reset Redis Cache if (class_exists('Redis')) { $redis = new \Redis(); $redisHost = isset($_GET['redis_host']) ? $_GET['redis_host'] : 'localhost'; $redisPort = isset($_GET['redis_port']) ? (int) $_GET['redis_port'] : 6379; if ($redis->connect($redisHost, $redisPort)) { if ($redis->flushAll()) { echo "Redis cache reset successfully.
"; } else { echo "Failed to reset Redis cache.
"; } } else { echo "Failed to connect to Redis.
"; } } else { echo "Redis is not enabled.
"; } break; case 'mysqlinfo': echo "

::: MySQL Information ====================

"; // Sử dụng constants từ wp-config.php if (defined('DB_HOST') && defined('DB_USER') && defined('DB_PASSWORD')) { $link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD); if (!$link) { die('Could not connect: ' . mysqli_error()); } echo ""; echo ""; echo ""; echo "
KeyValue
MySQL Version" . mysqli_get_server_info($link) . "
"; echo "

::: MySQL Variables ==============================

"; $result = mysqli_query($link, 'SHOW VARIABLES'); echo ""; echo ""; while ($row = mysqli_fetch_assoc($result)) { echo ""; } echo "
Variable NameValue
{$row['Variable_name']}{$row['Value']}
"; mysqli_close($link); } else { echo "MySQL constants are not defined in wp-config.php."; } break; case 'memoryinfo': echo "

::: Memory Usage and Execution Time ====================

"; echo ""; echo ""; // Memory Usage $memoryUsage = memory_get_usage(); echo ""; echo ""; // Peak Memory Usage $peakMemoryUsage = memory_get_peak_usage(); echo ""; echo ""; // Execution Time $executionTime = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; echo ""; echo ""; echo "
KeyValueUnitAnalysis
Memory Usage{$memoryUsage}bytes" . round($memoryUsage / 1024, 2) . " KB / " . round($memoryUsage / (1024 * 1024), 2) . " MB
Peak Memory Usage{$peakMemoryUsage}bytes" . round($peakMemoryUsage / 1024, 2) . " KB / " . round($peakMemoryUsage / (1024 * 1024), 2) . " MB
Execution Time{$executionTime}seconds" . round($executionTime * 1000, 2) . " milliseconds
"; break; case 'connectioncheck': echo "

::: Connection Check ====================

"; // Kiểm tra kết nối đến một API thực tế (ví dụ: WordPress.org) $url = 'https://api.wordpress.org/core/version-check/1.7/'; $response = @file_get_contents($url); echo ""; echo ""; echo ""; echo "
KeyValue
Connection to WordPress API" . ($response !== false ? 'Success' : 'Failed') . "
"; break; default: echo "Invalid tool selected."; break; } die; // Dừng script sau khi hiển thị kết quả } // ========================= GUILD TOOLS ========================= // if (isset($_GET['adminz_guid_telegram'])) { echo <<------------------------------

https://www.thegioididong.com/game-app/huong-dan-tao-bot-telegram-don-gian-ai-cung-co-the-thuc-hien-1395501

------------------------------

Create new bot with @botfather

Testadminzbot

1801547325:GAEDhT5bFLfCjKec8istwkKaOa4Pl7R0ZQE

------------------------------

Get your chat ID

1640851433

------------------------------

Send a message to your chatbot

search with your chat bot name and type XXX

------------------------------

Link to test: copy this link to open in browser

https://api.telegram.org/bot1801547325:GAEDhT5bFLfCjKec8istwkKaOa4Pl7R0ZQE/sendMessage?chat_id=1640851433&text=XXX

HTML; die; } // ========================= FILE TOOLS ========================= // if (isset($_GET['adminz_file_included_files'])) { echo "

::: Included Files ====================

"; echo ""; echo ""; // Lấy danh sách các file đã được include $includedFiles = get_included_files(); // Hiển thị từng file trong bảng foreach ($includedFiles as $index => $file) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
#File PathSizeLast Modified
" . ($index + 1) . "{$file}" . filesize($file) . " bytes" . date("Y-m-d H:i:s", filemtime($file)) . "
"; die; // Dừng script sau khi hiển thị } // // if (isset($_GET['adminz_file_security_scan_php'])) { $this->set_view_file(); echo "

::: Security Scan ==============

"; echo "

::: This tool is only php file. For other file types, please use other tools.

"; $current_file = str_replace('\\', '/', __FILE__); $current_file = preg_replace('#/+#', '/', $current_file); $scan_directory = function ($dir) use (&$scan_directory, $current_file) { $files = scandir($dir); $results = []; foreach ($files as $file) { if ($file === '.' || $file === '..') continue; $path = $dir . '/' . $file; $path = str_replace('\\', '/', $path); $path = preg_replace('#/+#', '/', $path); if (is_dir($path)) { $results = array_merge($results, $scan_directory($path)); } elseif (pathinfo($path, PATHINFO_EXTENSION) === 'php' && $path !== $current_file) { $content = file_get_contents($path); $reasons = []; if (preg_match('/eval\(/i', $content)) { $reasons[] = 'eval() found'; } if (preg_match('/assert\(/i', $content)) { $reasons[] = 'assert() found'; } if (preg_match('/create_function\(/i', $content)) { $reasons[] = 'create_function() found'; } if (!empty($reasons)) { $results[] = [ 'file' => $path, 'reasons' => implode(', ', $reasons), ]; } } } return $results; }; $suspicious_files = $scan_directory(ABSPATH); if ($suspicious_files) { echo ""; echo ""; foreach ($suspicious_files as $file) { $file_url = urlencode($file['file']); echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
File PathReasonsView
{$file['file']}{$file['reasons']}View
"; } else { echo "No suspicious files found."; } die; } // if (isset($_GET['adminz_file_core_checksums'])) { $this->set_view_file(); echo "

::: Core File Check ===================

"; // Lấy danh sách các file core từ WordPress.org $response = wp_remote_get('https://api.wordpress.org/core/checksums/1.0/?version=' . get_bloginfo('version')); if (is_wp_error($response)) { echo "Failed to fetch core checksums from WordPress.org."; die; } $checksums = json_decode($response['body'], true); if (empty($checksums['checksums'])) { echo "No checksums found for this WordPress version."; die; } $modified_files = []; foreach ($checksums['checksums'][get_bloginfo('version')] as $file => $checksum) { $file_path = ABSPATH . $file; if (file_exists($file_path)) { $file_checksum = md5_file($file_path); if ($file_checksum !== $checksum) { $modified_files[] = [ 'file' => $file, 'last_modified' => date("Y-m-d H:i:s", filemtime($file_path)), ]; } } } if ($modified_files) { echo "

Modified Core Files:

"; echo "
"; echo ""; echo ""; $stt = 1; foreach ($modified_files as $file_info) { echo ""; echo ""; echo ""; echo ""; $file_url = urlencode(ABSPATH . $file_info['file']); echo ""; echo ""; $stt++; } echo "
STTFile PathLast ModifiedView
{$stt}{$file_info['file']}{$file_info['last_modified']}View
"; echo "
"; } else { echo "No modified core files found."; } die; } // if (isset($_GET['adminz_file_large'])) { echo "

::: Large Files in wp-content/uploads ===================

"; $upload_dir = wp_upload_dir(); $base_dir = $upload_dir['basedir']; $large_files = []; $size_limit = 5 * 1024 * 1024; // 5MB // Hàm đệ quy để quét thư mục $scan_directory = function ($dir) use (&$scan_directory, &$large_files, $size_limit) { $files = scandir($dir); foreach ($files as $file) { if ($file === '.' || $file === '..') continue; $path = $dir . '/' . $file; if (is_dir($path)) { $scan_directory($path); } else { $size = filesize($path); if ($size > $size_limit) { $large_files[] = [ 'path' => $path, 'size' => size_format($size, 2), ]; } } } }; $scan_directory($base_dir); if ($large_files) { echo ""; echo ""; foreach ($large_files as $file) { echo ""; echo ""; echo ""; echo ""; } echo "
File PathSize
{$file['path']}{$file['size']}
"; } else { echo "No large files found."; } die; } if (isset($_GET['adminz_file_permission_check'])) { echo "

::: File Permission Checker ====================

"; // Danh sách các file và thư mục cần kiểm tra $paths_to_check = [ ABSPATH . 'wp-config.php', ABSPATH . '.htaccess', WP_CONTENT_DIR, WP_CONTENT_DIR . '/uploads', WP_CONTENT_DIR . '/plugins', WP_CONTENT_DIR . '/themes', WP_CONTENT_DIR . '/cache', ]; echo ""; echo ""; foreach ($paths_to_check as $path) { if (file_exists($path)) { // Lấy quyền truy cập $permissions = fileperms($path); $permissions_formatted = substr(sprintf('%o', $permissions), -4); // Chuyển sang dạng số (ví dụ: 0755) $permissions_human_readable = $this->get_permissions_human_readable($permissions); // Chuyển sang dạng ký tự (ví dụ: -rwxr-xr-x) // Đánh giá quyền truy cập $status = '✅ Safe'; if (is_file($path) && ($permissions & 0x0002)) { $status = '⚠️ Warning: File is writable by others'; } elseif (is_dir($path) && ($permissions & 0x0002)) { $status = '⚠️ Warning: Directory is writable by others'; } // Hiển thị kết quả echo ""; echo ""; echo ""; echo ""; echo ""; } else { echo ""; echo ""; echo ""; echo ""; } } echo "
PathPermissionsStatus
{$path}{$permissions_formatted} ({$permissions_human_readable}){$status}
{$path}File/Directory not found
"; die; // Dừng script sau khi hiển thị } // if (isset($_GET['adminz_file_image_clear_orphaned'])) { require_once(ABSPATH . 'wp-admin/includes/file.php'); echo "

::: Clearing Orphaned Image Files ====================

"; global $wpdb; // Đường dẫn thư mục uploads $upload_dir = wp_upload_dir(); $folderTarget = $upload_dir['basedir']; // Đường dẫn thư mục backup $folderBackup = WP_CONTENT_DIR . '/uploads/administrator-z/clear_image_orphaned_backup'; // Kiểm tra và tạo thư mục backup nếu nó không tồn tại if (!file_exists($folderBackup)) { wp_mkdir_p($folderBackup); // Tạo thư mục và các thư mục con nếu cần echo "

✅ Created backup folder: {$folderBackup}

"; } // Lấy danh sách các thư mục con trong uploads có tên là 4 chữ số (ví dụ: 2025, 2024) $sub_folders = glob($folderTarget . '/*', GLOB_ONLYDIR); $moved_files = []; foreach ($sub_folders as $sub_folder) { // Kiểm tra xem tên thư mục có phải là 4 chữ số không (ví dụ: 2025, 2024, v.v.) $folder_name = basename($sub_folder); if (preg_match('/^\d{4}$/', $folder_name)) { // Lấy tất cả các file trong thư mục con $files = list_files($sub_folder); foreach ($files as $file) { // Kiểm tra xem file có phải là ảnh không if (wp_check_filetype($file)['type'] && strpos(wp_check_filetype($file)['type'], 'image') !== false) { // Lấy tên file (không bao gồm kích thước) $file_name = basename($file); $file_name_without_size = preg_replace('/-\d+x\d+\.(jpg|jpeg|png|gif)$/', '.$1', $file_name); // Kiểm tra xem file có tồn tại trong metadata của bất kỳ attachment nào không $attachment = $wpdb->get_row( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE (meta_key = '_wp_attachment_metadata' OR meta_key = '_wp_attached_file') AND meta_value LIKE %s", '%' . $wpdb->esc_like($file_name_without_size) . '%' ) ); if (!$attachment) { // Đường dẫn file mới trong thư mục backup $new_file_path = $folderBackup . '/' . str_replace($folderTarget . '/', '', $file); // Kiểm tra xem file đã tồn tại trong thư mục backup chưa if (!file_exists($new_file_path)) { // Tạo thư mục con trong thư mục backup nếu nó chưa tồn tại $new_file_dir = dirname($new_file_path); if (!file_exists($new_file_dir)) { wp_mkdir_p($new_file_dir); } // Di chuyển file vào thư mục backup if (rename($file, $new_file_path)) { $moved_files[] = [ 'name' => basename($file), 'path' => str_replace($folderTarget . '/', '', $file), ]; echo "

✅ Moved: {$file_name}

"; } else { echo "

❌ Failed to move: {$file_name}

"; } } else { echo "

⚠️ File already exists in backup: {$file_name}

"; } } } } } } // Hiển thị danh sách các file đã được di chuyển if (!empty($moved_files)) { echo "

📂 List of moved files:

"; echo ""; echo ""; foreach ($moved_files as $key => $moved_file) { // Tạo URL của ảnh từ thư mục backup $file_url_backup = $upload_dir['baseurl'] . '/administrator-z/clear_image_orphaned_backup/' . $moved_file['path']; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
#File NameURL
{$key}{$moved_file['name']}View
"; } else { echo "

❌ No orphaned image files found.

"; } // Hiển thị danh sách các file trong thư mục backup echo "

📂 Files in Backup Folder:

"; $backup_files = list_files($folderBackup); if (!empty($backup_files)) { echo ""; echo ""; foreach ($backup_files as $key => $backup_file) { // Tạo URL của ảnh từ thư mục backup $file_url_backup = $upload_dir['baseurl'] . '/administrator-z/clear_image_orphaned_backup/' . str_replace($folderBackup . '/', '', $backup_file); echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
#File NameURL
{$key}" . basename($backup_file) . "View
"; } else { echo "

❌ No files found in backup folder.

"; } die; // Dừng script sau khi hoàn thành } // ========================= DEBUG TOOLS ========================= if (isset($_GET['adminz_show_debug_log'])) { $debug_log_path = WP_CONTENT_DIR . '/debug.log'; // Stop execution if log file does not exist if (!file_exists($debug_log_path)) { wp_die('Debug log file not found.'); } // Output log content as plain text header('Content-Type: text/plain; charset=utf-8'); readfile($debug_log_path); exit; } if (isset($_GET['adminz_empty_debug_log'])) { $debug_log_path = WP_CONTENT_DIR . '/debug.log'; file_put_contents($debug_log_path, ''); echo 'done'; exit; } // ========================= DATABASE TOOLS ========================= // if (isset($_GET['adminz_database_transients'])) { echo "

::: Transients Information =================

"; global $wpdb; // Lấy tất cả các transients từ bảng wp_options $transients = $wpdb->get_results( "SELECT option_name, option_value, autoload FROM $wpdb->options WHERE option_name LIKE '_transient_%' OR option_name LIKE '_site_transient_%'" ); if ($transients) { echo ""; echo ""; $counter = 1; // Biến đếm số thứ tự foreach ($transients as $transient) { $name = str_replace(['_transient_', '_site_transient_'], '', $transient->option_name); $value = $transient->option_value; // Lấy giá trị trực tiếp từ database echo ""; echo ""; // Cột số thứ tự echo ""; echo ""; echo ""; echo ""; $counter++; // Tăng biến đếm } echo "
#Transient NameValue (Raw from Database)Autoload
{$counter}{$name}"; echo ""; echo "{$transient->autoload}
"; } else { echo "No transients found."; } die; } // if (isset($_GET['adminz_database_transients_clear'])) { echo "

::: Clear Transients ====================

"; global $wpdb; // Xóa các transient hết hạn $expired_transients_deleted = $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%' AND option_value < UNIX_TIMESTAMP()" ); // Xóa các transient không hết hạn (nếu có yêu cầu) $all_transients_deleted = 0; if (isset($_GET['force_clear'])) { $all_transients_deleted = $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_%' OR option_name LIKE '\_site\_transient\_%'" ); } // Hiển thị kết quả echo "

✅ Successfully deleted {$expired_transients_deleted} expired transients.

"; if (isset($_GET['force_clear'])) { echo "

✅ Successfully deleted {$all_transients_deleted} non-expired transients.

"; } // Liên kết để xóa tất cả transient (bao gồm cả không hết hạn) echo "

Click here to clear ALL transients (including non-expired)

"; die; // Dừng script sau khi hiển thị } // if (isset($_GET['adminz_database_postmeta_clear_orphaned'])) { echo "

::: Clearing Orphaned Post Meta ====================

"; global $wpdb; // Xóa các bản ghi trong postmeta không có post_id tương ứng trong posts $query = " DELETE pm FROM {$wpdb->postmeta} pm LEFT JOIN {$wpdb->posts} p ON pm.post_id = p.ID WHERE p.ID IS NULL "; $result = $wpdb->query($query); if ($result !== false) { echo "

✅ Successfully deleted {$result} orphaned post meta records.

"; } else { echo "

❌ Error: Unable to delete orphaned post meta records.

"; } die; // Dừng script sau khi hoàn thành } if ($_GET['adminz_database_user_delete_by_role'] ?? '') { global $wpdb; $user_role = sanitize_text_field($_GET['adminz_database_user_delete_by_role']); // Xóa tất cả người dùng từ bảng users dựa trên role, sử dụng JOIN với bảng usermeta $wpdb->query($wpdb->prepare(" DELETE u FROM {$wpdb->users} u INNER JOIN {$wpdb->prefix}usermeta um ON u.ID = um.user_id WHERE um.meta_key = '{$wpdb->prefix}capabilities' AND um.meta_value LIKE %s ", '%' . $wpdb->esc_like($user_role) . '%')); echo "All users with the role '$user_role' have been deleted."; die; } // if (isset($_GET['adminz_database_usermeta_clear_orphaned'])) { echo "

::: Clearing Orphaned User Meta ====================

"; global $wpdb; // Xóa các bản ghi trong usermeta không có user_id tương ứng trong users $query = " DELETE um FROM {$wpdb->usermeta} um LEFT JOIN {$wpdb->users} u ON um.user_id = u.ID WHERE u.ID IS NULL "; $result = $wpdb->query($query); if ($result !== false) { echo "

✅ Successfully deleted {$result} orphaned user meta records.

"; } else { echo "

❌ Error: Unable to delete orphaned user meta records.

"; } die; // Dừng script sau khi hoàn thành } if (isset($_GET['adminz_database_attachment_clear_orphaned'])) { echo "

::: Clearing Attachment record without image file ====================

"; global $wpdb; // Lấy tất cả các bản ghi attachment từ database $attachments = $wpdb->get_results("SELECT ID, guid FROM {$wpdb->posts} WHERE post_type = 'attachment'"); $deleted_count = 0; foreach ($attachments as $attachment) { // Lấy đường dẫn file ảnh từ guid $file_path = str_replace(wp_upload_dir()['baseurl'], wp_upload_dir()['basedir'], $attachment->guid); // Kiểm tra xem file ảnh có tồn tại không if (!file_exists($file_path)) { // Nếu file ảnh không tồn tại, xóa bản ghi attachment $delete_result = $wpdb->delete($wpdb->posts, array('ID' => $attachment->ID)); if ($delete_result !== false) { $deleted_count++; } } } if ($deleted_count > 0) { echo "

✅ Successfully deleted {$deleted_count} orphaned attachment records.

"; } else { echo "

❌ No orphaned attachment records found.

"; } die; // Dừng script sau khi hoàn thành } // if (isset($_GET['adminz_database_optimize_tables'])) { echo "

::: Database Table Optimizer ====================

"; global $wpdb; // Lấy danh sách các bảng trong cơ sở dữ liệu $tables = $wpdb->get_results("SHOW TABLES", ARRAY_N); if (empty($tables)) { echo "

❌ No tables found in the database.

"; die; } echo ""; echo ""; foreach ($tables as $table) { $table_name = $table[0]; echo ""; echo ""; // Tối ưu hóa bảng $result = $wpdb->query("OPTIMIZE TABLE {$table_name}"); if ($result !== false) { echo ""; // Lấy thông tin chi tiết về kết quả tối ưu hóa $optimize_info = $wpdb->get_row("SHOW TABLE STATUS LIKE '{$table_name}'"); if ($optimize_info) { echo ""; } else { echo ""; } } else { echo ""; echo ""; } echo ""; } echo "
Table NameStatusOptimization Result
{$table_name}✅ OptimizedData Length: " . size_format($optimize_info->Data_length) . "
"; echo "Index Length: " . size_format($optimize_info->Index_length) . "
"; echo "Data Free: " . size_format($optimize_info->Data_free) . "
No details available❌ FailedError: " . $wpdb->last_error . "
"; die; // Dừng script sau khi hiển thị } // if (isset($_GET['adminz_database_scan'])) { echo "

::: Database Scan ====================

"; global $wpdb; // Lấy danh sách tất cả các bảng trong cơ sở dữ liệu $tables = $wpdb->get_results("SHOW TABLES", ARRAY_N); echo ""; echo ""; // Danh sách các mẫu mã độc phổ biến để quét (sử dụng regex) $malware_patterns = [ '/<\?php/i', // "; echo ""; // Quét từng bảng để tìm các dấu hiệu của mã độc $found_malware = false; $malware_details = []; // Lấy tất cả các cột trong bảng $columns = $wpdb->get_results("SHOW COLUMNS FROM {$table_name}", ARRAY_A); foreach ($columns as $column) { $column_name = $column['Field']; // Kiểm tra từng cột có kiểu dữ liệu TEXT hoặc VARCHAR if (strpos($column['Type'], 'text') !== false || strpos($column['Type'], 'varchar') !== false) { // Lấy toàn bộ dữ liệu từ cột $query = "SELECT * FROM {$table_name}"; $results = $wpdb->get_results($query); if (!empty($results)) { foreach ($results as $result) { $column_value = $result->$column_name; // Kiểm tra từng mẫu mã độc bằng regex foreach ($malware_patterns as $pattern) { if (preg_match($pattern, $column_value)) { $found_malware = true; $record_id = reset($result); // Lấy giá trị của cột đầu tiên (Record ID) $malware_data = htmlentities($column_value); // Mã hóa nội dung mã độc // Thêm thông tin vào chi tiết mã độc $malware_details[] = "Found pattern: " . htmlentities($pattern) . ""; $malware_details[] = "
Table NameStatusMalware Scan Result
" . htmlentities($table_name) . "
"; $malware_details[] = ""; $malware_details[] = ""; $malware_details[] = ""; $malware_details[] = ""; $malware_details[] = ""; $malware_details[] = "
Record IDMalware Content
" . htmlentities($record_id) . "
"; } } } } } } if ($found_malware) { echo "⚠️ Malware Detected"; echo "" . implode("", $malware_details) . ""; } else { echo "✅ Clean"; echo "No malware patterns found."; } echo ""; } echo ""; die; } // ========================= USER TOOLS ========================= // if ($_GET['adminz_user_login_with_user_id'] ?? '') { $user_id = intval($_GET['adminz_user_login_with_user_id']); $user = get_user_by('id', $user_id); if ($user) { // skip redirect if (get_current_user_id() == $user_id) { return; } // Đăng nhập người dùng wp_clear_auth_cookie(); // Xóa cookie hiện tại wp_set_current_user($user_id); // Thiết lập người dùng hiện tại wp_set_auth_cookie($user_id); // Thiết lập cookie đăng nhập // Chuyển hướng về trang chủ // wp_redirect( home_url() ); // exit; } else { echo "::: User ID $user_id không tồn tại. ==================="; } die; } // ========================= TEST TOOLS ========================= // if (($_GET['adminz_test_hooks'] ?? '') == 'wordpress') { add_action('shutdown', function () { global $wp_actions; // echo "
"; print_r( $wp_actions ); echo "
"; // die; echo ''; $i = 1; $focus = [ 'muplugins_loaded', 'plugins_loaded', 'after_setup_theme', 'init', 'widgets_init', 'pre_get_posts', 'wp_loaded', 'wp', 'template_redirect', 'wp_head', 'wp_enqueue_scripts', 'wp_footer', ]; foreach ($wp_actions as $key => $value) { if (in_array($key, $focus)) { $key = "$key"; } echo << HTML; $i++; } echo '
$i $key $value
'; }); } // if ($_GET['adminz_test_postmeta'] ?? '') { $post_id = esc_attr($_GET['adminz_test_postmeta']); // global $wpdb; // $results = $wpdb->get_results( // $wpdb->prepare("SELECT * FROM {$wpdb->prefix}postmeta WHERE post_id = %d", $post_id) // ); // if (!empty($results)) { // echo "
";
            //     print_r($results);
            //     echo "
"; // } else { // echo 'Meta not found: post_id = ' . $post_id; // } echo $this->view_meta_table(get_post_meta($post_id)); die; } // if ($_GET['adminz_test_postfield'] ?? '') { $post_id = esc_attr($_GET['adminz_test_postfield']); $post = get_post($post_id); if ($post) { echo "
";
                print_r($post);
                echo "
"; } else { echo 'Post not found: post_id = ' . $post_id; } die; } // if ($_GET['adminz_test_posttaxonomy'] ?? '') { $post_id = esc_attr($_GET['adminz_test_posttaxonomy']); $post = get_post($post_id); if ($post) { // Lấy tất cả các taxonomy của post type $taxonomies = get_object_taxonomies($post->post_type, 'objects'); foreach ($taxonomies as $taxonomy) { $terms = get_the_terms($post_id, $taxonomy->name); if (!empty($terms)) { echo "
";
                        print_r('---------- Taxonomy: ' . $taxonomy->name . ' - ' . $taxonomy->label);
                        echo "
"; echo "
";
                        print_r($terms);
                        echo "
"; } } } else { echo 'Post not found: post_id = ' . $post_id; } die; } // if ($_GET['adminz_test_termfield'] ?? '') { $term_id = esc_attr($_GET['adminz_test_termfield']); global $wpdb; $results = get_term($term_id); if (!empty($results)) { echo "
";
                print_r($results);
                echo "
"; } else { echo 'Term meta not found: term_id = ' . $term_id; } die; } // if ($_GET['adminz_test_termmeta'] ?? '') { $term_id = esc_attr($_GET['adminz_test_termmeta']); // global $wpdb; // $results = $wpdb->get_results( // $wpdb->prepare("SELECT * FROM {$wpdb->prefix}termmeta WHERE term_id = %d", $term_id) // ); // if (!empty($results)) { // echo "
";
            //     print_r($results);
            //     echo "
"; // } else { // echo 'Term meta not found: term_id = ' . $term_id; // } echo $this->view_meta_table(get_term_meta($term_id)); die; } // if ($_GET['adminz_test_userfield'] ?? '') { $user_id = esc_attr($_GET['adminz_test_userfield']); global $wpdb; $results = get_user_by('id', $user_id); if (!empty($results)) { echo "
";
                print_r($results);
                echo "
"; } else { echo 'User not found: user_id = ' . $user_id; } die; } // if ($_GET['adminz_test_usermeta'] ?? '') { $user_id = esc_attr($_GET['adminz_test_usermeta']); // global $wpdb; // $results = $wpdb->get_results( // $wpdb->prepare("SELECT * FROM {$wpdb->prefix}usermeta WHERE user_id = %d", $user_id) // ); // if (!empty($results)) { // echo "
";
            //     print_r($results);
            //     echo "
"; // } else { // echo 'User not found: user_id = ' . $user_id; // } echo $this->view_meta_table(get_user_meta($user_id)); die; } // if ($_GET['adminz_test_theme_template'] ?? '') { add_action('wp_footer', function () { global $template; echo '
' . basename($template) . '
'; }); } // ========================= TEST TOOLS ========================= // if (isset($_GET['adminz_rewrite_rules_explore'])) { echo "

::: Rewrite Rules Explorer =================

"; // Lấy tất cả các rewrite rules global $wp_rewrite; $rewrite_rules = $wp_rewrite->wp_rewrite_rules(); if (!empty($rewrite_rules)) { echo ""; echo ""; $counter = 1; // Biến đếm số thứ tự foreach ($rewrite_rules as $rule => $rewrite) { echo ""; echo ""; // Cột số thứ tự echo ""; echo ""; echo ""; $counter++; // Tăng biến đếm } echo "
#RuleRewrite
{$counter}{$rule}{$rewrite}
"; } else { echo "

No rewrite rules found.

"; } die; // Dừng script sau khi hiển thị } // if (isset($_GET['adminz_rewrite_rules_flush'])) { echo "

::: Flush Rewrite Rules =================

"; // Làm mới rewrite rules flush_rewrite_rules(); echo "

✅ Rewrite rules have been flushed successfully.

"; die; // Dừng script sau khi hiển thị } // ========================= Others TOOLS ========================= // if (isset($_GET['adminz_show_debug_log'])) { $debug_log_path = WP_CONTENT_DIR . '/debug.log'; if (file_exists($debug_log_path)) { header('Content-Type: text/plain'); readfile($debug_log_path); exit; } else { echo 'Không tìm thấy tệp debug.log'; exit; } } // if (isset($_GET['adminz_delete_all_products'])) { global $wpdb; $post_types = ['product', 'product_variation']; $posts = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_type IN ('%s', '%s')", $post_types[0], $post_types[1] ) ); if (!empty($posts)) { $post_ids = wp_list_pluck($posts, 'ID'); $post_ids_imploded = implode(',', array_map('absint', $post_ids)); $wpdb->query("DELETE FROM {$wpdb->posts} WHERE ID IN ($post_ids_imploded)"); $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id IN ($post_ids_imploded)"); $wpdb->query( "DELETE tr, tt FROM {$wpdb->term_relationships} tr INNER JOIN {$wpdb->term_taxonomy} tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tr.object_id IN ($post_ids_imploded)" ); $wpdb->query("DELETE FROM {$wpdb->comments} WHERE comment_post_ID IN ($post_ids_imploded)"); $wpdb->query( "DELETE cm FROM {$wpdb->commentmeta} cm INNER JOIN {$wpdb->comments} c ON cm.comment_id = c.comment_ID WHERE c.comment_post_ID IN ($post_ids_imploded)" ); // Xóa trong lookup tables của WooCommerce $wpdb->query("DELETE FROM {$wpdb->prefix}wc_product_meta_lookup WHERE product_id IN ($post_ids_imploded)"); $wpdb->query("DELETE FROM {$wpdb->prefix}wc_product_attributes_lookup WHERE product_id IN ($post_ids_imploded)"); echo ' done!'; } else { echo ' no post found '; } die; } // xóa ảnh trong wp_uploads nếu ko còn trong db if (isset($_GET['adminz_delete_image_files_without_id'])) { global $wpdb; $upload_dir = wp_get_upload_dir(); $base_upload_path = $upload_dir['basedir']; // Handle Confirmation if (isset($_POST['confirm_delete_files'])) { $selected_files = isset($_POST['selected_files']) ? $_POST['selected_files'] : []; if (!empty($selected_files)) { echo "

Deleting selected files...

"; foreach ($selected_files as $file_rel_path) { $file_full_path = realpath($base_upload_path . '/' . $file_rel_path); // Security check: ensure path is within uploads if ($file_full_path && strpos($file_full_path, realpath($base_upload_path)) === 0) { if (file_exists($file_full_path)) { if (@unlink($file_full_path)) { echo "✅ Deleted file: {$file_rel_path}
"; } else { echo "❌ Failed to delete file: {$file_rel_path}
"; } } } } } else { echo "

No files selected for deletion.

"; } echo "

Back to scan

"; die; } // Scan for files echo "

::: Scanning for Image Files Not in Database

"; echo "

Building database file map...

"; // Get all attached files from DB to compare $attached_files = $wpdb->get_col("SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attached_file'"); $metadata = $wpdb->get_col("SELECT meta_value FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attachment_metadata'"); $known_files = array_flip($attached_files); foreach ($metadata as $m) { $m = maybe_unserialize($m); if ($m && isset($m['file'])) { $known_files[$m['file']] = true; if (isset($m['sizes']) && is_array($m['sizes'])) { $base_path = dirname($m['file']); foreach ($m['sizes'] as $size) { $thumb_path = ($base_path === '.' ? '' : $base_path . '/') . $size['file']; $known_files[$thumb_path] = true; } } } } // Scan uploads/YYYY/MM $sub_folders = glob($base_upload_path . '/*', GLOB_ONLYDIR); $orphans = []; if (!function_exists('list_files')) { require_once(ABSPATH . 'wp-admin/includes/file.php'); } foreach ($sub_folders as $sub_folder) { $folder_name = basename($sub_folder); if (preg_match('/^\d{4}$/', $folder_name)) { $files = list_files($sub_folder); foreach ($files as $file) { if (wp_check_filetype($file)['type'] && strpos(wp_check_filetype($file)['type'], 'image') !== false) { // Normalize path to relative $rel_path = str_replace(DIRECTORY_SEPARATOR, '/', str_replace($base_upload_path . DIRECTORY_SEPARATOR, '', $file)); if (!isset($known_files[$rel_path])) { $path_info = pathinfo($rel_path); $filename = $path_info['filename']; $dir = $path_info['dirname'] !== '.' ? $path_info['dirname'] . '/' : ''; $ext = $path_info['extension']; // Rule 1 & 2: thumbnail pattern (name-WxH.ext) // → kiểm tra ảnh gốc trực tiếp hoặc qua scaled version if (preg_match('/^(.+)-(\d+x\d+)$/', $filename, $thumb_matches)) { $base_name = $thumb_matches[1]; // Rule 1: e.g. Before-70-600x396.jpg → Before-70.jpg if (isset($known_files[$dir . $base_name . '.' . $ext])) { continue; } // Rule 2: e.g. 5_Before-100x100.jpg → 5_Before-scaled.jpg if (isset($known_files[$dir . $base_name . '-scaled.' . $ext])) { continue; } } // Rule 3: pre-scaled original (name.jpg khi DB lưu name-scaled.jpg) // WP giữ file gốc trên disk nhưng _wp_attached_file trỏ đến -scaled if (isset($known_files[$dir . $filename . '-scaled.' . $ext])) { continue; } // Rule 4: rotated hoặc edited backup // e.g. photo-rotated.jpg, photo-e1609459200.jpg if (preg_match('/^(.+)-(rotated|e\d+)$/', $filename, $edit_matches)) { $base_name = $edit_matches[1]; // Kiểm tra ảnh gốc hoặc scaled version if ( isset($known_files[$dir . $base_name . '.' . $ext]) || isset($known_files[$dir . $base_name . '-scaled.' . $ext]) ) { continue; } } $orphans[] = $rel_path; } } } } } if (empty($orphans)) { echo "

✅ No orphaned image files found.

"; } else { echo "

Found " . count($orphans) . " files not referenced in database.

"; echo "
"; wp_nonce_field('adminz_tool'); echo ""; echo ""; $upload_url = wp_get_upload_dir()['baseurl']; foreach ($orphans as $index => $file_rel) { $file_url = $upload_url . '/' . $file_rel; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
# File Relation Path Preview Delete?
" . ($index + 1) . "{$file_rel}
"; echo "
"; echo ""; echo "
"; echo " "; } die; } // clean db image, nếu file ko còn trong wp_uploads if (isset($_GET['adminz_delete_image_ids_without_file'])) { global $wpdb; $upload_dir = wp_get_upload_dir(); $base_upload_path = $upload_dir['basedir']; // Handle Confirmation if (isset($_POST['confirm_delete']) && !empty($_POST['selected_ids'])) { $selected_ids = array_map('intval', $_POST['selected_ids']); echo "

Deleting selected attachments...

"; foreach ($selected_ids as $id) { $meta_value = get_post_meta($id, '_wp_attached_file', true); $file_path = $base_upload_path . '/' . $meta_value; if (!empty($meta_value) && !file_exists($file_path)) { wp_delete_attachment($id, true); echo "✅ Deleted attachment ID: {$id}
"; } else { echo "⚠️ Skipped attachment ID: {$id} (File exists or empty meta)
"; } } echo "

Back to scan

"; die; } // Scan for orphans $attachments = $wpdb->get_results(" SELECT ID, meta_value FROM {$wpdb->posts} LEFT JOIN {$wpdb->postmeta} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id WHERE post_type = 'attachment' AND meta_key = '_wp_attached_file' "); $orphans = []; foreach ($attachments as $attachment) { $file_path = $base_upload_path . '/' . $attachment->meta_value; if (!empty($attachment->meta_value) && !file_exists($file_path)) { $orphans[] = [ 'ID' => $attachment->ID, 'file' => $attachment->meta_value, 'path' => $file_path ]; } } echo "

::: Delete Attachment Records Without Image Files

"; if (empty($orphans)) { echo "

No orphaned attachment records found.

"; } else { echo "

Found " . count($orphans) . " orphaned records.

"; echo "
"; wp_nonce_field('adminz_tool'); echo ""; echo ""; foreach ($orphans as $index => $orphan) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } echo "
# ID Attached File Full Path Delete?
" . ($index + 1) . "{$orphan['ID']}{$orphan['file']}{$orphan['path']}
"; echo "
"; echo ""; echo "
"; // Add a tiny script for check all echo " "; } die; } // if (isset($_GET['adminz_test_rewrite_rules'])) { global $wp_rewrite; $rules = $wp_rewrite->wp_rewrite_rules(); echo '
'; echo '

Rewrite Rules

'; echo ''; echo ''; echo ''; if (!empty($rules)) { foreach ($rules as $regex => $query) { echo ''; echo ''; echo ''; echo ''; } } else { echo ''; } echo '
RegexQuery
' . esc_html($regex) . '' . esc_html($query) . '
Không có rewrite rules nào.
'; echo '
'; die; } } /** * Chuyển đổi quyền truy cập từ dạng số sang dạng ký tự (ví dụ: -rwxr-xr-x) */ function get_permissions_human_readable($permissions) { $type = is_dir($permissions) ? 'd' : '-'; $owner = ($permissions & 0x0100) ? 'r' : '-'; $owner .= ($permissions & 0x0080) ? 'w' : '-'; $owner .= ($permissions & 0x0040) ? 'x' : '-'; $group = ($permissions & 0x0020) ? 'r' : '-'; $group .= ($permissions & 0x0010) ? 'w' : '-'; $group .= ($permissions & 0x0008) ? 'x' : '-'; $others = ($permissions & 0x0004) ? 'r' : '-'; $others .= ($permissions & 0x0002) ? 'w' : '-'; $others .= ($permissions & 0x0001) ? 'x' : '-'; return $type . $owner . $group . $others; } function set_view_file() { if (isset($_GET['view_file'])) { $file_path = urldecode($_GET['view_file']); if (file_exists($file_path) && pathinfo($file_path, PATHINFO_EXTENSION) === 'php') { if (str_contains($file_path, 'wp-config.php')) { echo "wp-config.php is ignored for security reasons."; } else { echo "

Viewing File: {$file_path}

"; echo "
";
                    echo htmlspecialchars(file_get_contents($file_path));
                    echo "
"; } } else { echo "Invalid file path."; } die; } } function view_meta_table($metavalue) { // kiểm tra dữ liệu đầu vào if (empty($metavalue) || !is_array($metavalue)) { return 'Meta rỗng hoặc không hợp lệ'; } // khởi tạo html $html = ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; $html .= ''; foreach ($metavalue as $meta_key => $meta_values) { // lấy value đầu tiên (chuẩn WP meta) $raw_value = $meta_values[0] ?? ''; // unserialize nếu cần $value = maybe_unserialize($raw_value); $html .= ''; // cột meta key $html .= ''; // cột meta value: chỉ print_r trong
            $html .= '
'; $html .= ''; } $html .= ''; $html .= '
Meta keyMeta value
' . esc_html((string) $meta_key) . '
' . esc_html(print_r($value, true)) . '
'; return $html; } }