-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_events.php
More file actions
51 lines (44 loc) · 1.29 KB
/
fix_events.php
File metadata and controls
51 lines (44 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
function bootstrap() {
echo 'CONFIRMING ON CLI' . PHP_EOL;
if ( php_sapi_name() != 'cli' ) {
throw new Exception( 'This application must be run on the command line.' );
}
echo 'SETTING MEMORY LIMIT' . PHP_EOL;
ini_set( 'memory_limit', '3000M' );
echo 'autoloading' . PHP_EOL;
require_once 'vendor/autoload.php';
echo 'CHECKING IF WordPress IS LOADED';
if ( ! defined( 'ABSPATH' ) ) {
echo 'LOADING WordPress';
require_once 'public_html/wp-load.php';
}
echo 'SETTING TIMEZONE' . PHP_EOL;
date_default_timezone_set( 'America/New_York' );
echo 'CHECKING THAT SERVER NAME IS SET';
if ( empty( $_SERVER['SERVER_NAME'] ) ) {
echo 'SETTING SERVER NAME';
$_SERVER['SERVER_NAME'] = 'CLI';
}
echo 'PURGING CACHE';
//sg_cachepress_purge_everything();
echo 'BOOTSTRAPPING COMPLETE' . PHP_EOL;
}
bootstrap();
global $wpdb;
$sql = 'select Distinct(post_id) from grace_postmeta where meta_value like "O:31%"';
$posts = $wpdb->get_col($sql);
foreach ($posts as $post) {
$items = get_post_meta($post);
foreach ($items as $key => $item) {
if (is_array($item)) {
$item = $item[0];
}
if (substr($item, 0, 4) == "O:31") {
print($key . PHP_EOL);
$value = unserialize($item);
print(".");
update_post_meta($post, $key, $value->getValue());
}
}
}