addons
6 days ago
general-cleanup
6 days ago
class-adbc-admin-init.php
6 days ago
class-adbc-automation.php
6 days ago
class-adbc-hardcoded-items.php
6 days ago
class-adbc-migration.php
6 days ago
class-adbc-routes.php
6 days ago
class-adbc-scan-counter.php
7 months ago
class-adbc-settings.php
6 days ago
class-adbc-singleton.php
7 months ago
class-adbc-hardcoded-items.php
1477 lines
| 1 | <?php |
| 2 | |
| 3 | // Exit if accessed directly |
| 4 | if ( ! defined( 'ABSPATH' ) ) |
| 5 | exit; |
| 6 | |
| 7 | /** |
| 8 | * ADBC Hardcoded Items. |
| 9 | * |
| 10 | * This class provides methods for the hardcoded items scan process. |
| 11 | */ |
| 12 | class ADBC_Hardcoded_Items extends ADBC_Singleton { |
| 13 | |
| 14 | /** |
| 15 | * WordPress options. |
| 16 | * |
| 17 | * @var array |
| 18 | */ |
| 19 | private $wp_options = [ |
| 20 | 'siteurl' => '', |
| 21 | 'home' => '', |
| 22 | 'blogname' => '', |
| 23 | 'blogdescription' => '', |
| 24 | 'users_can_register' => '', |
| 25 | 'admin_email' => '', |
| 26 | 'start_of_week' => '', |
| 27 | 'use_balanceTags' => '', |
| 28 | 'use_smilies' => '', |
| 29 | 'require_name_email' => '', |
| 30 | 'comments_notify' => '', |
| 31 | 'posts_per_rss' => '', |
| 32 | 'rss_use_excerpt' => '', |
| 33 | 'mailserver_url' => '', |
| 34 | 'mailserver_login' => '', |
| 35 | 'mailserver_pass' => '', |
| 36 | 'mailserver_port' => '', |
| 37 | 'default_category' => '', |
| 38 | 'default_comment_status' => '', |
| 39 | 'default_ping_status' => '', |
| 40 | 'default_pingback_flag' => '', |
| 41 | 'posts_per_page' => '', |
| 42 | 'date_format' => '', |
| 43 | 'time_format' => '', |
| 44 | 'links_updated_date_format' => '', |
| 45 | 'comment_moderation' => '', |
| 46 | 'moderation_notify' => '', |
| 47 | 'permalink_structure' => '', |
| 48 | 'gzipcompression' => '', |
| 49 | 'hack_file' => '', |
| 50 | 'blog_charset' => '', |
| 51 | 'moderation_keys' => '', |
| 52 | 'active_plugins' => '', |
| 53 | 'category_base' => '', |
| 54 | 'ping_sites' => '', |
| 55 | 'advanced_edit' => '', |
| 56 | 'comment_max_links' => '', |
| 57 | 'gmt_offset' => '', |
| 58 | // 1.5 |
| 59 | 'default_email_category' => '', |
| 60 | 'recently_edited' => '', |
| 61 | 'template' => '', |
| 62 | 'stylesheet' => '', |
| 63 | 'comment_whitelist' => '', |
| 64 | 'blacklist_keys' => '', |
| 65 | 'comment_registration' => '', |
| 66 | 'html_type' => '', |
| 67 | // 1.5.1 |
| 68 | 'use_trackback' => '', |
| 69 | // 2.0 |
| 70 | 'default_role' => '', |
| 71 | 'db_version' => '', |
| 72 | // 2.0.1 |
| 73 | 'uploads_use_yearmonth_folders' => '', |
| 74 | 'upload_path' => '', |
| 75 | // 2.1 |
| 76 | 'blog_public' => '', |
| 77 | 'default_link_category' => '', |
| 78 | 'show_on_front' => '', |
| 79 | // 2.2 |
| 80 | 'tag_base' => '', |
| 81 | // 2.5 |
| 82 | 'show_avatars' => '', |
| 83 | 'avatar_rating' => '', |
| 84 | 'upload_url_path' => '', |
| 85 | 'thumbnail_size_w' => '', |
| 86 | 'thumbnail_size_h' => '', |
| 87 | 'thumbnail_crop' => '', |
| 88 | 'medium_size_w' => '', |
| 89 | 'medium_size_h' => '', |
| 90 | // 2.6 |
| 91 | 'avatar_default' => '', |
| 92 | // 2.7 |
| 93 | 'large_size_w' => '', |
| 94 | 'large_size_h' => '', |
| 95 | 'image_default_link_type' => '', |
| 96 | 'image_default_size' => '', |
| 97 | 'image_default_align' => '', |
| 98 | 'close_comments_for_old_posts' => '', |
| 99 | 'close_comments_days_old' => '', |
| 100 | 'thread_comments' => '', |
| 101 | 'thread_comments_depth' => '', |
| 102 | 'page_comments' => '', |
| 103 | 'comments_per_page' => '', |
| 104 | 'default_comments_page' => '', |
| 105 | 'comment_order' => '', |
| 106 | 'sticky_posts' => '', |
| 107 | 'widget_categories' => '', |
| 108 | 'widget_text' => '', |
| 109 | 'widget_rss' => '', |
| 110 | 'uninstall_plugins' => '', |
| 111 | // 2.8 |
| 112 | 'timezone_string' => '', |
| 113 | // 3.0 |
| 114 | 'page_for_posts' => '', |
| 115 | 'page_on_front' => '', |
| 116 | // 3.1 |
| 117 | 'default_post_format' => '', |
| 118 | // 3.5 |
| 119 | 'link_manager_enabled' => '', |
| 120 | // 4.3.0 |
| 121 | 'finished_splitting_shared_terms' => '', |
| 122 | 'site_icon' => '', |
| 123 | // 4.4.0 |
| 124 | 'medium_large_size_w' => '', |
| 125 | 'medium_large_size_h' => '', |
| 126 | // 4.9.6 |
| 127 | 'wp_page_for_privacy_policy' => '', |
| 128 | // 4.9.8 |
| 129 | 'show_comments_cookies_opt_in' => '', |
| 130 | // Deleted from new versions |
| 131 | 'blodotgsping_url' => '', 'bodyterminator' => '', 'emailtestonly' => '', 'phoneemail_separator' => '', |
| 132 | 'subjectprefix' => '', 'use_bbcode' => '', 'use_blodotgsping' => '', 'use_quicktags' => '', 'use_weblogsping' => '', |
| 133 | 'weblogs_cache_file' => '', 'use_preview' => '', 'use_htmltrans' => '', 'smilies_directory' => '', 'fileupload_allowedusers' => '', |
| 134 | 'use_phoneemail' => '', 'default_post_status' => '', 'default_post_category' => '', 'archive_mode' => '', 'time_difference' => '', |
| 135 | 'links_minadminlevel' => '', 'links_use_adminlevels' => '', 'links_rating_type' => '', 'links_rating_char' => '', |
| 136 | 'links_rating_ignore_zero' => '', 'links_rating_single_image' => '', 'links_rating_image0' => '', 'links_rating_image1' => '', |
| 137 | 'links_rating_image2' => '', 'links_rating_image3' => '', 'links_rating_image4' => '', 'links_rating_image5' => '', |
| 138 | 'links_rating_image6' => '', 'links_rating_image7' => '', 'links_rating_image8' => '', 'links_rating_image9' => '', |
| 139 | 'links_recently_updated_time' => '', 'links_recently_updated_prepend' => '', 'links_recently_updated_append' => '', |
| 140 | 'weblogs_cacheminutes' => '', 'comment_allowed_tags' => '', 'search_engine_friendly_urls' => '', 'default_geourl_lat' => '', |
| 141 | 'default_geourl_lon' => '', 'use_default_geourl' => '', 'weblogs_xml_url' => '', 'new_users_can_blog' => '', '_wpnonce' => '', |
| 142 | '_wp_http_referer' => '', 'Update' => '', 'action' => '', 'rich_editing' => '', 'autosave_interval' => '', 'deactivated_plugins' => '', |
| 143 | 'can_compress_scripts' => '', 'page_uris' => '', 'update_core' => '', 'update_plugins' => '', 'update_themes' => '', 'doing_cron' => '', |
| 144 | 'random_seed' => '', 'rss_excerpt_length' => '', 'secret' => '', 'use_linksupdate' => '', 'default_comment_status_page' => '', |
| 145 | 'wporg_popular_tags' => '', 'what_to_show' => '', 'rss_language' => '', 'language' => '', 'enable_xmlrpc' => '', 'enable_app' => '', |
| 146 | 'embed_autourls' => '', 'default_post_edit_rows' => '', |
| 147 | //Found in wp-admin/includes/upgrade.php |
| 148 | 'widget_search' => '', |
| 149 | 'widget_recent-posts' => '', |
| 150 | 'widget_recent-comments' => '', |
| 151 | 'widget_archives' => '', |
| 152 | 'widget_meta' => '', |
| 153 | 'sidebars_widgets' => '', |
| 154 | // Found in wp-admin/includes/schema.php but not with the above list |
| 155 | 'initial_db_version' => '', |
| 156 | 'WPLANG' => '', |
| 157 | // Found in wp-admin/includes/class-wp-plugins-list-table.php |
| 158 | 'recently_activated' => '', |
| 159 | // Found in wp-admin/network/site-info.php |
| 160 | 'rewrite_rules' => '', |
| 161 | // Found in wp-admin/network.php |
| 162 | 'auth_key' => '', |
| 163 | 'auth_salt' => '', |
| 164 | 'logged_in_key' => '', |
| 165 | 'logged_in_salt' => '', |
| 166 | 'nonce_key' => '', |
| 167 | 'nonce_salt' => '', |
| 168 | // Found in wp-includes/theme.php |
| 169 | 'theme_switched' => '', |
| 170 | // Found in wp-includes/class-wp-customize-manager.php |
| 171 | 'current_theme' => '', |
| 172 | // Found in wp-includes/cron.php |
| 173 | 'cron' => '', |
| 174 | 'widget_nav_menu' => '', |
| 175 | '_split_terms' => '', |
| 176 | // Added in the new adbc 3.2.7 |
| 177 | '_wp_suggested_policy_text_has_changed' => '', |
| 178 | 'active_sitewide_plugins' => '', |
| 179 | 'admin_email_lifespan' => '', |
| 180 | 'adminhash' => '', |
| 181 | 'allowed_themes' => '', |
| 182 | 'allowedthemes' => '', |
| 183 | 'auto_core_update_checked' => '', |
| 184 | 'auto_core_update_failed' => '', |
| 185 | 'auto_core_update_last_checked' => '', |
| 186 | 'auto_core_update_notified' => '', |
| 187 | 'auto_plugin_theme_update_emails' => '', |
| 188 | 'auto_update_core_dev' => '', |
| 189 | 'auto_update_core_major' => '', |
| 190 | 'auto_update_core_minor' => '', |
| 191 | 'auto_update_plugins' => '', |
| 192 | 'auto_update_themes' => '', |
| 193 | 'blocklist_keys' => '', |
| 194 | 'blog_count' => '', |
| 195 | 'blog_upload_space' => '', |
| 196 | 'category_children' => '', |
| 197 | 'comment_previously_approved' => '', |
| 198 | 'core_updater.lock' => '', |
| 199 | 'customize_stashed_theme_mods' => '', |
| 200 | 'dashboard_widget_options' => '', |
| 201 | 'db_upgraded' => '', |
| 202 | 'deactivated_sitewide_plugins' => '', |
| 203 | 'delete_blog_hash' => '', |
| 204 | 'disallowed_keys' => '', |
| 205 | 'dismissed_update_core' => '', |
| 206 | 'dismissed_update_plugins' => '', |
| 207 | 'dismissed_update_themes' => '', |
| 208 | 'embed_size_h' => '', |
| 209 | 'embed_size_w' => '', |
| 210 | 'fileupload_maxk' => '', |
| 211 | 'fileupload_url' => '', |
| 212 | 'finished_updating_comment_type' => '', |
| 213 | 'fresh_site' => '', |
| 214 | 'ftp_credentials' => '', |
| 215 | 'global_terms_enabled' => '', |
| 216 | 'https_detection_errors' => '', |
| 217 | 'https_migration_required' => '', |
| 218 | 'illegal_names' => '', |
| 219 | 'large_image_threshold' => '', |
| 220 | 'layout_columns' => '', |
| 221 | 'links_per_page' => '', |
| 222 | 'ms_files_rewriting' => '', |
| 223 | 'my_array' => '', |
| 224 | 'my_option_name' => '', |
| 225 | 'nav_menu_options' => '', |
| 226 | 'network_admin_hash' => '', |
| 227 | 'new_admin_email' => '', |
| 228 | 'post_count' => '', |
| 229 | 'product_cat_children' => '', |
| 230 | 'recovery_keys' => '', |
| 231 | 'recovery_mode_auth_key' => '', |
| 232 | 'recovery_mode_auth_salt' => '', |
| 233 | 'recovery_mode_email_last_sent' => '', |
| 234 | 'registration' => '', |
| 235 | 'registrationnotification' => '', |
| 236 | 'secret_key' => '', |
| 237 | 'site_admins' => '', |
| 238 | 'site_logo' => '', |
| 239 | 'stylesheet_root' => '', |
| 240 | 'template_root' => '', |
| 241 | 'theme_mods_twentytwentythree' => '', |
| 242 | 'theme_switch_menu_locations' => '', |
| 243 | 'theme_switched_via_customizer' => '', |
| 244 | 'update_core_major' => '', |
| 245 | 'update_services' => '', |
| 246 | 'update_translations' => '', |
| 247 | 'upgrade_500_was_gutenberg_active' => '', |
| 248 | 'use_fileupload' => '', |
| 249 | 'user_count' => '', |
| 250 | 'welcome_user_email' => '', |
| 251 | 'widget_block' => '', |
| 252 | 'widget_calendar' => '', |
| 253 | 'widget_custom_html' => '', |
| 254 | 'widget_media_audio' => '', |
| 255 | 'widget_media_gallery' => '', |
| 256 | 'widget_media_image' => '', |
| 257 | 'widget_media_video' => '', |
| 258 | 'widget_pages' => '', |
| 259 | 'widget_recent_comments' => '', |
| 260 | 'widget_recent_entries' => '', |
| 261 | 'widget_tag_cloud' => '', |
| 262 | 'wp_calendar_block_has_published_posts' => '', |
| 263 | 'wp_force_deactivated_plugins' => '', |
| 264 | 'wpmu_sitewide_plugins' => '', |
| 265 | 'wpmu_upgrade_site' => '', |
| 266 | 'wp_attachment_pages_enabled' => '', |
| 267 | // 6.9 |
| 268 | 'wp_notes_notify' => '', |
| 269 | // 7.0 |
| 270 | 'wordpress_api_key' => '', |
| 271 | ]; |
| 272 | |
| 273 | /** |
| 274 | * WordPress tables. |
| 275 | * |
| 276 | * @var array |
| 277 | */ |
| 278 | private $wp_tables = [ |
| 279 | 'terms' => '', |
| 280 | 'term_taxonomy' => '', |
| 281 | 'term_relationships' => '', |
| 282 | 'commentmeta' => '', |
| 283 | 'comments' => '', |
| 284 | 'links' => '', |
| 285 | 'options' => '', |
| 286 | 'postmeta' => '', |
| 287 | 'posts' => '', |
| 288 | 'users' => '', |
| 289 | 'usermeta' => '', |
| 290 | // Since 3.0 in wp-admin/includes/upgrade.php |
| 291 | 'sitecategories' => '', |
| 292 | // Since 4.4 |
| 293 | 'termmeta' => '', |
| 294 | 'blogs' => '', |
| 295 | 'blog_versions' => '', |
| 296 | 'blogmeta' => '', |
| 297 | 'registration_log' => '', |
| 298 | 'signups' => '', |
| 299 | 'site' => '', |
| 300 | 'sitemeta' => '', |
| 301 | ]; |
| 302 | |
| 303 | /** |
| 304 | * WordPress cron jobs. |
| 305 | * |
| 306 | * @var array |
| 307 | */ |
| 308 | private $wp_cron_jobs = [ |
| 309 | 'delete_expired_transients' => '', |
| 310 | 'do_pings' => '', |
| 311 | 'publish_future_post' => '', |
| 312 | 'recovery_mode_clean_expired_keys' => '', |
| 313 | 'update_network_counts' => '', |
| 314 | 'upgrader_scheduled_cleanup' => '', |
| 315 | 'wp_auto_updates_maybe_update' => '', |
| 316 | 'wp_delete_temp_updater_backups' => '', |
| 317 | 'wp_https_detection' => '', |
| 318 | 'wp_maybe_auto_update' => '', |
| 319 | 'wp_privacy_delete_old_export_files' => '', |
| 320 | 'wp_scheduled_auto_draft_delete' => '', |
| 321 | 'wp_scheduled_delete' => '', |
| 322 | 'wp_site_health_scheduled_check' => '', |
| 323 | 'wp_split_shared_term_batch' => '', |
| 324 | 'wp_update_comment_type_batch' => '', |
| 325 | 'wp_update_plugins' => '', |
| 326 | 'wp_update_themes' => '', |
| 327 | 'wp_update_user_counts' => '', |
| 328 | 'wp_version_check' => '', |
| 329 | 'importer_scheduled_cleanup' => '', |
| 330 | 'wp_schedule_delete' => '', |
| 331 | ]; |
| 332 | |
| 333 | /** |
| 334 | * WordPress transients. |
| 335 | * |
| 336 | * @var array |
| 337 | */ |
| 338 | private $wp_transients = [ |
| 339 | '_site_transient_available_translations' => '', |
| 340 | '_site_transient_theme_roots' => '', |
| 341 | '_site_transient_update_core' => '', |
| 342 | '_site_transient_update_plugins' => '', |
| 343 | '_site_transient_update_themes' => '', |
| 344 | '_site_transient_wporg_theme_feature_list' => '', |
| 345 | '_site_transient_wp_plugin_dependencies_plugin_data' => '', |
| 346 | '_transient_dirsize_cache' => '', |
| 347 | '_transient_doing_cron' => '', |
| 348 | '_transient_health-check-site-status-result' => '', |
| 349 | '_transient_is_multi_author' => '', |
| 350 | '_transient_mailserver_last_checked' => '', |
| 351 | '_transient_plugin_slugs' => '', |
| 352 | '_transient_random_seed' => '', |
| 353 | '_transient_settings_errors' => '', |
| 354 | '_transient_wp_core_block_css_files' => '', |
| 355 | '_transient_wporg_theme_feature_list' => '', |
| 356 | '_transient_featured_content_ids' => '', |
| 357 | '_transient_rewrite_rules' => '', |
| 358 | '_transient_twentyfifteen_categories' => '', |
| 359 | '_transient_twentyfourteen_category_count' => '', |
| 360 | '_transient_twentyseventeen_categories' => '', |
| 361 | '_transient_twentysixteen_categories' => '', |
| 362 | '_transient_global_styles' => '', |
| 363 | '_transient_update_core' => '', |
| 364 | '_transient_update_plugins' => '', |
| 365 | '_transient_update_themes' => '', |
| 366 | '_transient_wp_styles_for_blocks' => '', |
| 367 | '_site_transient_popular_importers_' => [ |
| 368 | 'rule' => 'starts_with', |
| 369 | 'concatenated_with' => 'md5' |
| 370 | ], |
| 371 | '_site_transient_g_url_details_response_' => [ |
| 372 | 'rule' => 'starts_with', |
| 373 | 'concatenated_with' => 'md5' |
| 374 | ], |
| 375 | '_site_transient_wp_font_collection_url_' => [ |
| 376 | 'rule' => 'starts_with', |
| 377 | 'concatenated_with' => 'string' // url |
| 378 | ], |
| 379 | '_site_transient_community-events-' => [ |
| 380 | 'rule' => 'starts_with', |
| 381 | 'concatenated_with' => 'md5' |
| 382 | ], |
| 383 | '_site_transient_wp_remote_block_patterns_' => [ |
| 384 | 'rule' => 'starts_with', |
| 385 | 'concatenated_with' => 'md5' |
| 386 | ], |
| 387 | '_site_transient_browser_' => [ |
| 388 | 'rule' => 'starts_with', |
| 389 | 'concatenated_with' => 'md5' |
| 390 | ], |
| 391 | '_site_transient_php_check_' => [ |
| 392 | 'rule' => 'starts_with', |
| 393 | 'concatenated_with' => 'md5' |
| 394 | ], |
| 395 | '_site_transient_poptags_' => [ |
| 396 | 'rule' => 'starts_with', |
| 397 | 'concatenated_with' => 'md5' |
| 398 | ], |
| 399 | '_site_transient_wordpress_credits_' => [ |
| 400 | 'rule' => 'starts_with', |
| 401 | 'concatenated_with' => 'string' |
| 402 | ], |
| 403 | '_site_transient_wp_theme_files_patterns-' => [ |
| 404 | 'rule' => 'starts_with', |
| 405 | 'concatenated_with' => 'md5' |
| 406 | ], |
| 407 | '_transient_wp_generating_att_' => [ |
| 408 | 'rule' => 'starts_with', |
| 409 | 'concatenated_with' => 'int' |
| 410 | ], |
| 411 | '_transient_oembed_' => [ |
| 412 | 'rule' => 'starts_with', |
| 413 | 'concatenated_with' => 'md5' |
| 414 | ], |
| 415 | '_transient_dash_v2_' => [ |
| 416 | 'rule' => 'starts_with', |
| 417 | 'concatenated_with' => 'md5' |
| 418 | ], |
| 419 | '_transient_rss_' => [ |
| 420 | 'rule' => 'starts_with', |
| 421 | 'concatenated_with' => 'md5' |
| 422 | ], |
| 423 | '_transient_feed_' => [ |
| 424 | 'rule' => 'starts_with', |
| 425 | 'concatenated_with' => 'md5' |
| 426 | ], |
| 427 | '_transient_feed_mod_' => [ |
| 428 | 'rule' => 'starts_with', |
| 429 | 'concatenated_with' => 'md5' |
| 430 | ], |
| 431 | '_site_transient_feed_' => [ |
| 432 | 'rule' => 'starts_with', |
| 433 | 'concatenated_with' => 'md5' |
| 434 | ], |
| 435 | '_site_transient_feed_mod_' => [ |
| 436 | 'rule' => 'starts_with', |
| 437 | 'concatenated_with' => 'md5' |
| 438 | ], |
| 439 | '_transient_scrape_key_' => [ |
| 440 | 'rule' => 'starts_with', |
| 441 | 'concatenated_with' => 'md5' |
| 442 | ], |
| 443 | '_site_transient_wp_plugin_dependencies_plugin_timeout_' => [ |
| 444 | 'rule' => 'starts_with', |
| 445 | 'concatenated_with' => 'string' |
| 446 | ], |
| 447 | '_transient_global_styles_' => [ |
| 448 | 'rule' => 'starts_with', |
| 449 | 'concatenated_with' => 'string' |
| 450 | ], |
| 451 | '_transient_global_styles_svg_filters_' => [ |
| 452 | 'rule' => 'starts_with', |
| 453 | 'concatenated_with' => 'string' |
| 454 | ], |
| 455 | '_transient_plugins_delete_result_' => [ |
| 456 | 'rule' => 'starts_with', |
| 457 | 'concatenated_with' => 'int' |
| 458 | ], |
| 459 | |
| 460 | ]; |
| 461 | |
| 462 | /** |
| 463 | * WordPress posts meta. |
| 464 | * |
| 465 | * @var array |
| 466 | */ |
| 467 | private $wp_posts_meta = [ |
| 468 | '_cover_hash' => '', |
| 469 | '_customize_changeset_uuid' => '', |
| 470 | '_customize_draft_post_name' => '', |
| 471 | '_customize_restore_dismissed' => '', |
| 472 | '_edit_last' => '', |
| 473 | '_edit_lock' => '', |
| 474 | '_encloseme' => '', |
| 475 | '_export_data_grouped' => '', |
| 476 | '_export_data_raw' => '', |
| 477 | '_export_file_name' => '', |
| 478 | '_export_file_path' => '', |
| 479 | '_export_file_url' => '', |
| 480 | '_menu_item_classes' => '', |
| 481 | '_menu_item_menu_item_parent' => '', |
| 482 | '_menu_item_object' => '', |
| 483 | '_menu_item_object_id' => '', |
| 484 | '_menu_item_orphaned' => '', |
| 485 | '_menu_item_target' => '', |
| 486 | '_menu_item_type' => '', |
| 487 | '_menu_item_url' => '', |
| 488 | '_menu_item_xfn' => '', |
| 489 | '_pingme' => '', |
| 490 | '_post_restored_from' => '', |
| 491 | '_source_url' => '', |
| 492 | '_starter_content_theme' => '', |
| 493 | '_thumbnail_id' => '', |
| 494 | '_trackbackme' => '', |
| 495 | '_wp_admin_notified' => '', |
| 496 | '_wp_attached_file' => '', |
| 497 | '_wp_attachment_backup_sizes' => '', |
| 498 | '_wp_attachment_context' => '', |
| 499 | '_wp_attachment_image_alt' => '', |
| 500 | '_wp_attachment_is_custom_background' => '', |
| 501 | '_wp_attachment_is_custom_header' => '', |
| 502 | '_wp_attachment_metadata' => '', |
| 503 | '_wp_desired_post_slug' => '', |
| 504 | '_wp_old_date' => '', |
| 505 | '_wp_old_slug' => '', |
| 506 | '_wp_page_template' => '', |
| 507 | '_wp_suggested_privacy_policy_content' => '', |
| 508 | '_wp_trash_meta_comments_status' => '', |
| 509 | '_wp_trash_meta_status' => '', |
| 510 | '_wp_trash_meta_time' => '', |
| 511 | '_wp_user_notified' => '', |
| 512 | '_wp_user_request_completed_timestamp' => '', |
| 513 | '_wp_user_request_confirmed_timestamp' => '', |
| 514 | 'enclosure' => '', |
| 515 | 'footnotes' => '', |
| 516 | 'imagedata' => '', |
| 517 | 'is_wp_suggestion' => '', |
| 518 | 'origin' => '', |
| 519 | '_wp_font_face_file' => '', |
| 520 | '_wp_ignored_hooked_blocks' => '', |
| 521 | ]; |
| 522 | |
| 523 | /** |
| 524 | * WordPress users meta. |
| 525 | * |
| 526 | * @var array |
| 527 | */ |
| 528 | private $wp_users_meta = [ |
| 529 | '_new_email' => '', |
| 530 | 'admin_color' => '', |
| 531 | 'aim' => '', |
| 532 | 'closedpostboxes_post' => '', |
| 533 | 'comment_shortcuts' => '', |
| 534 | 'community-events-location' => '', |
| 535 | 'default_password_nag' => '', |
| 536 | 'description' => '', |
| 537 | 'dismissed_wp_pointers' => '', |
| 538 | 'enable_custom_fields' => '', |
| 539 | 'first_name' => '', |
| 540 | 'icq' => '', |
| 541 | 'last_name' => '', |
| 542 | 'last_update' => '', |
| 543 | 'locale' => '', |
| 544 | 'managenav-menuscolumnshidden' => '', |
| 545 | 'manageuploadcolumnshidden' => '', |
| 546 | 'meta-box-order_post' => '', |
| 547 | 'metaboxhidden_nav-menus' => '', |
| 548 | 'metaboxhidden_post' => '', |
| 549 | 'msn' => '', |
| 550 | 'nav_menu_recently_edited' => '', |
| 551 | 'nickname' => '', |
| 552 | 'primary_blog' => '', |
| 553 | 'rich_editing' => '', |
| 554 | 'session_tokens' => '', |
| 555 | 'show_admin_bar_front' => '', |
| 556 | 'show_welcome_panel' => '', |
| 557 | 'source_domain' => '', |
| 558 | 'syntax_highlighting' => '', |
| 559 | 'upload_per_page' => '', |
| 560 | 'use_ssl' => '', |
| 561 | 'wp_capabilities' => '', |
| 562 | 'wp_dashboard_quick_press_last_post_id' => '', |
| 563 | 'wp_media_library_mode' => '', |
| 564 | 'wp_persisted_preferences' => '', |
| 565 | 'wp_user_level' => '', |
| 566 | 'wp_user-settings' => '', |
| 567 | 'wp_user-settings-time' => '', |
| 568 | 'wporg_favorites' => '', |
| 569 | 'yim' => '', |
| 570 | ]; |
| 571 | |
| 572 | /** |
| 573 | * WordPress post types. |
| 574 | * |
| 575 | * @var array |
| 576 | */ |
| 577 | private $wp_post_types = [ |
| 578 | 'post' => '', |
| 579 | 'page' => '', |
| 580 | 'attachment' => '', |
| 581 | 'revision' => '', |
| 582 | 'nav_menu_item' => '', |
| 583 | 'custom_css' => '', |
| 584 | 'customize_changeset' => '', |
| 585 | 'oembed_cache' => '', |
| 586 | 'user_request' => '', |
| 587 | 'wp_block' => '', |
| 588 | 'wp_global_styles' => '', |
| 589 | 'wp_navigation' => '', |
| 590 | 'wp_template' => '', |
| 591 | 'wp_template_part' => '', |
| 592 | 'wp_font_family' => '', // WP 6.5+ |
| 593 | 'wp_font_face' => '', // WP 6.5+ |
| 594 | ]; |
| 595 | |
| 596 | // TO-CHECK: Make sure all ADBC hardcoded items are added here |
| 597 | |
| 598 | /** |
| 599 | * ADBC plugin options. |
| 600 | * |
| 601 | * @var array |
| 602 | */ |
| 603 | private $adbc_options = [ |
| 604 | 'adbc_plugin_settings' => '', |
| 605 | 'adbc_plugin_scan_info_options' => '', |
| 606 | 'adbc_plugin_scan_info_tables' => '', |
| 607 | 'adbc_plugin_scan_info_cron_jobs' => '', |
| 608 | 'adbc_plugin_scan_info_users_meta' => '', |
| 609 | 'adbc_plugin_scan_info_posts_meta' => '', |
| 610 | 'adbc_plugin_scan_info_transients' => '', |
| 611 | 'adbc_plugin_should_stop_scan_options' => '', |
| 612 | 'adbc_plugin_should_stop_scan_tables' => '', |
| 613 | 'adbc_plugin_should_stop_scan_cron_jobs' => '', |
| 614 | 'adbc_plugin_should_stop_scan_users_meta' => '', |
| 615 | 'adbc_plugin_should_stop_scan_posts_meta' => '', |
| 616 | 'adbc_plugin_should_stop_scan_transients' => '', |
| 617 | 'adbc_plugin_automation' => '', |
| 618 | 'adbc_plugin_license_key' => '', |
| 619 | 'adbc_plugin_license_key_license' => '', |
| 620 | 'adbc_plugin_conflict_notice' => '', |
| 621 | 'adbc_plugin_pro_api_scan_balance' => '', // this is used in the new pro version |
| 622 | 'adbc_plugin_license_key_pro' => '', // this is used in the new pro version |
| 623 | 'adbc_plugin_license_key_pro_license' => '', // this is used in the new pro version |
| 624 | ]; |
| 625 | |
| 626 | /** |
| 627 | * ADBC plugin cron jobs. |
| 628 | * |
| 629 | * @var array |
| 630 | */ |
| 631 | private $adbc_cron_jobs = [ |
| 632 | 'adbc_cron_analytics' => '', |
| 633 | 'adbc_cron_automation' => '', |
| 634 | 'edd_sl_sdk_weekly_license_check_advanced-database-cleaner-premium' => '', |
| 635 | 'edd_sl_sdk_weekly_license_check_advanced-database-cleaner-pro' => '', |
| 636 | ]; |
| 637 | |
| 638 | /** |
| 639 | * ADBC plugin transients. |
| 640 | * For this specific case, we save both the final transient name and the original name. |
| 641 | * |
| 642 | * @var array |
| 643 | */ |
| 644 | private $adbc_transients = [ |
| 645 | '_transient_adbc_plugin_tables_to_repair' => 'adbc_plugin_tables_to_repair', |
| 646 | '_transient_adbc_plugin_innodb_conversion_lock' => 'adbc_plugin_innodb_conversion_lock', |
| 647 | '_transient_adbc_plugin_post_types_dict_updated' => 'adbc_plugin_post_types_dict_updated', |
| 648 | ]; |
| 649 | |
| 650 | /** |
| 651 | * Most popular posts_meta and users_meta used to decide if a relation is unknown. |
| 652 | * @var array |
| 653 | */ |
| 654 | private $known_meta_dict = [ |
| 655 | // TO-CHECK: inserted all postmeta that have more than 30 relations |
| 656 | "posts_meta" => [ |
| 657 | "_price" => "1023", |
| 658 | "_regular_price" => "882", |
| 659 | "_sale_price" => "682", |
| 660 | "_sku" => "510", |
| 661 | "_stock_status" => "469", |
| 662 | "_elementor_data" => "453", |
| 663 | "_stock" => "414", |
| 664 | "_yoast_wpseo_metadesc" => "354", |
| 665 | "_manage_stock" => "351", |
| 666 | "_elementor_edit_mode" => "335", |
| 667 | "_transaction_id" => "323", |
| 668 | "_product_attributes" => "312", |
| 669 | "_product_image_gallery" => "291", |
| 670 | "_payment_method" => "283", |
| 671 | "_customer_user" => "266", |
| 672 | "_yoast_wpseo_title" => "250", |
| 673 | "_visibility" => "236", |
| 674 | "_virtual" => "226", |
| 675 | "_sale_price_dates_to" => "206", |
| 676 | "related-posts" => "206", |
| 677 | "total_sales" => "205", |
| 678 | "_billing_email" => "192", |
| 679 | "_yoast_wpseo_focuskw" => "191", |
| 680 | "description" => "191", |
| 681 | "discount_type" => "190", |
| 682 | "_weight" => "184", |
| 683 | "coupon_amount" => "181", |
| 684 | "_sale_price_dates_from" => "175", |
| 685 | "_billing_first_name" => "173", |
| 686 | "_billing_phone" => "173", |
| 687 | "_order_total" => "172", |
| 688 | "layout" => "172", |
| 689 | "_purchase_note" => "170", |
| 690 | "title" => "168", |
| 691 | "rank_math_description" => "167", |
| 692 | "_backorders" => "166", |
| 693 | "_billing_last_name" => "165", |
| 694 | "_elementor_template_type" => "160", |
| 695 | "_width" => "157", |
| 696 | "_length" => "156", |
| 697 | "_height" => "155", |
| 698 | "_downloadable" => "154", |
| 699 | "usage_limit" => "153", |
| 700 | "individual_use" => "150", |
| 701 | "position" => "149", |
| 702 | "_featured" => "147", |
| 703 | "_sold_individually" => "145", |
| 704 | "expiry_date" => "143", |
| 705 | "_payment_method_title" => "142", |
| 706 | "free_shipping" => "138", |
| 707 | "keywords" => "135", |
| 708 | "_form" => "132", |
| 709 | "product_ids" => "131", |
| 710 | "_elementor_page_settings" => "129", |
| 711 | "_order_currency" => "126", |
| 712 | "rule" => "123", |
| 713 | "email" => "121", |
| 714 | "rank_math_title" => "121", |
| 715 | "exclude_product_ids" => "120", |
| 716 | "rank_math_focus_keyword" => "119", |
| 717 | "type" => "116", |
| 718 | "_wxr_import_menu_item" => "115", |
| 719 | "_wxr_import_parent" => "114", |
| 720 | "_wxr_import_user_slug" => "114", |
| 721 | "hide_on_screen" => "114", |
| 722 | "allorany" => "113", |
| 723 | "_shipping_address_1" => "112", |
| 724 | "_shipping_city" => "111", |
| 725 | "_wxr_import_has_attachment_refs" => "111", |
| 726 | "_billing_country" => "110", |
| 727 | "_shipping_postcode" => "109", |
| 728 | "price" => "109", |
| 729 | "_shipping_country" => "105", |
| 730 | "_billing_city" => "104", |
| 731 | "_billing_address_1" => "103", |
| 732 | "_format_link_url" => "103", |
| 733 | "_format_quote_source_url" => "101", |
| 734 | "thumbnail" => "101", |
| 735 | "_elementor_version" => "100", |
| 736 | "twp_disable_ajax_load_next_post" => "99", |
| 737 | "_shipping_first_name" => "96", |
| 738 | "site_layout" => "96", |
| 739 | "website_url" => "95", |
| 740 | "_shipping_last_name" => "94", |
| 741 | "Image" => "94", |
| 742 | "_elementor_css" => "93", |
| 743 | "apply_before_tax" => "93", |
| 744 | "status" => "93", |
| 745 | "_billing_postcode" => "91", |
| 746 | "_shipping_address_2" => "91", |
| 747 | "featured_item" => "88", |
| 748 | "item_value" => "88", |
| 749 | "_billing_state" => "87", |
| 750 | "currency_val" => "87", |
| 751 | "customer_email" => "87", |
| 752 | "feat_post" => "87", |
| 753 | "feat_serv_item" => "87", |
| 754 | "frame_style" => "87", |
| 755 | "remove_box_content" => "87", |
| 756 | "remove_title_page" => "87", |
| 757 | "testimonial_by" => "87", |
| 758 | "blog-cats" => "86", |
| 759 | "_aioseop_description" => "85", |
| 760 | "_shipping_state" => "83", |
| 761 | "related-cat" => "83", |
| 762 | "_aioseo_description" => "82", |
| 763 | "related-tag" => "82", |
| 764 | "_billing_address_2" => "80", |
| 765 | "_yoast_wpseo_meta-robots-noindex" => "79", |
| 766 | "_order_key" => "78", |
| 767 | "_layout" => "76", |
| 768 | "_post_type" => "76", |
| 769 | "_taxonomy" => "75", |
| 770 | "_label_plural" => "74", |
| 771 | "_label_singular" => "74", |
| 772 | "_rewrite" => "74", |
| 773 | "_tax_status" => "74", |
| 774 | "_taxonomy_rewrite" => "74", |
| 775 | "_tax_class" => "73", |
| 776 | "_billing_company" => "71", |
| 777 | "_shipping_company" => "70", |
| 778 | "panels_data" => "70", |
| 779 | "_customer_ip_address" => "69", |
| 780 | "_product_url" => "69", |
| 781 | "_order_tax" => "67", |
| 782 | "minimum_amount" => "66", |
| 783 | "usage_limit_per_user" => "65", |
| 784 | "_aioseop_title" => "64", |
| 785 | "_featured_header_id" => "64", |
| 786 | "_sidebar_primary" => "64", |
| 787 | "location" => "64", |
| 788 | "phone" => "64", |
| 789 | "url" => "64", |
| 790 | "date_expires" => "62", |
| 791 | "subtitle" => "62", |
| 792 | "address" => "61", |
| 793 | "_menu_item_icon" => "59", |
| 794 | "_sidebar_secondary" => "58", |
| 795 | "_wpb_shortcodes_custom_css" => "56", |
| 796 | "_order_shipping" => "55", |
| 797 | "video_url" => "55", |
| 798 | "views" => "55", |
| 799 | "_mail" => "54", |
| 800 | "featured" => "54", |
| 801 | "_wc_average_rating" => "53", |
| 802 | "_format_video_embed" => "52", |
| 803 | "exclude_sale_items" => "52", |
| 804 | "product_categories" => "52", |
| 805 | "_aioseo_title" => "51", |
| 806 | "_cart_discount" => "51", |
| 807 | "_seopress_titles_desc" => "51", |
| 808 | "link" => "51", |
| 809 | "_order_shipping_tax" => "50", |
| 810 | "exclude_product_categories" => "50", |
| 811 | "name" => "49", |
| 812 | "rating" => "49", |
| 813 | "_downloadable_files" => "48", |
| 814 | "maximum_amount" => "48", |
| 815 | "_default_attributes" => "47", |
| 816 | "city" => "47", |
| 817 | "rank_math_robots" => "46", |
| 818 | "usage_count" => "46", |
| 819 | "_et_pb_use_builder" => "45", |
| 820 | "_format_audio_embed" => "45", |
| 821 | "_shipping_phone" => "45", |
| 822 | "_yoast_wpseo_canonical" => "45", |
| 823 | "first_name" => "45", |
| 824 | "_yoast_wpseo_opengraph-description" => "44", |
| 825 | "geo_latitude" => "44", |
| 826 | "geo_longitude" => "44", |
| 827 | "last_name" => "44", |
| 828 | "_completed_date" => "43", |
| 829 | "_download_limit" => "43", |
| 830 | "_variation_description" => "43", |
| 831 | "twitter" => "43", |
| 832 | "facebook" => "42", |
| 833 | "_created_via" => "41", |
| 834 | "_fl_builder_enabled" => "41", |
| 835 | "_prices_include_tax" => "41", |
| 836 | "_seopress_titles_title" => "41", |
| 837 | "_yoast_wpseo_opengraph-image" => "41", |
| 838 | "post_views_count" => "41", |
| 839 | "thumb" => "41", |
| 840 | "_download_expiry" => "40", |
| 841 | "_email" => "40", |
| 842 | "menu-item-mm-megamenu-posts" => "40", |
| 843 | "menu-item-mm-megamenu-subcat" => "40", |
| 844 | "sidebar_select" => "40", |
| 845 | "start_date" => "40", |
| 846 | "_customer_user_agent" => "39", |
| 847 | "_format_gallery_images" => "39", |
| 848 | "_paid_date" => "39", |
| 849 | "field_group_layout" => "39", |
| 850 | "show_on_page" => "39", |
| 851 | "user_id" => "39", |
| 852 | "_fl_builder_data" => "38", |
| 853 | "country" => "38", |
| 854 | "limit_usage_to_x_items" => "38", |
| 855 | "longitude" => "38", |
| 856 | "video" => "38", |
| 857 | "_aioseop_keywords" => "37", |
| 858 | "_yoast_wpseo_twitter-description" => "37", |
| 859 | "_yoast_wpseo_twitter-title" => "37", |
| 860 | "author" => "37", |
| 861 | "latitude" => "37", |
| 862 | "portfolio_image" => "37", |
| 863 | "wpml_language" => "37", |
| 864 | "_button_text" => "36", |
| 865 | "_menu_item_megamenu" => "36", |
| 866 | "_post_like_count" => "36", |
| 867 | "_thankyou_action_done" => "36", |
| 868 | "_yoast_wpseo_opengraph-title" => "36", |
| 869 | "field_test_field" => "36", |
| 870 | "transaction_id" => "36", |
| 871 | "_crosssell_ids" => "35", |
| 872 | "_order_discount" => "35", |
| 873 | "_upsell_ids" => "35", |
| 874 | "_user_IP" => "35", |
| 875 | "_yoast_wpseo_meta-robots-nofollow" => "35", |
| 876 | "ct_builder_shortcodes" => "35", |
| 877 | "currency" => "35", |
| 878 | "_status" => "34", |
| 879 | "course_id" => "34", |
| 880 | "duration" => "34", |
| 881 | "heading" => "34", |
| 882 | "_dropship_location" => "33", |
| 883 | "_enable_dropship" => "33", |
| 884 | "_order_stock_reduced" => "33", |
| 885 | "_tracking_number" => "33", |
| 886 | "_wc_review_count" => "33", |
| 887 | "_wpb_vc_js_status" => "33", |
| 888 | "cyberchimps_page_section_order" => "33", |
| 889 | "cyberchimps_page_sidebar" => "33", |
| 890 | "cyberchimps_portfolio_link_toggle_four" => "33", |
| 891 | "cyberchimps_portfolio_link_toggle_one" => "33", |
| 892 | "cyberchimps_portfolio_link_toggle_three" => "33", |
| 893 | "cyberchimps_portfolio_link_toggle_two" => "33", |
| 894 | "cyberchimps_portfolio_link_url_four" => "33", |
| 895 | "cyberchimps_portfolio_link_url_one" => "33", |
| 896 | "cyberchimps_portfolio_link_url_three" => "33", |
| 897 | "cyberchimps_portfolio_link_url_two" => "33", |
| 898 | "cyberchimps_portfolio_lite_image_four" => "33", |
| 899 | "cyberchimps_portfolio_lite_image_four_caption" => "33", |
| 900 | "cyberchimps_portfolio_lite_image_one" => "33", |
| 901 | "cyberchimps_portfolio_lite_image_one_caption" => "33", |
| 902 | "cyberchimps_portfolio_lite_image_three" => "33", |
| 903 | "cyberchimps_portfolio_lite_image_three_caption" => "33", |
| 904 | "cyberchimps_portfolio_lite_image_two" => "33", |
| 905 | "cyberchimps_portfolio_lite_image_two_caption" => "33", |
| 906 | "cyberchimps_portfolio_title" => "33", |
| 907 | "cyberchimps_portfolio_title_toggle" => "33", |
| 908 | "cyberchimps_slider_lite_slide_one_image" => "33", |
| 909 | "cyberchimps_slider_lite_slide_one_url" => "33", |
| 910 | "cyberchimps_slider_lite_slide_three_image" => "33", |
| 911 | "cyberchimps_slider_lite_slide_three_url" => "33", |
| 912 | "cyberchimps_slider_lite_slide_two_image" => "33", |
| 913 | "cyberchimps_slider_lite_slide_two_url" => "33", |
| 914 | "cyberchimps_slider_size" => "33", |
| 915 | "redirect" => "33", |
| 916 | "width" => "33", |
| 917 | "_seopress_analysis_target_kw" => "32", |
| 918 | "_subscription_period" => "32", |
| 919 | "_user_liked" => "32", |
| 920 | "end_date" => "32", |
| 921 | "_order_number" => "31", |
| 922 | "_subscription_period_interval" => "31", |
| 923 | "amount" => "31", |
| 924 | "gallery" => "31", |
| 925 | "height" => "31", |
| 926 | "order_id" => "31", |
| 927 | "state" => "31", |
| 928 | "_locale" => "30", |
| 929 | "_my_meta_value_key" => "30", |
| 930 | "_type" => "30", |
| 931 | "_yoast_wpseo_twitter-image" => "30", |
| 932 | "ed_header_overlay" => "30", |
| 933 | "hide_title" => "30", |
| 934 | "post-image" => "30", |
| 935 | "source" => "30", |
| 936 | ], |
| 937 | // TO-CHECK: inserted all usermeta that have more than 20 relations |
| 938 | "users_meta" => [ |
| 939 | "billing_phone" => "477", |
| 940 | "billing_country" => "300", |
| 941 | "billing_first_name" => "290", |
| 942 | "billing_last_name" => "286", |
| 943 | "billing_city" => "284", |
| 944 | "billing_address_1" => "274", |
| 945 | "billing_postcode" => "270", |
| 946 | "billing_state" => "251", |
| 947 | "ignore_hints" => "226", |
| 948 | "billing_email" => "224", |
| 949 | "billing_address_2" => "206", |
| 950 | "billing_company" => "194", |
| 951 | "twitter" => "159", |
| 952 | "shipping_first_name" => "139", |
| 953 | "facebook" => "138", |
| 954 | "shipping_last_name" => "136", |
| 955 | "shipping_city" => "134", |
| 956 | "shipping_address_1" => "133", |
| 957 | "shipping_country" => "132", |
| 958 | "shipping_postcode" => "132", |
| 959 | "shipping_state" => "123", |
| 960 | "shipping_address_2" => "113", |
| 961 | "phone" => "112", |
| 962 | "shipping_company" => "93", |
| 963 | "linkedin" => "87", |
| 964 | "acf_user_settings" => "84", |
| 965 | "last_login" => "67", |
| 966 | "shipping_phone" => "59", |
| 967 | "instagram" => "58", |
| 968 | "display_name" => "48", |
| 969 | "pinterest" => "48", |
| 970 | "wp_email_tracking_ignore_notice" => "46", |
| 971 | "phone_number" => "41", |
| 972 | "country" => "40", |
| 973 | "themeisle_sdk_dismissed_notice_black_friday" => "39", |
| 974 | "address" => "39", |
| 975 | "dismiss-kirki-recommendation" => "39", |
| 976 | "youtube" => "38", |
| 977 | "avatar" => "36", |
| 978 | "wcfmmp_profile_settings" => "35", |
| 979 | "example_ignore_notice" => "33", |
| 980 | "wpclever_wpcstore_ignore" => "32", |
| 981 | "flickr" => "32", |
| 982 | "dokan_profile_settings" => "32", |
| 983 | "user_email" => "30", |
| 984 | "city" => "30", |
| 985 | "google" => "29", |
| 986 | "dribbble" => "27", |
| 987 | "shipping_email" => "27", |
| 988 | "gender" => "27", |
| 989 | "nag_remove_theme_review_notice_partially" => "26", |
| 990 | "remove_theme_review_notice" => "26", |
| 991 | "email" => "25", |
| 992 | "mobile" => "25", |
| 993 | "optionsframework_ignore_notice" => "24", |
| 994 | "user_phone" => "24", |
| 995 | "googleplus" => "23", |
| 996 | "user_url" => "22", |
| 997 | "wp_user_avatar" => "22", |
| 998 | ] |
| 999 | ]; |
| 1000 | |
| 1001 | /** |
| 1002 | * Constructor. |
| 1003 | */ |
| 1004 | protected function __construct() { |
| 1005 | parent::__construct(); |
| 1006 | $this->add_special_wordpress_options(); |
| 1007 | $this->add_special_wordpress_usermeta(); |
| 1008 | if ( ADBC_VERSION_TYPE === 'PREMIUM' ) |
| 1009 | $this->add_special_edd_sdk_cache_keys(); |
| 1010 | } |
| 1011 | |
| 1012 | /** |
| 1013 | * Add special WordPress options to the hardcoded options list. |
| 1014 | * |
| 1015 | * @return void |
| 1016 | */ |
| 1017 | private function add_special_wordpress_options() { |
| 1018 | |
| 1019 | // The 'user_roles' option is added as $prefix.'user_roles' |
| 1020 | $sites = ADBC_Sites::instance()->get_sites_list(); |
| 1021 | foreach ( $sites as $site ) { |
| 1022 | $this->wp_options[ $site['prefix'] . 'user_roles' ] = ''; |
| 1023 | } |
| 1024 | |
| 1025 | // Add also theme_mods option |
| 1026 | $child_theme_slug = get_stylesheet(); |
| 1027 | $parent_theme_slug = get_template(); |
| 1028 | $this->wp_options[ 'theme_mods_' . $child_theme_slug ] = ''; |
| 1029 | if ( $child_theme_slug != $parent_theme_slug ) { |
| 1030 | $this->wp_options[ 'theme_mods_' . $parent_theme_slug ] = ''; |
| 1031 | } |
| 1032 | |
| 1033 | } |
| 1034 | |
| 1035 | /** |
| 1036 | * Add special WordPress usermeta to the hardcoded usermeta list. |
| 1037 | * |
| 1038 | * @return void |
| 1039 | */ |
| 1040 | private function add_special_wordpress_usermeta() { |
| 1041 | |
| 1042 | // Add correct prefixed capabilities and user_level usermeta |
| 1043 | $sites = ADBC_Sites::instance()->get_sites_list(); |
| 1044 | foreach ( $sites as $site ) { |
| 1045 | $this->wp_users_meta[ $site['prefix'] . 'capabilities' ] = ''; |
| 1046 | $this->wp_users_meta[ $site['prefix'] . 'user_level' ] = ''; |
| 1047 | $this->wp_users_meta[ $site['prefix'] . 'user-settings' ] = ''; |
| 1048 | $this->wp_users_meta[ $site['prefix'] . 'user-settings-time' ] = ''; |
| 1049 | $this->wp_users_meta[ $site['prefix'] . 'dashboard_quick_press_last_post_id' ] = ''; |
| 1050 | } |
| 1051 | |
| 1052 | } |
| 1053 | |
| 1054 | /** |
| 1055 | * Add special EDD SDK options to the hardcoded items list. |
| 1056 | * |
| 1057 | * @return void |
| 1058 | */ |
| 1059 | private function add_special_edd_sdk_cache_keys() { |
| 1060 | |
| 1061 | $license_key = ADBC_License_Manager::get_license_data( false )['key'] ?? ''; |
| 1062 | |
| 1063 | if ( empty( $license_key ) ) |
| 1064 | return; |
| 1065 | |
| 1066 | $edd_sdk_cache_option_name = self::adbc_build_edd_cache_key( |
| 1067 | ADBC_PLUGIN_DIR_NAME, |
| 1068 | $license_key, |
| 1069 | false |
| 1070 | ); |
| 1071 | |
| 1072 | if ( ! empty( $edd_sdk_cache_option_name ) ) { |
| 1073 | $this->adbc_options[ $edd_sdk_cache_option_name ] = ''; |
| 1074 | } |
| 1075 | |
| 1076 | } |
| 1077 | |
| 1078 | /** |
| 1079 | * Get the WP hardcoded items based on the items type. |
| 1080 | * |
| 1081 | * @param string $items_type The items type to get the hardcoded items for. |
| 1082 | * @return array The hardcoded items or an empty array if the items type is not found. |
| 1083 | */ |
| 1084 | public function get_wordpress_items( $items_type ) { |
| 1085 | |
| 1086 | switch ( $items_type ) { |
| 1087 | case 'tables': |
| 1088 | return $this->wp_tables; |
| 1089 | case 'post_types': |
| 1090 | return $this->wp_post_types; |
| 1091 | case 'options': |
| 1092 | return $this->wp_options; |
| 1093 | case 'cron_jobs': |
| 1094 | return $this->wp_cron_jobs; |
| 1095 | case 'transients': |
| 1096 | return $this->wp_transients; |
| 1097 | case 'posts_meta': |
| 1098 | return $this->wp_posts_meta; |
| 1099 | case 'users_meta': |
| 1100 | return $this->wp_users_meta; |
| 1101 | default: |
| 1102 | return []; |
| 1103 | } |
| 1104 | |
| 1105 | } |
| 1106 | |
| 1107 | /** |
| 1108 | * Get the ADBC hardcoded items based on the items type. |
| 1109 | * |
| 1110 | * @param string $items_type The items type to get the hardcoded items for. |
| 1111 | * @return array The hardcoded items or an empty array if the items type is not found. |
| 1112 | */ |
| 1113 | public function get_adbc_items( $items_type ) { |
| 1114 | |
| 1115 | switch ( $items_type ) { |
| 1116 | case 'options': |
| 1117 | return $this->adbc_options; |
| 1118 | case 'cron_jobs': |
| 1119 | return $this->adbc_cron_jobs; |
| 1120 | case 'transients': |
| 1121 | return $this->adbc_transients; |
| 1122 | default: |
| 1123 | return []; |
| 1124 | } |
| 1125 | |
| 1126 | } |
| 1127 | |
| 1128 | /** |
| 1129 | * Load hardcoded scan results to tables rows. |
| 1130 | * This function will override the belongs_to property of the tables rows with the hardcoded scan results. |
| 1131 | * |
| 1132 | * @param array $tables_rows The tables rows to load the hardcoded scan results to. |
| 1133 | * |
| 1134 | * @return void |
| 1135 | */ |
| 1136 | public function load_hardcoded_scan_results_to_tables_rows( &$tables_rows ) { |
| 1137 | |
| 1138 | $wp_hardcoded_items = $this->get_wordpress_items( 'tables' ); |
| 1139 | $adbc_hardcoded_items = $this->get_adbc_items( 'tables' ); |
| 1140 | |
| 1141 | foreach ( $tables_rows as $table_name => $table_data ) { |
| 1142 | |
| 1143 | // For tables, we should search for the table name without prefix, because hardcoded tables are saved without any prefix. |
| 1144 | $table_name_without_prefix = $tables_rows[ $table_name ]->table_name_without_prefix; |
| 1145 | |
| 1146 | if ( isset( $wp_hardcoded_items[ $table_name_without_prefix ] ) ) { |
| 1147 | |
| 1148 | $tables_rows[ $table_name ]->belongs_to = [ |
| 1149 | 'type' => 'w', |
| 1150 | 'slug' => 'w', |
| 1151 | 'name' => __( 'WordPress core', 'advanced-database-cleaner' ), |
| 1152 | 'by' => 'l', |
| 1153 | 'percent' => 100, |
| 1154 | 'status' => 'active', |
| 1155 | ]; |
| 1156 | // Set known plugins/themes to empty arrays because we are sure that this item is not related to any plugin/theme. |
| 1157 | $tables_rows[ $table_name ]->known_plugins = []; |
| 1158 | $tables_rows[ $table_name ]->known_themes = []; |
| 1159 | |
| 1160 | } else if ( isset( $adbc_hardcoded_items[ $table_name_without_prefix ] ) ) { |
| 1161 | |
| 1162 | $tables_rows[ $table_name ]->belongs_to = [ |
| 1163 | 'type' => 'p', |
| 1164 | 'slug' => ADBC_PLUGIN_DIR_NAME, |
| 1165 | 'name' => ADBC_Plugins::instance()->get_plugin_name_from_slug( ADBC_PLUGIN_DIR_NAME ), |
| 1166 | 'by' => 'l', |
| 1167 | 'percent' => 100, |
| 1168 | 'status' => 'active', |
| 1169 | ]; |
| 1170 | // Set known plugins/themes to empty arrays because we are sure that this item is not related to any plugin/theme. |
| 1171 | $tables_rows[ $table_name ]->known_plugins = []; |
| 1172 | $tables_rows[ $table_name ]->known_themes = []; |
| 1173 | |
| 1174 | } |
| 1175 | } |
| 1176 | } |
| 1177 | |
| 1178 | /** |
| 1179 | * Load hardcoded scan results to items rows. |
| 1180 | * This function will override the belongs_to property of the items rows with the hardcoded scan results. |
| 1181 | * |
| 1182 | * @param array $items_rows The items rows to load the hardcoded scan results to. |
| 1183 | * @param string $items_type The items type to load the hardcoded scan results for. |
| 1184 | * @return void |
| 1185 | */ |
| 1186 | public function load_hardcoded_scan_results_to_items_rows( &$items_rows, $items_type ) { |
| 1187 | |
| 1188 | $adbc_hardcoded_items = $this->get_adbc_items( $items_type ); |
| 1189 | $wp_hardcoded_items = $this->get_wordpress_items( $items_type ); |
| 1190 | |
| 1191 | foreach ( $items_rows as $index => $item ) { |
| 1192 | |
| 1193 | if ( $this->is_item_belongs_to_wp_core( $item->name, $items_type, $wp_hardcoded_items ) ) { |
| 1194 | |
| 1195 | $items_rows[ $index ]->belongs_to = [ |
| 1196 | 'type' => 'w', |
| 1197 | 'slug' => 'w', |
| 1198 | 'name' => __( 'WordPress core', 'advanced-database-cleaner' ), |
| 1199 | 'by' => 'l', |
| 1200 | 'percent' => 100, |
| 1201 | 'status' => 'active', |
| 1202 | ]; |
| 1203 | // Set known plugins/themes to empty arrays because we are sure that this item is not related to any plugin/theme. |
| 1204 | $items_rows[ $index ]->known_plugins = []; |
| 1205 | $items_rows[ $index ]->known_themes = []; |
| 1206 | |
| 1207 | } else if ( isset( $adbc_hardcoded_items[ $item->name ] ) ) { |
| 1208 | |
| 1209 | $items_rows[ $index ]->belongs_to = [ |
| 1210 | 'type' => 'p', |
| 1211 | 'slug' => ADBC_PLUGIN_DIR_NAME, |
| 1212 | 'name' => ADBC_Plugins::instance()->get_plugin_name_from_slug( ADBC_PLUGIN_DIR_NAME ), |
| 1213 | 'by' => 'l', |
| 1214 | 'percent' => 100, |
| 1215 | 'status' => 'active', |
| 1216 | ]; |
| 1217 | // Set known plugins/themes to empty arrays because we are sure that this item is not related to any plugin/theme. |
| 1218 | $items_rows[ $index ]->known_plugins = []; |
| 1219 | $items_rows[ $index ]->known_themes = []; |
| 1220 | |
| 1221 | } |
| 1222 | |
| 1223 | } |
| 1224 | |
| 1225 | } |
| 1226 | |
| 1227 | /** |
| 1228 | * Exclude hardcoded items from selected items. |
| 1229 | * This function will remove the hardcoded items from the selected items. |
| 1230 | * |
| 1231 | * @param array $selected_items The selected items to exclude the hardcoded items from. |
| 1232 | * @param string $items_type The items type to exclude the hardcoded items from. |
| 1233 | * @param string $type_to_exclude The type of hardcoded items to exclude. Can be 'all', 'wp', or 'adbc'. |
| 1234 | * @return array The cleaned selected items without the hardcoded items. |
| 1235 | */ |
| 1236 | public function exclude_hardcoded_items_from_selected_items( $selected_items, $items_type, $type_to_exclude = 'all' ) { |
| 1237 | |
| 1238 | $exclude_wp = ( $type_to_exclude === 'all' || $type_to_exclude === 'wp' ); |
| 1239 | $exclude_adbc = ( $type_to_exclude === 'all' || $type_to_exclude === 'adbc' ); |
| 1240 | |
| 1241 | $adbc_hardcoded_items = $exclude_adbc ? $this->get_adbc_items( $items_type ) : []; |
| 1242 | $wp_hardcoded_items = $exclude_wp ? $this->get_wordpress_items( $items_type ) : []; |
| 1243 | $cleaned_items = []; |
| 1244 | |
| 1245 | foreach ( $selected_items as $selected_item ) { |
| 1246 | |
| 1247 | if ( empty( $selected_item['name'] ) ) |
| 1248 | continue; // skip malformed entry |
| 1249 | |
| 1250 | $name = $selected_item['name']; |
| 1251 | |
| 1252 | // For tables, we should search for the table name without prefix, |
| 1253 | // because hardcoded tables are saved without any prefix. |
| 1254 | if ( $items_type === 'tables' ) |
| 1255 | $name = ADBC_Tables::remove_prefix_from_table_name( $name ); |
| 1256 | |
| 1257 | $is_wp_core = false; |
| 1258 | $is_adbc = false; |
| 1259 | |
| 1260 | // Check WordPress core hardcoded items (exact + rule-based for transients). |
| 1261 | if ( $exclude_wp && $this->is_item_belongs_to_wp_core( $name, $items_type, $wp_hardcoded_items ) ) |
| 1262 | $is_wp_core = true; |
| 1263 | |
| 1264 | // Check ADBC hardcoded items (exact matches only). |
| 1265 | if ( $exclude_adbc && isset( $adbc_hardcoded_items[ $name ] ) ) |
| 1266 | $is_adbc = true; |
| 1267 | |
| 1268 | // If item is not hardcoded (WP core nor ADBC), keep it. |
| 1269 | if ( ! $is_wp_core && ! $is_adbc ) |
| 1270 | $cleaned_items[] = $selected_item; |
| 1271 | |
| 1272 | } |
| 1273 | |
| 1274 | return $cleaned_items; |
| 1275 | |
| 1276 | } |
| 1277 | |
| 1278 | |
| 1279 | /** |
| 1280 | * Check if an item exists in the dictionary of common meta keys. |
| 1281 | * |
| 1282 | * @param string $item_name The item name to check. |
| 1283 | * @param string $items_type The items type (posts_meta or users_meta). |
| 1284 | * @return bool True if item exists in common dict, false otherwise. |
| 1285 | */ |
| 1286 | public function is_item_in_known_meta_dict( $item_name, $items_type ) { |
| 1287 | |
| 1288 | if ( array_key_exists( $item_name, $this->known_meta_dict[ $items_type ] ) ) { |
| 1289 | return true; |
| 1290 | } |
| 1291 | |
| 1292 | return false; |
| 1293 | |
| 1294 | } |
| 1295 | |
| 1296 | /** |
| 1297 | * Remove the hardcoded items from the list. |
| 1298 | * |
| 1299 | * This function removes items that are known to belong to WordPress core |
| 1300 | * or to the ADBC plugin (hardcoded items) from the given list. |
| 1301 | * It supports both exact matches and rule-based entries. |
| 1302 | * |
| 1303 | * @param array $items_list The list of items to remove the hardcoded items from (passed by reference). |
| 1304 | * @param string $items_type The items type to remove the hardcoded items from. |
| 1305 | * @return array The list of items without the hardcoded items. |
| 1306 | */ |
| 1307 | public function remove_hardcoded_items_from_list( &$items_list, $items_type ) { |
| 1308 | |
| 1309 | $adbc_items = $this->get_adbc_items( $items_type ); |
| 1310 | $wp_hardcoded_items = $this->get_wordpress_items( $items_type ); |
| 1311 | |
| 1312 | foreach ( $items_list as $item_name => $data ) { |
| 1313 | |
| 1314 | if ( $item_name === '' ) |
| 1315 | continue; |
| 1316 | |
| 1317 | // Remove WordPress core hardcoded items (exact + rule-based). |
| 1318 | if ( $this->is_item_belongs_to_wp_core( $item_name, $items_type, $wp_hardcoded_items ) ) { |
| 1319 | unset( $items_list[ $item_name ] ); |
| 1320 | continue; |
| 1321 | } |
| 1322 | |
| 1323 | // Remove ADBC hardcoded items (exact matches for now). |
| 1324 | if ( isset( $adbc_items[ $item_name ] ) ) { |
| 1325 | unset( $items_list[ $item_name ] ); |
| 1326 | continue; |
| 1327 | } |
| 1328 | |
| 1329 | } |
| 1330 | |
| 1331 | return $items_list; |
| 1332 | |
| 1333 | } |
| 1334 | |
| 1335 | /** |
| 1336 | * Check if an item belongs to WordPress core. |
| 1337 | * |
| 1338 | * This function checks both hardcoded items without rules and items |
| 1339 | * defined with matching rules (starts_with, ends_with, contains) |
| 1340 | * for the given items type. |
| 1341 | * |
| 1342 | * @param string $item_name The item name to check. |
| 1343 | * @param string $items_type The items type (options, tables, cron_jobs, transients, posts_meta, users_meta). |
| 1344 | * @param array|null $wp_items Optional preloaded WP core items array to avoid recomputing it. |
| 1345 | * @return bool True if the item belongs to WordPress core, false otherwise. |
| 1346 | */ |
| 1347 | public function is_item_belongs_to_wp_core( $item_name, $items_type, $wp_items = null ) { |
| 1348 | |
| 1349 | if ( $wp_items === null ) |
| 1350 | $wp_items = $this->get_wordpress_items( $items_type ); |
| 1351 | |
| 1352 | if ( empty( $wp_items ) ) |
| 1353 | return false; |
| 1354 | |
| 1355 | // For all items except transients, only exact match is needed. |
| 1356 | if ( $items_type !== 'transients' ) { |
| 1357 | |
| 1358 | if ( isset( $wp_items[ $item_name ] ) ) |
| 1359 | return true; |
| 1360 | |
| 1361 | return false; |
| 1362 | |
| 1363 | } |
| 1364 | |
| 1365 | // ---- TRANSIENTS: exact and rule-based ---- // |
| 1366 | |
| 1367 | // First, check exact transients with no rule. |
| 1368 | if ( isset( $wp_items[ $item_name ] ) && ! is_array( $wp_items[ $item_name ] ) ) |
| 1369 | return true; |
| 1370 | |
| 1371 | // Then check rule-based entries. |
| 1372 | foreach ( $wp_items as $pattern => $data ) { |
| 1373 | |
| 1374 | if ( ! is_array( $data ) || empty( $data['rule'] ) ) |
| 1375 | continue; |
| 1376 | |
| 1377 | $rule = $data['rule']; // always starts_with, ends_with, contains |
| 1378 | $concat_type = isset( $data['concatenated_with'] ) ? $data['concatenated_with'] : 'string'; |
| 1379 | |
| 1380 | // ---- starts_with ---- // |
| 1381 | if ( $rule === 'starts_with' ) { |
| 1382 | |
| 1383 | if ( strpos( $item_name, $pattern ) !== 0 ) |
| 1384 | continue; |
| 1385 | |
| 1386 | $dynamic_part = substr( $item_name, strlen( $pattern ) ); |
| 1387 | if ( $this->is_valid_hardcoded_concatenation( $dynamic_part, $concat_type ) ) |
| 1388 | return true; |
| 1389 | |
| 1390 | } |
| 1391 | |
| 1392 | // ---- ends_with ---- // |
| 1393 | else if ( $rule === 'ends_with' ) { |
| 1394 | |
| 1395 | $pattern_len = strlen( $pattern ); |
| 1396 | if ( $pattern_len === 0 || substr( $item_name, -$pattern_len ) !== $pattern ) |
| 1397 | continue; |
| 1398 | |
| 1399 | $dynamic_part = substr( $item_name, 0, -$pattern_len ); |
| 1400 | if ( $this->is_valid_hardcoded_concatenation( $dynamic_part, $concat_type ) ) |
| 1401 | return true; |
| 1402 | |
| 1403 | } |
| 1404 | |
| 1405 | // ---- contains ---- // |
| 1406 | else if ( $rule === 'contains' ) { |
| 1407 | |
| 1408 | if ( strpos( $item_name, $pattern ) !== false ) |
| 1409 | return true; |
| 1410 | |
| 1411 | } |
| 1412 | |
| 1413 | } |
| 1414 | |
| 1415 | return false; |
| 1416 | |
| 1417 | } |
| 1418 | |
| 1419 | /** |
| 1420 | * Validate the dynamic part of a hardcoded item name based on its type. |
| 1421 | * |
| 1422 | * Supported types: |
| 1423 | * - md5 : 32 hex characters. |
| 1424 | * - int : numeric string. |
| 1425 | * - string : any non-empty string. |
| 1426 | * |
| 1427 | * @param string $value The dynamic part to validate. |
| 1428 | * @param string $type The expected type (md5, int, string). |
| 1429 | * @return bool True if the value matches the expected type, false otherwise. |
| 1430 | */ |
| 1431 | private function is_valid_hardcoded_concatenation( $value, $type ) { |
| 1432 | |
| 1433 | if ( $value === '' ) |
| 1434 | return false; |
| 1435 | |
| 1436 | switch ( $type ) { |
| 1437 | |
| 1438 | case 'md5': |
| 1439 | return strlen( $value ) === 32 && ctype_xdigit( $value ); |
| 1440 | |
| 1441 | case 'int': |
| 1442 | return ctype_digit( $value ); |
| 1443 | |
| 1444 | case 'string': |
| 1445 | default: |
| 1446 | return true; |
| 1447 | |
| 1448 | } |
| 1449 | |
| 1450 | } |
| 1451 | |
| 1452 | /** |
| 1453 | * Build the EDD updater cache option name. |
| 1454 | * |
| 1455 | * Added for ADBC integration so we can compute the cache key |
| 1456 | * without instantiating the updater and adding listeners. |
| 1457 | * |
| 1458 | * @param string $slug Plugin slug. |
| 1459 | * @param string $license License key. |
| 1460 | * @param bool $beta Whether beta updates are enabled. |
| 1461 | * @return string |
| 1462 | */ |
| 1463 | private static function adbc_build_edd_cache_key( $slug, $license = '', $beta = false ) { |
| 1464 | $key = md5( |
| 1465 | wp_json_encode( |
| 1466 | array( |
| 1467 | (string) $slug, |
| 1468 | (string) $license, |
| 1469 | (int) (bool) $beta, |
| 1470 | ) |
| 1471 | ) |
| 1472 | ); |
| 1473 | |
| 1474 | return "edd_sl_{$key}"; |
| 1475 | } |
| 1476 | |
| 1477 | } |