| 1 |
<?php |
| 2 |
|
| 3 |
namespace TierPricingTable\Addons\GlobalTieredPricing\CPT\Form; |
| 4 |
|
| 5 |
use TierPricingTable\Addons\GlobalTieredPricing\CPT\GlobalTieredPricingCPT; |
| 6 |
use TierPricingTable\Admin\Tips\Tip; |
| 7 |
use TierPricingTable\TierPricingTablePlugin; |
| 8 |
use WP_Post; |
| 9 |
class UpgradeTip extends Tip { |
| 10 |
public function __construct() { |
| 11 |
parent::__construct(); |
| 12 |
add_filter( |
| 13 |
'tiered_pricing_table/admin/tips/get_tip_by_slug', |
| 14 |
function ( $tip, $slug ) { |
| 15 |
if ( $slug === $this->getSlug() ) { |
| 16 |
return $this; |
| 17 |
} |
| 18 |
return $tip; |
| 19 |
}, |
| 20 |
10, |
| 21 |
2 |
| 22 |
); |
| 23 |
add_action( 'submitpost_box', function ( WP_Post $post ) { |
| 24 |
if ( GlobalTieredPricingCPT::SLUG !== $post->post_type ) { |
| 25 |
return; |
| 26 |
} |
| 27 |
$this->render(); |
| 28 |
} ); |
| 29 |
} |
| 30 |
|
| 31 |
protected function isValid() : bool { |
| 32 |
if ( $this->isSeen() ) { |
| 33 |
return false; |
| 34 |
} |
| 35 |
$activationDate = TierPricingTablePlugin::getPluginActivationDate(); |
| 36 |
if ( !$activationDate ) { |
| 37 |
return false; |
| 38 |
} |
| 39 |
// If activation date is more than 2 months ago |
| 40 |
return time() - $activationDate > MONTH_IN_SECONDS * 2; |
| 41 |
} |
| 42 |
|
| 43 |
public function render() { |
| 44 |
if ( !$this->isValid() ) { |
| 45 |
return; |
| 46 |
} |
| 47 |
?> |
| 48 |
|
| 49 |
<div> |
| 50 |
<div class="tiered-pricing-tip tiered-pricing-upgrade-tip" |
| 51 |
style="animation: pulse-animation 2s infinite;border-radius: 5px; margin-bottom: 20px; position: relative; padding: 20px 10px; background: #fff; border: 1px solid #c3c4c7;"> |
| 52 |
|
| 53 |
<div style="text-align: center" > |
| 54 |
|
| 55 |
<div style="white-space: nowrap;position: absolute;right: 10px;top: 5px;"> |
| 56 |
<a role="button" title="Close the tip" |
| 57 |
href="<?php |
| 58 |
echo esc_attr( $this->getMarkAsSeenURL() ); |
| 59 |
?>" |
| 60 |
style="text-decoration: none;color: #000;font-size: 1.2em;" |
| 61 |
class="tiered-pricing-tip-close-button"> |
| 62 |
× |
| 63 |
</a> |
| 64 |
</div> |
| 65 |
|
| 66 |
<h3 style="margin-top: 5px;"> |
| 67 |
🎉 <?php |
| 68 |
esc_html_e( 'You have got a discount!', 'tier-pricing-table' ); |
| 69 |
?> |
| 70 |
</h3> |
| 71 |
|
| 72 |
<div style="margin-top: 10px;"> |
| 73 |
<?php |
| 74 |
esc_html_e( 'You\'ve been using the free version for a while now, and we\'d like to offer you an exclusive discount on the premium version!', 'tier-pricing-table' ); |
| 75 |
?> |
| 76 |
</div> |
| 77 |
|
| 78 |
<div style="margin-top: 10px;"> |
| 79 |
<?php |
| 80 |
echo wp_kses_post( __( 'Use the coupon code below for a <b>20%</b> discount on upgrading your plan.', 'tier-pricing-table' ) ); |
| 81 |
?> |
| 82 |
</div> |
| 83 |
|
| 84 |
<div style="margin-top: 25px; text-align: center; "> |
| 85 |
<code style="font-size: 1.5em;">GRD20OFF</code> |
| 86 |
</div> |
| 87 |
|
| 88 |
<div style="margin-top: 20px;text-align:center"> |
| 89 |
<a target="_blank" |
| 90 |
href="<?php |
| 91 |
echo esc_attr( tpt_fs_activation_url() ); |
| 92 |
?>"> |
| 93 |
<?php |
| 94 |
esc_html_e( 'Upgrade your plan', 'tier-pricing-table' ); |
| 95 |
?> |
| 96 |
<svg style=" |
| 97 |
width: 0.8rem; |
| 98 |
height: 0.8rem; |
| 99 |
stroke: currentColor; |
| 100 |
fill: none;" |
| 101 |
xmlns='http://www.w3.org/2000/svg' |
| 102 |
stroke-width='10' stroke-dashoffset='0' |
| 103 |
stroke-dasharray='0' stroke-linecap='round' |
| 104 |
stroke-linejoin='round' viewBox='0 0 100 100'> |
| 105 |
<polyline fill="none" points="40 20 20 20 20 90 80 90 80 60"/> |
| 106 |
<polyline fill="none" points="60 10 90 10 90 40"/> |
| 107 |
<line fill="none" x1="89" y1="11" x2="50" y2="50"/> |
| 108 |
</svg> |
| 109 |
</a> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
</div> |
| 113 |
</div> |
| 114 |
<?php |
| 115 |
} |
| 116 |
|
| 117 |
public function getSlug() : string { |
| 118 |
return 'global-rule-2-months-discount'; |
| 119 |
} |
| 120 |
|
| 121 |
} |
| 122 |
|