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

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