PluginProbe
Phone Button / 1.1.1
Phone Button v1.1.1
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 1.1.1, at include/admin-output.php

313 lines 16.5 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 // ----------------------------------------------
53 // insert the data into an array
54 // ----------------------------------------------
55
56 $plugin_data_array = array(
57 'display_button_checkbox' => $display_button_checkbox,
58 'phone_number' => $phone_number,
59 'button_width' => $button_width,
60 'button_height' => $button_height,
61 'border_radius' => $border_radius,
62 'horizontal_position' => $horizontal_position,
63 'horizontal_spacing' => $horizontal_spacing,
64 'vertical_position' => $vertical_position,
65 'vertical_spacing' => $vertical_spacing,
66 'background_color' => $background_color,
67 'background_position' => $background_position,
68 'button_z_index' => $button_z_index,
69 'button_border' => $button_border,
70 'icon_image_url' => $icon_image_url,
71 'hide_button_on_desktop' => $hide_button_on_desktop,
72 'hide_button_on_mobile' => $hide_button_on_mobile,
73 'mobile_width' => $mobile_width,
74 'mobile_button_position_checkbox' => $mobile_button_position_checkbox,
75 'mobile_horizontal_position' => $mobile_horizontal_position,
76 'mobile_horizontal_spacing' => $mobile_horizontal_spacing,
77 'mobile_vertical_position' => $mobile_vertical_position,
78 'mobile_vertical_spacing' => $mobile_vertical_spacing,
79 ); // $creating_data_array = array(
80
81 // ----------------------------------------------
82 // creating a value with all the array data
83 // ----------------------------------------------
84
85 $array_key_name = '';
86 $array_item_value = '';
87
88 foreach($plugin_data_array as $key=>$item) {
89 $array_key_name .= "####" . $key;
90 $array_item_value .= "####" . $item;
91 } // foreach($medical_form_array as $key=>$item) {
92
93 // ----------------------------------------------
94 // inserting all the data to datbase
95 // ----------------------------------------------
96
97 $plugin_data = $array_key_name . "***" . $array_item_value;
98 $plugin_data = yydev_phone_btn_mysql_prep($plugin_data);
99
100 // update optuon on the database into wp_options
101 update_option($wp_options_name, $plugin_data);
102
103 $success_message = "The data was updated successfully";
104
105 } else { // if( wp_verify_nonce($_POST['yydev_phone_btn_nonce'], 'yydev_phone_btn_action') ) {
106 $error_message = "Form nonce was incorrect";
107 } // } else { // if( wp_verify_nonce($_POST['yydev_phone_btn_nonce'], 'yydev_phone_btn_action') ) {
108
109 } // if( isset($_POST['yydev_phone_btn_nonce']) ) {
110
111 // ========================================================================================================
112 // Get all the data and ouput it into the page
113 // ========================================================================================================
114
115 $getting_plugin_data = get_option($wp_options_name);
116
117 if( !empty($getting_plugin_data) ) {
118
119 // ----------------------------------------------
120 // breaking the string into to 2 variables. the array namd and vakue
121 // ----------------------------------------------
122
123 $break_array = explode("***", $getting_plugin_data);
124
125 $item_name = explode("####", $break_array[0]);
126 $key_name = explode("####", $break_array[1]);
127
128 $array_count = count($key_name);
129
130 // ----------------------------------------------
131 // creating an organized array with all values
132 // ----------------------------------------------
133
134 for($count_number = 0; $count_number < $array_count; $count_number++) {
135 $plugin_data_array[ $item_name[$count_number] ] = $key_name[$count_number];
136 } // for($count_number = 0; $count_number < $array_count; $count_number++) {
137
138 } // if( !empty($getting_plugin_data) ) {
139
140 ?>
141
142 <div class="wrap yydevelopment-btn-phone">
143
144 <h2 class="display-inline">Phone Button Settings</h2>
145 <p>Below you will be able to edit and make change to the phone button:</p>
146
147 <?php yydev_phone_btn_echo_success_message_if_exists($success_message); ?>
148 <?php yydev_phone_btn_echo_error_message_if_exists($error_message); ?>
149
150 <div class="insert-new">
151
152 <form class="edit-form-data" method="POST" action="">
153
154 <br />
155 <h2> Basic Settings: </h2>
156
157 <div class="yydev_phone_btn_line">
158 <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";} ?> />
159 <label for="display_button_checkbox">Display button on the site (when unselected the button won't show up)</label>
160 </div><!--yydev_phone_btn_line-->
161
162 <div class="yydev_phone_btn_line">
163 <label for="phone_number">Phone Number: </label>
164 <input type="text" id="phone_number" class="input-short" name="phone_number" value="<?php echo $plugin_data_array['phone_number']; ?>" />
165 <small>Example: 0999999999</small>
166 </div><!--yydev_phone_btn_line-->
167
168 <div class="yydev_phone_btn_line">
169 <label for="button_width">Button Width: </label>
170 <input type="text" id="button_width" class="input-very-short" name="button_width" value="<?php echo $plugin_data_array['button_width']; ?>" /> PX
171 </div><!--yydev_phone_btn_line-->
172
173 <div class="yydev_phone_btn_line">
174 <label for="button_height">Button Height: </label>
175 <input type="text" id="button_height" class="input-very-short" name="button_height" value="<?php echo $plugin_data_array['button_height']; ?>" /> PX
176 </div><!--yydev_phone_btn_line-->
177
178 <div class="yydev_phone_btn_line">
179 <label for="border_radius">Border Radius (Button Roundness): </label>
180 <input type="text" id="border_radius" class="input-very-short" name="border_radius" value="<?php echo $plugin_data_array['border_radius']; ?>" />
181 <small>Examples: 10px, 50%</small>
182 </div><!--yydev_phone_btn_line-->
183
184 <div class="yydev_phone_btn_line">
185 <label for="horizontal_position">Horizontal Position: </label>
186
187 <select name="horizontal_position">
188 <option value="left" <?php if($plugin_data_array['horizontal_position'] == "left") {echo "selected";} ?> >Left</option>
189 <option value="right" <?php if ($plugin_data_array['horizontal_position'] == "right") {echo "selected";} ?> >Right</option>
190 </select>
191
192 <label for="horizontal_spacing">Horizontal Spacing: </label>
193 <input type="text" id="horizontal_spacing" class="input-very-short" name="horizontal_spacing" value="<?php echo $plugin_data_array['horizontal_spacing']; ?>" />
194 <small>Examples: 10px, 50%</small>
195 </div><!--yydev_phone_btn_line-->
196
197
198 <div class="yydev_phone_btn_line">
199 <label for="vertical_position">Vertical Position: </label>
200
201 <select name="vertical_position">
202 <option value="top" <?php if($plugin_data_array['vertical_position'] == "top") {echo "selected";} ?> >Top</option>
203 <option value="bottom" <?php if ($plugin_data_array['vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option>
204 </select>
205
206 <label for="vertical_spacing">Vertical Spacing: </label>
207 <input type="text" id="vertical_spacing" class="input-very-short" name="vertical_spacing" value="<?php echo $plugin_data_array['vertical_spacing']; ?>" />
208 <small>Examples: 10px, 50%</small>
209 </div><!--yydev_phone_btn_line-->
210
211 <div class="yydev_phone_btn_line">
212 <label for="background_color">Background color hex: </label>
213 <input type="text" id="background_color" class="input-long" name="background_color" value="<?php echo $plugin_data_array['background_color']; ?>" />
214 <small>Example: #09547c</small>
215 </div><!--yydev_phone_btn_line-->
216
217 <div class="yydev_phone_btn_line">
218 <label for="background_position">Background icon position: </label>
219 <input type="text" id="background_position" class="input-short" name="background_position" value="<?php echo $plugin_data_array['background_position']; ?>" />
220 <small>Example: 50% 50%, 10px 10px</small>
221 </div><!--yydev_phone_btn_line-->
222
223 <div class="yydev_phone_btn_line">
224 <label for="button_z_index">Z-index: </label>
225 <input type="text" id="button_z_index" class="input-very-short" name="button_z_index" value="<?php echo $plugin_data_array['button_z_index']; ?>" />
226 <small>Example: 9999</small>
227 </div><!--yydev_phone_btn_line-->
228
229 <div class="yydev_phone_btn_line">
230 <label for="button_border">Border Settings: </label>
231 <input type="text" id="button_border" class="input-short" name="button_border" value="<?php echo $plugin_data_array['button_border']; ?>" />
232 <small>Example: 2px solid #bbdeff, none</small>
233 </div><!--yydev_phone_btn_line-->
234
235 <div class="yydev_phone_btn_line">
236 <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="" />
237 <label for="icon_image_url">Custom Icon Url: </label>
238 <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']; ?>" />
239 <input type="button" name="yydev_upload_image" class="yydev_upload_image button-secondary" value="Choose Image..." />
240
241 <div class="clear"></div>
242 </div><!--yydev_phone_btn_line-->
243
244
245 <br />
246 <h2> Display Settings: </h2>
247
248 <div class="yydev_phone_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_phone_btn_line-->
252
253 <div class="yydev_phone_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_phone_btn_line-->
257
258 <div class="yydev_phone_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 $plugin_data_array['mobile_width']; ?>" /> PX
261 </div><!--yydev_phone_btn_line-->
262
263
264 <br />
265 <h2> Mobile Positioning: </h2>
266
267
268 <div class="yydev_phone_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_phone_btn_line-->
272
273 <div class="yydev_phone_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 $plugin_data_array['mobile_horizontal_spacing']; ?>" />
283 <small>Examples: 10px, 50%</small>
284 </div><!--yydev_phone_btn_line-->
285
286
287 <div class="yydev_phone_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 $plugin_data_array['mobile_vertical_spacing']; ?>" />
297 <small>Examples: 10px, 50%</small>
298 </div><!--yydev_phone_btn_line-->
299
300 <br />
301
302 <?php
303 // creating nonce to make sure the form was submitted correctly from the right page
304 wp_nonce_field( 'yydev_phone_btn_action', 'yydev_phone_btn_nonce' );
305 ?>
306
307 <input type="submit" class="edit-form-data yydev-tags-submit" name="insert_top_btn" value="Submit Changes" />
308
309 </form>
310
311 <br /><br /><br />
312 <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>
313 </div><!--wrap-->