PluginProbe
Migrate to WordPress.com / 5.72
Migrate to WordPress.com v5.72
6.72 6.65 trunk 5.72 5.81 5.88
wpcom-migration / wp_admin.php

wp_admin.php in Migrate to WordPress.com 5.72, at wp_admin.php

173 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) exit;
4 if (!class_exists('WPCOMWPAdmin')) :
5 class WPCOMWPAdmin {
6 public $settings;
7 public $siteinfo;
8 public $bvinfo;
9 public $bvapi;
10
11 function __construct($settings, $siteinfo, $bvapi = null) {
12 $this->settings = $settings;
13 $this->siteinfo = $siteinfo;
14 $this->bvapi = $bvapi;
15 $this->bvinfo = new WPCOMInfo($this->settings);
16 }
17
18 public function mainUrl($_params = '') {
19 if (function_exists('network_admin_url')) {
20 return network_admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
21 } else {
22 return admin_url('admin.php?page='.$this->bvinfo->plugname.$_params);
23 }
24 }
25
26 function removeAdminNotices() {
27 if (array_key_exists('page', $_REQUEST) && $_REQUEST['page'] == $this->bvinfo->plugname) {
28 remove_all_actions('admin_notices');
29 remove_all_actions('all_admin_notices');
30 }
31 }
32
33 public function initHandler() {
34 if (!current_user_can('activate_plugins'))
35 return;
36
37 if ($this->bvinfo->isActivateRedirectSet()) {
38 $this->settings->updateOption($this->bvinfo->plug_redirect, 'no');
39 if (!wp_doing_ajax()) {
40 wp_redirect($this->mainUrl());
41 }
42 }
43 }
44
45 public function menu() {
46 $brand = $this->bvinfo->getBrandInfo();
47 if (!is_array($brand) || (!array_key_exists('hide', $brand) && !array_key_exists('hide_from_menu', $brand))) {
48 $bname = $this->bvinfo->getBrandName();
49 $icon = $this->bvinfo->getBrandIcon();
50 add_menu_page($bname, $bname, 'manage_options', $this->bvinfo->plugname,
51 array($this, 'adminPage'), plugins_url($icon, __FILE__ ));
52 }
53 }
54
55 public function hidePluginDetails($plugin_metas, $slug) {
56 $brand = $this->bvinfo->getBrandInfo();
57 $bvslug = $this->bvinfo->slug;
58
59 if ($slug === $bvslug && is_array($brand) && array_key_exists('hide_plugin_details', $brand)) {
60 foreach ($plugin_metas as $pluginKey => $pluginValue) {
61 if (strpos($pluginValue, sprintf('>%s<', translate('View details')))) {
62 unset($plugin_metas[$pluginKey]);
63 break;
64 }
65 }
66 }
67 return $plugin_metas;
68 }
69
70 public function settingsLink($links, $file) {
71 if ( $file == plugin_basename( dirname(__FILE__).'/wpcom_migration.php' ) ) {
72 $links[] = '<a href="'.$this->mainUrl().'">'.__( 'Settings' ).'</a>';
73 }
74 return $links;
75 }
76
77 public function wpcomsecAdminMenu($hook) {
78 if ($hook === 'toplevel_page_wpcom-migration') {
79 wp_enqueue_style('wpcom-variables', plugins_url('assets/css/variables.css', __FILE__));
80 wp_enqueue_style('wpcom-styles', plugins_url('assets/css/style.css', __FILE__));
81 wp_enqueue_style('wpcom-fonts', plugins_url('assets/css/fonts.css', __FILE__));
82 }
83 }
84
85 public function getPluginLogo() {
86 $brand = $this->bvinfo->getBrandInfo();
87 if ($brand && array_key_exists('logo', $brand)) {
88 return $brand['logo'];
89 }
90 return $this->bvinfo->logo;
91 }
92
93 public function getWebPage() {
94 $brand = $this->bvinfo->getBrandInfo();
95 if ($brand && array_key_exists('webpage', $brand)) {
96 return $brand['webpage'];
97 }
98 return $this->bvinfo->webpage;
99 }
100
101 public function siteInfoTags() {
102 require_once dirname( __FILE__ ) . '/recover.php';
103 $secret = WPCOMRecover::defaultSecret($this->settings);
104 $public = WPCOMAccount::getApiPublicKey($this->settings);
105 $tags = "<input type='hidden' name='url' value='".esc_attr($this->siteinfo->wpurl())."'/>\n".
106 "<input type='hidden' name='homeurl' value='".esc_attr($this->siteinfo->homeurl())."'/>\n".
107 "<input type='hidden' name='siteurl' value='".esc_attr($this->siteinfo->siteurl())."'/>\n".
108 "<input type='hidden' name='dbsig' value='".esc_attr($this->siteinfo->dbsig(false))."'/>\n".
109 "<input type='hidden' name='plug' value='".esc_attr($this->bvinfo->plugname)."'/>\n".
110 "<input type='hidden' name='adminurl' value='".esc_attr($this->mainUrl())."'/>\n".
111 "<input type='hidden' name='bvversion' value='".esc_attr($this->bvinfo->version)."'/>\n".
112 "<input type='hidden' name='serverip' value='".esc_attr($_SERVER["SERVER_ADDR"])."'/>\n".
113 "<input type='hidden' name='abspath' value='".esc_attr(ABSPATH)."'/>\n".
114 "<input type='hidden' name='secret' value='".esc_attr($secret)."'/>\n".
115 "<input type='hidden' name='public' value='".esc_attr($public)."'/>\n";
116 return $tags;
117 }
118
119 public function activateWarning() {
120 global $hook_suffix;
121 if (!WPCOMAccount::isConfigured($this->settings) && $hook_suffix == 'index.php' ) {
122 ?>
123 <div id="message" class="updated" style="padding: 8px; font-size: 16px; background-color: #dff0d8">
124 <a class="button-primary" href="<?php echo esc_url($this->mainUrl()); ?>">Activate DreamHost Automated Migration</a>
125 &nbsp;&nbsp;&nbsp;<b>Almost Done:</b> Activate your DreamHost account to migrate your site.
126 </div>
127 <?php
128 }
129 }
130
131 public function adminPage() {
132 require_once dirname( __FILE__ ) . '/admin/main_page.php';
133 }
134
135 public function initWhitelabel($plugins) {
136 $slug = $this->bvinfo->slug;
137
138 if (!is_array($plugins) || !isset($slug, $plugins)) {
139 return $plugins;
140 }
141
142 $brand = $this->bvinfo->getBrandInfo();
143 if (is_array($brand)) {
144 if (array_key_exists('hide', $brand)) {
145 unset($plugins[$slug]);
146 } else {
147 if (array_key_exists('name', $brand)) {
148 $plugins[$slug]['Name'] = $brand['name'];
149 }
150 if (array_key_exists('title', $brand)) {
151 $plugins[$slug]['Title'] = $brand['title'];
152 }
153 if (array_key_exists('description', $brand)) {
154 $plugins[$slug]['Description'] = $brand['description'];
155 }
156 if (array_key_exists('authoruri', $brand)) {
157 $plugins[$slug]['AuthorURI'] = $brand['authoruri'];
158 }
159 if (array_key_exists('author', $brand)) {
160 $plugins[$slug]['Author'] = $brand['author'];
161 }
162 if (array_key_exists('authorname', $brand)) {
163 $plugins[$slug]['AuthorName'] = $brand['authorname'];
164 }
165 if (array_key_exists('pluginuri', $brand)) {
166 $plugins[$slug]['PluginURI'] = $brand['pluginuri'];
167 }
168 }
169 }
170 return $plugins;
171 }
172 }
173 endif;