abstract-rate.php
3 days ago
admin-notices.php
3 days ago
interface-rate.php
3 days ago
rate-notice-implementation.php
3 days ago
rate-notice.php
3 days ago
rate-notice-implementation.php
64 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FS\Rate; |
| 4 | |
| 5 | class RateNoticeImplementation extends RateNotice |
| 6 | { |
| 7 | |
| 8 | /** |
| 9 | * Action links |
| 10 | * |
| 11 | * @return array |
| 12 | */ |
| 13 | protected function action_links() { |
| 14 | $actions[] = sprintf( |
| 15 | __( '%1$sOk, you deserved it%2$s', 'flexible-shipping' ), |
| 16 | '<a target="_blank" href="' . esc_url( 'https://octol.io/fs-rate' ) . '">', |
| 17 | '</a>' |
| 18 | ); |
| 19 | $actions[] = sprintf( |
| 20 | __( '%1$sNope, maybe later%2$s', 'flexible-shipping' ), |
| 21 | '<a data-type="date" class="fs-close-temporary-notice notice-dismiss-link" data-source="' . self::CLOSE_TEMPORARY_NOTICE . '" href="#">', |
| 22 | '</a>' |
| 23 | ); |
| 24 | $actions[] = sprintf( |
| 25 | __( '%1$sI already did%2$s', 'flexible-shipping' ), |
| 26 | '<a class="close-rate-notice notice-dismiss-link" data-source="already-did" href="#">', |
| 27 | '</a>' |
| 28 | ); |
| 29 | |
| 30 | return $actions; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Should show message |
| 35 | * |
| 36 | * @return bool |
| 37 | */ |
| 38 | public function should_show_message() { |
| 39 | $notice_date_dissmis = get_option( WPDesk_Flexible_Shipping_Rate_Notice::SETTINGS_OPTION_RATE_NOTICE_DATE_DISMISS, date( "Y-m-d H:i:s", strtotime( 'NOW + 2 weeks' ) ) ); |
| 40 | $notice_date = strtotime( $notice_date_dissmis ); |
| 41 | $current_date = strtotime( 'NOW' ); |
| 42 | $difference = $current_date - $notice_date; |
| 43 | $days = (int) floor( $difference / ( 60 * 60 * 24 ) ); |
| 44 | if ( $days > 0 ) { |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Get rate message |
| 53 | * |
| 54 | * @return string |
| 55 | */ |
| 56 | protected function get_message() { |
| 57 | $message = __( 'Awesome, you\'ve been using Flexible Shipping for more than 2 weeks. Could you please do me a BIG favor and give it a 5-star rating on WordPress? ~Octolize Team', 'flexible-shipping' ); |
| 58 | $message .= '<br/>'; |
| 59 | $message .= implode( ' | ', $this->action_links() ); |
| 60 | return $message; |
| 61 | } |
| 62 | |
| 63 | } |
| 64 |