class-affiliate.php
1 year ago
class-email-signup.php
1 year ago
class-polylang.php
1 year ago
class-review-box.php
1 year ago
class-upgrade-box.php
1 year ago
class-wpml.php
1 year ago
folders.class.php
1 year ago
form.class.php
1 year ago
form.fields.php
1 year ago
import.export.class.php
1 year ago
media.replace.php
1 year ago
notifications.class.php
1 year ago
plugins.class.php
1 year ago
svg.class.php
1 year ago
tree.class.php
1 year ago
class-affiliate.php
243 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class Folders affiliate program |
| 4 | * |
| 5 | * @author : Premio <contact@premio.io> |
| 6 | * @license : GPL2 |
| 7 | * */ |
| 8 | |
| 9 | if (! defined('ABSPATH')) { |
| 10 | exit; |
| 11 | } |
| 12 | |
| 13 | class Folder_affiliate_program |
| 14 | { |
| 15 | |
| 16 | /** |
| 17 | * The Name of this plugin. |
| 18 | * |
| 19 | * @var string $pluginName The Name of this plugin. |
| 20 | * @since 1.0.0 |
| 21 | * @access public |
| 22 | */ |
| 23 | public $pluginName = "Folders"; |
| 24 | |
| 25 | /** |
| 26 | * The Slug of this plugin. |
| 27 | * |
| 28 | * @var string $pluginSlug The Slug of this plugin. |
| 29 | * @since 1.0.0 |
| 30 | * @access public |
| 31 | */ |
| 32 | public $pluginSlug = "folders"; |
| 33 | |
| 34 | |
| 35 | /** |
| 36 | * Define the core functionality of the plugin. |
| 37 | * |
| 38 | * Set the plugin name and the plugin version that can be used throughout the plugin. |
| 39 | * Load the dependencies, define the locale, and set the hooks for the admin area and |
| 40 | * the public-facing side of the site. |
| 41 | * |
| 42 | * @since 1.0.0 |
| 43 | */ |
| 44 | public function __construct() |
| 45 | { |
| 46 | add_action("wp_ajax_".$this->pluginSlug."_affiliate_program", [$this, "affiliate_program"]); |
| 47 | |
| 48 | add_action('admin_notices', [$this, 'admin_notices']); |
| 49 | |
| 50 | }//end __construct() |
| 51 | |
| 52 | |
| 53 | /** |
| 54 | * Updates settings for Affiliate Box |
| 55 | * |
| 56 | * @since 1.0.0 |
| 57 | * @access public |
| 58 | * @return status |
| 59 | */ |
| 60 | public function affiliate_program() |
| 61 | { |
| 62 | if (current_user_can('manage_options')) { |
| 63 | $nonce = filter_input(INPUT_POST, 'nonce'); |
| 64 | $days = filter_input(INPUT_POST, 'days'); |
| 65 | if (!empty($nonce) && wp_verify_nonce($nonce, $this->pluginSlug."_affiliate_program")) { |
| 66 | if ($days == -1) { |
| 67 | add_option($this->pluginSlug."_hide_affiliate_box", "1"); |
| 68 | } else { |
| 69 | $date = gmdate("Y-m-d", strtotime("+".$days." days")); |
| 70 | update_option($this->pluginSlug."_show_affiliate_box_after", $date); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | die; |
| 75 | } |
| 76 | |
| 77 | }//end affiliate_program() |
| 78 | |
| 79 | |
| 80 | /** |
| 81 | * Display Affiliate box |
| 82 | * |
| 83 | * @since 1.0.0 |
| 84 | * @access public |
| 85 | * @return html |
| 86 | */ |
| 87 | public function admin_notices() |
| 88 | { |
| 89 | $current_date = gmdate("Y-m-d H:i:s"); |
| 90 | if (current_user_can('manage_options')) { |
| 91 | $is_hidden = get_option($this->pluginSlug."_hide_affiliate_box"); |
| 92 | if ($is_hidden !== false) { |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | $date_to_show = get_option($this->pluginSlug."_show_affiliate_box_after"); |
| 97 | if ($date_to_show === false || empty($date_to_show)) { |
| 98 | $date = gmdate("Y-m-d", strtotime("+5 days")); |
| 99 | update_option($this->pluginSlug."_show_affiliate_box_after", $date); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | $current_date = gmdate("Y-m-d"); |
| 104 | if ($current_date < $date_to_show) { |
| 105 | return; |
| 106 | } |
| 107 | ?> |
| 108 | <style> |
| 109 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate p a { |
| 110 | display: inline-block; |
| 111 | float: right; |
| 112 | text-decoration: none; |
| 113 | color: #999999; |
| 114 | position: absolute; |
| 115 | right: 12px; |
| 116 | top: 12px; |
| 117 | } |
| 118 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate p a:hover, .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate p a:focus { |
| 119 | color: #333333; |
| 120 | } |
| 121 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate .button span { |
| 122 | display: inline-block; |
| 123 | line-height: 27px; |
| 124 | font-size: 16px; |
| 125 | } |
| 126 | .<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate { |
| 127 | padding: 1px 100px 12px 12px; |
| 128 | margin: 15px 15px 2px; |
| 129 | position: relative; |
| 130 | } |
| 131 | .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup { |
| 132 | position: fixed; |
| 133 | width: 100%; |
| 134 | height: 100%; |
| 135 | z-index: 10001; |
| 136 | background: rgba(0,0,0,0.65); |
| 137 | top: 0; |
| 138 | left: 0; |
| 139 | display: none; |
| 140 | } |
| 141 | .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup-content { |
| 142 | background: #ffffff; |
| 143 | padding: 20px; |
| 144 | position: absolute; |
| 145 | max-width: 450px; |
| 146 | width: 100%; |
| 147 | margin: 0 auto; |
| 148 | top: 45%; |
| 149 | left: 0; |
| 150 | right: 0; |
| 151 | -webkit-border-radius: 5px; |
| 152 | -moz-border-radius: 5px; |
| 153 | border-radius: 5px; |
| 154 | } |
| 155 | .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-title { |
| 156 | padding: 0 0 10px 0; |
| 157 | font-weight: bold; |
| 158 | } |
| 159 | .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options a { |
| 160 | display: block; |
| 161 | margin: 5px 0 5px 0; |
| 162 | color: #333; |
| 163 | text-decoration: none; |
| 164 | } |
| 165 | .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options a.dismiss { |
| 166 | color: #999; |
| 167 | } |
| 168 | .<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options a:hover, .affiliate-options a:focus { |
| 169 | color: #0073aa; |
| 170 | } |
| 171 | button.<?php echo esc_attr($this->pluginSlug) ?>-close-affiliate-popup { |
| 172 | position: absolute; |
| 173 | top: 5px; |
| 174 | right: 0; |
| 175 | border: none; |
| 176 | background: transparent; |
| 177 | cursor: pointer; |
| 178 | } |
| 179 | a.button.button-primary.<?php echo esc_attr($this->pluginSlug) ?>-affiliate-btn { |
| 180 | font-size: 14px; |
| 181 | background: #F51366; |
| 182 | color: #fff; |
| 183 | border: solid 1px #F51366; |
| 184 | border-radius: 3px; |
| 185 | line-height: 24px; |
| 186 | -webkit-box-shadow: 0 3px 5px -3px #333333; |
| 187 | -moz-box-shadow: 0 3px 5px -3px #333333; |
| 188 | box-shadow: 0 3px 5px -3px #333333; |
| 189 | text-shadow: none; |
| 190 | } |
| 191 | </style> |
| 192 | <div class="notice notice-info chaty-notice <?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate <?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate"> |
| 193 | <p><?php |
| 194 | $message = esc_html__("Hi there, you've been using %1\$s for a while now. Do you know that %2\$s has an affiliate program? Join now and get %3\$s ", "folders"); |
| 195 | printf(esc_attr($message), esc_attr($this->pluginName), "<b>".esc_attr($this->pluginName)."</b>", "<b>".esc_html__("25% lifetime commission", "folders")."</b>") ?> <a href="javascript:;" class="dismiss-btn"><span class="dashicons dashicons-no-alt"></span> <?php esc_html_e("Dismiss", "folders") ?></a></p> |
| 196 | <div class="clear clearfix"></div> |
| 197 | <a class="button button-primary <?php echo esc_attr($this->pluginSlug) ?>-affiliate-btn" target="_blank" href="https://premio.io/affiliates/?utm_source=inapp&plugin=folders&domain=<?php echo esc_url($_SERVER['HTTP_HOST']) ?>"><?php esc_html_e("Tell me more", "folders") ?> <span class="dashicons dashicons-arrow-right-alt"></span></a> |
| 198 | </div> |
| 199 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup"> |
| 200 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup-content"> |
| 201 | <button class="<?php echo esc_attr($this->pluginSlug) ?>-close-affiliate-popup"><span class="dashicons dashicons-no-alt"></span></button> |
| 202 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-affiliate-title"><?php esc_html_e("Would you like us to remind you about this later?", "folders") ?></div> |
| 203 | <div class="<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options"> |
| 204 | <a href="javascript:;" data-days="3"><?php esc_html_e("Remind me in 3 days", "folders") ?></a> |
| 205 | <a href="javascript:;" data-days="10"><?php esc_html_e("Remind me in 10 days", "folders") ?></a> |
| 206 | <a href="javascript:;" data-days="-1" class="dismiss"><?php esc_html_e("Don't remind me about this", "folders") ?></a> |
| 207 | </div> |
| 208 | </div> |
| 209 | </div> |
| 210 | <script> |
| 211 | jQuery(document).ready(function(){ |
| 212 | jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate p a.dismiss-btn", function(){ |
| 213 | jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup").show(); |
| 214 | }); |
| 215 | jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-close-affiliate-popup", function(){ |
| 216 | jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup").hide(); |
| 217 | }); |
| 218 | jQuery(document).on("click", ".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-options a", function(){ |
| 219 | var dataDays = jQuery(this).attr("data-days"); |
| 220 | jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup").hide(); |
| 221 | jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate").hide(); |
| 222 | jQuery.ajax({ |
| 223 | url: "<?php echo esc_url(admin_url("admin-ajax.php")) ?>", |
| 224 | data: "action=<?php echo esc_attr($this->pluginSlug) ?>_affiliate_program&days="+dataDays+"&nonce=<?php echo esc_attr(wp_create_nonce($this->pluginSlug."_affiliate_program")) ?>", |
| 225 | type: "post", |
| 226 | success: function() { |
| 227 | jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-affiliate-popup").remove(); |
| 228 | jQuery(".<?php echo esc_attr($this->pluginSlug) ?>-premio-affiliate").remove(); |
| 229 | } |
| 230 | }); |
| 231 | }); |
| 232 | }); |
| 233 | </script> |
| 234 | <?php |
| 235 | }//end if |
| 236 | |
| 237 | }//end admin_notices() |
| 238 | |
| 239 | |
| 240 | }//end class |
| 241 | |
| 242 | $Folder_affiliate_program = new Folder_affiliate_program(); |
| 243 |