PluginProbe
Fast Chat Button / trunk
Fast Chat Button vtrunk
trunk 1.0.0 1.0.1 1.1.0 1.1.1 2.0.0 2.1.0 2.1.1
fast-chat-button / include / admin-output.php

admin-output.php in Fast Chat Button trunk, at include/admin-output.php

337 lines 18.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
2 <?php
3
4 $success_message = '';
5 $error_message = '';
6
7 // ====================================================
8 // Include the file that contains all the info
9 // ====================================================
10 include('settings.php');
11
12 // ===============================================
13 // This will allow us to use the media uploader
14 // ===============================================
15 wp_enqueue_media();
16
17 // ========================================================================================================
18 // Update the data if it's changed
19 // ========================================================================================================
20
21 if( isset($_POST['yydev_chat_button_nonce']) ) {
22
23 if( wp_verify_nonce($_POST['yydev_chat_button_nonce'], 'yydev_chat_button_action') ) {
24
25 // ----------------------------------------------
26 // getting all the values and clear data
27 // ----------------------------------------------
28
29 $display_button_checkbox = yydev_chat_btn_checkbox_isset('display_button_checkbox');
30 $chat_number = sanitize_text_field( $_POST['chat_number'] );
31 $chat_message = sanitize_text_field( $_POST['chat_message'] );
32 $button_width = intval( $_POST['button_width'] );
33 $button_height = intval( $_POST['button_height'] );
34 $horizontal_position = sanitize_text_field( $_POST['horizontal_position'] );
35 $horizontal_spacing = sanitize_text_field( $_POST['horizontal_spacing'] );
36 $vertical_position = sanitize_text_field( $_POST['vertical_position'] );
37 $vertical_spacing = sanitize_text_field( $_POST['vertical_spacing'] );
38 $button_z_index = intval( $_POST['button_z_index'] );
39 $icon_image_url = esc_url_raw( $_POST['icon_image_url'] );
40 $chat_button_type = sanitize_text_field( $_POST['chat_button_type'] );
41 $hide_button_on_desktop = yydev_chat_btn_checkbox_isset('hide_button_on_desktop');
42 $hide_button_on_mobile = yydev_chat_btn_checkbox_isset('hide_button_on_mobile');
43 $mobile_width = intval( $_POST['mobile_width'] );
44 $mobile_button_position_checkbox = yydev_chat_btn_checkbox_isset('mobile_button_position_checkbox');
45 $mobile_horizontal_position = sanitize_text_field( $_POST['mobile_horizontal_position'] );
46 $mobile_horizontal_spacing = sanitize_text_field( $_POST['mobile_horizontal_spacing'] );
47 $mobile_vertical_position = sanitize_text_field( $_POST['mobile_vertical_position'] );
48 $mobile_vertical_spacing = sanitize_text_field( $_POST['mobile_vertical_spacing'] );
49
50 $exclude_option = sanitize_text_field( $_POST['exclude_option'] );
51 $exclude_ids = sanitize_text_field( $_POST['exclude_ids'] );
52
53 // ----------------------------------------------
54 // insert the data into an array
55 // ----------------------------------------------
56
57 $plugin_data_array = array(
58 'display_button_checkbox' => $display_button_checkbox,
59 'chat_number' => $chat_number,
60 'chat_message' => $chat_message,
61 'button_width' => $button_width,
62 'button_height' => $button_height,
63 'horizontal_position' => $horizontal_position,
64 'horizontal_spacing' => $horizontal_spacing,
65 'vertical_position' => $vertical_position,
66 'vertical_spacing' => $vertical_spacing,
67 'button_z_index' => $button_z_index,
68 'icon_image_url' => $icon_image_url,
69 'chat_button_type' => $chat_button_type,
70 'hide_button_on_desktop' => $hide_button_on_desktop,
71 'hide_button_on_mobile' => $hide_button_on_mobile,
72 'mobile_width' => $mobile_width,
73 'mobile_button_position_checkbox' => $mobile_button_position_checkbox,
74 'mobile_horizontal_position' => $mobile_horizontal_position,
75 'mobile_horizontal_spacing' => $mobile_horizontal_spacing,
76 'mobile_vertical_position' => $mobile_vertical_position,
77 'mobile_vertical_spacing' => $mobile_vertical_spacing,
78
79 'exclude_option' => $exclude_option,
80 'exclude_ids' => $exclude_ids,
81 ); // $creating_data_array = array(
82
83 // ----------------------------------------------
84 // creating a value with all the array data
85 // ----------------------------------------------
86
87 $array_key_name = '';
88 $array_item_value = '';
89
90 foreach($plugin_data_array as $key=>$item) {
91 $array_key_name .= "####" . $key;
92 $array_item_value .= "####" . $item;
93 } // foreach($medical_form_array as $key=>$item) {
94
95 // ----------------------------------------------
96 // inserting all the data to datbase
97 // ----------------------------------------------
98
99 $plugin_data = $array_key_name . "***" . $array_item_value;
100 $plugin_data = sanitize_text_field($plugin_data);
101
102 // update optuon on the database into wp_options
103 update_option($wp_options_name, $plugin_data);
104
105 $success_message = "The data was updated successfully";
106
107 } else { // if( wp_verify_nonce($_POST['yydev_chat_button_nonce'], 'yydev_chat_button_action') ) {
108 $error_message = "Form nonce was incorrect";
109 } // } else { // if( wp_verify_nonce($_POST['yydev_chat_button_nonce'], 'yydev_chat_button_action') ) {
110
111 } // if( isset($_POST['yydev_chat_button_nonce']) ) {
112
113
114 // ========================================================================================================
115 // Get all the data and ouput it into the page
116 // ========================================================================================================
117
118 $getting_plugin_data = get_option($wp_options_name);
119
120 if( !empty($getting_plugin_data) ) {
121
122 // ----------------------------------------------
123 // breaking the string into to 2 variables. the array namd and vakue
124 // ----------------------------------------------
125
126 $break_array = explode("***", $getting_plugin_data);
127
128 $item_name = explode("####", $break_array[0]);
129 $key_name = explode("####", $break_array[1]);
130
131 $array_count = count($key_name);
132
133 // ----------------------------------------------
134 // creating an organized array with all values
135 // ----------------------------------------------
136
137 for($count_number = 0; $count_number < $array_count; $count_number++) {
138 $plugin_data_array[ $item_name[$count_number] ] = $key_name[$count_number];
139 } // for($count_number = 0; $count_number < $array_count; $count_number++) {
140
141 } // if( !empty($getting_plugin_data) ) {
142
143 ?>
144
145 <div class="wrap yydevelopment-btn-chat">
146
147 <h2 class="display-inline">Fast Whatsapp Button Settings</h2>
148 <p>Below you will be able to edit and make change to the button:</p>
149
150 <?php yydev_chat_btn_echo_success_message_if_exists($success_message); ?>
151 <?php yydev_chat_btn_echo_error_message_if_exists($error_message); ?>
152
153 <div class="insert-new">
154
155 <form class="edit-form-data" method="POST" action="">
156
157 <br />
158 <h2> Basic Settings: </h2>
159
160 <div class="yydev_chat_btn_line">
161 <input type="checkbox" id="display_button_checkbox" class="checkbox" name="display_button_checkbox" value="1" <?php if($plugin_data_array['display_button_checkbox'] == 1) {echo "checked";} ?> />
162 <label for="display_button_checkbox">Display button on the site (when unselected the button won't show up)</label>
163 </div><!--yydev_chat_btn_line-->
164
165 <div class="yydev_chat_btn_line">
166 <label for="chat_number">Whatsapp Number: </label>
167 <input type="text" id="chat_number" class="input-short" name="chat_number" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['chat_number']); ?>" />
168 <small>Example: 972739999999</small>
169 </div><!--yydev_chat_btn_line-->
170
171 <div class="yydev_chat_btn_line">
172 <label for="chat_message">Whatsapp Message: </label>
173 <input type="text" id="chat_message" class="input-short" name="chat_message" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['chat_message']); ?>" />
174 <small>Example: Thanks for contacting us</small>
175 </div><!--yydev_chat_btn_line-->
176
177 <div class="yydev_chat_btn_line">
178 <label for="button_width">Image Width: </label>
179 <input type="text" id="button_width" class="input-very-short" name="button_width" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['button_width']); ?>" /> PX
180 </div><!--yydev_chat_btn_line-->
181
182 <div class="yydev_chat_btn_line">
183 <label for="button_height">Image Height: </label>
184 <input type="text" id="button_height" class="input-very-short" name="button_height" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['button_height']); ?>" /> PX
185 </div><!--yydev_chat_btn_line-->
186
187 <div class="yydev_chat_btn_line">
188 <label for="button_z_index">Z-index: </label>
189 <input type="text" id="button_z_index" class="input-very-short" name="button_z_index" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['button_z_index']); ?>" />
190 <small>Example: 9999</small>
191 </div><!--yydev_chat_btn_line-->
192
193 <div class="yydev_chat_btn_line">
194 <label for="horizontal_position">Horizontal Position: </label>
195
196 <select name="horizontal_position">
197 <option value="left" <?php if($plugin_data_array['horizontal_position'] == "left") {echo "selected";} ?> >Left</option>
198 <option value="right" <?php if ($plugin_data_array['horizontal_position'] == "right") {echo "selected";} ?> >Right</option>
199 </select>
200
201 <label for="horizontal_spacing">Horizontal Spacing: </label>
202 <input type="text" id="horizontal_spacing" class="input-very-short" name="horizontal_spacing" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['horizontal_spacing']); ?>" />
203 <small>Examples: 10px, 50%</small>
204 </div><!--yydev_chat_btn_line-->
205
206
207 <div class="yydev_chat_btn_line">
208 <label for="vertical_position">Vertical Position: </label>
209
210 <select name="vertical_position">
211 <option value="top" <?php if($plugin_data_array['vertical_position'] == "top") {echo "selected";} ?> >Top</option>
212 <option value="bottom" <?php if ($plugin_data_array['vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option>
213 </select>
214
215 <label for="vertical_spacing">Vertical Spacing: </label>
216 <input type="text" id="vertical_spacing" class="input-very-short" name="vertical_spacing" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['vertical_spacing']); ?>" />
217 <small>Examples: 10px, 50%</small>
218 </div><!--yydev_chat_btn_line-->
219
220 <div class="yydev_chat_btn_line">
221 <img class="yydev_light_img_bg" src="<?php echo esc_url($plugin_data_array['icon_image_url']); ?>" alt="" />
222 <br /><br />
223 <?php
224
225 $chat_button1 = plugin_dir_url(dirname(__FILE__)) . 'images/chat-button1.png';
226 $chat_button2 = plugin_dir_url(dirname(__FILE__)) . 'images/chat-button2.png';
227 $chat_button3 = plugin_dir_url(dirname(__FILE__)) . 'images/chat-button3.png';
228
229 ?>
230 <label for="chat_button_type">Whatsapp Button type: </label>
231 <select name="chat_button_type" class="chat_button_type">
232 <option value="<?php echo $chat_button1; ?>" <?php if($plugin_data_array['chat_button_type'] === $chat_button1) {echo "selected";} ?> >Whatsapp Button 1</option>
233 <option value="<?php echo $chat_button2; ?>" <?php if($plugin_data_array['chat_button_type'] === $chat_button2) {echo "selected";} ?> >Whatsapp Button 2</option>
234 <option value="<?php echo $chat_button3; ?>" <?php if($plugin_data_array['chat_button_type'] === $chat_button3) {echo "selected";} ?> >Whatsapp Button 3</option>
235 <option value="custom" <?php if($plugin_data_array['chat_button_type'] === 'custom') {echo "selected";} ?> >Custom Image</option>
236 </select>
237 <br /><br />
238 <input type="text" id="icon_image_url" class="input-very-long yydev_image_input" name="icon_image_url" value="<?php echo esc_url($plugin_data_array['icon_image_url']); ?>" />
239 <input type="button" name="yydev_upload_image" class="yydev_upload_image button-secondary" value="Choose Custom Icon..." />
240
241 <div class="clear"></div>
242 </div><!--yydev_chat_btn_line-->
243
244
245 <br />
246 <h2> Display Settings: </h2>
247
248 <div class="yydev_chat_btn_line">
249 <input type="checkbox" id="hide_button_on_desktop" class="checkbox" name="hide_button_on_desktop" value="1" <?php if($plugin_data_array['hide_button_on_desktop'] == 1) {echo "checked";} ?> />
250 <label for="hide_button_on_desktop">Hide the button on desktop (will display button only on mobile)</label>
251 </div><!--yydev_chat_btn_line-->
252
253 <div class="yydev_chat_btn_line">
254 <input type="checkbox" id="hide_button_on_mobile" class="checkbox" name="hide_button_on_mobile" value="1" <?php if($plugin_data_array['hide_button_on_mobile'] == 1) {echo "checked";} ?> />
255 <label for="hide_button_on_mobile">Hide the button on mobile (will display button only on desktop)</label>
256 </div><!--yydev_chat_btn_line-->
257
258 <div class="yydev_chat_btn_line">
259 <label for="mobile_width">Define mobile screen resolution (affect the 2 checkboxes above): </label>
260 <input type="text" id="mobile_width" class="input-very-short" name="mobile_width" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['mobile_width']); ?>" /> PX
261 </div><!--yydev_chat_btn_line-->
262
263
264 <br />
265 <h2> Mobile Positioning: </h2>
266
267
268 <div class="yydev_chat_btn_line">
269 <input type="checkbox" id="mobile_button_position_checkbox" class="checkbox" name="mobile_button_position_checkbox" value="1" <?php if($plugin_data_array['mobile_button_position_checkbox'] == 1) {echo "checked";} ?> />
270 <label for="mobile_button_position_checkbox">Choose different button positioning on mobile (works only if selected)</label>
271 </div><!--yydev_chat_btn_line-->
272
273 <div class="yydev_chat_btn_line">
274 <label for="mobile_horizontal_position">Horizontal Position: </label>
275
276 <select name="mobile_horizontal_position">
277 <option value="left" <?php if($plugin_data_array['mobile_horizontal_position'] == "left") {echo "selected";} ?> >Left</option>
278 <option value="right" <?php if ($plugin_data_array['mobile_horizontal_position'] == "right") {echo "selected";} ?> >Right</option>
279 </select>
280
281 <label for="mobile_horizontal_spacing">Horizontal Spacing: </label>
282 <input type="text" id="mobile_horizontal_spacing" class="input-very-short" name="mobile_horizontal_spacing" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['mobile_horizontal_spacing']); ?>" />
283 <small>Examples: 10px, 50%</small>
284 </div><!--yydev_chat_btn_line-->
285
286
287 <div class="yydev_chat_btn_line">
288 <label for="mobile_vertical_position">Vertical Position: </label>
289
290 <select name="mobile_vertical_position">
291 <option value="top" <?php if($plugin_data_array['mobile_vertical_position'] == "top") {echo "selected";} ?> >Top</option>
292 <option value="bottom" <?php if ($plugin_data_array['mobile_vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option>
293 </select>
294
295 <label for="mobile_vertical_spacing">Vertical Spacing: </label>
296 <input type="text" id="mobile_vertical_spacing" class="input-very-short" name="mobile_vertical_spacing" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['mobile_vertical_spacing']); ?>" />
297 <small>Examples: 10px, 50%</small>
298 </div><!--yydev_chat_btn_line-->
299
300 <br />
301 <h2> Include/Exclude Pages By ID: </h2>
302
303 <p> Insert the pages ID and separate them by comma. You can use <a target="_blank" href="https://wordpress.org/plugins/show-posts-and-pages-id/">Show Pages IDs</a> plugin for help.
304 <br /><br />
305 Example <small>(one page)</small>: 14
306 <br /> Example <small>(multiple pages)</small>: 14, 16, 23 </p>
307
308 <div class="yydev_top_btn_line">
309
310 <label for="exclude_option">Include/Exclude Option: </label>
311
312 <select name="exclude_option" id='exclude_option'>
313 <option value="none" <?php if($plugin_data_array['exclude_option'] == "none") {echo "selected";} ?> >Not Active (Default)</option>
314 <option value="exclude" <?php if($plugin_data_array['exclude_option'] == "exclude") {echo "selected";} ?> >Exclude Pages By ID</option>
315 <option value="include" <?php if ($plugin_data_array['exclude_option'] == "include") {echo "selected";} ?> >Include Only On Pages</option>
316 </select>
317
318 <input type="text" id="exclude_ids" class="input-short" name="exclude_ids" value="<?php echo yydev_chat_btn_html_output($plugin_data_array['exclude_ids']); ?>" />
319
320 </div><!--yydev_top_btn_line-->
321
322 <br />
323
324 <?php
325 // creating nonce to make sure the form was submitted correctly from the right page
326 wp_nonce_field( 'yydev_chat_button_action', 'yydev_chat_button_nonce' );
327 ?>
328
329 <input type="submit" class="edit-form-data yydev-tags-submit" name="insert_top_btn" value="Submit Changes" />
330
331 </form>
332
333 <br /><br /><br />
334 <span id="footer-thankyou-code">This plugin was create by <a target="_blank" href="https://www.yydevelopment.com">YYDevelopment</a>. If you liked the plugin please give it a <a target="_blank" href="https://wordpress.org/plugins/fast-chat-button/#reviews">5 stars review</a>.
335 If you want to help support this FREE plugin <a target="_blank" href="https://www.yydevelopment.com/coffee-break/?plugin=fast-chat-button">buy us a coffee</a>.</span>
336 </span>
337 </div><!--wrap-->