-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-distil.php
113 lines (87 loc) · 3.26 KB
/
simple-distil.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
/*
Plugin Name: Simple Distil Cache Plugin for Wordpress
Plugin URI: http://uvision.co/
Description: A simple plugin to add Distil auth token and uuid and clear cache of domain and subdomain . You simply enter your API key and uuid and apply.
Version: 1.0
Author: Omar Uddin
Author URI: http://uvision.co/
*/
?>
<?php
add_action('admin_menu', 'distil_menu') ;
function distil_menu() {
add_options_page('Simple Distil', 'Simple Distil Cache Settings', 'administrator', __FILE__, 'distil_settings') ;
add_action( 'admin_init', 'distil_register_mysettings') ;
}
function distil_register_mysettings() {
register_setting('distil-settings-group', 'distil_api') ;
register_setting('distil-settings-group', 'UUID') ;
}
function distil_settings() {
$post_arr = array();
$post_arr = $_POST;
if (!empty($post_arr)) {
$service_url = "https://api.distilnetworks.com:443/api/v1/domains/".get_option('UUID')."/cache.json?auth_token=".get_option('distil_api');
$ch = curl_init($service_url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);
$json = curl_exec ($ch);
curl_close ($ch);
$msg = '';
$json_decode = json_decode($json);
if(isset($json_decode->error)){
$msg = $json_decode->error;
}
if(isset($json_decode->message)){
$msg = $json_decode->message;
}
}
?>
<div class="wrap">
<h2><?php _e('Simple Distil', 'simple_distil') ; ?></h2>
<p>
<?php
_e('Simple Distil allows you to easilly add your Distil API key and clear cache of domain and subdomain.', 'simple_distil') ;
echo '<br/>' ;
_e('Just go to your Distil <a href="http://www.distilnetworks.com/">management console</a>, find your auth token, add domain UUID and hit save.', 'simple_distil') ;
echo '<br/>' ;
_e('If you want to clear cache click on clear cache button, be sure to clear the cache across the entire site!', 'simple_distil') ;
echo '<br/><br/>' ;
_e('That\'s all, you\'re ready to go.', 'simple_distil') ;
?>
</p>
<form method="post" action="options.php" id="distil_form">
<?php settings_fields('distil-settings-group'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row" style="width: 300px; text-align:right;"><?php _e('Distil Auth Token', 'simple_distil') ; ?></th>
<td>
<input type="text" size="80" name="distil_api" value="<?php echo get_option('distil_api'); ?>">
</td>
</tr>
<tr valign="top">
<th scope="row" style="width: 300px; text-align:right;"><?php _e('UUID', 'UUID') ; ?></th>
<td>
<input type="text" size="80" name="UUID" value="<?php echo get_option('UUID'); ?>">
</td>
</tr>
</table>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Save Settings') ?>" />
</p>
</form>
<form method="post" action="" >
<h2><?php echo $msg;?><h2>
<p class="submit">
<input type="submit" class="button-primary" value="<?php _e('Clear Cache') ?>" name="clear_cache"/>
</p>
</form>
<p>
<?php
_e('Get your own Distil account now - <a href="https://portal.distilnetworks.com">https://portal.distilnetworks.com/</a>', 'simple_distil') ;
?>
</p>
</div>
<?php
}
?>