mystickymenu
Last commit date
css
6 years ago
fonts
7 years ago
images
6 years ago
js
6 years ago
languages
7 years ago
class-review-box.php
6 years ago
index.php
8 years ago
mystickymenu-affiliate.php
6 years ago
mystickymenu-fonts.php
6 years ago
mystickymenu-popup.php
6 years ago
mystickymenu.php
6 years ago
readme.txt
5 years ago
uninstall.php
7 years ago
welcome-bar.php
6 years ago
mystickymenu-affiliate.php
170 lines
| 1 | <?php |
| 2 | class MyStickyMenu_affiliate_program { |
| 3 | |
| 4 | public $plugin = "mystickymenu"; |
| 5 | |
| 6 | public function __construct() { |
| 7 | add_action("wp_ajax_".$this->plugin."_affiliate_program", array($this, "mystickymenu_affiliate_program")); |
| 8 | |
| 9 | add_action('admin_notices', array($this, 'mystickymenu_admin_notices')); |
| 10 | } |
| 11 | |
| 12 | public function mystickymenu_affiliate_program() { |
| 13 | $nonce = filter_input(INPUT_POST, 'nonce', FILTER_SANITIZE_STRING); |
| 14 | $days = filter_input(INPUT_POST, 'days', FILTER_SANITIZE_STRING); |
| 15 | if(!empty($nonce) && wp_verify_nonce($nonce, $this->plugin."_affiliate_program")) { |
| 16 | if($days == -1) { |
| 17 | add_option($this->plugin."_hide_affiliate_box", "1"); |
| 18 | } else { |
| 19 | $date = date("Y-m-d", strtotime("+".$days." days")); |
| 20 | update_option($this->plugin."_show_affiliate_box_after", $date); |
| 21 | } |
| 22 | } |
| 23 | die; |
| 24 | } |
| 25 | |
| 26 | public function mystickymenu_admin_notices() { |
| 27 | $is_hidden = get_option($this->plugin."_hide_affiliate_box"); |
| 28 | if($is_hidden !== false) { |
| 29 | return; |
| 30 | } |
| 31 | |
| 32 | $date_to_show = get_option($this->plugin."_show_affiliate_box_after"); |
| 33 | if($date_to_show === false || empty($date_to_show)) { |
| 34 | $date = date("Y-m-d", strtotime("+5 days")); |
| 35 | update_option($this->plugin."_show_affiliate_box_after", $date); |
| 36 | return; |
| 37 | } |
| 38 | $current_date = date("Y-m-d"); |
| 39 | if( $date_to_show != '' && $current_date < $date_to_show) { |
| 40 | return; |
| 41 | } |
| 42 | ?> |
| 43 | <style> |
| 44 | .premio-affiliate p a { |
| 45 | display: inline-block; |
| 46 | float: right; |
| 47 | text-decoration: none; |
| 48 | color: #999999; |
| 49 | position: absolute; |
| 50 | right: 12px; |
| 51 | top: 12px; |
| 52 | } |
| 53 | .premio-affiliate p a:hover, .premio-affiliate p a:focus { |
| 54 | color: #333333; |
| 55 | } |
| 56 | .premio-affiliate .button span { |
| 57 | display: inline-block; |
| 58 | line-height: 27px; |
| 59 | font-size: 16px; |
| 60 | } |
| 61 | .premio-affiliate { |
| 62 | padding: 1px 100px 12px 12px; |
| 63 | margin: 15px 15px 2px; |
| 64 | position: relative; |
| 65 | } |
| 66 | .affiliate-popup { |
| 67 | position: fixed; |
| 68 | width: 100%; |
| 69 | height: 100%; |
| 70 | z-index: 10001; |
| 71 | background: rgba(0,0,0,0.65); |
| 72 | top: 0; |
| 73 | left: 0; |
| 74 | display: none; |
| 75 | } |
| 76 | .affiliate-popup-content { |
| 77 | background: #ffffff; |
| 78 | padding: 20px; |
| 79 | position: absolute; |
| 80 | max-width: 450px; |
| 81 | width: 100%; |
| 82 | margin: 0 auto; |
| 83 | top: 45%; |
| 84 | left: 0; |
| 85 | right: 0; |
| 86 | -webkit-border-radius: 5px; |
| 87 | -moz-border-radius: 5px; |
| 88 | border-radius: 5px;: ; |
| 89 | } |
| 90 | .affiliate-title { |
| 91 | padding: 0 0 10px 0; |
| 92 | font-weight: bold; |
| 93 | } |
| 94 | .affiliate-options a { |
| 95 | display: block; |
| 96 | margin: 5px 0 5px 0; |
| 97 | color: #333; |
| 98 | text-decoration: none; |
| 99 | } |
| 100 | .affiliate-options a.dismiss { |
| 101 | color: #999; |
| 102 | } |
| 103 | .affiliate-options a:hover, .affiliate-options a:focus { |
| 104 | color: #0073aa; |
| 105 | } |
| 106 | button.close-affiliate-popup { |
| 107 | position: absolute; |
| 108 | top: 5px; |
| 109 | right: 0; |
| 110 | border: none; |
| 111 | background: transparent; |
| 112 | cursor: pointer; |
| 113 | } |
| 114 | a.button.button-primary.affiliate-btn { |
| 115 | font-size: 14px; |
| 116 | background: #F51366; |
| 117 | color: #fff; |
| 118 | border: solid 1px #F51366; |
| 119 | border-radius: 3px; |
| 120 | line-height: 24px; |
| 121 | -webkit-box-shadow: 0 3px 5px -3px #333333; |
| 122 | -moz-box-shadow: 0 3px 5px -3px #333333; |
| 123 | box-shadow: 0 3px 5px -3px #333333; |
| 124 | text-shadow: none; |
| 125 | } |
| 126 | </style> |
| 127 | <div class="notice notice-info premio-affiliate <?php echo esc_attr($this->plugin) ?>-premio-affiliate"> |
| 128 | <p>Hi there, you've been using My Sticky Menu for a while now. Do you know that <b>My Sticky Menu</b> has an affiliate program? Join now and get <b>25% lifetime commission</b> <a href="javascript:;" class="dismiss-btn"><span class="dashicons dashicons-no-alt"></span> Dismiss</a></p> |
| 129 | <div class="clear clearfix"></div> |
| 130 | <a class="button button-primary affiliate-btn" target="_blank" href="https://premio.io/affiliates/?utm_source=inapp&plugin=mystickymenu&domain=<?php echo $_SERVER['HTTP_HOST'] ?>">Tell me more <span class="dashicons dashicons-arrow-right-alt"></span></a> |
| 131 | </div> |
| 132 | <div class="affiliate-popup"> |
| 133 | <div class="affiliate-popup-content"> |
| 134 | <button class="close-affiliate-popup"><span class="dashicons dashicons-no-alt"></span></button> |
| 135 | <div class="affiliate-title">Would you like us to remind you about this later?</div> |
| 136 | <div class="affiliate-options"> |
| 137 | <a href="javascript:;" data-days="3">Remind me in 3 days</a> |
| 138 | <a href="javascript:;" data-days="10">Remind me in 10 days</a> |
| 139 | <a href="javascript:;" data-days="-1" class="dismiss">Don't remind me about this</a> |
| 140 | </div> |
| 141 | </div> |
| 142 | </div> |
| 143 | <script> |
| 144 | jQuery(document).ready(function(){ |
| 145 | jQuery(document).on("click", ".premio-affiliate p a.dismiss-btn", function(){ |
| 146 | jQuery(".affiliate-popup").show(); |
| 147 | }); |
| 148 | jQuery(document).on("click", ".close-affiliate-popup", function(){ |
| 149 | jQuery(".affiliate-popup").hide(); |
| 150 | }); |
| 151 | jQuery(document).on("click", ".affiliate-options a", function(){ |
| 152 | var dataDays = jQuery(this).attr("data-days"); |
| 153 | jQuery(".affiliate-popup").hide(); |
| 154 | jQuery(".<?php echo esc_attr($this->plugin) ?>-premio-affiliate").hide(); |
| 155 | jQuery.ajax({ |
| 156 | url: "<?php echo admin_url("admin-ajax.php") ?>", |
| 157 | data: "action=<?php echo esc_attr($this->plugin) ?>_affiliate_program&days="+dataDays+"&nonce=<?php echo esc_attr(wp_create_nonce($this->plugin."_affiliate_program")) ?>", |
| 158 | type: "post", |
| 159 | success: function() { |
| 160 | jQuery(".affiliate-popup").remove(); |
| 161 | jQuery(".<?php echo esc_attr($this->plugin) ?>-premio-affiliate").remove(); |
| 162 | } |
| 163 | }); |
| 164 | }); |
| 165 | }); |
| 166 | </script> |
| 167 | <?php |
| 168 | } |
| 169 | } |
| 170 | $MyStickyMenu_affiliate_program = new MyStickyMenu_affiliate_program(); |