wp_admin.php
5.53 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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
if (!defined('ABSPATH')) exit;
if (!class_exists('PTNWPAdmin')) :
class PTNWPAdmin {
public $settings;
public $siteinfo;
public $bvinfo;
public $bvapi;
function __construct($settings, $siteinfo, $bvapi = null) {
$this->settings = $settings;
$this->siteinfo = $siteinfo;
$this->bvapi = $bvapi;
$this->bvinfo = new PTNInfo($this->settings);
}
public function mainUrl($_params = '') {
if (function_exists('network_admin_url')) {
return network_admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
} else {
return admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
}
}
function removeAdminNotices() {
if (array_key_exists('page', $_REQUEST) && $_REQUEST['page'] == $this->bvinfo->plugname) {
remove_all_actions('admin_notices');
remove_all_actions('all_admin_notices');
}
}
public function initHandler() {
if (!current_user_can('activate_plugins'))
return;
if ($this->bvinfo->isActivateRedirectSet()) {
$this->settings->updateOption($this->bvinfo->plug_redirect, 'no');
wp_redirect($this->mainUrl());
}
}
public function menu() {
$brand = $this->bvinfo->getBrandInfo();
if (!is_array($brand) || (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand))) {
$bname = $this->bvinfo->getBrandName();
$icon = $this->bvinfo->getBrandIcon();
add_menu_page($bname, $bname, 'manage_options', $this->bvinfo->plugname,
array($this, 'adminPage'), plugins_url($icon, __FILE__ ));
}
}
public function hidePluginDetails($plugin_metas, $slug) {
$brand = $this->bvinfo->getBrandInfo();
$bvslug = $this->bvinfo->slug;
if ($slug === $bvslug && is_array($brand) && array_key_exists('hide_plugin_details', $brand)) {
foreach ($plugin_metas as $pluginKey => $pluginValue) {
if (strpos($pluginValue, sprintf('>%s<', translate('View details')))) {
unset($plugin_metas[$pluginKey]);
break;
}
}
}
return $plugin_metas;
}
public function settingsLink($links, $file) {
if ( $file == plugin_basename( dirname(__FILE__).'/pantheon.php' ) ) {
$links[] = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>';
}
return $links;
}
public function ptnsecAdminMenu($hook) {
if ($hook === 'toplevel_page_pantheon') {
wp_enqueue_style( 'ptnsurface', plugins_url( 'css/style.css', __FILE__));
wp_enqueue_style('ptnsurface');
}
}
public function getPluginLogo() {
$brand = $this->bvinfo->getBrandInfo();
if ($brand && array_key_exists('logo', $brand)) {
return $brand['logo'];
}
return $this->bvinfo->logo;
}
public function getWebPage() {
$brand = $this->bvinfo->getBrandInfo();
if ($brand && array_key_exists('webpage', $brand)) {
return $brand['webpage'];
}
return $this->bvinfo->webpage;
}
public function siteInfoTags() {
require_once dirname( __FILE__ ) . '/recover.php';
$secret = PTNRecover::defaultSecret($this->settings);
$public = PTNAccount::getApiPublicKey($this->settings);
$tags = "<input type='hidden' name='url' value='".esc_attr($this->siteinfo->wpurl())."'/>\n".
"<input type='hidden' name='homeurl' value='".esc_attr($this->siteinfo->homeurl())."'/>\n".
"<input type='hidden' name='siteurl' value='".esc_attr($this->siteinfo->siteurl())."'/>\n".
"<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n".
"<input type='hidden' name='plug' value='".esc_attr($this->bvinfo->plugname)."'/>\n".
"<input type='hidden' name='adminurl' value='".esc_attr($this->mainUrl())."'/>\n".
"<input type='hidden' name='bvversion' value='".esc_attr($this->bvinfo->version)."'/>\n".
"<input type='hidden' name='serverip' value='".esc_attr($_SERVER["SERVER_ADDR"])."'/>\n".
"<input type='hidden' name='abspath' value='".esc_attr(ABSPATH)."'/>\n".
"<input type='hidden' name='secret' value='".esc_attr($secret)."'/>\n".
"<input type='hidden' name='public' value='".esc_attr($public)."'/>\n";
return $tags;
}
public function activateWarning() {
global $hook_suffix;
if (!PTNAccount::isConfigured($this->settings) && $hook_suffix == 'index.php' ) {
?>
<div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
<a class="button-primary" href="<?php echo esc_url($this->mainUrl()); ?>">Activate Pantheon</a>
<b>Almost Done:</b> Activate your Pantheon account to migrate your site.
</div>
<?php
}
}
public function adminPage() {
require_once dirname( __FILE__ ) . '/admin/main_page.php';
}
public function initBranding($plugins) {
$slug = $this->bvinfo->slug;
if (!is_array($plugins) || !isset($slug, $plugins)) {
return $plugins;
}
$brand = $this->bvinfo->getBrandInfo();
if (is_array($brand)) {
if (array_key_exists('hide', $brand)) {
unset($plugins[$slug]);
} else {
if (array_key_exists('name', $brand)) {
$plugins[$slug]['Name'] = $brand['name'];
}
if (array_key_exists('title', $brand)) {
$plugins[$slug]['Title'] = $brand['title'];
}
if (array_key_exists('description', $brand)) {
$plugins[$slug]['Description'] = $brand['description'];
}
if (array_key_exists('authoruri', $brand)) {
$plugins[$slug]['AuthorURI'] = $brand['authoruri'];
}
if (array_key_exists('author', $brand)) {
$plugins[$slug]['Author'] = $brand['author'];
}
if (array_key_exists('authorname', $brand)) {
$plugins[$slug]['AuthorName'] = $brand['authorname'];
}
if (array_key_exists('pluginuri', $brand)) {
$plugins[$slug]['PluginURI'] = $brand['pluginuri'];
}
}
}
return $plugins;
}
}
endif;