| 1 |
<?php |
| 2 |
|
| 3 |
namespace MasterAddons\Inc\Classes\Notifications; |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) { |
| 6 |
exit; // Exit if accessed directly |
| 7 |
} |
| 8 |
|
| 9 |
use MasterAddons\Inc\Classes\Notifications\Base\User_Data; |
| 10 |
use MasterAddons\Inc\Classes\Notifications\Model\Notice; |
| 11 |
|
| 12 |
if (!class_exists('What_We_Collect')) { |
| 13 |
/** |
| 14 |
* Class for what we collect |
| 15 |
* |
| 16 |
* Jewel Theme <[email protected]> |
| 17 |
*/ |
| 18 |
class What_We_Collect extends Notice |
| 19 |
{ |
| 20 |
|
| 21 |
|
| 22 |
use User_Data; |
| 23 |
|
| 24 |
public $color = 'warning'; |
| 25 |
|
| 26 |
/** |
| 27 |
* Constructor method |
| 28 |
* |
| 29 |
* @author Jewel Theme <[email protected]> |
| 30 |
*/ |
| 31 |
public function __construct() |
| 32 |
{ |
| 33 |
parent::__construct(); |
| 34 |
add_action('wp_ajax_jltma_allow_collect', array($this, 'jltma_allow_collect')); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Allow collect data |
| 39 |
* |
| 40 |
* @author Jewel Theme <[email protected]> |
| 41 |
*/ |
| 42 |
public function jltma_allow_collect() |
| 43 |
{ |
| 44 |
check_ajax_referer('jltma_allow_collect_nonce'); |
| 45 |
|
| 46 |
if ( ! current_user_can( 'manage_options' ) ) { |
| 47 |
wp_send_json_error( [ 'message' => __( 'Insufficient permissions', 'master-addons' ) ] ); |
| 48 |
} |
| 49 |
|
| 50 |
$this->jltma_collect_ajax_data(); |
| 51 |
|
| 52 |
} |
| 53 |
|
| 54 |
public function jltma_collect_ajax_data(){ |
| 55 |
|
| 56 |
if (!empty(get_option('jltma_what_we_collect'))) { |
| 57 |
return; |
| 58 |
} |
| 59 |
|
| 60 |
$email = get_bloginfo('admin_email'); |
| 61 |
|
| 62 |
$author_obj = get_user_by('email', $email); |
| 63 |
$user_id = $author_obj->ID; |
| 64 |
$full_name = $author_obj->display_name; |
| 65 |
|
| 66 |
$response = $this->get_collect_data($user_id, array( |
| 67 |
'first_name' => $full_name, |
| 68 |
'email' => $email, |
| 69 |
)); |
| 70 |
|
| 71 |
update_option('jltma_what_we_collect', 'yes'); |
| 72 |
return $response; |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Title Content |
| 77 |
* |
| 78 |
* @author Jewel Theme <[email protected]> |
| 79 |
*/ |
| 80 |
public function set_title() |
| 81 |
{ |
| 82 |
printf( |
| 83 |
'<h4>Wanna get some discount for %1$s? No Worries!! We got you!! give us your email we will send you the discount code?</h4>', |
| 84 |
esc_html__('Master Addons', 'master-addons') |
| 85 |
); |
| 86 |
} |
| 87 |
|
| 88 |
/** |
| 89 |
* Link for collect data |
| 90 |
* |
| 91 |
* @author Jewel Theme <[email protected]> |
| 92 |
*/ |
| 93 |
public function what_we_collect_link() |
| 94 |
{ |
| 95 |
echo '<a href="!#" class="jltma-wwc-link">' . esc_html__('what we collect', 'master-addons') . '</a>'; |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Notice Content |
| 100 |
* |
| 101 |
* @author Jewel Theme <[email protected]> |
| 102 |
*/ |
| 103 |
public function notice_content() |
| 104 |
{ ?> |
| 105 |
<div class="jltma-notice-review-box jltma-wwc"> |
| 106 |
<p> |
| 107 |
<?php |
| 108 |
echo wp_kses_post( sprintf( |
| 109 |
/* translators: %1$s: Plugin name "Master Addons". */ |
| 110 |
__('Want to help make <strong>%1$s</strong> even more awesome? Allow %1$s to collect non-sensitive diagnostic data and usage information.', 'master-addons'), |
| 111 |
esc_html__('Master Addons', 'master-addons') |
| 112 |
) ); |
| 113 |
?> |
| 114 |
(<?php $this->what_we_collect_link(); ?>)</p> |
| 115 |
<div class="jltma-wwc-content" style="display:none"> |
| 116 |
<?php |
| 117 |
echo wp_kses_post( sprintf( |
| 118 |
/* translators: %1$s: URL to the Privacy Policy page. */ |
| 119 |
__('Server environment details (php, mysql, server, WordPress versions), Number of users in your site, Site language, Number of active and inactive plugins, Local or Production Site, IP Address, Site name and url, Your name and email address etc. No sensitive data is tracked. Learn more about our <a href="%1$s" target="_blank">Privacy Policy</a>, how we handle and collects your data.', 'master-addons'), |
| 120 |
esc_url('https://master-addons.com/privacy-policy') |
| 121 |
) ); ?> |
| 122 |
</div> |
| 123 |
</div> |
| 124 |
|
| 125 |
<?php |
| 126 |
} |
| 127 |
|
| 128 |
/** |
| 129 |
* Plugin rate url |
| 130 |
* |
| 131 |
* @author Jewel Theme <[email protected]> |
| 132 |
*/ |
| 133 |
public function plugin_rate_url() |
| 134 |
{ |
| 135 |
return '#'; |
| 136 |
} |
| 137 |
|
| 138 |
/** |
| 139 |
* Footer Content |
| 140 |
* |
| 141 |
* @author Jewel Theme <[email protected]> |
| 142 |
*/ |
| 143 |
public function footer_content() |
| 144 |
{ |
| 145 |
?> |
| 146 |
<a class="button button-primary allow-button" href="<?php echo esc_url($this->plugin_rate_url()); ?>" rel="nofollow" target="_blank"> |
| 147 |
<?php echo esc_html__('Allow', 'master-addons'); ?> |
| 148 |
</a> |
| 149 |
<a class="button button-secondary button-reject jltma-notice-dismiss" href="#" rel="nofollow"> |
| 150 |
<?php echo esc_html__('No Thanks', 'master-addons'); ?> |
| 151 |
</a> |
| 152 |
<?php |
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* Intervals |
| 157 |
* |
| 158 |
* @author Jewel Theme <[email protected]> |
| 159 |
*/ |
| 160 |
public function intervals() |
| 161 |
{ |
| 162 |
return array(7, 10, 15, 20, 15, 25, 30); |
| 163 |
} |
| 164 |
|
| 165 |
/** |
| 166 |
* Core Script |
| 167 |
* |
| 168 |
* @param [type] $trigger_time . |
| 169 |
* @author Jewel Theme <[email protected]> |
| 170 |
*/ |
| 171 |
public function core_script($trigger_time) |
| 172 |
{ |
| 173 |
parent::core_script($trigger_time); |
| 174 |
?> |
| 175 |
|
| 176 |
<script> |
| 177 |
jQuery('body').on('click', '.jltma-notice-what_we_collect .jltma-wwc-link', function(e) { |
| 178 |
e.preventDefault(); |
| 179 |
if (jQuery(this).hasClass('show')) { |
| 180 |
jQuery(this).removeClass("show"); |
| 181 |
jQuery('.jltma-wwc-content').stop().slideUp(200); |
| 182 |
} else { |
| 183 |
jQuery(this).addClass("show"); |
| 184 |
jQuery('.jltma-wwc-content').stop().slideDown(200); |
| 185 |
} |
| 186 |
}); |
| 187 |
|
| 188 |
jQuery('body').on('click', '.jltma-notice-what_we_collect .allow-button', function(e) { |
| 189 |
|
| 190 |
e.preventDefault(); |
| 191 |
|
| 192 |
let noticeWrapper = jQuery(this).closest('.notice-jltma'); |
| 193 |
|
| 194 |
noticeWrapper.css('opacity', '0.4').find('button').prop('disabled', true); |
| 195 |
|
| 196 |
jQuery.ajax({ |
| 197 |
url: '<?php echo esc_url(admin_url('admin-ajax.php')); ?>', |
| 198 |
method: 'POST', |
| 199 |
crossDomain: true, |
| 200 |
data: { |
| 201 |
action: 'jltma_allow_collect', |
| 202 |
_wpnonce: '<?php echo esc_js(wp_create_nonce('jltma_allow_collect_nonce')); ?>', |
| 203 |
} |
| 204 |
}) |
| 205 |
.done(function(response) { |
| 206 |
noticeWrapper.children(':not(.notice-dismiss)').hide().end().append('<p class="jltma--notice-message"><strong>' + response.data + '</strong></p>'); |
| 207 |
let subsTimeout = setTimeout(function() { |
| 208 |
jltma_notice_action(null, noticeWrapper.children(), 'disable'); |
| 209 |
clearTimeout(subsTimeout); |
| 210 |
}, 1500); |
| 211 |
}) |
| 212 |
.always(function() { |
| 213 |
noticeWrapper.css('opacity', '1').find('button').prop('disabled', false); |
| 214 |
}) |
| 215 |
|
| 216 |
}); |
| 217 |
</script> |
| 218 |
|
| 219 |
<?php |
| 220 |
} |
| 221 |
} |
| 222 |
} |
| 223 |
|