| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
/** |
| 6 |
* QuantumCloud Promo + Support Page |
| 7 |
* Revised On: 18-10-2023 |
| 8 |
*/ |
| 9 |
|
| 10 |
if ( ! defined( 'qcld_wpchatbot_comments_support_path' ) ) { |
| 11 |
define( 'qcld_wpchatbot_comments_support_path', plugin_dir_path( __FILE__ ) ); |
| 12 |
} |
| 13 |
|
| 14 |
if ( ! defined( 'qcld_wpchatbot_comments_support_url' ) ) { |
| 15 |
define( 'qcld_wpchatbot_comments_support_url', plugin_dir_url( __FILE__ ) ); |
| 16 |
} |
| 17 |
|
| 18 |
if ( ! defined( 'qcld_support_img_url' ) ) { |
| 19 |
define( 'qcld_support_img_url', qcld_wpchatbot_comments_support_url . '/images' ); |
| 20 |
} |
| 21 |
|
| 22 |
/** |
| 23 |
* Callback function to add the menu |
| 24 |
* |
| 25 |
* @return void |
| 26 |
*/ |
| 27 |
function qcld_wpchatbot_comments_show_promo_page_callback_func() { |
| 28 |
$capability = function_exists( 'qcld_wpchatbot_get_menu_capability' ) ? qcld_wpchatbot_get_menu_capability( 'wpbot_support' ) : 'manage_options'; |
| 29 |
|
| 30 |
/*add_submenu_page( |
| 31 |
'comment-link-remove', |
| 32 |
esc_html__( 'More WordPress Goodies for You!', 'chatbot' ), |
| 33 |
esc_html__( 'Support', 'chatbot' ), |
| 34 |
$capability, |
| 35 |
'qcclr_comment_supports', |
| 36 |
'qcld_wpchatbot_comments_promo_support_page_callback_func' |
| 37 |
);*/ |
| 38 |
|
| 39 |
} //show_promo_page_callback_func. |
| 40 |
|
| 41 |
add_action( 'admin_menu', 'qcld_wpchatbot_comments_show_promo_page_callback_func', 110 ); |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
if ( ! function_exists( 'qcld_wpchatbot_comments_include_promo_page_scripts' ) ) { |
| 46 |
|
| 47 |
/** |
| 48 |
* Script Main Class function |
| 49 |
* |
| 50 |
* @return void |
| 51 |
*/ |
| 52 |
function qcld_wpchatbot_comments_include_promo_page_scripts() { |
| 53 |
|
| 54 |
if ( isset( $_GET['page'] ) && ! empty( $_GET['page'] ) && ( $_GET['page'] == 'wpbot_support_page' ) ) { |
| 55 |
|
| 56 |
$support_css_ver = defined( 'QCLD_wpCHATBOT_VERSION' ) ? QCLD_wpCHATBOT_VERSION : '1.0.0'; |
| 57 |
$support_deps = array(); |
| 58 |
|
| 59 |
if ( defined( 'QCLD_wpCHATBOT_PLUGIN_URL' ) ) { |
| 60 |
wp_enqueue_style( |
| 61 |
'qlcd-wp-chatbot-admin-style', |
| 62 |
QCLD_wpCHATBOT_PLUGIN_URL . 'css/admin-style.css', |
| 63 |
array(), |
| 64 |
$support_css_ver, |
| 65 |
'screen' |
| 66 |
); |
| 67 |
$support_deps[] = 'qlcd-wp-chatbot-admin-style'; |
| 68 |
} |
| 69 |
|
| 70 |
wp_enqueue_style( |
| 71 |
'qcld-wpchatbot-support-style-css', |
| 72 |
qcld_wpchatbot_comments_support_url . 'css/support-page.css', |
| 73 |
$support_deps, |
| 74 |
$support_css_ver, |
| 75 |
'screen' |
| 76 |
); |
| 77 |
|
| 78 |
} |
| 79 |
} |
| 80 |
|
| 81 |
add_action( 'admin_enqueue_scripts', 'qcld_wpchatbot_comments_include_promo_page_scripts' ); |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
/******************************* |
| 86 |
* Callback function to show the HTML. |
| 87 |
*/ |
| 88 |
|
| 89 |
require_once qcld_wpchatbot_comments_support_path . '/qc-clr-recommendbot-support-plugin.php'; |
| 90 |
|
| 91 |
if ( ! function_exists( 'qcpromo_wpbot_free_support_page_callback_func' ) ) { |
| 92 |
|
| 93 |
/** |
| 94 |
* Callback function |
| 95 |
* |
| 96 |
* @return void |
| 97 |
*/ |
| 98 |
function qcpromo_wpbot_free_support_page_callback_func() { |
| 99 |
|
| 100 |
$plugin_version = defined( 'QCLD_wpCHATBOT_VERSION' ) ? QCLD_wpCHATBOT_VERSION : ''; |
| 101 |
$plugin_img = defined( 'QCLD_wpCHATBOT_IMG_URL' ) ? QCLD_wpCHATBOT_IMG_URL . '/chatbot.png' : ''; |
| 102 |
|
| 103 |
?> |
| 104 |
<div class="wrap qcld-main-wrapper wpbot-support-page"> |
| 105 |
<h1 class="screen-reader-text"><?php esc_html_e( 'Get Support', 'chatbot' ); ?></h1> |
| 106 |
|
| 107 |
<div class="wpbot-support-inner"> |
| 108 |
<div class="qcld-wp-chatbot-wrap-header"> |
| 109 |
<div class="qcld-wp-chatbot-wrap-header-logo"> |
| 110 |
<?php if ( $plugin_img ) : ?> |
| 111 |
<img src="<?php echo esc_url( $plugin_img ); ?>" alt="WPBot"> |
| 112 |
<?php endif; ?> |
| 113 |
<div class="qcld-wp-chatbot-wrap-header-copy"> |
| 114 |
<a href="#" class="qcld-wp-chatbot-wrap-site__logo"><?php esc_html_e( 'WPBot Control Panel', 'chatbot' ); ?></a> |
| 115 |
<?php if ( $plugin_version ) : ?> |
| 116 |
<p><strong><?php esc_html_e( 'Core Version:', 'chatbot' ); ?></strong> v<?php echo esc_html( $plugin_version ); ?></p> |
| 117 |
<?php endif; ?> |
| 118 |
</div> |
| 119 |
</div> |
| 120 |
<ul class="qcld-wp-chatbot-wrap-version-wrapper"> |
| 121 |
<li> |
| 122 |
<a class="wpchatbot-Upgrade" href="https://www.wpbot.pro/" target="_blank"><?php esc_html_e( 'Upgrade To Pro', 'chatbot' ); ?></a> |
| 123 |
</li> |
| 124 |
</ul> |
| 125 |
</div> |
| 126 |
|
| 127 |
<div class="wpbot-support-hero"> |
| 128 |
<h2><?php esc_html_e( 'Get Support', 'chatbot' ); ?></h2> |
| 129 |
<p><?php esc_html_e( 'Stuck? Need help? Is the plugin missing a feature you need? Open a support ticket and our team will help you out.', 'chatbot' ); ?></p> |
| 130 |
</div> |
| 131 |
|
| 132 |
<div class="wpbot-support-grid"> |
| 133 |
<article class="wpbot-support-card"> |
| 134 |
<div class="wpbot-support-card__icon"> |
| 135 |
<span class="dashicons dashicons-sos" aria-hidden="true"></span> |
| 136 |
</div> |
| 137 |
<h3><?php esc_html_e( 'Priority Support', 'chatbot' ); ?></h3> |
| 138 |
<p><?php esc_html_e( 'Pro users get faster, one-on-one help from our support team.', 'chatbot' ); ?></p> |
| 139 |
<a class="wpbot-support-btn wpbot-support-btn--primary" href="<?php echo esc_url( 'https://qc.turbopowers.com/' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Get Priority Support', 'chatbot' ); ?></a> |
| 140 |
</article> |
| 141 |
|
| 142 |
<article class="wpbot-support-card"> |
| 143 |
<div class="wpbot-support-card__icon"> |
| 144 |
<span class="dashicons dashicons-book-alt" aria-hidden="true"></span> |
| 145 |
</div> |
| 146 |
<h3><?php esc_html_e( 'Knowledge Base', 'chatbot' ); ?></h3> |
| 147 |
<p><?php esc_html_e( 'Browse guides and documentation to find quick answers on your own.', 'chatbot' ); ?></p> |
| 148 |
<a class="wpbot-support-btn wpbot-support-btn--outline" href="<?php echo esc_url( 'https://wpbot.pro/docs/' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Online KnowledgeBase', 'chatbot' ); ?></a> |
| 149 |
</article> |
| 150 |
|
| 151 |
<article class="wpbot-support-card"> |
| 152 |
<div class="wpbot-support-card__icon"> |
| 153 |
<span class="dashicons dashicons-wordpress" aria-hidden="true"></span> |
| 154 |
</div> |
| 155 |
<h3><?php esc_html_e( 'Free Version Support', 'chatbot' ); ?></h3> |
| 156 |
<p><?php esc_html_e( 'Get help from the WordPress.org support forum for the free version.', 'chatbot' ); ?></p> |
| 157 |
<a class="wpbot-support-btn wpbot-support-btn--soft" href="<?php echo esc_url( 'https://wordpress.org/support/plugin/chatbot/' ); ?>" target="_blank" rel="noopener noreferrer"><?php esc_html_e( 'Get Support for Free Version', 'chatbot' ); ?></a> |
| 158 |
</article> |
| 159 |
</div> |
| 160 |
</div> |
| 161 |
</div> |
| 162 |
<?php |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
/******************************* |
| 168 |
* Handle Ajex Request for Form Processing. |
| 169 |
*/ |
| 170 |
add_action( 'wp_ajax_qcld_wpchatbot_comments_process_qc_promo_form', 'qcld_wpchatbot_comments_process_qc_promo_form' ); |
| 171 |
|
| 172 |
if ( ! function_exists( 'qcld_wpchatbot_comments_process_qc_promo_form' ) ) { |
| 173 |
|
| 174 |
/** |
| 175 |
* Comnt process function |
| 176 |
* |
| 177 |
* @return void |
| 178 |
*/ |
| 179 |
function qcld_wpchatbot_comments_process_qc_promo_form() { |
| 180 |
|
| 181 |
check_ajax_referer( 'wpchatbot', 'security' ); |
| 182 |
|
| 183 |
$data['status'] = 'failed'; |
| 184 |
$data['message'] = esc_html__( |
| 185 |
'Problem in processing your form submission request! Apologies for the inconveniences.<br> |
| 186 |
Please email to <span style="color:#22A0C9;font-weight:bold !important;font-size:14px "> [email protected] </span> with any feedback. We will get back to you right away!', |
| 187 |
'chatbot' |
| 188 |
); |
| 189 |
|
| 190 |
$name = isset( $_POST['post_name'] ) ? trim( sanitize_text_field( $_POST['post_name'] ) ) : ''; |
| 191 |
$email = isset( $_POST['post_email'] ) ? trim( sanitize_email( $_POST['post_email'] ) ) : ''; |
| 192 |
$subject = isset( $_POST['post_subject'] ) ? trim( sanitize_text_field( $_POST['post_subject'] ) ) : ''; |
| 193 |
$message = isset( $_POST['post_message'] ) ? trim( sanitize_text_field( $_POST['post_message'] ) ) : ''; |
| 194 |
$plugin_name = isset( $_POST['post_plugin_name'] ) ? trim( sanitize_text_field( $_POST['post_plugin_name'] ) ) : ''; |
| 195 |
|
| 196 |
if ( $name == '' || $email == '' || $subject == '' || $message == '' ) { |
| 197 |
$data['message'] = esc_html__( 'Please fill up all the requried form fields.', 'chatbot' ); |
| 198 |
} elseif ( filter_var( $email, FILTER_VALIDATE_EMAIL ) === false ) { |
| 199 |
$data['message'] = esc_html__( 'Invalid email address.', 'chatbot' ); |
| 200 |
} else { |
| 201 |
|
| 202 |
// build email body. |
| 203 |
|
| 204 |
$bodyContent = ''; |
| 205 |
|
| 206 |
$bodyContent .= '<p><strong>' . esc_html__( 'Support Request Details:', 'chatbot' ) . '</strong></p><hr>'; |
| 207 |
|
| 208 |
$bodyContent .= '<p>' . esc_html__( 'Name', 'chatbot' ) . ' : ' . esc_html( $name ) . '</p>'; |
| 209 |
$bodyContent .= '<p>' . esc_html__( 'Email', 'chatbot' ) . ' : ' . esc_html( $email ) . '</p>'; |
| 210 |
$bodyContent .= '<p>' . esc_html__( 'Subject', 'chatbot' ) . ' : ' . esc_html( $subject ) . '</p>'; |
| 211 |
$bodyContent .= '<p>' . esc_html__( 'Message', 'chatbot' ) . ' : ' . esc_html( $message ) . '</p>'; |
| 212 |
|
| 213 |
$bodyContent .= '<p>' . esc_html__( 'Sent Via the Plugin', 'chatbot' ) . ' : ' . esc_html( $plugin_name ) . '</p>'; |
| 214 |
|
| 215 |
$bodyContent .= '<p></p><p>' . esc_html__( 'Mail sent from:', 'chatbot' ) . ' <strong>' . esc_html( get_bloginfo( 'name' ) ) . '</strong>, ' . esc_html__( 'URL:', 'chatbot' ) . ' [' . esc_html( get_bloginfo( 'url' ) ) . '].</p>'; |
| 216 |
$bodyContent .= '<p>' . esc_html__( 'Mail Generated on:', 'chatbot' ) . ' ' . esc_html( gmdate( 'F j, Y, g:i a' ) ) . '</p>'; |
| 217 |
|
| 218 |
$toEmail = '[email protected]'; // Receivers email address. |
| 219 |
// $toEmail = "[email protected]"; //Receivers email address. |
| 220 |
|
| 221 |
// Extract Domain. |
| 222 |
$url = get_site_url(); |
| 223 |
$url = wp_parse_url( $url ); |
| 224 |
$domain = isset( $url['host'] ) ? $url['host'] : ''; |
| 225 |
|
| 226 |
$fakeFromEmailAddress = 'wordpress@' . $domain; |
| 227 |
|
| 228 |
$to = $toEmail; |
| 229 |
$body = $bodyContent; |
| 230 |
$headers = array(); |
| 231 |
$headers[] = 'Content-Type: text/html; charset=UTF-8'; |
| 232 |
$headers[] = 'From: ' . esc_attr( $name ) . ' <' . esc_attr( $fakeFromEmailAddress ) . '>'; |
| 233 |
$headers[] = 'Reply-To: ' . esc_attr( $name ) . ' <' . esc_attr( $email ) . '>'; |
| 234 |
|
| 235 |
$finalSubject = esc_html( 'From Plugin Support Page:' ) . ' ' . esc_attr( $subject ); |
| 236 |
|
| 237 |
$result = wp_mail( $to, $finalSubject, $body, $headers ); |
| 238 |
|
| 239 |
if ( $result ) { |
| 240 |
$data['status'] = 'success'; |
| 241 |
$data['message'] = esc_html__( 'Your email was sent successfully. Thanks!', 'chatbot' ); |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
ob_clean(); |
| 246 |
|
| 247 |
echo json_encode( $data ); |
| 248 |
|
| 249 |
die(); |
| 250 |
} |
| 251 |
} |
| 252 |
|