| 1 |
<?php |
| 2 |
/** |
| 3 |
* Support Page |
| 4 |
* |
| 5 |
* @package Wow_Pluign |
| 6 |
* @author Dmytro Lobov <helper@wow-company.com> |
| 7 |
* @copyright 2019 Wow-Company |
| 8 |
* @since 1.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
$plugin = $this->plugin['name'] . ' v.' . $this->plugin['version']; |
| 16 |
$website = get_option( 'home' ); |
| 17 |
|
| 18 |
?> |
| 19 |
|
| 20 |
<div class="about-wrap wow-support"> |
| 21 |
<div class="feature-section one-col"> |
| 22 |
<div class="col"> |
| 23 |
|
| 24 |
<p><?php printf( esc_attr__( 'To get your support related question answered in the fastest timing, please send a message via the form below or write to us on email %1$s', |
| 25 |
$this->plugin['text'] ), '<a href="mailto:helper@wow-company.com">helper@wow-company.com</a>' ); ?> |
| 26 |
.</p> |
| 27 |
|
| 28 |
<p><?php esc_attr_e( 'Also, you can send us your ideas and suggestions for improving the plugin.', |
| 29 |
$this->plugin['text'] ); ?></p> |
| 30 |
<?php $error = array(); |
| 31 |
if ( ! empty( $_POST['action'] ) && ! empty( $_POST['wow_support_field'] ) ) { |
| 32 |
if ( wp_verify_nonce( $_POST['wow_support_field'], 'wow_support_action' ) |
| 33 |
&& current_user_can( 'manage_options' ) |
| 34 |
) { |
| 35 |
|
| 36 |
$fname = ! empty( $_POST['wow-fname'] ) ? sanitize_text_field( $_POST['wow-fname'] ) : ''; |
| 37 |
$lname = ! empty( $_POST['wow-lname'] ) ? sanitize_text_field( $_POST['wow-lname'] ) : ''; |
| 38 |
$message = ! empty( $_POST['wow-message'] ) ? wp_kses_post( $_POST['wow-message'] ) : ''; |
| 39 |
$email = ! empty( $_POST['wow-email'] ) ? sanitize_email( $_POST['wow-email'] ) : ''; |
| 40 |
$type = ! empty( $_POST['wow-message-type'] ) ? sanitize_text_field( $_POST['wow-message-type'] ) |
| 41 |
: ''; |
| 42 |
|
| 43 |
if ( empty( $fname ) ) { |
| 44 |
$fname = 'Anonymous'; |
| 45 |
} |
| 46 |
if ( empty( $lname ) ) { |
| 47 |
$lname = 'Customer'; |
| 48 |
} |
| 49 |
if ( empty( $message ) ) { |
| 50 |
$error[] = esc_attr__( 'Please, Enter your Message.', $this->plugin['text'] ); |
| 51 |
} |
| 52 |
if ( empty( $email ) ) { |
| 53 |
$error[] = esc_attr__( 'Please, Enter your Email.', $this->plugin['text'] ); |
| 54 |
} |
| 55 |
if ( count( $error ) == 0 ) { |
| 56 |
|
| 57 |
|
| 58 |
$headers = array( |
| 59 |
'From: ' . esc_attr( $fname ) . ' ' . esc_attr( $lname ) . ' <' . sanitize_email( $email ) . '>', |
| 60 |
'content-type: text/html', |
| 61 |
); |
| 62 |
$message_mail = ' |
| 63 |
<html> |
| 64 |
<head></head> |
| 65 |
<body> |
| 66 |
<table> |
| 67 |
<tr> |
| 68 |
<td><strong>Plugin:</strong></td> |
| 69 |
<td>' . esc_attr( $plugin ) . '</td> |
| 70 |
</tr> |
| 71 |
<tr> |
| 72 |
<td><strong>Website:</strong></td> |
| 73 |
<td><a href="' . esc_url( $website ) . '">' . esc_url( $website ) . '</a></td> |
| 74 |
</tr> |
| 75 |
</table> |
| 76 |
' . nl2br( wp_kses_post( $message ) ) . ' |
| 77 |
</body> |
| 78 |
</html>'; |
| 79 |
wp_mail( 'helper@wow-company.com', 'Support Ticket: ' . $type, $message_mail, $headers ); |
| 80 |
echo '<div class="wow-alert wow-alert-update "><p class="wow_error">' |
| 81 |
. esc_attr__( 'Your Message sent to the Support.', $this->plugin['text'] ) . '</p></div>'; |
| 82 |
|
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
} else { |
| 87 |
echo '<div class="wow-alert wow-alert-error "><p class="wow_error">' |
| 88 |
. esc_attr__( 'Sorry, but message did not send. Please, contact us helper@wow-company.com', |
| 89 |
$this->plugin['text'] ) . ' </p></div>'; |
| 90 |
} |
| 91 |
} |
| 92 |
?> |
| 93 |
<?php if ( count( $error ) > 0 ) { |
| 94 |
echo '<div class="wow-alert wow-alert-error "><p class="wow_error">' . implode( "<br />", $error ) |
| 95 |
. '</p></div>'; |
| 96 |
} ?> |
| 97 |
|
| 98 |
|
| 99 |
<form method="post" action="" class="wow-plugin"> |
| 100 |
<div class="columns"> |
| 101 |
<div class="column"> |
| 102 |
<div class="field"> |
| 103 |
<label class="label"> |
| 104 |
<?php esc_html_e( 'First Name', $this->plugin['text'] ); ?> |
| 105 |
</label> |
| 106 |
<div class="control is-expanded"> |
| 107 |
<input type="text" class="input" name="wow-fname" value="" |
| 108 |
placeholder="<?php esc_html_e( 'Enter Your First Name', $this->plugin['text'] ); ?>"> |
| 109 |
</div> |
| 110 |
</div> |
| 111 |
|
| 112 |
</div> |
| 113 |
<div class="column"> |
| 114 |
<div class="field"> |
| 115 |
<label class="label"> |
| 116 |
<?php esc_html_e( 'Last Name', $this->plugin['text'] ); ?> |
| 117 |
</label> |
| 118 |
<div class="control is-expanded"> |
| 119 |
<input type="text" name="wow-lname" value="" class="input" |
| 120 |
placeholder="<?php esc_html_e( 'Enter Your Last Name', $this->plugin['text'] ); ?>"> |
| 121 |
</div> |
| 122 |
</div> |
| 123 |
|
| 124 |
</div> |
| 125 |
</div> |
| 126 |
<div class="columns"> |
| 127 |
<div class="column"> |
| 128 |
<div class="field"> |
| 129 |
<label class="label"> |
| 130 |
<?php esc_html_e( 'Link to the page with issue', $this->plugin['text'] ); ?> |
| 131 |
</label> |
| 132 |
<div class="control is-expanded"> |
| 133 |
<input type="text" class="input" name="wow-website" |
| 134 |
value="<?php echo esc_url( get_option( 'home' ) ); ?>"> |
| 135 |
</div> |
| 136 |
</div> |
| 137 |
|
| 138 |
</div> |
| 139 |
<div class="column"> |
| 140 |
<div class="field"> |
| 141 |
<label class="label"> |
| 142 |
<?php esc_html_e( 'Contact email', $this->plugin['text'] ); ?> |
| 143 |
</label> |
| 144 |
<div class="control is-expanded"> |
| 145 |
<input type="text" class="input" name="wow-email" |
| 146 |
value="<?php echo sanitize_email( get_option( 'admin_email' ) ); ?>"> |
| 147 |
</div> |
| 148 |
</div> |
| 149 |
</div> |
| 150 |
|
| 151 |
</div> |
| 152 |
|
| 153 |
<div class="columns"> |
| 154 |
|
| 155 |
<div class="column"> |
| 156 |
<div class="field"> |
| 157 |
<label class="label"> |
| 158 |
<?php esc_html_e( 'Plugin', $this->plugin['text'] ); ?> |
| 159 |
</label> |
| 160 |
<div class="control is-expanded"> |
| 161 |
<input type="text" class="input" disabled name="wow-plugin" |
| 162 |
value="<?php if ( ! empty( $name ) ) { |
| 163 |
esc_attr_e( $plugin ); |
| 164 |
}; ?>"> |
| 165 |
</div> |
| 166 |
</div> |
| 167 |
</div> |
| 168 |
<div class="column"> |
| 169 |
<div class="field"> |
| 170 |
<label class="label"> |
| 171 |
<?php esc_html_e( 'Message type', $this->plugin['text'] ); ?> |
| 172 |
</label> |
| 173 |
<div class="control is-expanded"> |
| 174 |
<div class="select is-fullwidth"> |
| 175 |
<select name="wow-message-type"> |
| 176 |
<option value="Issue"><?php esc_html_e( 'Issue', $this->plugin['text'] ); ?></option> |
| 177 |
<option value="Idea"><?php esc_html_e( 'Idea', $this->plugin['text'] ); ?></option> |
| 178 |
</select> |
| 179 |
</div> |
| 180 |
</div> |
| 181 |
</div> |
| 182 |
</div> |
| 183 |
</div> |
| 184 |
<div class="columns"> |
| 185 |
<div class="column"> |
| 186 |
<div class="field"> |
| 187 |
<div class="control is-expanded"> |
| 188 |
|
| 189 |
<?php |
| 190 |
$content = esc_attr__( 'Enter Your Message', $this->plugin['text'] ); |
| 191 |
$editor_id = 'editormessage'; |
| 192 |
$settings = array( |
| 193 |
'textarea_name' => 'wow-message', |
| 194 |
); |
| 195 |
wp_editor( $content, $editor_id, $settings ); ?> |
| 196 |
|
| 197 |
</div> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
|
| 201 |
</div> |
| 202 |
<div class="columns"> |
| 203 |
<div class="column"> |
| 204 |
<input type="submit" class="button button-primary" name="action" |
| 205 |
value="<?php esc_html_e( 'Send to Support', $this->plugin['text'] ); ?>"> |
| 206 |
</div> |
| 207 |
</div> |
| 208 |
<?php wp_nonce_field( 'wow_support_action', 'wow_support_field' ); ?> |
| 209 |
</form> |
| 210 |
</div> |
| 211 |
|
| 212 |
</div> |
| 213 |
</div> |
| 214 |
<?php |
| 215 |
|