| @@ -64,21 +64,21 @@ | ||
| 64 | 64 | */ |
| 65 | 65 | private static function get_options() { |
| 66 | 66 | $options = get_option( self::$option_name ); |
| 67 | 67 | |
| 68 | - if ( ! $options ) { | |
| 69 | - $default_options = array( | |
| 70 | - // Do not send email within 15 days after updating. | |
| 71 | - 'last_' . self::MONTHLY => self::get_date_from_today( '-' . self::DELAY_AFTER_UPGRADE . ' days' ), | |
| 72 | - 'last_' . self::YEARLY => '', | |
| 73 | - 'renewal_date' => '', | |
| 74 | - ); | |
| 68 | + if ( $options ) { | |
| 69 | + return $options; | |
| 70 | + } | |
| 75 | 71 | |
| 76 | - self::save_options( $default_options ); | |
| 77 | - return $default_options; | |
| 78 | - } | |
| 72 | + $default_options = array( | |
| 73 | + // Do not send email within 15 days after updating. | |
| 74 | + 'last_' . self::MONTHLY => self::get_date_from_today( '-' . self::DELAY_AFTER_UPGRADE . ' days' ), | |
| 75 | + 'last_' . self::YEARLY => '', | |
| 76 | + 'renewal_date' => '', | |
| 77 | + ); | |
| 79 | 78 | |
| 80 | - return $options; | |
| 79 | + self::save_options( $default_options ); | |
| 80 | + return $default_options; | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * Saves summary emails options. |
| @@ -178,10 +178,9 @@ | ||
| 178 | 178 | // Return the actual renewal date if it exists. |
| 179 | 179 | $license_info = FrmAddonsController::get_primary_license_info(); |
| 180 | 180 | |
| 181 | 181 | if ( ! empty( $license_info['expires'] ) ) { |
| 182 | - $renewal_date = gmdate( 'Y-m-d', $license_info['expires'] ); | |
| 183 | - | |
| 182 | + $renewal_date = gmdate( 'Y-m-d', $license_info['expires'] ); | |
| 184 | 183 | $options['renewal_date'] = $renewal_date; |
| 185 | 184 | self::save_options( $options ); |
| 186 | 185 | return $renewal_date; |
| 187 | 186 | } |
| @@ -212,13 +211,9 @@ | ||
| 212 | 211 | * |
| 213 | 212 | * @return DateTime|false |
| 214 | 213 | */ |
| 215 | 214 | private static function get_date_obj( $date ) { |
| 216 | - if ( $date instanceof DateTime ) { | |
| 217 | - return $date; | |
| 218 | - } | |
| 219 | - | |
| 220 | - return date_create( $date ); | |
| 215 | + return $date instanceof DateTime ? $date : date_create( $date ); | |
| 221 | 216 | } |
| 222 | 217 | |
| 223 | 218 | /** |
| 224 | 219 | * Gets the days different between 2 dates. |
| @@ -236,13 +231,9 @@ | ||
| 236 | 231 | } |
| 237 | 232 | |
| 238 | 233 | $date2 = self::get_date_obj( $date2 ); |
| 239 | 234 | |
| 240 | - if ( ! $date2 ) { | |
| 241 | - return false; | |
| 242 | - } | |
| 243 | - | |
| 244 | - return date_diff( $date1, $date2 )->days; | |
| 235 | + return $date2 ? date_diff( $date1, $date2 )->days : false; | |
| 245 | 236 | } |
| 246 | 237 | |
| 247 | 238 | /** |
| 248 | 239 | * Gets sent date of the last monthly or yearly email. |
| @@ -401,13 +392,9 @@ | ||
| 401 | 392 | * |
| 402 | 393 | * @return string |
| 403 | 394 | */ |
| 404 | 395 | public static function get_section_style( $border_pos = 'top' ) { |
| 405 | - if ( $border_pos ) { | |
| 406 | - $border = 'border-' . $border_pos . ': 1px solid #eaecf0;'; | |
| 407 | - } else { | |
| 408 | - $border = ''; | |
| 409 | - } | |
| 396 | + $border = $border_pos ? 'border-' . $border_pos . ': 1px solid #eaecf0;' : ''; | |
| 410 | 397 | return 'padding: 3em 4.375em;' . $border; |
| 411 | 398 | } |
| 412 | 399 | |
| 413 | 400 | /** |
| @@ -426,9 +413,9 @@ | ||
| 426 | 413 | * |
| 427 | 414 | * @return string |
| 428 | 415 | */ |
| 429 | 416 | public static function get_button_style( $display_block = false ) { |
| 430 | - return 'display: ' . ( $display_block ? 'block' : 'inline-block' ) . '; font-size: 0.875em; line-height: 2.4; border-radius: 1.2em; border: 1px solid #d0d5dd; font-weight: 600; text-align: center; margin-top: 2.6em; color: #1d2939; text-decoration: none; padding-left: 1em; padding-right: 1em;'; | |
| 417 | + return 'display: ' . ( $display_block ? 'block' : 'inline-block' ) . '; font-size: 0.875em; line-height: 2.4; border-radius: 1.2em; border: 1px solid #d0d5dd; font-weight: 600; text-align: center; margin-top: 2.6em; color: #1d2939; text-decoration: none; padding-left: 1em; padding-right: 1em;'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 431 | 418 | } |
| 432 | 419 | |
| 433 | 420 | /** |
| 434 | 421 | * Shows the section heading with icon. |
| @@ -440,9 +427,9 @@ | ||
| 440 | 427 | */ |
| 441 | 428 | public static function section_heading_with_icon( $icon, $text ) { |
| 442 | 429 | ?> |
| 443 | 430 | <h2 style="<?php echo esc_attr( self::get_heading2_style() ); ?>"> |
| 444 | - <img style="vertical-align: bottom; height: 24px; width: auto;" src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/' . $icon . '.png' ); ?>" alt="<?php echo esc_attr( $icon ); ?>" /> | |
| 431 | + <img style="vertical-align: bottom; height: 24px; width: auto;" src="<?php echo esc_url( FrmAppHelper::plugin_url() . '/images/' . $icon . '.png' ); ?>" alt="<?php echo esc_attr( $icon ); ?>" /><?php // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong ?> | |
| 445 | 432 | <span style="display: inline-block; vertical-align: text-bottom;"><?php echo esc_html( $text ); ?></span> |
| 446 | 433 | </h2> |
| 447 | 434 | <?php |
| 448 | 435 | } |
| @@ -534,16 +521,16 @@ | ||
| 534 | 521 | |
| 535 | 522 | // Replace link utm. |
| 536 | 523 | $button_html = str_replace( 'utm_medium=inbox', 'utm_medium=summary-email', $button_html ); |
| 537 | 524 | |
| 538 | - if ( strpos( $button_html, 'style="' ) ) { | |
| 525 | + if ( str_contains( $button_html, 'style="' ) ) { | |
| 539 | 526 | // Maybe this button contains inline style. |
| 540 | 527 | return $button_html; |
| 541 | 528 | } |
| 542 | 529 | |
| 543 | 530 | // Add inline CSS for specific button types. |
| 544 | - if ( strpos( $button_html, 'frm-button-primary' ) ) { | |
| 545 | - $button_html = str_replace( '<a', '<a style="' . self::get_button_style() . '"', $button_html ); | |
| 531 | + if ( str_contains( $button_html, 'frm-button-primary' ) ) { | |
| 532 | + return str_replace( '<a', '<a style="' . self::get_button_style() . '"', $button_html ); | |
| 546 | 533 | } |
| 547 | 534 | |
| 548 | 535 | return $button_html; |
| 549 | 536 | } |