abstract-rate.php
8 hours ago
admin-notices.php
8 hours ago
interface-rate.php
8 hours ago
rate-notice-implementation.php
8 hours ago
rate-notice.php
8 hours ago
abstract-rate.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPDesk\FS\Rate; |
| 4 | |
| 5 | abstract class RateNotice implements RateNoticeInterface { |
| 6 | |
| 7 | const NOTICE_NAME = 'flexible_shipping_rate_plugin'; |
| 8 | |
| 9 | const CLOSE_TEMPORARY_NOTICE = 'close-temporary-notice-date'; |
| 10 | |
| 11 | /** |
| 12 | * Get message |
| 13 | * |
| 14 | * @return mixed |
| 15 | */ |
| 16 | abstract protected function get_message(); |
| 17 | |
| 18 | /** |
| 19 | * Action links |
| 20 | * |
| 21 | * @return array |
| 22 | */ |
| 23 | protected function action_links() { |
| 24 | $actions[] = sprintf( |
| 25 | __( '%1$sOk, you deserved it%2$s', 'flexible-shipping' ), |
| 26 | '<a target="_blank" href="' . esc_url( 'https://octol.io/fs-rate' ) . '">', |
| 27 | '</a>' |
| 28 | ); |
| 29 | $actions[] = sprintf( |
| 30 | __( '%1$sNope, maybe later%2$s', 'flexible-shipping' ), |
| 31 | '<a data-type="date" class="fs-close-temporary-notice notice-dismiss-link" data-source="' . self::CLOSE_TEMPORARY_NOTICE . '" href="#">', |
| 32 | '</a>' |
| 33 | ); |
| 34 | $actions[] = sprintf( |
| 35 | __( '%1$sI already did%2$s', 'flexible-shipping' ), |
| 36 | '<a class="close-rate-notice notice-dismiss-link" data-source="already-did" href="#">', |
| 37 | '</a>' |
| 38 | ); |
| 39 | return $actions; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Should show message |
| 44 | * |
| 45 | * @return bool |
| 46 | */ |
| 47 | public function should_show_message() { |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Show admin notice |
| 53 | * |
| 54 | * @return string|void |
| 55 | */ |
| 56 | public function show_message() { |
| 57 | new \FSVendor\WPDesk\Notice\PermanentDismissibleNotice( |
| 58 | $this->get_message(), |
| 59 | self::NOTICE_NAME, |
| 60 | \FSVendor\WPDesk\Notice\Notice::NOTICE_TYPE_INFO, |
| 61 | 10, |
| 62 | array( |
| 63 | 'class' => self::NOTICE_NAME, |
| 64 | 'id' => self::NOTICE_NAME, |
| 65 | ) |
| 66 | ); |
| 67 | } |
| 68 | |
| 69 | } |
| 70 |