Skip to content

Commit 6642996

Browse files
chore: remove BF global notice integration via SDK
1 parent 39f1008 commit 6642996

2 files changed

Lines changed: 0 additions & 117 deletions

File tree

inc/admin.php

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ public function __construct() {
114114

115115
add_filter( 'themeisle-sdk/survey/' . OPTML_PRODUCT_SLUG, [ $this, 'get_survey_metadata' ], 10, 2 );
116116
add_action( 'admin_init', [ $this, 'mark_user_with_offload' ] );
117-
add_filter( 'themeisle_sdk_blackfriday_data', [ $this, 'add_black_friday_data' ] );
118117
}
119118

120119
/**
@@ -1650,56 +1649,6 @@ public function get_bf_notices( $user_plan ) {
16501649
return $notices;
16511650
}
16521651

1653-
/**
1654-
* Set the black friday data.
1655-
*
1656-
* @param array<string, mixed> $configs The configuration array for the loaded products.
1657-
* @return array<string, mixed> The modified configuration array.
1658-
*/
1659-
public function add_black_friday_data( $configs ) {
1660-
1661-
$service_data = $this->settings->get( 'service_data' );
1662-
$user_plan = isset( $service_data['plan'] ) ? $service_data['plan'] : 'free';
1663-
1664-
$is_free_plan = 'free' === $user_plan;
1665-
$is_monthly_plan = strpos( $user_plan, '-yearly' ) === false && ! $is_free_plan;
1666-
1667-
if ( ! $is_free_plan && ! $is_monthly_plan ) {
1668-
return $configs;
1669-
}
1670-
1671-
$config = $configs['default'];
1672-
1673-
$message = sprintf(
1674-
// translators: $1$s is the promo code, $2$s is the discount amount ('25% off')
1675-
__( 'Use coupon code %1$s for an instant %2$s on your first billing cycle on Optimole plan.', 'optimole-wp' ),
1676-
'<strong>BFCM2525</strong>',
1677-
'<strong>' . strtoupper( __( '25% off', 'optimole-wp' ) ) . '</strong>'
1678-
);
1679-
$title = __( 'Optimole Black Friday Private Sale is live!', 'optimole-wp' );
1680-
$sale_url = esc_url_raw( tsdk_utmify( self::get_upgrade_base_link(), 'bfcm25', 'global_notice' ) );
1681-
1682-
if ( $is_monthly_plan ) {
1683-
$message = sprintf(
1684-
// translators: %1$s is opening strong tag, %2$s is closing strong tag, %3$s is the discount amount ('15% off')
1685-
__( '%1$sSwitch to a yearly plan%2$s and get an instant %3$s on your payment. Contact us to redeem your deal', 'optimole-wp' ),
1686-
'<strong>',
1687-
'</strong>',
1688-
'<strong>' . strtoupper( __( '15% off', 'optimole-wp' ) ) . '</strong>'
1689-
);
1690-
$sale_url = $this->get_sale_url_for_monthly_plan();
1691-
}
1692-
1693-
$config['title'] = $title;
1694-
$config['message'] = $message;
1695-
$config['sale_url'] = $sale_url;
1696-
$config['dismiss'] = true;
1697-
1698-
$configs['optimole-wp'] = $config;
1699-
1700-
return $configs;
1701-
}
1702-
17031652
/**
17041653
* Get the sale url for yearly plan.
17051654
*

tests/test-admin.php

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -411,70 +411,4 @@ public function test_get_bf_notices_date_boundaries() {
411411
$result = $this->admin->get_bf_notices( 'free' );
412412
$this->assertNotEmpty( $result, 'Should show notices at exact end time' );
413413
}
414-
415-
/**
416-
* Test add_black_friday_data yearly plans.
417-
*/
418-
public function test_add_black_friday_data_yearly_plans() {
419-
$base_config = [ 'default' => [ 'title' => 'Base', 'message' => 'Message' ] ];
420-
// Mock settings to return a yearly plan
421-
update_option( 'optml_settings', [ 'service_data' => [ 'plan' => 'starter-yearly' ] ] );
422-
// Reinitialize admin to pick up the new settings
423-
$this->admin = new Optml_Admin();
424-
$result = $this->admin->add_black_friday_data( $base_config );
425-
$this->assertEquals( $base_config, $result );
426-
$this->assertArrayNotHasKey( 'optimole-wp', $result );
427-
}
428-
429-
/**
430-
* Test add_black_friday_data free plan.
431-
*/
432-
public function test_add_black_friday_data_free_plan() {
433-
$base_config = [ 'default' => [ 'title' => 'Base', 'message' => 'Message' ] ];
434-
// Mock settings to return a free plan
435-
update_option( 'optml_settings', [ 'service_data' => [ 'plan' => 'free' ] ] );
436-
// Reinitialize admin to pick up the new settings
437-
$this->admin = new Optml_Admin();
438-
$result = $this->admin->add_black_friday_data( $base_config );
439-
$this->assertArrayHasKey( 'optimole-wp', $result );
440-
$config = $result['optimole-wp'];
441-
$this->assertStringContainsString( 'Black Friday', $config['title'] );
442-
$this->assertStringContainsString( 'BFCM2525', $config['message'] );
443-
$this->assertStringContainsString( '25% OFF', $config['message'] );
444-
$this->assertStringContainsString( 'upgrade', $config['sale_url'] );
445-
$this->assertTrue( $config['dismiss'] );
446-
}
447-
448-
/**
449-
* Test add_black_friday_data monthly plan.
450-
*/
451-
public function test_add_black_friday_data_monthly_plan() {
452-
$base_config = [ 'default' => [ 'title' => 'Base', 'message' => 'Message' ] ];
453-
// Mock settings to return a monthly plan
454-
update_option( 'optml_settings', [ 'service_data' => [ 'plan' => 'starter' ] ] );
455-
// Reinitialize admin to pick up the new settings
456-
$this->admin = new Optml_Admin();
457-
$result = $this->admin->add_black_friday_data( $base_config );
458-
$this->assertArrayHasKey( 'optimole-wp', $result );
459-
$config = $result['optimole-wp'];
460-
$this->assertStringContainsString( 'Black Friday', $config['title'] );
461-
$this->assertStringContainsString( 'Switch to a yearly plan', $config['message'] );
462-
$this->assertStringContainsString( '15% OFF', $config['message'] );
463-
$this->assertStringContainsString( 'contact', $config['sale_url'] );
464-
$this->assertTrue( $config['dismiss'] );
465-
}
466-
467-
/**
468-
* Test get_sale_url_for_monthly_plan.
469-
*/
470-
public function test_get_sale_url_for_monthly_plan() {
471-
$reflection = new \ReflectionMethod( $this->admin, 'get_sale_url_for_monthly_plan' );
472-
$reflection->setAccessible( true );
473-
$url = $reflection->invoke( $this->admin );
474-
475-
$this->assertStringContainsString( 'contact_subject', $url );
476-
$this->assertStringContainsString( 'contact_website', $url );
477-
$this->assertStringContainsString( 'contact_description', $url );
478-
$this->assertStringContainsString( 'Upgrade%20to%20yearly%20plan', $url );
479-
}
480414
}

0 commit comments

Comments
 (0)