Cookiebot_Base_Notice.php
1 year ago
Cookiebot_Notices.php
1 year ago
Cookiebot_Recommendation_Notice.php
2 years ago
Cookiebot_Temp_Notice.php
2 years ago
Cookiebot_Recommendation_Notice.php
95 lines
| 1 | <?php |
| 2 | |
| 3 | namespace cybot\cookiebot\admin_notices; |
| 4 | |
| 5 | use function cybot\cookiebot\lib\get_view_html; |
| 6 | |
| 7 | class Cookiebot_Recommendation_Notice extends Cookiebot_Base_Notice { |
| 8 | const COOKIEBOT_NOTICE_OPTION_KEY = 'cookiebot_notice_recommend'; |
| 9 | const COOKIEBOT_NOTICE_TEMPLATE_PATH = 'admin/notices/cookiebot-recommendation-notice.php'; |
| 10 | const COOKIEBOT_NOTICE_LINK_TEMPLATE_PATH = 'admin/notices/cookiebot-recommendation-notice-links.php'; |
| 11 | |
| 12 | const COOKIEBOT_NOTICE_TIMES = array( |
| 13 | 'later' => array( |
| 14 | 'msg' => 'Never show again is clicked', |
| 15 | 'action' => 'hide_temp_notice', |
| 16 | 'name' => 'review_nonce', |
| 17 | 'str' => false, |
| 18 | 'time' => 'hide', |
| 19 | ), |
| 20 | 'hide' => array( |
| 21 | 'msg' => 'Never show again is clicked', |
| 22 | 'action' => 'hide_recommendation', |
| 23 | 'name' => 'review_nonce', |
| 24 | 'str' => false, |
| 25 | 'time' => 'hide', |
| 26 | ), |
| 27 | 'visit' => array( |
| 28 | 'msg' => 'Show me after 1 day', |
| 29 | 'action' => 'hide_recommendation_next', |
| 30 | 'name' => 'review_nonce', |
| 31 | 'str' => true, |
| 32 | 'time' => '+1 day', |
| 33 | ), |
| 34 | 'two_week' => array( |
| 35 | 'msg' => 'Show me after 2 weeks', |
| 36 | 'action' => 'hide_recommendation_for_two_weeks', |
| 37 | 'name' => 'review_nonce', |
| 38 | 'str' => true, |
| 39 | 'time' => '+2 weeks', |
| 40 | ), |
| 41 | ); |
| 42 | |
| 43 | public function __construct() { |
| 44 | parent::__construct(); |
| 45 | // Check if recommendation notice delay option exists |
| 46 | if ( get_option( static::COOKIEBOT_NOTICE_OPTION_KEY, false ) === false ) { |
| 47 | // Delay in 1 day |
| 48 | add_option( static::COOKIEBOT_NOTICE_OPTION_KEY, strtotime( '+1 day' ) ); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * @return string |
| 54 | */ |
| 55 | public function get_link_html() { |
| 56 | $two_week_review_ignore = wp_nonce_url( |
| 57 | add_query_arg( array( static::COOKIEBOT_NOTICE_OPTION_KEY => 'hide' ) ), |
| 58 | static::COOKIEBOT_NOTICE_TIMES['hide']['action'], |
| 59 | static::COOKIEBOT_NOTICE_TIMES['hide']['name'] |
| 60 | ); |
| 61 | $two_week_review_temp = wp_nonce_url( |
| 62 | add_query_arg( array( static::COOKIEBOT_NOTICE_OPTION_KEY => 'two_week' ) ), |
| 63 | static::COOKIEBOT_NOTICE_TIMES['two_week']['action'], |
| 64 | static::COOKIEBOT_NOTICE_TIMES['two_week']['name'] |
| 65 | ); |
| 66 | $visit_review_temp = wp_nonce_url( |
| 67 | add_query_arg( array( static::COOKIEBOT_NOTICE_OPTION_KEY => 'visit' ) ), |
| 68 | static::COOKIEBOT_NOTICE_TIMES['visit']['action'], |
| 69 | static::COOKIEBOT_NOTICE_TIMES['visit']['name'] |
| 70 | ); |
| 71 | |
| 72 | return get_view_html( |
| 73 | static::COOKIEBOT_NOTICE_LINK_TEMPLATE_PATH, |
| 74 | array( |
| 75 | 'two_week_review_ignore' => $two_week_review_ignore, |
| 76 | 'two_week_review_temp' => $two_week_review_temp, |
| 77 | 'visit_review_temp' => $visit_review_temp, |
| 78 | ) |
| 79 | ); |
| 80 | } |
| 81 | |
| 82 | public function define_translations() { |
| 83 | $this->translations = array( |
| 84 | 'title' => __( |
| 85 | 'Share your experience', |
| 86 | 'cookiebot' |
| 87 | ), |
| 88 | 'msg' => __( |
| 89 | 'Hi there! We are thrilled you love the Cookiebot CMP plugin. Could you do us a huge favor and leave a 5-star rating on WordPress? Your support will help us spread the word and empower more WordPress websites to meet GDPR and CCPA compliance standards effortlessly. Thank you for your support!', |
| 90 | 'cookiebot' |
| 91 | ), |
| 92 | ); |
| 93 | } |
| 94 | } |
| 95 |