File: /home/vspt/public_html/wp-content/plugins/winwheel4wp/templates/edit_wheel.php
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } ?>
<?php $wheel = (array) $wheel; ?>
<style>
.winwheel4wp_tabs_buttons {
border-bottom: 1px solid #ccc;
}
.winwheel4wp_tabs_buttons a {
color: #555;
text-decoration: none;
padding: .5em 1em;
display: inline-block;
}
.winwheel4wp_tabs_buttons li {
border: 1px solid #ccc;
border-bottom: none;
display: inline-block;
background-color: #e5e5e5;
margin: 0;
margin-left: .25em;
}
.winwheel4wp_tabs_buttons .ui-tabs-active {
background-color: white;
}
.winwheel4wp_settings_label {
width: 10em;
margin-right: 2em;
display: inline-block;
}
</style>
<div class="wrap winwheel4wp_settings">
<h1>Win Wheel For Wordpress - <?php echo esc_html( $wheel['wheel_name'] ) ?></h1>
<div id="winwheel4wp_configre_wheel_tabs">
<ul class="winwheel4wp_tabs_buttons">
<li><a href="#winwheel4wp_configre_wheel_tabs_basic">Basic</a></li>
<li><a href="#winwheel4wp_configre_wheel_tabs_slices">Slices</a></li>
<li><a href="#winwheel4wp_configre_wheel_tabs_data_collection">Data Collection</a></li>
<li><a href="#winwheel4wp_configre_wheel_tabs_ACE">Anti-Cheat Engine</a></li>
<li><a href="#winwheel4wp_configre_wheel_tabs_translations">Translate UI</a></li>
<li><a href="#winwheel4wp_configre_wheel_tabs_extras">Extras</a></li>
</ul>
<form method="POST" charset="UTF-8" enctype="multipart/form-data">
<div id="winwheel4wp_configre_wheel_tabs">
<div id="winwheel4wp_configre_wheel_tabs_basic">
<div class="card">
<h2>Basic</h2>
<h4>Wheel name</h4>
<input type="text" name="wheel_name" value="<?php echo $wheel['wheel_name']?>">
<br><br>
<div class="winwheel4wp_settings_section winwheel4wp_settings_section_extra">
<div><input name="win_msg_in_modal" type="hidden" value="0"><input name="win_msg_in_modal" type="checkbox" value="1" <?php echo ($wheel['win_msg_in_modal'] == true) ? 'checked' : ''; ?>> Show Win message in modal box</div>
<div><input name="is_live" type="hidden" value="1"><input name="is_live" type="checkbox" value="0" <?php echo ($wheel['is_live'] == true) ? '' : 'checked'; ?>> Pause this Win Wheel</div>
<div><span style="width: 11em; display: inline-block;">Slice font size</span> <input min=1 max=200 value="<?php echo $wheel['slice_font_size']; ?>" name="slice_font_size" type="number"> (1-200, default 100)</div>
<div><span style="width: 11em; display: inline-block;">Max Wheel width</span> <input min=1 max=200 value="<?php echo $wheel['max_wheel_width']; ?>" name="max_wheel_width" type="number"> (1-200, default 24)</div>
<div><span style="width: 11em; display: inline-block;">Wheel spin time</span> <input min=1 max=30 value="<?php echo $wheel['wheel_spin_time']; ?>" name="wheel_spin_time" type="number"> seconds</div>
</div>
</div>
<div class="card">
<h2>Graphics</h2>
<div class="winwheel4wp_settings_section winwheel4wp_settings_section_extra">
<div>
<span style="width: 11em; display: inline-block;">Custom Marker image</span>
<input style="inline-block; width: 11em; margin-right: .5em" type="text" id="custom_marker_image" name="custom_marker_image" value="<?php echo $wheel['custom_marker_image']?>"><a id="winwheel4wp_select_marker_image" class="button" style="vertical-align: baseline">Select</a>
</div>
<div>
<span style="width: 11em; display: inline-block;">Custom Wheel image</span>
<input style="inline-block; width: 11em; margin-right: .5em" type="text" id="custom_wheel_image" name="custom_wheel_image" value="<?php echo $wheel['custom_wheel_image']?>"><a id="winwheel4wp_select_wheel_image" class="button" style="vertical-align: baseline">Select</a>
</div>
<div><span style="width: 11em; display: inline-block;">Win message background color</span> <input type="color" name="win_msg_color" value="<?php echo $wheel['win_msg_color'] ?>" style="padding: 0; width: 5em;"></div>
</div>
</div>
</div>
<div id="winwheel4wp_configre_wheel_tabs_slices">
<div class="card" style="max-width: 90em">
<h2>Slices</h2>
<div class="winwheel4wp_settings_section">
<div class="winwheel4wp_table_overflow_fix">
<table class="winwheel4wp_settings_wheel_overview">
<tr>
<th></th>
<th>Slice label</th>
<th>Win message</th>
<th>Send to email</th>
<th>Unlimited<br>Wins</th>
<th>Available<br>Wins</th>
<th>Win<br>Probability</th>
<th>Times<br>Won</th>
<th>Reset wins</th>
</tr>
<?php foreach(range(1,8) as $i) { ?>
<tr>
<td style="color: grey;"><strong><?php echo $i ?></strong></td>
<td><textarea rows=2 name="slice_<?php echo $i?>"><?php echo esc_html(stripslashes($wheel['slice_'.$i])) ?></textarea></td>
<td style="white-space: nowrap;">
<textarea rows=2 name="slice_<?php echo $i?>_win"><?php echo esc_html(stripslashes($wheel['slice_'.$i.'_win'])) ?></textarea>
<a data-target="slice_<?php echo $i?>_win" title="Preview win message in new window" class="win_message_preview" href="#"><span class="dashicons dashicons-search"></span></a>
</td>
<td><input name="slice_<?php echo $i?>_send_mail" type="hidden" value="0"><!--
--><input name="slice_<?php echo $i?>_send_mail" type="checkbox" value="1" <?php echo ($wheel['slice_'.$i.'_send_mail'] == true) ? 'checked' : ''; ?>></td>
<td><input class="infinite_wins_checkbox" name="slice_<?php echo $i?>_infinite" type="hidden" value="0"><!--
--><input class="infinite_wins_checkbox" name="slice_<?php echo $i?>_infinite" type="checkbox" value="1" <?php echo ($wheel['slice_'.$i.'_infinite'] == true) ? 'checked' : ''; ?>></td>
<td>
<input name="slice_<?php echo $i?>_qty" type="number" value="<?php echo $wheel['slice_'.$i.'_qty']?>" style="max-width: 5em" min="0">
<div style="color: gray; font-size: .7rem; font-weight: bold; letter-spacing: .5px;" id="slice_<?php echo $i?>_qty_unlimited">UNLIMITED</div>
</td>
<td>
<select class="win_multiplier" style="width: 8em;" data-for="slice_<?php echo $i?>_win_multiplier">
<option value="100" <?php echo ($wheel["slice_$i".'_win_multiplier'] == 100) ? 'selected' : ''?>>Very High</option>
<option value="25" <?php echo ($wheel["slice_$i".'_win_multiplier'] == 25) ? 'selected' : ''?>>High</option>
<option value="12" <?php echo ($wheel["slice_$i".'_win_multiplier'] == 12) ? 'selected' : ''?>>Normal</option>
<option value="6" <?php echo ($wheel["slice_$i".'_win_multiplier'] == 6) ? 'selected' : ''?>>Low</option>
<option value="1" <?php echo ($wheel["slice_$i".'_win_multiplier'] == 1) ? 'selected' : ''?>>Very Low</option>
<?php
if ( ! in_array( $wheel["slice_$i".'_win_multiplier'], array(100,25,12,6,1) ) ) { ?>
<option value="<?php echo $wheel["slice_$i".'_win_multiplier'] ?>" selected><?php echo $wheel["slice_$i".'_win_multiplier'] ?></option>
<?php } ?>
</select>
<input class="win_multiplier" style="width: 7em; background-color: azure; font-weight: bold" name="slice_<?php echo $i?>_win_multiplier" type="number" min="1" max="100000" value="<?php echo $wheel["slice_$i".'_win_multiplier'] ?>">
<div class="probability_calc" style="border-bottom: 1px solid grey; display: none;">= <span data-win_multiplier="slice_<?php echo $i?>_win_multiplier" class="probability_percent"></span>%</div>
</td>
<td id="slice_<?php echo $i?>_cumulative_wins"style="font-size: 1.8em"><?php echo $cumulative_wins[$i] ?></td>
<td><a class="reset_slice" data-slice_number="<?php echo $i; ?>" style="text-decoration: none" href="#"><span class="dashicons dashicons-image-rotate"></a></td>
</tr>
<?php } ?>
</table>
</div>
</div>
</div>
<?php if ($wheel['enable_custom_win_probability'] == true) { ?>
<div>
<p style="background-color: azure; font-size:1.2em">Custom win probabilty ratios are <strong>enabled</strong>, use numbers to fine tune win ratio, higher number = higher chance to win</p>
</div>
<?php } ?>
<?php if ($wheel['infinite_has_more_chance'] == true) { ?>
<div class="card">
<h2>Extra options</h2>
<div><input name="infinite_has_more_chance" type="hidden" value="0"><input name="infinite_has_more_chance" type="checkbox" value="1" <?php echo ($wheel['infinite_has_more_chance'] == true) ? 'checked' : ''; ?>> Infinite slices are more likely to win</div>
</div>
<?php } ?>
</div>
<div id="winwheel4wp_configre_wheel_tabs_data_collection">
<div class="card">
<h2>Data collection</h2>
<div class="winwheel4wp_settings_section winwheel4wp_settings_section_extra">
<div><input name="require_email" type="hidden" value="0"><input name="require_email" type="checkbox" value="1" <?php echo ($wheel['require_email'] == true) ? 'checked' : ''; ?>> Collect E-mail</div>
<div><input name="require_name" type="hidden" value="0"><input name="require_name" type="checkbox" value="1" <?php echo ($wheel['require_name'] == true) ? 'checked' : ''; ?>> Collect Name</div>
<div><input name="require_phone_number" type="hidden" value="0"><input name="require_phone_number" type="checkbox" value="1" <?php echo ($wheel['require_phone_number'] == true) ? 'checked' : ''; ?>> Collect Phone number</div>
<div><span style="width: 11em; display: inline-block;">Phone number length</span> <input min=0 max=30 value="<?php echo $wheel['phone_number_length']; ?>" name="phone_number_length" type="number"> numbers (0-30, <strong>0 disables length checking</strong>)</div>
</div>
</div>
<div class="card">
<h2>MailChimp</h2>
<div class="winwheel4wp_settings_section winwheel4wp_settings_section_extra">
<div><input name="mailchimp_enabled" type="hidden" value="0"><input name="mailchimp_enabled" type="checkbox" value="1" <?php echo ($wheel['mailchimp_enabled'] == true) ? 'checked' : ''; ?>> Subscribe user to MailChimp</div>
<div><input name="double_optin" type="hidden" value="0"><input name="double_optin" type="checkbox" value="1" <?php echo ($wheel['double_optin'] == true) ? 'checked' : ''; ?>> Double Opt-In</div>
<br>
<div><span style="width: 11em; display: inline-block;">MailChimp API Key</span> <input value="<?php echo $wheel['mailchimp_api_key']; ?>" name="mailchimp_api_key" type="text"></div>
<div><span style="width: 11em; display: inline-block;">MailChimp List ID</span> <input value="<?php echo $wheel['mailchimp_list_id']; ?>" name="mailchimp_list_id" type="text"></div>
</div>
</div>
<div class="card">
<h2>Connect with Webhooks</h2>
<p style="max-width:45em;">Webhooks are event notifications sent to URLs of your choice. They can be used to integrate with third-party services which support them (for example <a href="https://zapier.com" target="_new">Zapier</a>). If enabled, Win Wheel will send collected form data in JSON format to specified URL.</p>
<div><input name="webhooks_enabled" type="hidden" value="0"><input name="webhooks_enabled" type="checkbox" value="1" <?php echo ($wheel['webhooks_enabled'] == true) ? 'checked' : ''; ?>> Enabled</div>
<br>
<div><span style="width: 11em; display: inline-block;">Webhook URL</span> <input value="<?php echo $wheel['webhooks_url']; ?>" name="webhooks_url" type="text"></div>
</div>
</div>
<div id="winwheel4wp_configre_wheel_tabs_ACE">
<div class="card">
<h2>Anti-cheat engine</h2>
<div class=" winwheel4wp_settings_section winwheel4wp_settings_section_extra">
<div><input name="email_checking" type="hidden" value="0"><input name="email_checking" type="checkbox" value="1" <?php echo ($wheel['email_checking'] == true) ? 'checked' : ''; ?>> Limit spins by checking E-mail</div>
<div><input name="cookie_checking" type="hidden" value="0"><input name="cookie_checking" type="checkbox" value="1" <?php echo ($wheel['cookie_checking'] == true) ? 'checked' : ''; ?>> Limit spins by checking Cookies</div>
<div><input name="ip_checking" type="hidden" value="0"><input name="ip_checking" type="checkbox" value="1" <?php echo ($wheel['ip_checking'] == true) ? 'checked' : ''; ?>> Limit spins by checking IP</div>
<div><input name="phone_number_checking" type="hidden" value="0"><input name="phone_number_checking" type="checkbox" value="1" <?php echo ($wheel['phone_number_checking'] == true) ? 'checked' : ''; ?>> Limit spins by checking Phone number</div>
<br>
<div><span style="width: 11em; display: inline-block;">Max spins per user</span> <input min=1 value="<?php echo $wheel['max_spins_per_user']; ?>" name="max_spins_per_user" type="number"></div>
<div><span style="width: 11em; display: inline-block;">Allow spin after</span> <input min=1 value="<?php echo $wheel['reset_counter_minutes']; ?>" name="reset_counter_minutes" type="number"> minutes</div>
</div>
</div>
<div class="card">
<h2>ReCAPTCHA settings</h2>
<div class="winwheel4wp_settings_section">
<div><input name="require_captcha" type="hidden" value="0"><input name="require_captcha" type="checkbox" value="1" <?php echo ($wheel['require_captcha'] == true) ? 'checked' : ''; ?>> Enable ReCAPTCHA protection</div>
<br>
<div>Site Key:</div><input type="text" name="recaptcha_site_key" value="<?php echo get_option('winwheel4wp_recaptcha_site_key')?>">
<div>Secret:</div><input type="text" name="recaptcha_secret" value="<?php echo get_option('winwheel4wp_recaptcha_secret')?>">
</div>
</div>
</div>
<div id="winwheel4wp_configre_wheel_tabs_translations">
<div class="card">
<h2>Translate UI elements</h2>
<div class="winwheel4wp_settings_section">
<?php foreach($wheel as $key => $value) { ?>
<?php if (strpos($key,'lang_') === 0) { ?>
<p>
<?php echo $key ?>
<input type="text" name="<?php echo $key ?>" value="<?php echo esc_html(stripslashes($wheel[$key]))?>">
</p>
<?php } ?>
<?php } ?>
</div>
</div>
</div>
<div id="winwheel4wp_configre_wheel_tabs_extras">
<div class="card">
<h2>Extras</h2>
<div class="winwheel4wp_settings_section winwheel4wp_settings_section_extra">
<div><input name="enable_spin_again_dialog" type="hidden" value="0"><input name="enable_spin_again_dialog" type="checkbox" value="1" <?php echo ($wheel['enable_spin_again_dialog'] == true) ? 'checked' : ''; ?>> Show 'Spin again' dialog when user retries to spin</div>
<div><input name="enable_custom_win_probability" type="hidden" value="0"><input name="enable_custom_win_probability" type="checkbox" value="1" <?php echo ($wheel['enable_custom_win_probability'] == true) ? 'checked' : ''; ?>> Enable custom win probability ratios</div>
</div>
</div>
</div>
<br><br><input class="button button-primary" type="submit" value="Save all">
</div>
</form>
</div>
</div>
<script>
window.addEventListener('load',function(){
jQuery(function() {
jQuery('#winwheel4wp_configre_wheel_tabs').tabs({
beforeActivate: function (event, ui) { history.pushState(null,null, ui.newPanel.selector); }
});
jQuery('select.win_multiplier').change(function(){
jQuery( 'input[name=' + jQuery(this).attr('data-for') + ']' ).val( this.value );
});
var enable_custom_win_probability = <?php echo $wheel['enable_custom_win_probability'] ?>;
if ( enable_custom_win_probability ) {
jQuery('select.win_multiplier').hide();
jQuery('input.win_multiplier').show();
jQuery('.probability_calc').show();
} else {
jQuery('input.win_multiplier').hide();
}
jQuery('input.win_multiplier').change( function() {
var totals = 0;
jQuery.each(jQuery('input.win_multiplier'), function( i, v ) {
totals += parseInt( jQuery( v ).val() );
});
jQuery.each(jQuery('span.probability_percent'), function( i, v ) {
var name = jQuery( v ).data('win_multiplier');
var input_val = jQuery('input[name="'+name+'"]').val();
jQuery( v ).html( ( ( input_val / totals ) * 100 ).toFixed( 2 ) );
});
} );
jQuery('input.win_multiplier').trigger('change');
function winwheel4wp_toggle_qty_fields() {
jQuery.each(jQuery('.infinite_wins_checkbox'),function(i,el) {
var qty_el = jQuery('input[name="' + el.name.replace('_infinite','_qty') + '"]');
var qty_unlimited_el = jQuery('#' + el.name.replace('_infinite','_qty_unlimited'));
if (el.checked) {
qty_el.hide();
qty_unlimited_el.show();
} else {
qty_el.show();
qty_unlimited_el.hide();
}
});
}
winwheel4wp_toggle_qty_fields();
jQuery('.infinite_wins_checkbox').change(winwheel4wp_toggle_qty_fields);
jQuery('.reset_slice').click(function(){
var slice_number = jQuery(this).data('slice_number');
if ( ! confirm("Reset total wins for slice "+slice_number+" ?") ) return;
jQuery.post(ajaxurl,
{
action: 'winwheel4wp_reset_slice',
wheel_id: '<?php echo $wheel['wheel_id'] ?>',
slice_number: slice_number
},function(){
jQuery('#slice_'+slice_number+'_cumulative_wins').html('0');
});
});
});
jQuery('.win_message_preview').click( function() {
var target = jQuery(this).attr('data-target');
jQuery.post('<?php echo admin_url( 'admin-ajax.php' ) ?>',
{
action: 'winwheel4wp_win_message_preview',
data: jQuery('textarea[name="'+target+'"]').val(),
win_msg_color: jQuery('input[name="win_msg_color"]').val(),
_wpnonce: '<?php echo wp_create_nonce('winwheel4wp_win_message_preview'); ?>'
},
function ( response ) {
var preview_window = window.open( '', '_blank');
preview_window.document.write( response );
});
});
});
</script>
<script>
jQuery('#winwheel4wp_select_marker_image').click(function(event) {
event.preventDefault();
winwheel4wp_image_picker('#custom_marker_image');
});
jQuery('#winwheel4wp_select_wheel_image').click(function(event) {
event.preventDefault();
winwheel4wp_image_picker('#custom_wheel_image');
});
function winwheel4wp_image_picker(e)
{
var media = wp.media({
title: 'Select image',
button: {
text: 'Use this image'
},
multiple: false
});
media.on('select',function() {
var attachment = media.state().get('selection').first().toJSON();
jQuery(e).val(attachment.url);
});
media.open();
}
</script>