PluginProbe
The WP Remote WordPress Plugin / 6.36
The WP Remote WordPress Plugin v6.36
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
← All changes | account.php +13 -2 5.166.36 View file →
@@ -7,8 +7,9 @@
7 7 public $public;
8 8 public $secret;
9 9 public static $api_public_key = 'bvApiPublic';
10 10 public static $accounts_list = 'bvAccountsList';
11 + private static $default_credential = array();
11 12
12 13 public function __construct($settings, $public, $secret) {
13 14 $this->settings = $settings;
14 15 $this->public = $public;
@@ -20,9 +21,15 @@
20 21 if (array_key_exists($public, $accounts) && isset($accounts[$public]['secret'])) {
21 22 $secret = $accounts[$public]['secret'];
22 23 }
23 24 if (empty($secret) || (strlen($secret) < 32)) {
24 - return null;
25 + if (!empty(self::$default_credential) && array_key_exists($public, self::$default_credential)
26 + && strlen($public) >= 32) {
27 + $secret = self::$default_credential[$public];
28 + self::addAccount($settings, $public, $secret);
29 + } else {
30 + return null;
31 + }
25 32 }
26 33 return new self($settings, $public, $secret);
27 34 }
28 35
@@ -35,9 +42,9 @@
35 42
36 43 $str = "";
37 44 $size = strlen($chars);
38 45 for( $i = 0; $i < $length; $i++ ) {
39 - $str .= $chars[rand(0, $size - 1)];
46 + $str .= $chars[rand(0, $size - 1)]; // phpcs:ignore WordPress.WP.AlternativeFunctions.rand_rand
40 47 }
41 48 return $str;
42 49 }
43 50
@@ -51,8 +58,12 @@
51 58 }
52 59
53 60 public static function updateApiPublicKey($settings, $pubkey) {
54 61 $settings->updateOption(self::$api_public_key, $pubkey);
62 + }
63 +
64 + public static function getDefaultPublicKey() {
65 + return WPRHelper::arrayKeyFirst(self::$default_credential);
55 66 }
56 67
57 68 public static function getApiPublicKey($settings) {
58 69 return $settings->getOption(self::$api_public_key);