public function legacy_dir_migrate() { global $wpdb, $wf, $blog_id; $ud = wp_upload_dir(); $affected_rows = 0; $tables = array( $wpdb->postmeta, $wpdb->usermeta, MPU::site_table("termmeta")); if (MASTERPRESS_MULTI) { foreach ($tables as $table) { // hard-code blogs.dir here, as it's the only setup that was supported anyway (any others would have failed with masterpress 1.0) $sql = "UPDATE $table SET meta_value = REPLACE(meta_value, '/blogs.dir/$blog_id/mp/uploads/', '/blogs.dir/$blog_id/mp/files/' ) WHERE meta_value LIKE '%/blogs.dir/$blog_id/mp/uploads/%' "; $affected_rows += $wpdb->query( $sql ); // there's no need to update the /sites/files type URLs, as no install could have ever had these working } if (is_main_site()) { foreach ($tables as $table) { $sql = "UPDATE $table SET meta_value = REPLACE(meta_value, '" . WP_CONTENT_URL . "/mp/uploads', '" . $ud["baseurl"] . "/mp/files" . "' ) WHERE meta_value LIKE '%/mp/uploads/%' "; $affected_rows += $wpdb->query( $sql ); } } } else { foreach ($tables as $table) { $sql = "UPDATE $table SET meta_value = REPLACE(meta_value, '" . WP_CONTENT_URL . "/mp/uploads', '" . $ud["baseurl"] . "/mp/files" . "' ) WHERE meta_value LIKE '%/mp/uploads/%' "; $affected_rows += $wpdb->query( $sql ); } } update_option("mp_legacy_dir", "0"); MPV::success( sprintf( __("%d database records were migrated to the new content path", MASTERPRESS_DOMAIN), $affected_rows ) ); $this->manage(); }