| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: Botpenguin |
| 4 |
* Plugin URI: https://botpenguin.com |
| 5 |
* Description: BotPenguin is an AI powered chatbot platform that enables you to quickly and easily build incredible chatbots to communicate and engage your customers on website, Facebook messenger and other platforms. |
| 6 |
* Version: 1.5.4 |
| 7 |
* Author: BotPenguin |
| 8 |
* Author URI: https://botpenguin.com |
| 9 |
* License: GPL2 |
| 10 |
* Text Domain: botpenguinbot |
| 11 |
*/ |
| 12 |
|
| 13 |
|
| 14 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 15 |
add_action('wp_head', 'BOTPENGUIN_function'); |
| 16 |
|
| 17 |
function BOTPENGUIN_function() |
| 18 |
{ |
| 19 |
$textvar = get_option('test_plugin_variable', 'botpenguin bot script'); |
| 20 |
|
| 21 |
$custom_js = "<script id='BotPenguin-messenger-widget' src='https://cdn.botpenguin.com/botpenguin.js' defer>${textvar}</script>"; |
| 22 |
// Output the JavaScript code to the head |
| 23 |
echo $custom_js; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Activate the plugin. |
| 28 |
*/ |
| 29 |
register_activation_hook(__FILE__, 'BOTPENGUIN_activate'); |
| 30 |
add_action('admin_init', 'BOTPENGUIN_redirect'); |
| 31 |
|
| 32 |
function BOTPENGUIN_activate() { |
| 33 |
add_option('BOTPENGUIN_do_activation_redirect', true); |
| 34 |
} |
| 35 |
|
| 36 |
function BOTPENGUIN_redirect() { |
| 37 |
if (get_option('BOTPENGUIN_do_activation_redirect', false)) { |
| 38 |
delete_option('BOTPENGUIN_do_activation_redirect'); |
| 39 |
wp_redirect('admin.php?page=botpenguinbot%2Fbotpenguinbot.php'); |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
add_action('admin_menu', 'BOTPENGUIN_admin_menu'); |
| 44 |
|
| 45 |
function BOTPENGUIN_admin_menu() |
| 46 |
{ |
| 47 |
add_menu_page('BotPenguin', 'BotPenguin', 'manage_options', __FILE__, 'BOTPENGUIN_footer_text_admin_page','dashicons-format-chat'); |
| 48 |
//add_management_page('BotPenguin', 'BotPenguin', 'manage_options', __FILE__, 'BOTPENGUIN_footer_text_admin_page'); |
| 49 |
} |
| 50 |
|
| 51 |
function BOTPENGUIN_footer_text_admin_page() |
| 52 |
{ |
| 53 |
|
| 54 |
$textvar = get_option('test_plugin_variable', 'botpenguin bot script'); |
| 55 |
if (isset($_POST['change-clicked'])) { |
| 56 |
|
| 57 |
if ( ! isset( $_POST['my_botpenguin_update_setting'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['my_botpenguin_update_setting'] ) ), 'botpenguin-update-setting' ) ) { |
| 58 |
die( "<br><br>Hmm .. looks like you didn't send any credentials.. No CSRF for you! " ); |
| 59 |
} |
| 60 |
$footertext = esc_url_raw($_POST['footertext']); |
| 61 |
$footerval = explode('//',$footertext); |
| 62 |
update_option('test_plugin_variable', end($footerval)); |
| 63 |
$textvar = get_option('test_plugin_variable', 'botpenguin bot script'); |
| 64 |
} |
| 65 |
|
| 66 |
?> |
| 67 |
<div class="wrap"> |
| 68 |
<div id="poststuff"> |
| 69 |
<div id="post-body" class="metabox-holder columns-2"> |
| 70 |
<div id="post-body-content"> |
| 71 |
<div class="postbox"> |
| 72 |
<div class="inside"> |
| 73 |
<img src="<?php echo plugin_dir_url( __FILE__ ) . 'images/logo.png'; ?>" alt="BotPenguin"> |
| 74 |
<h1> |
| 75 |
BotPenguin - Settings |
| 76 |
</h1> |
| 77 |
<h3 class="cc-labels"><?php esc_html_e('Instructions: ', 'botpenguinbot'); ?></h3> |
| 78 |
|
| 79 |
<p>1. |
| 80 |
<?php esc_html_e('If you do not have a BotPenguin account, please log on to <a href="https://app.botpenguin.com" target="_blank">BotPenguin</a>, and sign up', 'botpenguinbot'); ?> |
| 81 |
</p> |
| 82 |
<p>2. |
| 83 |
<?php esc_html_e('Create your website chatbot, choosing a template or from scratch. Check out this video if you need help in building the chatflow.', 'botpenguinbot'); ?> |
| 84 |
</p> |
| 85 |
<p> |
| 86 |
<a href="https://www.youtube.com/watch?v=r_djmDuX988" target="_blank">How to create an effective chatflow using BotPenguin</a> |
| 87 |
</p> |
| 88 |
<p>3. |
| 89 |
<?php esc_html_e('Once you are ready, you can click on install, then choose WordPress, and obtain the key snippet.', 'botpenguinbot'); ?> |
| 90 |
</p> |
| 91 |
<p>4. |
| 92 |
<?php esc_html_e('Paste it below and you are done.', 'botpenguinbot'); ?> |
| 93 |
</p> |
| 94 |
<p> |
| 95 |
<a class="add-new-h2" target="_blank" href="<?php echo esc_url("https://help.botpenguin.com/botpenguin-resource-center/how-botpenguin-works/install-your-website-chatbot/install-website-bot-on-wordpress"); ?>"> |
| 96 |
<?php esc_html_e('Read Tutorial', 'botpenguinbot'); ?> |
| 97 |
</a> <a class="add-new-h2" target="_blank" href="<?php echo esc_url("https://youtu.be/ZRtAz78LSOI"); ?>"> |
| 98 |
<?php esc_html_e('Watch Tutorial', 'botpenguinbot'); ?></a> |
| 99 |
</p> |
| 100 |
<h3 class="cc-labels" for="script"><?php esc_html_e('BotPenguin Key Snippet:', 'botpenguinbot'); ?></h3> |
| 101 |
<?php $PHP_SELF = sanitize_url($_SERVER['REQUEST_URI']); ?> |
| 102 |
<form action="<?php echo esc_url($PHP_SELF); ?>" method="post"> |
| 103 |
<input style="width:100%" type="text" class="regular-text" value="<?php echo esc_html($textvar); ?>" placeholder="Paste your BotPenguin Key here, it resembles e056149d872d8429c7hduofhuhu8e56fb193dcc6c933f5" name="footertext"> |
| 104 |
<input name="change-clicked" type="hidden" value="1" /> |
| 105 |
<input name="my_botpenguin_update_setting" type="hidden" value="<?php echo wp_create_nonce('botpenguin-update-setting'); ?>" /> |
| 106 |
<br /> |
| 107 |
<br /> |
| 108 |
<input class="button button-primary" type="submit" value="<?php esc_html_e('Save settings', 'botpenguinbot'); ?>" /> |
| 109 |
</form> |
| 110 |
</div> |
| 111 |
</div> |
| 112 |
</div> |
| 113 |
<?php require_once('sidebar.php'); ?> |
| 114 |
</div> |
| 115 |
</div> |
| 116 |
</div> |
| 117 |
|
| 118 |
<?php |
| 119 |
} |
| 120 |
?> |