Skip to content

Commit

Permalink
integration options bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
froger-me committed Jan 9, 2024
1 parent ac1a607 commit be6cdab
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class WP_Package_Updater {
private $type;
private $use_license;
private $package_id;

private static $json_options;
private $json_options;

public function __construct( $package_file_path, $package_path ) {
global $wp_filesystem;
Expand Down Expand Up @@ -548,16 +547,16 @@ protected function get_option( $option ) {
WP_Filesystem();
}

if ( ! isset( self::$json_options ) ) {
if ( ! isset( $this->json_options ) ) {
$wppus_json = $wp_filesystem->get_contents( $this->package_path . 'wppus.json' );

if ( $wppus_json ) {
self::$json_options = json_decode( $wppus_json, true );
$this->json_options = json_decode( $wppus_json, true );
}
}

if ( isset( self::$json_options[ $option ] ) ) {
return self::$json_options[ $option ];
if ( isset( $this->json_options[ $option ] ) ) {
return $this->json_options[ $option ];
}

return '';
Expand All @@ -572,17 +571,17 @@ protected function update_option( $option, $value ) {
WP_Filesystem();
}

if ( ! isset( self::$json_options ) ) {
if ( ! isset( $this->json_options ) ) {
$wppus_json = $wp_filesystem->get_contents( $this->package_path . 'wppus.json' );

if ( $wppus_json ) {
self::$json_options = json_decode( $wppus_json, true );
$this->json_options = json_decode( $wppus_json, true );
}
}

self::$json_options[ $option ] = $value;
$this->json_options[ $option ] = $value;
$wppus_json = wp_json_encode(
self::$json_options,
$this->json_options,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);

Expand All @@ -598,25 +597,25 @@ protected function delete_option( $option ) {
WP_Filesystem();
}

if ( ! isset( self::$json_options ) ) {
if ( ! isset( $this->json_options ) ) {
$wppus_json = $wp_filesystem->get_contents( $this->package_path . 'wppus.json' );

if ( $wppus_json ) {
self::$json_options = json_decode( $wppus_json, true );
$this->json_options = json_decode( $wppus_json, true );
}
}

$save = false;

if ( isset( self::$json_options[ $option ] ) ) {
if ( isset( $this->json_options[ $option ] ) ) {
$save = true;

unset( self::$json_options[ $option ] );
unset( $this->json_options[ $option ] );
}

if ( $save ) {
$wppus_json = wp_json_encode(
self::$json_options,
$this->json_options,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);

Expand All @@ -633,15 +632,15 @@ protected function save_wppus_options() {
WP_Filesystem();
}

if ( ! isset( self::$json_options ) ) {
if ( ! isset( $this->json_options ) ) {
$wppus_json = $wp_filesystem->get_contents( $this->package_path . 'wppus.json' );

if ( $wppus_json ) {
self::$json_options = json_decode( $wppus_json, true );
$this->json_options = json_decode( $wppus_json, true );
}
}

update_option( 'wppus_' . $this->package_slug . '_options', self::$json_options );
update_option( 'wppus_' . $this->package_slug . '_options', $this->json_options );
}

protected function restore_wppus_options() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class WP_Package_Updater {
private $type;
private $use_license;
private $package_id;

private static $json_options;
private $json_options;

public function __construct( $package_file_path, $package_path ) {
global $wp_filesystem;
Expand Down Expand Up @@ -548,16 +547,16 @@ protected function get_option( $option ) {
WP_Filesystem();
}

if ( ! isset( self::$json_options ) ) {
if ( ! isset( $this->json_options ) ) {
$wppus_json = $wp_filesystem->get_contents( $this->package_path . 'wppus.json' );

if ( $wppus_json ) {
self::$json_options = json_decode( $wppus_json, true );
$this->json_options = json_decode( $wppus_json, true );
}
}

if ( isset( self::$json_options[ $option ] ) ) {
return self::$json_options[ $option ];
if ( isset( $this->json_options[ $option ] ) ) {
return $this->json_options[ $option ];
}

return '';
Expand All @@ -572,17 +571,17 @@ protected function update_option( $option, $value ) {
WP_Filesystem();
}

if ( ! isset( self::$json_options ) ) {
if ( ! isset( $this->json_options ) ) {
$wppus_json = $wp_filesystem->get_contents( $this->package_path . 'wppus.json' );

if ( $wppus_json ) {
self::$json_options = json_decode( $wppus_json, true );
$this->json_options = json_decode( $wppus_json, true );
}
}

self::$json_options[ $option ] = $value;
$this->json_options[ $option ] = $value;
$wppus_json = wp_json_encode(
self::$json_options,
$this->json_options,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);

Expand All @@ -598,25 +597,25 @@ protected function delete_option( $option ) {
WP_Filesystem();
}

if ( ! isset( self::$json_options ) ) {
if ( ! isset( $this->json_options ) ) {
$wppus_json = $wp_filesystem->get_contents( $this->package_path . 'wppus.json' );

if ( $wppus_json ) {
self::$json_options = json_decode( $wppus_json, true );
$this->json_options = json_decode( $wppus_json, true );
}
}

$save = false;

if ( isset( self::$json_options[ $option ] ) ) {
if ( isset( $this->json_options[ $option ] ) ) {
$save = true;

unset( self::$json_options[ $option ] );
unset( $this->json_options[ $option ] );
}

if ( $save ) {
$wppus_json = wp_json_encode(
self::$json_options,
$this->json_options,
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);

Expand All @@ -633,15 +632,15 @@ protected function save_wppus_options() {
WP_Filesystem();
}

if ( ! isset( self::$json_options ) ) {
if ( ! isset( $this->json_options ) ) {
$wppus_json = $wp_filesystem->get_contents( $this->package_path . 'wppus.json' );

if ( $wppus_json ) {
self::$json_options = json_decode( $wppus_json, true );
$this->json_options = json_decode( $wppus_json, true );
}
}

update_option( 'wppus_' . $this->package_slug . '_options', self::$json_options );
update_option( 'wppus_' . $this->package_slug . '_options', $this->json_options );
}

protected function restore_wppus_options() {
Expand Down

0 comments on commit be6cdab

Please sign in to comment.