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

279 lines 14.4 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['insert_top_btn']) ) {
22
23 // ----------------------------------------------
24 // getting all the values and clear data
25 // ----------------------------------------------
26
27 $display_button_checkbox = yydev_phone_btn_checkbox_isset('display_button_checkbox');
28 $phone_number = sanitize_text_field( $_POST['phone_number'] );
29 $button_width = intval( $_POST['button_width'] );
30 $button_height = intval( $_POST['button_height'] );
31 $border_radius = sanitize_text_field( $_POST['border_radius'] );
32 $horizontal_position = sanitize_text_field( $_POST['horizontal_position'] );
33 $horizontal_spacing = sanitize_text_field( $_POST['horizontal_spacing'] );
34 $vertical_position = sanitize_text_field( $_POST['vertical_position'] );
35 $vertical_spacing = sanitize_text_field( $_POST['vertical_spacing'] );
36 $background_color = sanitize_text_field( $_POST['background_color'] );
37 $button_border = sanitize_text_field( $_POST['button_border'] );
38 $icon_image_url = esc_url_raw( $_POST['icon_image_url'] );
39 $mobile_display_checkbox = yydev_phone_btn_checkbox_isset('mobile_display_checkbox');
40 $mobile_width = intval( $_POST['mobile_width'] );
41 $mobile_button_position_checkbox = yydev_phone_btn_checkbox_isset('mobile_button_position_checkbox');
42 $mobile_horizontal_position = sanitize_text_field( $_POST['mobile_horizontal_position'] );
43 $mobile_horizontal_spacing = sanitize_text_field( $_POST['mobile_horizontal_spacing'] );
44 $mobile_vertical_position = sanitize_text_field( $_POST['mobile_vertical_position'] );
45 $mobile_vertical_spacing = sanitize_text_field( $_POST['mobile_vertical_spacing'] );
46
47 // ----------------------------------------------
48 // insert the data into an array
49 // ----------------------------------------------
50
51 $plugin_data_array = array(
52 'display_button_checkbox' => $display_button_checkbox,
53 'phone_number' => $phone_number,
54 'button_width' => $button_width,
55 'button_height' => $button_height,
56 'border_radius' => $border_radius,
57 'horizontal_position' => $horizontal_position,
58 'horizontal_spacing' => $horizontal_spacing,
59 'vertical_position' => $vertical_position,
60 'vertical_spacing' => $vertical_spacing,
61 'background_color' => $background_color,
62 'button_border' => $button_border,
63 'icon_image_url' => $icon_image_url,
64 'mobile_display_checkbox' => $mobile_display_checkbox,
65 'mobile_width' => $mobile_width,
66 'mobile_button_position_checkbox' => $mobile_button_position_checkbox,
67 'mobile_horizontal_position' => $mobile_horizontal_position,
68 'mobile_horizontal_spacing' => $mobile_horizontal_spacing,
69 'mobile_vertical_position' => $mobile_vertical_position,
70 'mobile_vertical_spacing' => $mobile_vertical_spacing,
71 ); // $creating_data_array = array(
72
73 // ----------------------------------------------
74 // creating a value with all the array data
75 // ----------------------------------------------
76
77 $array_key_name = '';
78 $array_item_value = '';
79
80 foreach($plugin_data_array as $key=>$item) {
81 $array_key_name .= "####" . $key;
82 $array_item_value .= "####" . $item;
83 } // foreach($medical_form_array as $key=>$item) {
84
85 // ----------------------------------------------
86 // inserting all the data to datbase
87 // ----------------------------------------------
88
89 $plugin_data = $array_key_name . "***" . $array_item_value;
90 $plugin_data = yydev_phone_btn_mysql_prep($plugin_data);
91
92 // update optuon on the database into wp_options
93 update_option($wp_options_name, $plugin_data);
94
95 $success_message = "The data was updated successfully";
96
97 } // if( isset($_POST['insert_top_btn']) ) {
98
99 // ========================================================================================================
100 // Get all the data and ouput it into the page
101 // ========================================================================================================
102
103 $getting_plugin_data = get_option($wp_options_name);
104
105 if( !empty($getting_plugin_data) ) {
106
107 // ----------------------------------------------
108 // breaking the string into to 2 variables. the array namd and vakue
109 // ----------------------------------------------
110
111 $break_array = explode("***", $getting_plugin_data);
112
113 $item_name = explode("####", $break_array[0]);
114 $key_name = explode("####", $break_array[1]);
115
116 $array_count = count($key_name);
117
118 // ----------------------------------------------
119 // creating an organized array with all values
120 // ----------------------------------------------
121
122 for($count_number = 0; $count_number < $array_count; $count_number++) {
123 $plugin_data_array[ $item_name[$count_number] ] = $key_name[$count_number];
124 } // for($count_number = 0; $count_number < $array_count; $count_number++) {
125
126 } // if( !empty($getting_plugin_data) ) {
127
128 ?>
129
130 <div class="wrap yydevelopment-btn-phone">
131
132 <h2 class="display-inline">Phone Button Settings</h2>
133 <p>Below you will be able to edit and make change to the phone button:</p>
134
135 <?php yydev_phone_btn_echo_success_message_if_exists($success_message); ?>
136 <?php yydev_phone_btn_echo_error_message_if_exists($error_message); ?>
137
138 <div class="insert-new">
139
140 <form class="edit-form-data" method="POST" action="">
141
142 <br />
143 <h2> Basic Settings: </h2>
144
145 <div class="yydev_phone_btn_line">
146 <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";} ?> />
147 <label for="display_button_checkbox">Display button on the site (when unselected the button won't show up)</label>
148 </div><!--yydev_phone_btn_line-->
149
150 <div class="yydev_phone_btn_line">
151 <label for="phone_number">Phone Number: </label>
152 <input type="text" id="phone_number" class="input-short" name="phone_number" value="<?php echo $plugin_data_array['phone_number']; ?>" />
153 <small>Example: 0999999999</small>
154 </div><!--yydev_phone_btn_line-->
155
156 <div class="yydev_phone_btn_line">
157 <label for="button_width">Button Width: </label>
158 <input type="text" id="button_width" class="input-very-short" name="button_width" value="<?php echo $plugin_data_array['button_width']; ?>" /> PX
159 </div><!--yydev_phone_btn_line-->
160
161 <div class="yydev_phone_btn_line">
162 <label for="button_height">Button Height: </label>
163 <input type="text" id="button_height" class="input-very-short" name="button_height" value="<?php echo $plugin_data_array['button_height']; ?>" /> PX
164 </div><!--yydev_phone_btn_line-->
165
166 <div class="yydev_phone_btn_line">
167 <label for="border_radius">Border Radius (Button Roundness): </label>
168 <input type="text" id="border_radius" class="input-very-short" name="border_radius" value="<?php echo $plugin_data_array['border_radius']; ?>" />
169 <small>Examples: 10px, 50%</small>
170 </div><!--yydev_phone_btn_line-->
171
172 <div class="yydev_phone_btn_line">
173 <label for="horizontal_position">Horizontal Position: </label>
174
175 <select name="horizontal_position">
176 <option value="left" <?php if($plugin_data_array['horizontal_position'] == "left") {echo "selected";} ?> >Left</option>
177 <option value="right" <?php if ($plugin_data_array['horizontal_position'] == "right") {echo "selected";} ?> >Right</option>
178 </select>
179
180 <label for="horizontal_spacing">Horizontal Spacing: </label>
181 <input type="text" id="horizontal_spacing" class="input-very-short" name="horizontal_spacing" value="<?php echo $plugin_data_array['horizontal_spacing']; ?>" />
182 <small>Examples: 10px, 50%</small>
183 </div><!--yydev_phone_btn_line-->
184
185
186 <div class="yydev_phone_btn_line">
187 <label for="vertical_position">Vertical Position: </label>
188
189 <select name="vertical_position">
190 <option value="top" <?php if($plugin_data_array['vertical_position'] == "top") {echo "selected";} ?> >Top</option>
191 <option value="bottom" <?php if ($plugin_data_array['vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option>
192 </select>
193
194 <label for="vertical_spacing">Vertical Spacing: </label>
195 <input type="text" id="vertical_spacing" class="input-very-short" name="vertical_spacing" value="<?php echo $plugin_data_array['vertical_spacing']; ?>" />
196 <small>Examples: 10px, 50%</small>
197 </div><!--yydev_phone_btn_line-->
198
199 <div class="yydev_phone_btn_line">
200 <label for="background_color">Background color hex: </label>
201 <input type="text" id="background_color" class="input-long" name="background_color" value="<?php echo $plugin_data_array['background_color']; ?>" />
202 <small>Example: #09547c</small>
203 </div><!--yydev_phone_btn_line-->
204
205 <div class="yydev_phone_btn_line">
206 <label for="button_border">Border Settings: </label>
207 <input type="text" id="button_border" class="input-short" name="button_border" value="<?php echo $plugin_data_array['button_border']; ?>" />
208 <small>Example: 2px solid #bbdeff, none</small>
209 </div><!--yydev_phone_btn_line-->
210
211 <div class="yydev_phone_btn_line">
212 <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="" />
213 <label for="icon_image_url">Custom Icon Url: </label>
214 <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']; ?>" />
215 <input type="button" name="yydev_upload_image" class="yydev_upload_image button-secondary" value="Choose Image..." />
216
217 <div class="clear"></div>
218 </div><!--yydev_phone_btn_line-->
219
220
221 <br />
222 <h2> Mobile Settings: </h2>
223
224 <div class="yydev_phone_btn_line">
225 <input type="checkbox" id="mobile_display_checkbox" class="checkbox" name="mobile_display_checkbox" value="1" <?php if($plugin_data_array['mobile_display_checkbox'] == 1) {echo "checked";} ?> />
226 <label for="mobile_display_checkbox">Hide the button on desktop (will display button only on mobile)</label>
227 </div><!--yydev_phone_btn_line-->
228
229 <div class="yydev_phone_btn_line">
230 <label for="mobile_width">Show button only when screen width is smaller than: </label>
231 <input type="text" id="mobile_width" class="input-very-short" name="mobile_width" value="<?php echo $plugin_data_array['mobile_width']; ?>" /> PX
232 </div><!--yydev_phone_btn_line-->
233
234
235 <br />
236 <h2> Mobile Positioning: </h2>
237
238
239 <div class="yydev_phone_btn_line">
240 <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";} ?> />
241 <label for="mobile_button_position_checkbox">Choose different button positioning on mobile (works only if selected)</label>
242 </div><!--yydev_phone_btn_line-->
243
244 <div class="yydev_phone_btn_line">
245 <label for="mobile_horizontal_position">Horizontal Position: </label>
246
247 <select name="mobile_horizontal_position">
248 <option value="left" <?php if($plugin_data_array['mobile_horizontal_position'] == "left") {echo "selected";} ?> >Left</option>
249 <option value="right" <?php if ($plugin_data_array['mobile_horizontal_position'] == "right") {echo "selected";} ?> >Right</option>
250 </select>
251
252 <label for="mobile_horizontal_spacing">Horizontal Spacing: </label>
253 <input type="text" id="mobile_horizontal_spacing" class="input-very-short" name="mobile_horizontal_spacing" value="<?php echo $plugin_data_array['mobile_horizontal_spacing']; ?>" />
254 <small>Examples: 10px, 50%</small>
255 </div><!--yydev_phone_btn_line-->
256
257
258 <div class="yydev_phone_btn_line">
259 <label for="mobile_vertical_position">Vertical Position: </label>
260
261 <select name="mobile_vertical_position">
262 <option value="top" <?php if($plugin_data_array['mobile_vertical_position'] == "top") {echo "selected";} ?> >Top</option>
263 <option value="bottom" <?php if ($plugin_data_array['mobile_vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option>
264 </select>
265
266 <label for="mobile_vertical_spacing">Vertical Spacing: </label>
267 <input type="text" id="mobile_vertical_spacing" class="input-very-short" name="mobile_vertical_spacing" value="<?php echo $plugin_data_array['mobile_vertical_spacing']; ?>" />
268 <small>Examples: 10px, 50%</small>
269 </div><!--yydev_phone_btn_line-->
270
271 <br />
272
273 <input type="submit" class="edit-form-data yydev-tags-submit" name="insert_top_btn" value="Submit Changes" />
274
275 </form>
276
277 <br /><br /><br />
278 <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>
279 </div><!--wrap-->