PluginProbe
Gmedia Photo Gallery / trunk
Gmedia Photo Gallery vtrunk
trunk 0.6.3 0.8.6 0.9.23 1.1.1 1.12.4 1.13.4 1.14.7 1.16.4 1.16.6 1.16.7 1.17.6 1.18.0 1.2.6 1.20.0 1.21.6 1.21.8 1.21.9 1.22.0 1.23.0 1.24.0 1.24.1 1.25.0 1.25.1 1.3.7 All 37 releases
grand-media / admin / support.php

support.php in Gmedia Photo Gallery trunk, at admin/support.php

305 lines 14.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined( 'ABSPATH' ) || die( 'No script kiddies please!' );
3
4 /**
5 * gmediaSupport()
6 *
7 * @return void content
8 */
9 function gmediaSupport() {
10 global $gmCore, $gmGallery;
11 if ( ! empty( $_POST ) ) {
12 if ( ! current_user_can( 'manage_options' ) ) {
13 wp_die( esc_html__( 'You are not allowed to run this process.', 'grand-media' ), '', array( 'response' => 403 ) );
14 }
15 check_admin_referer( 'gmedia_support' );
16 }
17 $current_user = wp_get_current_user();
18 $alert = '';
19
20 $subject = $gmCore->_post( 'subject' );
21 $name = trim( $gmCore->_post( 'name', '' ) );
22 $email = trim( $gmCore->_post( 'email', '' ) );
23 $summary = trim( $gmCore->_post( 'summary', '' ) );
24 $message = trim( $gmCore->_post( 'message', '' ) );
25
26 $domain = trim( $gmCore->_post( 'domain', '' ) );
27 $link = trim( $gmCore->_post( 'link', '' ) );
28 $wp_admin_user = trim( $gmCore->_post( 'wp_admin_user', '' ) );
29 $wp_admin_password = trim( $gmCore->_post( 'wp_admin_password', '' ) );
30 $ftp_host = trim( $gmCore->_post( 'ftp_host', '' ) );
31 $ftp_user = trim( $gmCore->_post( 'ftp_user', '' ) );
32 $ftp_password = trim( $gmCore->_post( 'ftp_password', '' ) );
33
34 if ( $subject && $name && $email && is_email( $email ) && $summary && $message ) {
35 $subjects = array(
36 'billing_issue' => 'Billing Issue',
37 'feature_request' => 'Feature Request',
38 'customization' => 'Customization',
39 'pre_sale_question' => 'Pre-Sale Question',
40 'bug' => 'Bug',
41 );
42 $title = $subjects[ $subject ];
43 $content = "{$summary}\r\n\r\n";
44 $content .= "Email: {$name} <{$email}>\r\n\r\n";
45
46 $section = '';
47 if ( $domain ) {
48 $section .= "Domain: {$domain}\r\n";
49 }
50 if ( $link ) {
51 $section .= "Link: {$link}\r\n";
52 }
53 if ( $section ) {
54 $content .= "{$section}\r\n";
55 $section = '';
56 }
57 if ( $wp_admin_user && $wp_admin_password ) {
58 $section .= 'WP URI: ' . wp_login_url() . "\r\n";
59 $section .= "WP User: {$wp_admin_user}\r\n";
60 $section .= "WP Pass: {$wp_admin_password}\r\n";
61 }
62 if ( $section ) {
63 $content .= "{$section}\r\n";
64 $section = '';
65 }
66 if ( $ftp_host && $ftp_user && $ftp_password ) {
67 $section .= "FTP Host: {$ftp_host}\r\n";
68 $section .= "FTP User: {$ftp_user}\r\n";
69 $section .= "FTP Pass: {$ftp_password}\r\n";
70 }
71 if ( $section ) {
72 $content .= "{$section}\r\n";
73 $section = '';
74 }
75
76 $license = empty( $gmGallery->options['license_key'] ) ? 'FREE' : $gmGallery->options['license_key'];
77 $content .= "License: {$license}\r\n";
78
79 $content .= "Message: \r\n{$message}\r\n\r\n";
80 $headers = array(
81 'From: Gmedia Support <support@gmedia.gallery>',
82 "Reply-To: {$name} <{$email}>",
83 );
84 if ( wp_mail( 'gmediafolder@gmail.com', $title, $content, $headers ) ) {
85 $alert = $gmCore->alert( 'success', esc_html__( 'Your message has been sent! We\'ll get back to you as soon as we can.', 'grand-media' ) );
86 $subject = $name = $email = $summary = $message = $domain = $link = $wp_admin_user = $wp_admin_password = $ftp_host = $ftp_user = $ftp_password = '';
87 } else {
88 $alert = $gmCore->alert( 'danger', esc_html__( 'Can\'t send message. Something is wrong.', 'grand-media' ) );
89 }
90 } elseif ( ! empty( $_POST ) ) {
91 $alert = $gmCore->alert( 'danger', esc_html__( 'Fill all required (*) fields, please.', 'grand-media' ) );
92 }
93
94 ?>
95 <div class="card m-0 mw-100 p-0" id="gm_support">
96 <div class="card-body" id="gmedia-msg-panel"><?php echo wp_kses_post( $alert ); ?></div>
97 <form method="post" class="card-body" id="gm_support_form">
98 <?php if ( current_user_can( 'manage_options' ) ) { ?>
99 <?php wp_nonce_field( 'gmedia_support' ); ?>
100 <div class="container-fluid">
101 <div class="form-header clearfix">
102 <div class="alignleft">
103 <img src="<?php echo esc_url( plugins_url( 'assets/img/icon-128x128.png', __FILE__ ) ); ?>" alt="" style="width:94px; height:94px;">
104 </div>
105 <div class="form-header-body">
106 <h1 class="form-title">Have questions? We're happy to help!</h1>
107 <h2 class="plugin-title">Gmedia Gallery</h2>
108 <h3>We'll do our best to get back to you as soon as we can.</h3>
109 </div>
110 </div>
111 <div class="row">
112 <div class="col-sm-7">
113 <section id="contact_form">
114 <div>
115 <fieldset>
116 <div class="form-group has-feedback">
117 <label class="control-label"><?php esc_html_e( 'First and Last Name', 'grand-media' ); ?> *</label>
118 <input type="text" name="name" class="form-control" value="<?php echo esc_attr( $name ? $name : $current_user->display_name ); ?>" required>
119 <span class="fa-solid fa-user form-control-feedback"></span>
120 </div>
121 <div class="form-group has-feedback">
122 <label class="control-label"><?php esc_html_e( 'Your Email Address', 'grand-media' ); ?> *</label>
123 <input type="email" name="email" class="form-control" value="<?php echo esc_attr( $email ? $email : $current_user->user_email ); ?>" required>
124 <span class="fa-solid fa-envelope form-control-feedback"></span>
125 </div>
126 <div class="form-group hidden">
127 <label class="control-label"><?php esc_html_e( 'Context', 'grand-media' ); ?></label>
128 <select id="context_plugin" class="form-control">
129 <option>GmediaGallery</option>
130 </select>
131 </div>
132 <div class="form-group form-subjects">
133 <label class="control-label"><?php esc_html_e( 'Subject', 'grand-media' ); ?> *</label>
134 <div class="well well-sm" style="background-color: #fff;">
135 <div class="radio">
136 <label><input type="radio" name="subject" <?php /* checked($subject, 'billing_issue', true); */ ?> value="billing_issue" required data-sections=".message" data-msglabel="<?php esc_attr_e( 'Please describe the issue you are having. Be detailed but brief.', 'grand-media' ); ?>"> <?php esc_html_e( 'Billing Issue', 'grand-media' ); ?>
137 </label></div>
138 <div class="radio">
139 <label><input type="radio" name="subject" <?php /* checked($subject, 'feature_request', true); */ ?> value="feature_request" required data-sections=".message" data-msglabel="<?php esc_attr_e( 'Describe the feature you would like to see added.', 'grand-media' ); ?>"> <?php esc_html_e( 'Feature Request', 'grand-media' ); ?>
140 </label></div>
141 <div class="radio">
142 <label><input type="radio" name="subject" <?php /* checked($subject, 'customization', true); */ ?> value="customization" required data-sections=".site,.message" data-msglabel="<?php esc_attr_e( 'Please describe the use-case and the different features you would like to be custom developed for you.', 'grand-media' ); ?>"> <?php esc_html_e( 'Customization', 'grand-media' ); ?>
143 </label></div>
144 <div class="radio">
145 <label><input type="radio" name="subject" <?php /* checked($subject, 'pre_sale_question', true); */ ?> value="pre_sale_question" required data-sections=".message" data-msglabel="<?php esc_attr_e( 'What would you like to know before purchasing?', 'grand-media' ); ?>"> <?php esc_html_e( 'Pre-Sale Question', 'grand-media' ); ?>
146 </label></div>
147 <div class="radio">
148 <label><input type="radio" name="subject" <?php /* checked($subject, 'bug', true); */ ?> value="bug" required data-sections=".site,.message,.credentials" data-msglabel="<?php esc_attr_e( 'Please describe the bug and how to reproduce it.', 'grand-media' ); ?>"> <?php esc_html_e( 'Bug', 'grand-media' ); ?>
149 </label></div>
150 </div>
151 </div>
152 </fieldset>
153 <div class="dynamic">
154 <fieldset class="message">
155 <div class="form-group has-feedback">
156 <label class="control-label"><?php esc_html_e( 'Summary (In 10 words or less, summarize your issue or question)', 'grand-media' ); ?> *</label>
157 <input type="text" name="summary" class="form-control" value="<?php echo esc_attr( $summary ); ?>" required>
158 <span class="fa-solid fa-table-cells-large form-control-feedback"></span>
159 </div>
160 <div class="form-group has-feedback">
161 <label class="control-label"><span id="msglabel"><?php esc_html_e( 'Please describe the issue you are having. Be detailed but brief', 'grand-media' ); ?></span> *</label>
162 <textarea name="message" cols="44" rows="10" class="form-control" required><?php echo esc_textarea( $message ); ?></textarea>
163 <span class="fa-solid fa-pen-to-square form-control-feedback"></span>
164 </div>
165 </fieldset>
166 <fieldset class="site">
167 <div class="form-group has-feedback">
168 <label class="control-label"><?php esc_html_e( 'Your Site Address', 'grand-media' ); ?></label>
169 <input type="text" name="domain" class="form-control" value="<?php echo esc_attr( $domain ? $domain : home_url() ); ?>">
170 <span class="fa-solid fa-globe form-control-feedback"></span>
171 </div>
172 <div class="form-group has-feedback">
173 <label class="control-label"><?php esc_html_e( 'If it\'s about a specific page on your site, please add the relevant link', 'grand-media' ); ?></label>
174 <?php // translators: url. ?>
175 <input type="text" name="link" class="form-control" value="<?php echo esc_attr( $link ); ?>" placeholder="<?php echo esc_attr( sprintf( __( 'Relevant Page on Your Site (E.g. %s)', 'grand-media' ), home_url( '/relevant-page/' ) ) ); ?>">
176 <span class="fa-solid fa-globe form-control-feedback"></span>
177 </div>
178 </fieldset>
179 <fieldset class="credentials">
180 <h4 class="title" data-bs-toggle="collapse" href="#wpLogin"><span><?php esc_html_e( 'WordPress Login', 'grand-media' ); ?></span>
181 <small class="fa-solid fa-plus"></small>
182 </h4>
183 <div id="wpLogin" class="collapse">
184 <div class="form-group has-feedback">
185 <label class="control-label"><?php esc_html_e( 'Username', 'grand-media' ); ?></label>
186 <input type="text" name="wp_admin_user" class="form-control" value="<?php echo esc_attr( $wp_admin_user ); ?>">
187 <span class="fa-solid fa-user form-control-feedback"></span>
188 </div>
189 <div class="form-group has-feedback">
190 <label class="control-label"><?php esc_html_e( 'Password', 'grand-media' ); ?></label>
191 <input type="password" name="wp_admin_password" class="form-control" value="<?php echo esc_attr( $wp_admin_password ); ?>">
192 <span class="fa-solid fa-lock form-control-feedback"></span>
193 </div>
194 <p><?php esc_html_e( 'Instead of providing your primary admin account, create a new admin that can be disabled when the support case is closed.', 'grand-media' ); ?></p>
195 </div>
196 </fieldset>
197 <fieldset class="credentials">
198 <h4 class="title" data-bs-toggle="collapse" href="#ftpAccess"><span><?php esc_html_e( 'FTP Access', 'grand-media' ); ?></span>
199 <small class="fa-solid fa-plus"></small>
200 </h4>
201 <div id="ftpAccess" class="collapse">
202 <div class="form-group has-feedback">
203 <label class="control-label"><?php esc_html_e( 'FTP Host', 'grand-media' ); ?></label>
204 <input type="text" name="ftp_host" class="form-control" value="<?php echo esc_attr( $ftp_host ); ?>">
205 <span class="fa-solid fa-globe form-control-feedback"></span>
206 </div>
207 <div class="form-group has-feedback">
208 <label class="control-label"><?php esc_html_e( 'FTP User', 'grand-media' ); ?></label>
209 <input type="text" name="ftp_user" class="form-control" value="<?php echo esc_attr( $ftp_user ); ?>">
210 <span class="fa-solid fa-user form-control-feedback"></span>
211 </div>
212 <div class="form-group has-feedback">
213 <label class="control-label"><?php esc_html_e( 'FTP Password', 'grand-media' ); ?></label>
214 <input type="password" name="ftp_password" class="form-control" value="<?php echo esc_attr( $ftp_password ); ?>">
215 <span class="fa-solid fa-lock form-control-feedback"></span>
216 </div>
217 <p><?php esc_html_e( 'Instead of providing your primary FTP account, create a new FTP user that can be disabled when the support case is closed.', 'grand-media' ); ?></p>
218 </div>
219 </fieldset>
220 </div>
221 </div>
222 <footer style="margin-top: 20px;">
223 <button class="btn btn-lg btn-primary"><?php esc_html_e( 'Submit', 'grand-media' ); ?></button>
224 </footer>
225 </section>
226 </div>
227 <div class="col-sm-5">
228 <section class="well well-md">
229 <h3>Frequently Asked Questions</h3>
230 <div id="faq">
231 <ul class="clearfix">
232 <li><p>All submitted data will not be saved and is used solely for the purposes your support request. You will not be added to a mailing list, solicited without your permission, nor will your site be administered after this support case is closed.</p></li>
233
234 </ul>
235 </div>
236 </section>
237 </div>
238 </div>
239 <style>
240 #gm_support .form-header {
241 margin-bottom: 20px;
242 }
243
244 #gm_support .form-header-body {
245 margin-left: 110px;
246 padding-top: 15px;
247 padding-bottom: 0;
248 }
249
250 #gm_support h1.form-title {
251 font-size: 20px;
252 font-weight: bold;
253 line-height: 1.2em;
254 margin: 0;
255 }
256
257 #gm_support h2.plugin-title {
258 font-size: 18px;
259 line-height: 1.2em;
260 margin: 0;
261 }
262
263 #gm_support h3 {
264 font-size: 14px;
265 line-height: 1.8em;
266 margin: 0;
267 }
268
269 #gm_support .form-subjects .radio {
270 margin: 7px 0;
271 }
272
273 #gm_support .credentials h4 {
274 cursor: pointer;
275 color: #2e6286;
276 }
277
278 #gm_support .credentials h4:hover {
279 cursor: pointer;
280 color: #2e6da4;
281 }
282
283 #gm_support .dynamic fieldset {
284 display: none;
285 }
286 </style>
287 <script>
288 jQuery(function($) {
289 $('.form-subjects input').on('change', function() {
290 console.log(this);
291 var label = $(this).attr('data-msglabel'),
292 sections = $(this).attr('data-sections');
293 $('.dynamic fieldset').hide().filter(sections).show();
294 $('#msglabel').text(label);
295 });
296 });
297 </script>
298
299 </div>
300 </form>
301 <?php } ?>
302 </div>
303 <?php
304 }
305