Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added generic filter on the show-optin option key
Browse files Browse the repository at this point in the history
renventura committed Jan 22, 2025
1 parent 226448f commit ee61ade
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Telemetry/Opt_In/Opt_In_Template.php
Original file line number Diff line number Diff line change
@@ -133,6 +133,22 @@ public function get_option_name( string $stellar_slug ) {
$stellar_slug
);

/**
* Filters the name of the option stored in the options table.
* This filter can be used to apply a generic option name.
* Usage of this filter is highly discouraged.
*
* @since 2.3
*
* @param string $option_name
* @param string $stellar_slug The current stellar slug.
*/
$option_name = apply_filters(
'stellarwp/telemetry/show_optin_option_name',
$option_name,
$stellar_slug
);

/**
* Filters the name of the option stored in the options table.
*
1 change: 1 addition & 0 deletions tests/wpunit/TemplateTest.php
Original file line number Diff line number Diff line change
@@ -117,6 +117,7 @@ static function ( string $_template_file, bool $require_once, array $args ) use
public function test_get_option_name() {
$template = Config::get_container()->get( Opt_In_Template::class );

$this->assertSame( 'stellarwp_telemetry_show_optin', $template->get_option_name( self::PLUGIN_SLUG ) );
$this->assertSame( 'stellarwp_telemetry_' . self::PLUGIN_SLUG . '_show_optin', $template->get_option_name( self::PLUGIN_SLUG ) );
}

0 comments on commit ee61ade

Please sign in to comment.