Skip to content
Merged
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
91 changes: 0 additions & 91 deletions classes/controllers/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ public static function menu() {

$menu_name = FrmAppHelper::get_menu_name();
add_menu_page( 'Formidable', $menu_name, 'frm_view_forms', 'formidable', 'FrmFormsController::route', self::menu_icon(), self::get_menu_position() );

self::maybe_add_black_friday_submenu_item();
}

/**
Expand All @@ -42,82 +40,6 @@ private static function menu_icon() {
return apply_filters( 'frm_icon', $icon );
}

/**
* @since 6.16
*
* @return void
*/
private static function maybe_add_black_friday_submenu_item() {
if ( ! current_user_can( 'frm_change_settings' ) ) {
return;
}

$is_black_friday = self::is_black_friday();
$is_cyber_monday = self::is_cyber_monday();

if ( ! $is_black_friday && ! $is_cyber_monday ) {
return;
}

$black_friday_menu_label = $is_black_friday ? __( 'Black Friday!', 'formidable' ) : __( 'Cyber Monday!', 'formidable' );
$black_friday_menu_label = '<span class="frm-orange-text">' . esc_html( $black_friday_menu_label ) . '</span>';

add_action(
'admin_menu',
function () use ( $black_friday_menu_label ) {
add_submenu_page(
'formidable',
'Formidable',
$black_friday_menu_label,
'frm_change_settings',
'formidable-black-friday',
function () {
// This function should do nothing. The redirect is handled earlier to avoid header conflicts.
}
);
},
1000
);
}

/**
* Black Friday sale is from November 25 to 29.
*
* @since 6.16
*
* @return bool
*/
private static function is_black_friday() {
return self::within_sale_date_range( '2024-11-25', '2024-11-29' );
}

/**
* Cyber Monday sale rules from November 30 to December 4.
*
* @since 6.16
*
* @return bool
*/
private static function is_cyber_monday() {
return self::within_sale_date_range( '2024-11-30', '2024-12-04' );
}

/**
* Check if the current time is within a sale date range.
* Our sales are based on Eastern Time, so we use New York's timezone.
*
* @since 6.16
*
* @param string $from The beginning of the date range. Y-m-d format is expected.
* @param string $to The end of the date range. Y-m-d format is expected.
* @return bool
*/
private static function within_sale_date_range( $from, $to ) {
$date = new DateTime( 'now', new DateTimeZone( 'America/New_York' ) );
$today = $date->format( 'Y-m-d' );
return $today >= $from && $today <= $to;
}

/**
* @since 3.0
*/
Expand Down Expand Up @@ -640,19 +562,6 @@ public static function admin_init() {
die();
}

if ( 'formidable-black-friday' === FrmAppHelper::get_param( 'page' ) && current_user_can( 'frm_change_settings' ) ) {
wp_redirect(
FrmAppHelper::admin_upgrade_link(
array(
'medium' => 'black-friday-submenu',
'content' => self::is_cyber_monday() ? 'cyber-monday-submenu' : 'black-friday-submenu',
),
'black-friday'
)
);
die();
}

// Register personal data hooks.
new FrmPersonalData();

Expand Down