PluginProbe
Phone Button / 2.0.0
Phone Button v2.0.0
trunk 1.0.0 1.0.1 1.0.3 1.1.0 1.1.1 2.0.0 2.1.0 2.1.1 2.1.2
phone-button / include / admin-output.php

admin-output.php in Phone Button 2.0.0, at include/admin-output.php

341 lines 17.9 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_phone_btn_nonce']) ) {
22
23 if( wp_verify_nonce($_POST['yydev_phone_btn_nonce'], 'yydev_phone_btn_action') ) {
24
25 // ----------------------------------------------
26 // getting all the values and clear data
27 // ----------------------------------------------
28
29 $display_button_checkbox = yydev_phone_btn_checkbox_isset('display_button_checkbox');
30 $phone_number = sanitize_text_field( $_POST['phone_number'] );
31 $button_width = intval( $_POST['button_width'] );
32 $button_height = intval( $_POST['button_height'] );
33 $border_radius = sanitize_text_field( $_POST['border_radius'] );
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 $background_color = sanitize_text_field( $_POST['background_color'] );
39 $background_position = sanitize_text_field( $_POST['background_position'] );
40 $button_z_index = intval( $_POST['button_z_index'] );
41 $button_border = sanitize_text_field( $_POST['button_border'] );
42 $icon_image_url = esc_url_raw( $_POST['icon_image_url'] );
43 $hide_button_on_desktop = yydev_phone_btn_checkbox_isset('hide_button_on_desktop');
44 $hide_button_on_mobile = yydev_phone_btn_checkbox_isset('hide_button_on_mobile');
45 $mobile_width = intval( $_POST['mobile_width'] );
46 $mobile_button_position_checkbox = yydev_phone_btn_checkbox_isset('mobile_button_position_checkbox');
47 $mobile_horizontal_position = sanitize_text_field( $_POST['mobile_horizontal_position'] );
48 $mobile_horizontal_spacing = sanitize_text_field( $_POST['mobile_horizontal_spacing'] );
49 $mobile_vertical_position = sanitize_text_field( $_POST['mobile_vertical_position'] );
50 $mobile_vertical_spacing = sanitize_text_field( $_POST['mobile_vertical_spacing'] );
51
52 $exclude_option = sanitize_text_field( $_POST['exclude_option'] );
53 $exclude_ids = sanitize_text_field( $_POST['exclude_ids'] );
54
55 // ----------------------------------------------
56 // insert the data into an array
57 // ----------------------------------------------
58
59 $plugin_data_array = array(
60 'display_button_checkbox' => $display_button_checkbox,
61 'phone_number' => $phone_number,
62 'button_width' => $button_width,
63 'button_height' => $button_height,
64 'border_radius' => $border_radius,
65 'horizontal_position' => $horizontal_position,
66 'horizontal_spacing' => $horizontal_spacing,
67 'vertical_position' => $vertical_position,
68 'vertical_spacing' => $vertical_spacing,
69 'background_color' => $background_color,
70 'background_position' => $background_position,
71 'button_z_index' => $button_z_index,
72 'button_border' => $button_border,
73 'icon_image_url' => $icon_image_url,
74 'hide_button_on_desktop' => $hide_button_on_desktop,
75 'hide_button_on_mobile' => $hide_button_on_mobile,
76 'mobile_width' => $mobile_width,
77 'mobile_button_position_checkbox' => $mobile_button_position_checkbox,
78 'mobile_horizontal_position' => $mobile_horizontal_position,
79 'mobile_horizontal_spacing' => $mobile_horizontal_spacing,
80 'mobile_vertical_position' => $mobile_vertical_position,
81 'mobile_vertical_spacing' => $mobile_vertical_spacing,
82
83 'exclude_option' => $exclude_option,
84 'exclude_ids' => $exclude_ids,
85 ); // $creating_data_array = array(
86
87 // ----------------------------------------------
88 // creating a value with all the array data
89 // ----------------------------------------------
90
91 $array_key_name = '';
92 $array_item_value = '';
93
94 foreach($plugin_data_array as $key=>$item) {
95 $array_key_name .= "####" . $key;
96 $array_item_value .= "####" . $item;
97 } // foreach($medical_form_array as $key=>$item) {
98
99 // ----------------------------------------------
100 // inserting all the data to datbase
101 // ----------------------------------------------
102
103 $plugin_data = $array_key_name . "***" . $array_item_value;
104 $plugin_data = yydev_phone_btn_mysql_prep($plugin_data);
105
106 // update optuon on the database into wp_options
107 update_option($wp_options_name, $plugin_data);
108
109 $success_message = "The data was updated successfully";
110
111 } else { // if( wp_verify_nonce($_POST['yydev_phone_btn_nonce'], 'yydev_phone_btn_action') ) {
112 $error_message = "Form nonce was incorrect";
113 } // } else { // if( wp_verify_nonce($_POST['yydev_phone_btn_nonce'], 'yydev_phone_btn_action') ) {
114
115 } // if( isset($_POST['yydev_phone_btn_nonce']) ) {
116
117 // ========================================================================================================
118 // Get all the data and ouput it into the page
119 // ========================================================================================================
120
121 $getting_plugin_data = get_option($wp_options_name);
122
123 if( !empty($getting_plugin_data) ) {
124
125 // ----------------------------------------------
126 // breaking the string into to 2 variables. the array namd and vakue
127 // ----------------------------------------------
128
129 $break_array = explode("***", $getting_plugin_data);
130
131 $item_name = explode("####", $break_array[0]);
132 $key_name = explode("####", $break_array[1]);
133
134 $array_count = count($key_name);
135
136 // ----------------------------------------------
137 // creating an organized array with all values
138 // ----------------------------------------------
139
140 for($count_number = 0; $count_number < $array_count; $count_number++) {
141 $plugin_data_array[ $item_name[$count_number] ] = $key_name[$count_number];
142 } // for($count_number = 0; $count_number < $array_count; $count_number++) {
143
144 } // if( !empty($getting_plugin_data) ) {
145
146 ?>
147
148 <div class="wrap yydevelopment-btn-phone">
149
150 <h2 class="display-inline">Phone Button Settings</h2>
151 <p>Below you will be able to edit and make change to the phone button:</p>
152
153 <?php yydev_phone_btn_echo_success_message_if_exists($success_message); ?>
154 <?php yydev_phone_btn_echo_error_message_if_exists($error_message); ?>
155
156 <div class="insert-new">
157
158 <form class="edit-form-data" method="POST" action="">
159
160 <br />
161 <h2> Basic Settings: </h2>
162
163 <div class="yydev_phone_btn_line">
164 <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";} ?> />
165 <label for="display_button_checkbox">Display button on the site (when unselected the button won't show up)</label>
166 </div><!--yydev_phone_btn_line-->
167
168 <div class="yydev_phone_btn_line">
169 <label for="phone_number">Phone Number: </label>
170 <input type="text" id="phone_number" class="input-short" name="phone_number" value="<?php echo $plugin_data_array['phone_number']; ?>" />
171 <small>Example: 0999999999</small>
172 </div><!--yydev_phone_btn_line-->
173
174 <div class="yydev_phone_btn_line">
175 <label for="button_width">Button Width: </label>
176 <input type="text" id="button_width" class="input-very-short" name="button_width" value="<?php echo $plugin_data_array['button_width']; ?>" /> PX
177 </div><!--yydev_phone_btn_line-->
178
179 <div class="yydev_phone_btn_line">
180 <label for="button_height">Button Height: </label>
181 <input type="text" id="button_height" class="input-very-short" name="button_height" value="<?php echo $plugin_data_array['button_height']; ?>" /> PX
182 </div><!--yydev_phone_btn_line-->
183
184 <div class="yydev_phone_btn_line">
185 <label for="border_radius">Border Radius (Button Roundness): </label>
186 <input type="text" id="border_radius" class="input-very-short" name="border_radius" value="<?php echo $plugin_data_array['border_radius']; ?>" />
187 <small>Examples: 10px, 50%</small>
188 </div><!--yydev_phone_btn_line-->
189
190 <div class="yydev_phone_btn_line">
191 <label for="horizontal_position">Horizontal Position: </label>
192
193 <select name="horizontal_position">
194 <option value="left" <?php if($plugin_data_array['horizontal_position'] == "left") {echo "selected";} ?> >Left</option>
195 <option value="right" <?php if ($plugin_data_array['horizontal_position'] == "right") {echo "selected";} ?> >Right</option>
196 </select>
197
198 <label for="horizontal_spacing">Horizontal Spacing: </label>
199 <input type="text" id="horizontal_spacing" class="input-very-short" name="horizontal_spacing" value="<?php echo $plugin_data_array['horizontal_spacing']; ?>" />
200 <small>Examples: 10px, 50%</small>
201 </div><!--yydev_phone_btn_line-->
202
203
204 <div class="yydev_phone_btn_line">
205 <label for="vertical_position">Vertical Position: </label>
206
207 <select name="vertical_position">
208 <option value="top" <?php if($plugin_data_array['vertical_position'] == "top") {echo "selected";} ?> >Top</option>
209 <option value="bottom" <?php if ($plugin_data_array['vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option>
210 </select>
211
212 <label for="vertical_spacing">Vertical Spacing: </label>
213 <input type="text" id="vertical_spacing" class="input-very-short" name="vertical_spacing" value="<?php echo $plugin_data_array['vertical_spacing']; ?>" />
214 <small>Examples: 10px, 50%</small>
215 </div><!--yydev_phone_btn_line-->
216
217 <div class="yydev_phone_btn_line">
218 <label for="background_color">Background color hex: </label>
219 <input type="text" id="background_color" class="input-long" name="background_color" value="<?php echo $plugin_data_array['background_color']; ?>" />
220 <small>Example: #09547c</small>
221 </div><!--yydev_phone_btn_line-->
222
223 <div class="yydev_phone_btn_line">
224 <label for="background_position">Background icon position: </label>
225 <input type="text" id="background_position" class="input-short" name="background_position" value="<?php echo $plugin_data_array['background_position']; ?>" />
226 <small>Example: 50% 50%, 10px 10px</small>
227 </div><!--yydev_phone_btn_line-->
228
229 <div class="yydev_phone_btn_line">
230 <label for="button_z_index">Z-index: </label>
231 <input type="text" id="button_z_index" class="input-very-short" name="button_z_index" value="<?php echo $plugin_data_array['button_z_index']; ?>" />
232 <small>Example: 9999</small>
233 </div><!--yydev_phone_btn_line-->
234
235 <div class="yydev_phone_btn_line">
236 <label for="button_border">Border Settings: </label>
237 <input type="text" id="button_border" class="input-short" name="button_border" value="<?php echo $plugin_data_array['button_border']; ?>" />
238 <small>Example: 2px solid #bbdeff, none</small>
239 </div><!--yydev_phone_btn_line-->
240
241 <div class="yydev_phone_btn_line">
242 <img class="yydev_light_img_bg" style="background:<?php echo $plugin_data_array['background_color']; ?>" src="<?php echo $plugin_data_array['icon_image_url']; ?>" alt="" />
243 <label for="icon_image_url">Custom Icon Url: </label>
244 <input type="text" id="icon_image_url" class="input-very-long yydev_image_input" name="icon_image_url" value="<?php echo $plugin_data_array['icon_image_url']; ?>" />
245 <input type="button" name="yydev_upload_image" class="yydev_upload_image button-secondary" value="Choose Image..." />
246
247 <div class="clear"></div>
248 </div><!--yydev_phone_btn_line-->
249
250
251 <br />
252 <h2> Display Settings: </h2>
253
254 <div class="yydev_phone_btn_line">
255 <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";} ?> />
256 <label for="hide_button_on_desktop">Hide the button on desktop (will display button only on mobile)</label>
257 </div><!--yydev_phone_btn_line-->
258
259 <div class="yydev_phone_btn_line">
260 <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";} ?> />
261 <label for="hide_button_on_mobile">Hide the button on mobile (will display button only on desktop)</label>
262 </div><!--yydev_phone_btn_line-->
263
264 <div class="yydev_phone_btn_line">
265 <label for="mobile_width">Define mobile screen resolution (affect the 2 checkboxes above): </label>
266 <input type="text" id="mobile_width" class="input-very-short" name="mobile_width" value="<?php echo $plugin_data_array['mobile_width']; ?>" /> PX
267 </div><!--yydev_phone_btn_line-->
268
269
270 <br />
271 <h2> Mobile Positioning: </h2>
272
273
274 <div class="yydev_phone_btn_line">
275 <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";} ?> />
276 <label for="mobile_button_position_checkbox">Choose different button positioning on mobile (works only if selected)</label>
277 </div><!--yydev_phone_btn_line-->
278
279 <div class="yydev_phone_btn_line">
280 <label for="mobile_horizontal_position">Horizontal Position: </label>
281
282 <select name="mobile_horizontal_position">
283 <option value="left" <?php if($plugin_data_array['mobile_horizontal_position'] == "left") {echo "selected";} ?> >Left</option>
284 <option value="right" <?php if ($plugin_data_array['mobile_horizontal_position'] == "right") {echo "selected";} ?> >Right</option>
285 </select>
286
287 <label for="mobile_horizontal_spacing">Horizontal Spacing: </label>
288 <input type="text" id="mobile_horizontal_spacing" class="input-very-short" name="mobile_horizontal_spacing" value="<?php echo $plugin_data_array['mobile_horizontal_spacing']; ?>" />
289 <small>Examples: 10px, 50%</small>
290 </div><!--yydev_phone_btn_line-->
291
292
293 <div class="yydev_phone_btn_line">
294 <label for="mobile_vertical_position">Vertical Position: </label>
295
296 <select name="mobile_vertical_position">
297 <option value="top" <?php if($plugin_data_array['mobile_vertical_position'] == "top") {echo "selected";} ?> >Top</option>
298 <option value="bottom" <?php if ($plugin_data_array['mobile_vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option>
299 </select>
300
301 <label for="mobile_vertical_spacing">Vertical Spacing: </label>
302 <input type="text" id="mobile_vertical_spacing" class="input-very-short" name="mobile_vertical_spacing" value="<?php echo $plugin_data_array['mobile_vertical_spacing']; ?>" />
303 <small>Examples: 10px, 50%</small>
304 </div><!--yydev_phone_btn_line-->
305
306 <br />
307 <h2> Include/Exclude Pages By ID: </h2>
308
309 <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.
310 <br /><br />
311 Example <small>(one page)</small>: 14
312 <br /> Example <small>(multiple pages)</small>: 14, 16, 23 </p>
313
314 <div class="yydev_phone_btn_line">
315
316 <label for="exclude_option">Include/Exclude Option: </label>
317
318 <select name="exclude_option" id='exclude_option'>
319 <option value="none" <?php if($plugin_data_array['exclude_option'] == "none") {echo "selected";} ?> >Not Active (Default)</option>
320 <option value="exclude" <?php if($plugin_data_array['exclude_option'] == "exclude") {echo "selected";} ?> >Exclude Pages By ID</option>
321 <option value="include" <?php if ($plugin_data_array['exclude_option'] == "include") {echo "selected";} ?> >Include Only On Pages</option>
322 </select>
323
324 <input type="text" id="exclude_ids" class="input-short" name="exclude_ids" value="<?php echo $plugin_data_array['exclude_ids']; ?>" />
325
326 </div><!--yydev_phone_btn_line-->
327
328 <br />
329
330 <?php
331 // creating nonce to make sure the form was submitted correctly from the right page
332 wp_nonce_field( 'yydev_phone_btn_action', 'yydev_phone_btn_nonce' );
333 ?>
334
335 <input type="submit" class="edit-form-data yydev-tags-submit" name="insert_top_btn" value="Submit Changes" />
336
337 </form>
338
339 <br /><br /><br />
340 <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/phone-button/#reviews">5 stars review</a>.</span>
341 </div><!--wrap-->