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