| 1 |
<?php |
| 2 |
$is_lws = false; |
| 3 |
if (isset($_SERVER['lwscache'])) { |
| 4 |
$is_lws = true; |
| 5 |
} |
| 6 |
?> |
| 7 |
|
| 8 |
<div class="lws_tk_div_title_plugins"> |
| 9 |
<h3 class="lws_tk_title_plugins"> <?php esc_html_e('AI Management', 'lws-tools'); ?></h3> |
| 10 |
<h4 class="lws_tk_subtitle_plugins"><?php esc_html_e('WPilot, your personal WordPress expert', 'lws-tools'); ?></h4> |
| 11 |
<p class="lws_tk_text_base" style="margin-bottom: 0;"> |
| 12 |
<?php esc_html_e('WPilot is your dedicated AI assistant for WordPress. He automatically analyzes your site, plugins, and theme to provide personalized advice. He guides you through creating, updating, and optimizing your site while helping you troubleshoot common issues. Enjoy a true co-pilot for building and evolving your site with ease.', 'lws-tools'); ?> |
| 13 |
</p> |
| 14 |
</div> |
| 15 |
<div class="lws_tk_tab_line lws_tk_tab_border lws_tk_tab_border_blue"> |
| 16 |
<div class="lws_tk_tab" style="width: 100%;"> |
| 17 |
<label class="lws_tk_ia_label" for=''> |
| 18 |
<div> |
| 19 |
<span><?php esc_html_e('Activate WPilot, the AI assistant', 'lws-tools'); ?></span> |
| 20 |
</div> |
| 21 |
<label class="mab_mml_ttbt_td_switch"> |
| 22 |
<input class="mab_mml_ttbt_input" name="ia_chatbot_state" id="ia_chatbot_state" type="checkbox" <?php echo ((get_option('lws_tk_ia_chatbot_state', false) || !$is_lws) ? '' : 'checked'); ?>> |
| 23 |
<span class="mab_mml_ttbt_td_s_slider round"></span> |
| 24 |
</label> |
| 25 |
</label> |
| 26 |
</div> |
| 27 |
</div> |
| 28 |
|
| 29 |
<script> |
| 30 |
document.getElementById('ia_chatbot_state').addEventListener('change', function() { |
| 31 |
var isChecked = this.checked; |
| 32 |
let checkbox = this; |
| 33 |
|
| 34 |
let is_lws = "<?php echo $is_lws; ?>"; |
| 35 |
|
| 36 |
if (!is_lws) { |
| 37 |
checkbox.checked = false; |
| 38 |
showLWSModal(); |
| 39 |
return; |
| 40 |
} |
| 41 |
|
| 42 |
let ajaxRequest = jQuery.ajax({ |
| 43 |
url: ajaxurl, |
| 44 |
type: "POST", |
| 45 |
timeout: 120000, |
| 46 |
context: document.body, |
| 47 |
data: { |
| 48 |
_ajax_nonce: "<?php echo esc_html(wp_create_nonce("ia_chatbot_nonce")); ?>", |
| 49 |
action: 'update_ia_chatbot_state', |
| 50 |
state: isChecked ? 1 : 0, |
| 51 |
}, |
| 52 |
|
| 53 |
success: function(data) { |
| 54 |
if (data === null || typeof data != 'string') { |
| 55 |
return 0; |
| 56 |
} |
| 57 |
|
| 58 |
try { |
| 59 |
var returnData = JSON.parse(data); |
| 60 |
} catch (e) { |
| 61 |
console.log(e); |
| 62 |
returnData = { |
| 63 |
'code': "NOT_JSON", |
| 64 |
'data': "FAIL" |
| 65 |
}; |
| 66 |
} |
| 67 |
|
| 68 |
switch (returnData['code']) { |
| 69 |
case 'SUCCESS': |
| 70 |
callPopup('success', '<?php echo esc_html__('IA Chatbot state updated successfully.', 'lws-tools'); ?>'); |
| 71 |
break; |
| 72 |
case "NOT_LWS": |
| 73 |
callPopup('error', '<?php echo esc_html__('Chatbot is only available on LWS hostings.', 'lws-tools'); ?>'); |
| 74 |
checkbox.checked = false; |
| 75 |
break; |
| 76 |
default: |
| 77 |
callPopup('error', '<?php echo esc_html__('Error updating IA Chatbot state.', 'lws-tools'); ?>'); |
| 78 |
break; |
| 79 |
} |
| 80 |
}, |
| 81 |
error: function(error) { |
| 82 |
callPopup('error', '<?php echo esc_html__('Unknown error while updating IA Chatbot state.', 'lws-tools'); ?>'); |
| 83 |
console.log(error); |
| 84 |
return 1; |
| 85 |
} |
| 86 |
}); |
| 87 |
}); |
| 88 |
|
| 89 |
function showLWSModal() { |
| 90 |
document.getElementById('lwsModal').style.display = 'block'; |
| 91 |
} |
| 92 |
|
| 93 |
function closeLWSModal() { |
| 94 |
document.getElementById('lwsModal').style.display = 'none'; |
| 95 |
} |
| 96 |
|
| 97 |
// Close modal when clicking outside of it |
| 98 |
window.onclick = function(event) { |
| 99 |
var modal = document.getElementById('lwsModal'); |
| 100 |
if (event.target == modal) { |
| 101 |
modal.style.display = 'none'; |
| 102 |
} |
| 103 |
} |
| 104 |
</script> |
| 105 |
|
| 106 |
<!-- LWS Modal --> |
| 107 |
<div id="lwsModal" class="lws-modal"> |
| 108 |
<div class="lws-modal-content"> |
| 109 |
<span class="lws-modal-close" onclick="closeLWSModal()">×</span> |
| 110 |
<div class="lws-modal-body"> |
| 111 |
<h2 class="lws-modal-title"><?php esc_html_e('Available only with LWS Hostings', 'lws-tools'); ?></h2> |
| 112 |
<p class="lws-modal-subtitle"> |
| 113 |
<?php esc_html_e('The intelligent assistant WPilot is reserved for customers with LWS hosting.', 'lws-tools'); ?> |
| 114 |
</p> |
| 115 |
|
| 116 |
<div class="lws-modal-features"> |
| 117 |
<h3><?php esc_html_e('WPilot is your WordPress co-pilot:', 'lws-tools'); ?></h3> |
| 118 |
<ul> |
| 119 |
<li><?php esc_html_e('Analyzes your site, extensions and theme', 'lws-tools'); ?></li> |
| 120 |
<li><?php esc_html_e('Helps you create, maintain and optimize your site', 'lws-tools'); ?></li> |
| 121 |
<li><?php esc_html_e('Provides personalized advice and solves common problems', 'lws-tools'); ?></li> |
| 122 |
</ul> |
| 123 |
</div> |
| 124 |
|
| 125 |
<div class="lws-modal-offer"> |
| 126 |
<h3><?php esc_html_e('Get WPilot with LWS WordPress hosting', 'lws-tools'); ?></h3> |
| 127 |
<p class="lws-modal-offer-subtitle"> |
| 128 |
<?php esc_html_e('The best WordPress host to create your site easily.', 'lws-tools'); ?> |
| 129 |
</p> |
| 130 |
|
| 131 |
<div class="lws-modal-benefits"> |
| 132 |
<div class="lws-benefit"> |
| 133 |
<?php esc_html_e('1-click installation – Ultra-fast and reliable WordPress', 'lws-tools'); ?> |
| 134 |
</div> |
| 135 |
<div class="lws-benefit"> |
| 136 |
<?php esc_html_e('Free domain (.fr, .com...)', 'lws-tools'); ?> |
| 137 |
</div> |
| 138 |
<div class="lws-benefit"> |
| 139 |
<?php esc_html_e('Secure site + 100% SSD storage', 'lws-tools'); ?> |
| 140 |
</div> |
| 141 |
<div class="lws-benefit"> |
| 142 |
<?php esc_html_e('AI, Divi Builder, Elegant Themes included', 'lws-tools'); ?> |
| 143 |
</div> |
| 144 |
</div> |
| 145 |
|
| 146 |
<div class="lws-modal-price"> |
| 147 |
<span class="lws-price-highlight"><?php esc_html_e('Only €2.99/month instead of €4.99', 'lws-tools'); ?></span> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
|
| 151 |
<div style="text-align: center; margin-top: 20px;"> |
| 152 |
<a href="https://www.lws.fr/hebergement_wordpress.php" class="lws-modal-cta" target="_blank"> |
| 153 |
<?php esc_html_e('Take advantage of the LWS WordPress offer', 'lws-tools'); ?> |
| 154 |
</a> |
| 155 |
</div> |
| 156 |
</div> |
| 157 |
</div> |
| 158 |
</div> |