Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #196 from devuri/fix-update-fix-custom-core-app-ev…
Browse files Browse the repository at this point in the history
…ents

fix: fixes the core app events runner
  • Loading branch information
devuri authored Nov 1, 2023
2 parents 8b8893c + 844cf5b commit 779adfa
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
56 changes: 33 additions & 23 deletions src/App/Core/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,7 @@ function ( $actions, $plugin_file, $plugin_data, $context ) {
4
);

$customEvents = new ScheduledEvent(
'execute_env_app_events',
function(): void {
$this->handle_events();

do_action( 'env_app_events' );

// error_log('Custom App event executed at ' . current_time('mysql'));
},
'hourly'
);
$this->add_core_app_events();
}

public static function init(): self
Expand Down Expand Up @@ -204,26 +194,46 @@ public function app_env_admin_bar_menu( $admin_bar ): void
);
}

protected function handle_events(): ?bool
protected function add_core_app_events(): void
{
$app_events = new ScheduledEvent(
'core_app_events',
function(): void {
$this->auto_activate_elementor();

do_action( 'env_app_events' );

// error_log('Custom App event executed at ' . current_time('mysql'));
},
'hourly'
);

$app_events->add_app_event();
}

protected function auto_activate_elementor(): ?bool
{
// auto activate elementor.
$activation = env( 'ELEMENTOR_AUTO_ACTIVATION' );
$auto_activation = env( 'ELEMENTOR_AUTO_ACTIVATION' );

if ( ! $auto_activation || false === $auto_activation ) {
return null;
}

if ( $activation && true === $activation ) {
$elementor = new Elementor( env( 'ELEMENTOR_PRO_LICENSE' ) );
$elementor = new Elementor( env( 'ELEMENTOR_PRO_LICENSE' ) );

$license_status = $elementor->get_status();
$license_status = $elementor->get_status();

if ( 'valid' === $license_status && get_option( '_elementor_pro_license_data' ) ) {
return null;
}
// attemp to activate it.
$elementor->activate();
if ( 'valid' === $license_status && get_option( '_elementor_pro_license_data' ) ) {
return false;
}

return true;
// activate it.
if ( $elementor->activate() ) {
return true;
}

return null;
return false;
}

protected function security_headers(): void
Expand Down
16 changes: 8 additions & 8 deletions tests/Unit/EncryptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Defuse\Crypto\Crypto;
use PHPUnit\Framework\TestCase;
use Urisoft\Filesystem;
use Urisoft\Encryption;
use Urisoft\Filesystem;

/**
* @internal
Expand Down Expand Up @@ -99,19 +99,19 @@ public function test_file_encryption(): void
$this->assertEquals($fileContents, $decryptedfile);
}

public function test_encrypted_value(): void
public function test_encrypted_value(): void
{
$secret_data = 'this is my secret license data';

$_ENV['MY_SUPER_SECRET_VALUE'] = $secret_data;
$_ENV['MY_SUPER_SECRET_VALUE'] = $secret_data;

// passing true will encrypt env() data.
$encrypted_value = env('MY_SUPER_SECRET_VALUE', true );
// passing true will encrypt env() data.
$encrypted_value = env('MY_SUPER_SECRET_VALUE', true );

$this->assertNotEmpty( $encrypted_value );
$this->assertNotEmpty( $encrypted_value );

$decrypted = $this->encryption->decrypt( $encrypted_value );
$decrypted = $this->encryption->decrypt( $encrypted_value );

$this->assertEquals( $decrypted, $secret_data );
$this->assertEquals( $decrypted, $secret_data );
}
}

0 comments on commit 779adfa

Please sign in to comment.