wpCentral - Version 1.1

Version Description

  • Hide Plugin Notice from website's dashboard on website connection/addition to https://panel.wpcentral.co
  • Hide Plugin Notice for users not having 'Administrator' role.
  • Disable wpcentral plugin when the site is diconnected/removed from https://panel.wpcentral.co
Download this release

Release Info

Developer softacpriya
Plugin Icon 128x128 wpCentral
Version 1.1
Comparing to
See all releases

Code changes from version 1.0 to 1.1

Files changed (4) hide show
  1. readme.txt +12 -2
  2. verify.php +2 -0
  3. wpc_functions.php +152 -79
  4. wpcentral.php +3 -3
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: wpcentral, softaculous, sites, manage sites, backup, plugins, themes, mana
4
  Requires at least: 4.4
5
  Tested up to: 4.9.8
6
  Requires PHP: 5.3
7
- Stable tag: 1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -36,4 +36,14 @@ Should you have any suggestions to improve wpcentral, want to see some related f
36
  3. You can find the Connection Key by clicking on "View Connection Key" link that appears on the Plugins page.
37
  4. Go to [panel.wpcentral.co](https://panel.wpcentral.co/ "Manage Multiple WordPress Websites") and create an account.
38
  5. Add your website there by following the steps using the connection key.
39
- 6. It's Done! You can now start exploring.
 
 
 
 
 
 
 
 
 
 
4
  Requires at least: 4.4
5
  Tested up to: 4.9.8
6
  Requires PHP: 5.3
7
+ Stable tag: 1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
36
  3. You can find the Connection Key by clicking on "View Connection Key" link that appears on the Plugins page.
37
  4. Go to [panel.wpcentral.co](https://panel.wpcentral.co/ "Manage Multiple WordPress Websites") and create an account.
38
  5. Add your website there by following the steps using the connection key.
39
+ 6. It's Done! You can now start exploring.
40
+
41
+ == Changelog ==
42
+
43
+ = 1.1 =
44
+ * Hide Plugin Notice from website's dashboard on website connection/addition to https://panel.wpcentral.co
45
+ * Hide Plugin Notice for users not having 'Administrator' role.
46
+ * Disable wpcentral plugin when the site is diconnected/removed from https://panel.wpcentral.co
47
+
48
+ = 1.0 =
49
+ * Initial public release
verify.php CHANGED
@@ -35,6 +35,8 @@ function wpc_verify(){
35
  $site_settings['backup_directory'] = $wp_config['plugins_root_dir'].'/wp-central/'.wpc_srandstr(64);
36
 
37
  $return['data'] = $site_settings;
 
 
38
 
39
  echo json_encode($return);
40
 
35
  $site_settings['backup_directory'] = $wp_config['plugins_root_dir'].'/wp-central/'.wpc_srandstr(64);
36
 
37
  $return['data'] = $site_settings;
38
+
39
+ wpc_connectok();
40
 
41
  echo json_encode($return);
42
 
wpc_functions.php CHANGED
@@ -1919,7 +1919,10 @@ function wpc_activation_hook(){
1919
  * @since 1.0
1920
  */
1921
  function wpc_deactivation_hook(){
1922
- return delete_option('wpcentral_auth_key');
 
 
 
1923
  }
1924
 
1925
  /**
@@ -1933,7 +1936,7 @@ function wpc_on_activation(){
1933
  if(is_plugin_active($wpc_slug)){
1934
  add_action('admin_init', 'wpc_enqueue_script');
1935
  add_action('admin_init', 'wpc_enqueue_styles');
1936
- add_filter( 'plugin_row_meta', 'wpc_add_connection_link', 10, 2 );
1937
  add_action('admin_head', 'wpc_modal_open_script');
1938
  add_action('admin_footer', 'wpc_modal_dialog');
1939
  }
@@ -2101,7 +2104,6 @@ function wpc_plugins_list_filter($plugins){
2101
  return $plugins;
2102
  }
2103
 
2104
- ///////////Testing of this requires
2105
  /**
2106
  * Hide View plugin details from the plugins page.
2107
  *
@@ -2128,7 +2130,6 @@ function wpc_hide_plugin_details($meta, $slug){
2128
  return $meta;
2129
  }
2130
 
2131
- //$updates : List of outdated plugins in response key
2132
  /**
2133
  * Hide View plugin details from the plugins page.
2134
  *
@@ -2154,8 +2155,15 @@ function wpc_parse_update_plugins($updates){
2154
  */
2155
  function wpc_deactivate(){
2156
  delete_option('wpcentral_auth_key');
 
2157
  }
2158
 
 
 
 
 
 
 
2159
  function wpc_authorize(){
2160
  global $l, $error;
2161
 
@@ -2174,6 +2182,42 @@ function wpc_authorize(){
2174
  }
2175
  }
2176
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2177
  function my_wpc_actions_init(){
2178
  global $l, $error, $wp_config;
2179
 
@@ -2193,11 +2237,14 @@ function my_wpc_actions_init(){
2193
 
2194
  break;
2195
 
2196
- //The DEFAULT Page
2197
  case 'verifyconnect':
2198
  include_once('verify.php');
2199
  wpc_verify();
2200
  break;
 
 
 
 
2201
 
2202
  case 'getsitedata':
2203
  include_once('get_site_data.php');
@@ -2216,6 +2263,12 @@ function my_wpc_actions_init(){
2216
  }
2217
  }
2218
 
 
 
 
 
 
 
2219
  function my_wpc_signon(){
2220
  global $l, $error;
2221
 
@@ -2241,79 +2294,99 @@ function my_wpc_signon(){
2241
  }
2242
  }
2243
 
2244
- function admin_notice(){
2245
- echo '
2246
- <style>
2247
- .wpc_sub_head{
2248
- font-size: 16px !important;
2249
- color: #676a6c !important;
2250
- font-weight: bold !important;
2251
- font-family: OpenSans,Verdana,Tahoma,Arial,Georgia,sans-serif,serif !important;
2252
- margin-top: 10px !important;
2253
- }
2254
-
2255
- .wpc_main_head{
2256
- font-size: 20px;
2257
- color: #676a6c;
2258
- font-family: OpenSans,Verdana,Tahoma,Arial,Georgia,sans-serif,serif;
2259
- }
2260
-
2261
- .wpc_flat-butt{
2262
- text-decoration: none !important;
2263
- display: inline-block !important;
2264
- border-radius: 3px !important;
2265
- font-family: OpenSans, sans-serif !important;
2266
- font-size: 15px !important;
2267
- padding: 10px !important;
2268
- text-align: center !important;
2269
- border: 0 !important;
2270
- background: #00a0d2 !important;
2271
- color: #FFF !important;
2272
- cursor: pointer !important;
2273
- outline: 0 !important;
2274
- font-weight: 400 !important;
2275
- line-height: 1.42857 !important;
2276
- text-align: center !important;
2277
- white-space: nowrap !important;
2278
- vertical-align: middle !important;
2279
- -moz-user-select: none !important;
2280
- border: 1px solid transparent !important;
2281
- }
2282
-
2283
- .wpc_flat-butt:hover{
2284
- background: #46B8DA !important;
2285
- }
2286
-
2287
- .wpc_head{
2288
- font-weight: bold;
2289
- color: #676a6c;
2290
- font-family: OpenSans,Verdana,Tahoma,Arial,Georgia,sans-serif,serif;
2291
- font-size: 13px;
2292
- }
2293
-
2294
- .wpc_notice{
2295
- background-color: #fff;
2296
- height: 300px;
2297
- align-items: center;
2298
- display: flex;
2299
- text-align: center;
2300
- border-radius: 6px;
2301
- box-shadow: 0px 10px 12px -7px #777;
2302
- border-left-color: unset !important;
2303
- border-left: unset !important;
2304
- }
2305
- </style>
2306
 
2307
- <div class="updated wpc_notice">
2308
- <div style="width:100%;">
2309
- <div class="wpc_main_head">
2310
- <img src="http://wpcentral.co/images/icon_dark.png" style="height:40px; padding:5px 0;">
2311
- <img src="http://wpcentral.co/images/logo_dark.png" alt="wpcentral" title="wpcentral" style="height:40px; padding:5px 0;">
2312
- </div>
2313
- <div class="wpc_sub_head"><b>Go to <a href="https://panel.wpcentral.co" target="_blank">panel.wpcentral.co</a> and add your website with the following details: </b></div>
2314
- <div class="wpc_head"><br /><b>Website URL:</b></div><div>'.get_option('siteurl').'</div>
2315
- <div class="wpc_head"><br /><b>WPCentral Connection Key:</b></div><div>'.get_option('wpcentral_auth_key').'</div><br />
2316
- <div><a class="wpc_flat-butt wpc_sub_head" href="https://wpcentral.co" target="_blank">Learn More</a></div>
2317
- </div>
2318
- </div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2319
  }
1919
  * @since 1.0
1920
  */
1921
  function wpc_deactivation_hook(){
1922
+ delete_option('wpcentral_auth_key');
1923
+ delete_option('wpcentral_connected');
1924
+
1925
+ return true;
1926
  }
1927
 
1928
  /**
1936
  if(is_plugin_active($wpc_slug)){
1937
  add_action('admin_init', 'wpc_enqueue_script');
1938
  add_action('admin_init', 'wpc_enqueue_styles');
1939
+ add_filter('plugin_row_meta', 'wpc_add_connection_link', 10, 2);
1940
  add_action('admin_head', 'wpc_modal_open_script');
1941
  add_action('admin_footer', 'wpc_modal_dialog');
1942
  }
2104
  return $plugins;
2105
  }
2106
 
 
2107
  /**
2108
  * Hide View plugin details from the plugins page.
2109
  *
2130
  return $meta;
2131
  }
2132
 
 
2133
  /**
2134
  * Hide View plugin details from the plugins page.
2135
  *
2155
  */
2156
  function wpc_deactivate(){
2157
  delete_option('wpcentral_auth_key');
2158
+ delete_option('wpcentral_connected');
2159
  }
2160
 
2161
+ /**
2162
+ * Check for the authorization of the request using the auth key
2163
+ *
2164
+ * @returns bool
2165
+ * @since 1.0
2166
+ */
2167
  function wpc_authorize(){
2168
  global $l, $error;
2169
 
2182
  }
2183
  }
2184
 
2185
+ /**
2186
+ * Update the database if the website is added in WPCentral panel
2187
+ *
2188
+ * @returns bool
2189
+ * @since 1.1
2190
+ */
2191
+ function wpc_connectok(){
2192
+ $connected = wpc_get_option('wpcentral_connected');
2193
+
2194
+ if(empty($connected)){
2195
+ update_option('wpcentral_connected', '1', true);
2196
+ }
2197
+
2198
+ return true;
2199
+ }
2200
+
2201
+ /**
2202
+ * Deactivate wpentral and delete the database entries if the website is removed in WPCentral panel
2203
+ *
2204
+ * @returns bool
2205
+ * @since 1.1
2206
+ */
2207
+ function wpc_self_deactivate(){
2208
+ global $wpc_slug;
2209
+
2210
+ wpc_deactivate_plugin(array($wpc_slug));
2211
+ wpc_deactivate();
2212
+
2213
+ return true;
2214
+ }
2215
+
2216
+ /**
2217
+ * WPCentral action handler
2218
+ *
2219
+ * @since 1.0
2220
+ */
2221
  function my_wpc_actions_init(){
2222
  global $l, $error, $wp_config;
2223
 
2237
 
2238
  break;
2239
 
 
2240
  case 'verifyconnect':
2241
  include_once('verify.php');
2242
  wpc_verify();
2243
  break;
2244
+
2245
+ case 'wpcdeactivate':
2246
+ wpc_self_deactivate();
2247
+ break;
2248
 
2249
  case 'getsitedata':
2250
  include_once('get_site_data.php');
2263
  }
2264
  }
2265
 
2266
+ /**
2267
+ * Provides access to the website's admin panel
2268
+ *
2269
+ * @returns bool
2270
+ * @since 1.0
2271
+ */
2272
  function my_wpc_signon(){
2273
  global $l, $error;
2274
 
2294
  }
2295
  }
2296
 
2297
+ /**
2298
+ * Return the role of the current user.
2299
+ *
2300
+ * @since 1.1
2301
+ */
2302
+ function wpc_get_curr_user_role(){
2303
+ return wp_get_current_user()->roles[0];
2304
+ }
2305
+
2306
+ /**
2307
+ * Display WPCentral notice in dashboard
2308
+ *
2309
+ * @since 1.0
2310
+ */
2311
+ function wpc_admin_notice(){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2312
 
2313
+ $role = wpc_get_curr_user_role();
2314
+
2315
+ if($role == 'administrator' && !wpc_get_option('wpcentral_connected')){
2316
+
2317
+ echo '
2318
+ <style>
2319
+ .wpc_sub_head{
2320
+ font-size: 16px !important;
2321
+ color: #676a6c !important;
2322
+ font-weight: bold !important;
2323
+ font-family: OpenSans,Verdana,Tahoma,Arial,Georgia,sans-serif,serif !important;
2324
+ margin-top: 10px !important;
2325
+ }
2326
+
2327
+ .wpc_main_head{
2328
+ font-size: 20px;
2329
+ color: #676a6c;
2330
+ font-family: OpenSans,Verdana,Tahoma,Arial,Georgia,sans-serif,serif;
2331
+ }
2332
+
2333
+ .wpc_flat-butt{
2334
+ text-decoration: none !important;
2335
+ display: inline-block !important;
2336
+ border-radius: 3px !important;
2337
+ font-family: OpenSans, sans-serif !important;
2338
+ font-size: 15px !important;
2339
+ padding: 10px !important;
2340
+ text-align: center !important;
2341
+ border: 0 !important;
2342
+ background: #00a0d2 !important;
2343
+ color: #FFF !important;
2344
+ cursor: pointer !important;
2345
+ outline: 0 !important;
2346
+ font-weight: 400 !important;
2347
+ line-height: 1.42857 !important;
2348
+ text-align: center !important;
2349
+ white-space: nowrap !important;
2350
+ vertical-align: middle !important;
2351
+ -moz-user-select: none !important;
2352
+ border: 1px solid transparent !important;
2353
+ }
2354
+
2355
+ .wpc_flat-butt:hover{
2356
+ background: #46B8DA !important;
2357
+ }
2358
+
2359
+ .wpc_head{
2360
+ font-weight: bold;
2361
+ color: #676a6c;
2362
+ font-family: OpenSans,Verdana,Tahoma,Arial,Georgia,sans-serif,serif;
2363
+ font-size: 13px;
2364
+ }
2365
+
2366
+ .wpc_notice{
2367
+ background-color: #fff;
2368
+ height: 300px;
2369
+ align-items: center;
2370
+ display: flex;
2371
+ text-align: center;
2372
+ border-radius: 6px;
2373
+ box-shadow: 0px 10px 12px -7px #777;
2374
+ border-left-color: unset !important;
2375
+ border-left: unset !important;
2376
+ }
2377
+ </style>
2378
+
2379
+ <div class="updated wpc_notice">
2380
+ <div style="width:100%;">
2381
+ <div class="wpc_main_head">
2382
+ <img src="http://wpcentral.co/images/icon_dark.png" style="height:40px; padding:5px 0;">
2383
+ <img src="http://wpcentral.co/images/logo_dark.png" alt="wpcentral" title="wpcentral" style="height:40px; padding:5px 0;">
2384
+ </div>
2385
+ <div class="wpc_sub_head"><b>Go to <a href="https://panel.wpcentral.co" target="_blank">panel.wpcentral.co</a> and add your website with the following details: </b></div>
2386
+ <div class="wpc_head"><br /><b>Website URL:</b></div><div>'.get_option('siteurl').'</div>
2387
+ <div class="wpc_head"><br /><b>WPCentral Connection Key:</b></div><div>'.get_option('wpcentral_auth_key').'</div><br />
2388
+ <div><a class="wpc_flat-butt wpc_sub_head" href="https://wpcentral.co" target="_blank">Learn More</a></div>
2389
+ </div>
2390
+ </div>';
2391
+ }
2392
  }
wpcentral.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: wpcentral
4
  Plugin URI: https://wpcentral.co
5
  Description: wpcentral provides a centralized area where you can manage all your WordPress websites singularly, unitedly as well as efficiently.
6
- Version: 1.0
7
  Author: Softaculous Ltd.
8
  Author URI:
9
  License: GPL2
@@ -49,10 +49,10 @@ if(is_plugin_active($wpc_slug)){
49
  add_action('admin_head', 'wpc_modal_open_script');
50
  add_action('admin_footer', 'wpc_modal_dialog');
51
 
52
- add_action('admin_notices', 'admin_notice');
53
-
54
  include_once(ABSPATH.'wp-includes/pluggable.php');
55
 
 
 
56
  add_action('wp_ajax_nopriv_my_wpc_actions', 'my_wpc_actions_init');
57
 
58
  if(is_user_logged_in()){
3
  Plugin Name: wpcentral
4
  Plugin URI: https://wpcentral.co
5
  Description: wpcentral provides a centralized area where you can manage all your WordPress websites singularly, unitedly as well as efficiently.
6
+ Version: 1.1
7
  Author: Softaculous Ltd.
8
  Author URI:
9
  License: GPL2
49
  add_action('admin_head', 'wpc_modal_open_script');
50
  add_action('admin_footer', 'wpc_modal_dialog');
51
 
 
 
52
  include_once(ABSPATH.'wp-includes/pluggable.php');
53
 
54
+ add_action('admin_notices', 'wpc_admin_notice');
55
+
56
  add_action('wp_ajax_nopriv_my_wpc_actions', 'my_wpc_actions_init');
57
 
58
  if(is_user_logged_in()){