Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ class My_Experiment extends Abstract_Experiment {
}

/**
* Registers the experiment's hooks and functionality.
* Initializes the experiment's hooks and functionality.
*
* @since 0.1.0
*/
public function register(): void {
// Register your hooks here
public function init(): void {
// Initialize your hooks here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Initialize your hooks here
// Initializes your experiment. Use this to set up your needed hooks.

add_action( 'init', array( $this, 'initialize' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
add_filter( 'the_content', array( $this, 'filter_content' ) );
Expand Down
4 changes: 2 additions & 2 deletions includes/Abstracts/Abstract_Experiment.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ final protected function get_field_option_name( string $option_name ): string {
}

/**
* Registers the experiment.
* Initializes the experiment.
*
* Must be implemented by child classes to set up hooks and functionality.
*
* @since 0.1.0
*/
abstract public function register(): void;
abstract public function init(): void;
}
4 changes: 2 additions & 2 deletions includes/Contracts/Experiment.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ public function get_label(): string;
public function get_description(): string;

/**
* Registers the experiment's hooks and functionality.
* Initializes the experiment's hooks and functionality.
*
* This method is called when the experiment is initialized.
* Use this to add actions, filters, and set up the experiment.
*
* @since 0.1.0
*/
public function register(): void;
public function init(): void;

/**
* Checks if the experiment is currently enabled.
Expand Down
6 changes: 3 additions & 3 deletions includes/Experiment_Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private function get_default_experiments(): array {
/**
* Initializes all enabled experiments.
*
* Loops through all registered experiments and calls their register() method
* Loops through all registered experiments and calls their init() method
* if they are enabled.
*
* @since 0.1.0
Expand Down Expand Up @@ -203,8 +203,8 @@ public function initialize_experiments(): void {
continue;
}

// Register the experiment.
$experiment->register();
// Initialize the experiment.
$experiment->init();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function load_experiment_metadata(): array {
*
* @since 0.1.0
*/
public function register(): void {
public function init(): void {
add_action( 'wp_footer', array( $this, 'add_footer_content' ), 20 );
add_filter( 'document_title_parts', array( $this, 'modify_title' ), 10, 1 );
add_action( 'rest_api_init', array( $this, 'register_rest_route' ) );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function load_experiment_metadata(): array {
*
* @since x.x.x
*/
public function register(): void {
public function init(): void {
add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) );
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Experiments/Image_Generation/Image_Generation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function load_experiment_metadata(): array {
*
* @since x.x.x
*/
public function register(): void {
public function init(): void {
add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) );
}

Expand Down
2 changes: 1 addition & 1 deletion includes/Experiments/Title_Generation/Title_Generation.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function load_experiment_metadata(): array {
*
* @since 0.1.0
*/
public function register(): void {
public function init(): void {
add_action( 'wp_abilities_api_init', array( $this, 'register_abilities' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ protected function load_experiment_metadata(): array {
}

/**
* Registers the experiment.
* Initializes the experiment.
*
* @since 0.1.0
*/
public function register(): void {
public function init(): void {
// No-op for testing.
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Includes/Abilities/Image_GenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ protected function load_experiment_metadata(): array {
}

/**
* Registers the experiment.
* Initializes the experiment.
*
* @since x.x.x
*/
public function register(): void {
public function init(): void {
// No-op for testing.
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Includes/Abilities/Image_ImportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ protected function load_experiment_metadata(): array {
}

/**
* Registers the experiment.
* Initializes the experiment.
*
* @since x.x.x
*/
public function register(): void {
public function init(): void {
// No-op for testing.
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Includes/Abilities/Title_GenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ protected function load_experiment_metadata(): array {
}

/**
* Registers the experiment.
* Initializes the experiment.
*
* @since 0.1.0
*/
public function register(): void {
public function init(): void {
// No-op for testing.
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Includes/Abstracts/Abstract_AbilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ protected function load_experiment_metadata(): array {
}

/**
* Registers the experiment.
* Initializes the experiment.
*
* @since 0.1.0
*/
public function register(): void {
public function init(): void {
// No-op for testing.
}
}
Expand Down
26 changes: 13 additions & 13 deletions tests/Integration/Includes/Experiment_LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
*/
class Mock_Experiment extends Abstract_Experiment {
/**
* Tracks if register was called.
* Tracks if init was called.
*
* @var bool
*/
public $register_called = false;
public $init_called = false;

/**
* Loads experiment metadata.
Expand All @@ -41,12 +41,12 @@ protected function load_experiment_metadata(): array {
}

/**
* Registers the experiment.
* Initializes the experiment.
*
* @since 0.1.0
*/
public function register(): void {
$this->register_called = true;
public function init(): void {
$this->init_called = true;
}
}

Expand Down Expand Up @@ -183,7 +183,7 @@ function ( $registry ) {
}

/**
* Test initialize_experiments calls register on enabled experiments.
* Test initialize_experiments calls init on enabled experiments.
*
* @since 0.1.0
*/
Expand All @@ -198,8 +198,8 @@ public function test_initialize_experiments_calls_register() {
$this->loader->initialize_experiments();

$this->assertTrue(
$experiment->register_called,
'Experiment register() should be called'
$experiment->init_called,
'Experiment init() should be called'
);

// Cleanup.
Expand All @@ -220,14 +220,14 @@ public function test_initialize_experiments_prevents_double_initialization() {
$this->assertTrue( $this->loader->is_initialized(), 'Should be initialized' );

// Reset the flag to track second call.
$experiment->register_called = false;
$experiment->init_called = false;

// Try to initialize again.
$this->loader->initialize_experiments();

$this->assertFalse(
$experiment->register_called,
'Experiment register() should not be called twice'
$experiment->init_called,
'Experiment init() should not be called twice'
);
}

Expand Down Expand Up @@ -296,8 +296,8 @@ public function test_disabled_experiments_are_skipped() {
$this->loader->initialize_experiments();

$this->assertFalse(
$experiment->register_called,
'Disabled experiment register() should not be called'
$experiment->init_called,
'Disabled experiment init() should not be called'
);
}
}
4 changes: 2 additions & 2 deletions tests/Integration/Includes/Experiment_RegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ protected function load_experiment_metadata(): array {
}

/**
* Registers the experiment.
* Initializes the experiment.
*
* @since 0.1.0
*/
public function register(): void {
public function init(): void {
// No-op for testing.
}
}
Expand Down
Loading