Skip to content

Instantly share code, notes, and snippets.

@codename065
Created August 12, 2021 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codename065/66fed509a2b898d4bcddcb12081d9023 to your computer and use it in GitHub Desktop.
Save codename065/66fed509a2b898d4bcddcb12081d9023 to your computer and use it in GitHub Desktop.
<?php
global $wpdb;
$files = $wpdb->get_var("select meta_value from {$wpdb->prefix}postmeta where meta_key = '__wpdm_files' and post_id = '{$package['ID']}'");
preg_match_all("/i\:([0-9]+)/", $files, $matches);
$find = $matches[0];
$replace = [];
foreach($matches[1] as $index) {
$replace[] = "s:".strlen($index).':"'.$index.'"';
}
$files = str_replace($find, $replace, $files);
$files = $package['files'] = unserialize($files);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment