�S93� 'e�1 ����A � 6 93� � 93� �!93� @ ��A 6 6 P 93� @ �������� �������������������������������������������� ����X�93� ����2xY �Ⱦ�A ]93� ������� ����A P:3� BW�1 ����A �Q93� ����2��{r�ྷA �w(3� 6 6 (!93� 8!93� @ Pr�A 6 6 !93� P!93� h!93� 6 �93� �93� 93� ���������������������������� ���� ��������������������@�:� �����ǰ���~����A hP:� ������| �8��A ��3� ����ʚyӱ� ���A ����#�R�}��(��A `T93� 'e�1 ����A x"93� @ XL�A G G �"93� @ @f(3� G ���������������������������� ���� ������������������f>� ����;{Q{v�9�>� �f>� ����Xs�|p��� �>� �:� �����ǰ���~��3�>� ؘ�A ������| ���>� P93� 'e�1 � �>� P$93� @ XL�A G G �#93� @ �k�A G G $93� @ ������������ ������������ ���� ����������������������:� �����ǰ���~����A ���A ������| �8��A ȭ�3� ����ʚyӱ� ���A ����#�R�}��(��A H%93� �'93� @ R(3� M @ `T(3� M M %93� @ (�A N N ���������������������������� ���� ��������������������@�:� �����ǰ���~����A ���A ������| �8��A ���3� ����ʚyӱ� ���A (�A O O &93� � O 0&93� O &93� @&93� @ (�A P P �&93� @ P�'3� ���������������������������� ���� ��������������������HC:� �����ǰ���~����A ���A ������| �8��A X��3� ����ʚyӱ� ���A @ ��'3� S S '93� @'93� Q �&93� �&93� O p&93� �&93� �'93� O �'93� D N U oY83� ���������������������������� ���� ��������������������Pq:� �����ǰ���~����A ���A ������| �8��A ��3� ����ʚyӱ� ���A 093� �"93� x$93� X(93� E W wY83� �j63� (83� �
93� h(93� ���������������������������� ���� ����������������������:� �����ǰ���~����A ���A ������| �8��A ��3� ����ʚyӱ� ���A ���A a @ ��_3� a a �)93� a �)93� �:3� � a �493� � b �������� ���������������� ����������������������������������A ������| �8��A PQ93� ����2��{r�ྷA ��3� ����ʚyӱ� ���A X��3� ����ʚyӱ� ���A (+93� �+93� @ ���A c c h+93� c �*93� �*93� 8+93� c �*93� ���������������������������� ���� ���������������������J>� �����ǰ���~����A ���A ������| �8��A x��3� ����ʚyӱ� ���A �,93� @ ��A f f �,93� f �,93� e 8,93� P,93� � e �,93� ������������ ������������ ���� ����������������������:� �����ǰ���~����A ���A ������| �8��A ��3� ����ʚyӱ� ���A ����#�R�}��(��A h-93� �-93� � i �-93� i -93� (-93� �-93� i .93� � j �������� �������������������� ������������������������_93� ����2xY �Ⱦ�A p�;3� ���� �p1 �ȋ�A (�;3� �����/������)�A ����#�R�}��(��A k @ �A k k /93� @ �4)3� k � k k ������������ ������������ ���� ���������������������5:� �����ǰ���~����A ���A ������| �8��A emaining days, hours, minutes & seconds for the promotion
*
* @since 3.7.4
*
* @return array
*/
private function get_countdown_data() {
$data = [
'days' => 0,
'hours' => 0,
'minutes' => 0,
'seconds' => 0,
];
if ( rocket_get_constant( 'WP_ROCKET_IS_TESTING', false ) ) {
return $data;
}
$promo_end = $this->pricing->get_promo_end();
if ( 0 === $promo_end ) {
return $data;
}
$now = date_create();
$end = date_timestamp_set( date_create(), $promo_end );
if ( $now > $end ) {
return $data;
}
$remaining = date_diff( $now, $end );
$format = explode( ' ', $remaining->format( '%d %H %i %s' ) );
$data['days'] = $format[0];
$data['hours'] = $format[1];
$data['minutes'] = $format[2];
$data['seconds'] = $format[3];
return $data;
}
/**
* Get upgrade types
*
* @return array
*/
private function get_upgrade_types(): array {
$types = [];
foreach ( $this->get_upgrade_choices() as $choice_key => $choice ) {
$types[] = 'stacked' === $choice_key ? end( $choice )['name'] : $choice['name'];
}
return $types;
}
/**
* Returns the promotion message to display in the banner
*
* @param string $promo_name Name of the promotion.
* @param int $promo_discount Discount percentage.
*
* @return string
*/
private function get_promo_message( $promo_name = '', $promo_discount = 0 ) {
$license_types = $this->get_upgrade_types();
return sprintf(
// translators: %1$s = promotion name, %2$s =
, %3$s = , %4$s = promotion discount percentage, %5$s = , %6$s = Growth or Multi.
esc_html__(
'Take advantage of %1$s to speed up more websites:%2$s get a %3$s%4$s off%5$s for %3$supgrading your license to %6$s!%5$s',
'rocket'
),
$promo_name,
'
',
'',
$promo_discount . '%',
'',
implode( ' ' . esc_html__( 'or', 'rocket' ) . ' ', $license_types ),
);
}
/**
* Checks if current user can use the promotion
*
* @since 3.7.4
*
* @return boolean
*/
private function can_use_promo() {
if ( rocket_get_constant( 'WP_ROCKET_WHITE_LABEL_ACCOUNT' ) ) {
return false;
}
if ( ! $this->can_upgrade() ) {
return false;
}
if ( $this->is_expired_soon() ) {
return false;
}
if ( $this->is_new_user() ) {
return false;
}
return $this->pricing->is_promo_active();
}
/**
* Checks if the license expires in less than 30 days
*
* @return boolean
*/
private function is_expired_soon() {
$expiration_delay = $this->user->get_license_expiration() - time();
return 30 * DAY_IN_SECONDS > $expiration_delay;
}
/**
* Checks if the User license bought less than 14 days
*
* @return boolean
*/
private function is_new_user() {
return ( 14 * DAY_IN_SECONDS ) > time() - $this->user->get_creation_date();
}
/**
* Checks if the current license can upgrade
*
* @return boolean
*/
private function can_upgrade() {
return (
! $this->user->is_license_expired()
&&
! empty( $this->user->get_available_upgrades() )
);
}
/**
* Gets the upgrade choices depending on the current license level
*
* @return array
*/
private function get_upgrade_choices() {
$choices = [];
foreach ( $this->user->get_available_upgrades() as $available_upgrade ) {
$upgrade_data = $this->get_generic_upgrade_data( $available_upgrade );
if ( ! empty( $available_upgrade->stack ) && ! empty( $available_upgrade->slug ) ) {
if ( ! isset( $choices['stacked'] ) ) {
$choices['stacked'] = [];
}
$choices['stacked'][ $available_upgrade->slug ] = $upgrade_data;
continue;
}
$choices[ $available_upgrade->slug ] = $upgrade_data;
}
return $choices;
}
/**
* Prepare the upgrade array based on the upgrade object from the API.
*
* @param object $upgrade_item Upgrade item object from the API.
* @return array
*/
private function get_generic_upgrade_data( $upgrade_item ) {
$data = [
'name' => $upgrade_item->name,
'price' => $this->pricing->is_promo_active() ? $upgrade_item->saving : $upgrade_item->regular_price,
'websites' => $upgrade_item->websites,
'upgrade_url' => $upgrade_item->upgrade_url,
];
if ( $this->pricing->is_promo_active() ) {
$data['saving'] = $upgrade_item->regular_price - $upgrade_item->saving;
$data['regular_price'] = $upgrade_item->regular_price;
}
return $data;
}
}