@@ -36,11 +36,11 @@ final class Plugin extends Singleton {
3636 const GITHUB_REPO = 'https://github.com/j7-dev/wp-react-plugin ' ; // change to your repo URL
3737
3838 /**
39- * Github Personal Access Token
39+ * Plugin Update Checker Personal Access Token
4040 *
4141 * @var string
4242 */
43- public static $ github_pat ;
43+ public static $ puc_pat ;
4444
4545 /**
4646 * Plugin Directory
@@ -94,7 +94,7 @@ public function __construct() {
9494 \add_action ( 'tgmpa_register ' , array ( $ this , 'register_required_plugins ' ) );
9595 \add_action ( 'plugins_loaded ' , array ( $ this , 'check_required_plugins ' ) );
9696
97- $ this ->set_github_pat ();
97+ $ this ->set_puc_pat ();
9898 $ this ->plugin_update_checker ();
9999 }
100100
@@ -140,7 +140,7 @@ public function plugin_update_checker(): void {
140140 */
141141 $ update_checker ->setBranch ( 'master ' );
142142 // if your repo is private, you need to set authentication
143- // $update_checker->setAuthentication(self::$github_pat );
143+ // $update_checker->setAuthentication( self::$puc_pat );
144144 $ update_checker ->getVcsApi ()->enableReleaseAssets ();
145145 } catch ( \Throwable $ th ) { // phpcs:ignore
146146 // throw $th;
@@ -243,20 +243,19 @@ public function register_required_plugins(): void {
243243 }
244244
245245 /**
246- * Set Github Personal Access Token
246+ * Set Plugin Update Checker Personal Access Token
247247 *
248- * @return void
248+ * @return array
249249 */
250- private function set_github_pat () {
251- // spilt your Github personal access token into 4 parts
252- // because Github will revoke the token if it's exposed
253- $ a = array ( 'ghp_xxxx ' );
254- $ b = array ( 'xxxxxxxxx ' );
255- $ c = array ( 'xxxxxxxxx ' );
256- $ d = array ( 'xxxxxxxxx ' );
257- $ arr = array_merge ( $ a , $ b , $ c , $ d );
258- $ pat = implode ( '' , $ arr );
259- self ::$ github_pat = $ pat ;
250+ public static function set_puc_pat (): void {
251+ $ env_file = __DIR__ . '/.puc_pat ' ;
252+
253+ // Check if .env file exists
254+ if ( file_exists ( $ env_file ) ) {
255+ // Read contents of .env file
256+ $ env_contents = file_get_contents ( $ env_file );
257+ self ::$ puc_pat = trim ($ env_contents );
258+ }
260259 }
261260
262261 /**
0 commit comments