-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvzm_asset_handler.php
76 lines (58 loc) · 1.76 KB
/
vzm_asset_handler.php
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/*
Name: Thesis Developer Asset Handler
Author: Tim Milligan
Version: 1.3
*/
class vzm_asset_handler {
public function __construct() {
if (is_dir(WP_CONTENT_DIR . '/thesis'))
add_action('admin_init', array($this, 'get_all_updates'), 100);
}
public function get_all_updates() {
global $thesis;
if (get_transient('vzm_callout'))
return;
set_transient('vzm_callout', time(), 60*60*24);
$objects = array(
'skins' => thesis_skins::get_items(),
'boxes' => thesis_user_boxes::get_items(),
'packages' => thesis_user_packages::get_items()
);
$transients = array(
'skins' => 'thesis_skins_update',
'boxes' => 'thesis_boxes_update',
'packages' => 'thesis_packages_update'
);
$all = array();
foreach ($objects as $object => $array)
if (is_array($array) && !empty($array))
foreach ($array as $class => $data)
$all[$object][$class] = $data['version'];
foreach ($transients as $key => $transient)
if (get_transient($transient))
unset($all[$key]);
if (empty($all))
return;
$all['thesis'] = $thesis->version;
$from = 'http://files.voidzonemedia.com/update.php';
$post_args = array(
'body' => array(
'data' => serialize($all),
'wp' => $GLOBALS['wp_version'],
'php' => phpversion(),
'user-agent' => "WordPress/{$GLOBALS['wp_version']};" . home_url()
)
);
$post = wp_remote_post($from, $post_args);
if (is_wp_error($post) || empty($post['body']))
return;
$returned = @unserialize($post['body']);
if (!is_array($returned))
return;
foreach ($returned as $type => $data) // will only return the data that we need to update
if (in_array("thesis_{$type}_update", $transients))
set_transient("thesis_{$type}_update", $returned[$type], 60*60*24);
}
}
?>