| @@ -17,10 +17,12 @@ | ||
| 17 | 17 | // ======================================================================================================== |
| 18 | 18 | // Update the data if it's changed |
| 19 | 19 | // ======================================================================================================== |
| 20 | 20 | |
| 21 | -if( isset($_POST['insert_top_btn']) ) { | |
| 21 | +if( isset($_POST['yydev_phone_btn_nonce']) ) { | |
| 22 | 22 | |
| 23 | + if( wp_verify_nonce($_POST['yydev_phone_btn_nonce'], 'yydev_phone_btn_action') ) { | |
| 24 | + | |
| 23 | 25 | // ---------------------------------------------- |
| 24 | 26 | // getting all the values and clear data |
| 25 | 27 | // ---------------------------------------------- |
| 26 | 28 | |
| @@ -33,11 +35,14 @@ | ||
| 33 | 35 | $horizontal_spacing = sanitize_text_field( $_POST['horizontal_spacing'] ); |
| 34 | 36 | $vertical_position = sanitize_text_field( $_POST['vertical_position'] ); |
| 35 | 37 | $vertical_spacing = sanitize_text_field( $_POST['vertical_spacing'] ); |
| 36 | 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'] ); | |
| 37 | 41 | $button_border = sanitize_text_field( $_POST['button_border'] ); |
| 38 | 42 | $icon_image_url = esc_url_raw( $_POST['icon_image_url'] ); |
| 39 | - $mobile_display_checkbox = yydev_phone_btn_checkbox_isset('mobile_display_checkbox'); | |
| 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'); | |
| 40 | 45 | $mobile_width = intval( $_POST['mobile_width'] ); |
| 41 | 46 | $mobile_button_position_checkbox = yydev_phone_btn_checkbox_isset('mobile_button_position_checkbox'); |
| 42 | 47 | $mobile_horizontal_position = sanitize_text_field( $_POST['mobile_horizontal_position'] ); |
| 43 | 48 | $mobile_horizontal_spacing = sanitize_text_field( $_POST['mobile_horizontal_spacing'] ); |
| @@ -43,8 +48,11 @@ | ||
| 43 | 48 | $mobile_horizontal_spacing = sanitize_text_field( $_POST['mobile_horizontal_spacing'] ); |
| 44 | 49 | $mobile_vertical_position = sanitize_text_field( $_POST['mobile_vertical_position'] ); |
| 45 | 50 | $mobile_vertical_spacing = sanitize_text_field( $_POST['mobile_vertical_spacing'] ); |
| 46 | 51 | |
| 52 | + $exclude_option = sanitize_text_field( $_POST['exclude_option'] ); | |
| 53 | + $exclude_ids = sanitize_text_field( $_POST['exclude_ids'] ); | |
| 54 | + | |
| 47 | 55 | // ---------------------------------------------- |
| 48 | 56 | // insert the data into an array |
| 49 | 57 | // ---------------------------------------------- |
| 50 | 58 | |
| @@ -58,11 +66,14 @@ | ||
| 58 | 66 | 'horizontal_spacing' => $horizontal_spacing, |
| 59 | 67 | 'vertical_position' => $vertical_position, |
| 60 | 68 | 'vertical_spacing' => $vertical_spacing, |
| 61 | 69 | 'background_color' => $background_color, |
| 70 | + 'background_position' => $background_position, | |
| 71 | + 'button_z_index' => $button_z_index, | |
| 62 | 72 | 'button_border' => $button_border, |
| 63 | 73 | 'icon_image_url' => $icon_image_url, |
| 64 | - 'mobile_display_checkbox' => $mobile_display_checkbox, | |
| 74 | + 'hide_button_on_desktop' => $hide_button_on_desktop, | |
| 75 | + 'hide_button_on_mobile' => $hide_button_on_mobile, | |
| 65 | 76 | 'mobile_width' => $mobile_width, |
| 66 | 77 | 'mobile_button_position_checkbox' => $mobile_button_position_checkbox, |
| 67 | 78 | 'mobile_horizontal_position' => $mobile_horizontal_position, |
| 68 | 79 | 'mobile_horizontal_spacing' => $mobile_horizontal_spacing, |
| @@ -67,8 +78,11 @@ | ||
| 67 | 78 | 'mobile_horizontal_position' => $mobile_horizontal_position, |
| 68 | 79 | 'mobile_horizontal_spacing' => $mobile_horizontal_spacing, |
| 69 | 80 | 'mobile_vertical_position' => $mobile_vertical_position, |
| 70 | 81 | 'mobile_vertical_spacing' => $mobile_vertical_spacing, |
| 82 | + | |
| 83 | + 'exclude_option' => $exclude_option, | |
| 84 | + 'exclude_ids' => $exclude_ids, | |
| 71 | 85 | ); // $creating_data_array = array( |
| 72 | 86 | |
| 73 | 87 | // ---------------------------------------------- |
| 74 | 88 | // creating a value with all the array data |
| @@ -86,9 +100,9 @@ | ||
| 86 | 100 | // inserting all the data to datbase |
| 87 | 101 | // ---------------------------------------------- |
| 88 | 102 | |
| 89 | 103 | $plugin_data = $array_key_name . "***" . $array_item_value; |
| 90 | - $plugin_data = yydev_phone_btn_mysql_prep($plugin_data); | |
| 104 | + $plugin_data = sanitize_text_field($plugin_data); | |
| 91 | 105 | |
| 92 | 106 | // update optuon on the database into wp_options |
| 93 | 107 | update_option($wp_options_name, $plugin_data); |
| 94 | 108 | |
| @@ -93,10 +107,14 @@ | ||
| 93 | 107 | update_option($wp_options_name, $plugin_data); |
| 94 | 108 | |
| 95 | 109 | $success_message = "The data was updated successfully"; |
| 96 | 110 | |
| 97 | -} // if( isset($_POST['insert_top_btn']) ) { | |
| 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') ) { | |
| 98 | 114 | |
| 115 | +} // if( isset($_POST['yydev_phone_btn_nonce']) ) { | |
| 116 | + | |
| 99 | 117 | // ======================================================================================================== |
| 100 | 118 | // Get all the data and ouput it into the page |
| 101 | 119 | // ======================================================================================================== |
| 102 | 120 | |
| @@ -148,25 +166,25 @@ | ||
| 148 | 166 | </div><!--yydev_phone_btn_line--> |
| 149 | 167 | |
| 150 | 168 | <div class="yydev_phone_btn_line"> |
| 151 | 169 | <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']; ?>" /> | |
| 170 | + <input type="text" id="phone_number" class="input-short" name="phone_number" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['phone_number']); ?>" /> | |
| 153 | 171 | <small>Example: 0999999999</small> |
| 154 | 172 | </div><!--yydev_phone_btn_line--> |
| 155 | 173 | |
| 156 | 174 | <div class="yydev_phone_btn_line"> |
| 157 | 175 | <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 | |
| 176 | + <input type="text" id="button_width" class="input-very-short" name="button_width" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['button_width']); ?>" /> PX | |
| 159 | 177 | </div><!--yydev_phone_btn_line--> |
| 160 | 178 | |
| 161 | 179 | <div class="yydev_phone_btn_line"> |
| 162 | 180 | <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 | |
| 181 | + <input type="text" id="button_height" class="input-very-short" name="button_height" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['button_height']); ?>" /> PX | |
| 164 | 182 | </div><!--yydev_phone_btn_line--> |
| 165 | 183 | |
| 166 | 184 | <div class="yydev_phone_btn_line"> |
| 167 | 185 | <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']; ?>" /> | |
| 186 | + <input type="text" id="border_radius" class="input-very-short" name="border_radius" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['border_radius']); ?>" /> | |
| 169 | 187 | <small>Examples: 10px, 50%</small> |
| 170 | 188 | </div><!--yydev_phone_btn_line--> |
| 171 | 189 | |
| 172 | 190 | <div class="yydev_phone_btn_line"> |
| @@ -177,9 +195,9 @@ | ||
| 177 | 195 | <option value="right" <?php if ($plugin_data_array['horizontal_position'] == "right") {echo "selected";} ?> >Right</option> |
| 178 | 196 | </select> |
| 179 | 197 | |
| 180 | 198 | <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']; ?>" /> | |
| 199 | + <input type="text" id="horizontal_spacing" class="input-very-short" name="horizontal_spacing" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['horizontal_spacing']); ?>" /> | |
| 182 | 200 | <small>Examples: 10px, 50%</small> |
| 183 | 201 | </div><!--yydev_phone_btn_line--> |
| 184 | 202 | |
| 185 | 203 | |
| @@ -191,28 +209,40 @@ | ||
| 191 | 209 | <option value="bottom" <?php if ($plugin_data_array['vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option> |
| 192 | 210 | </select> |
| 193 | 211 | |
| 194 | 212 | <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']; ?>" /> | |
| 213 | + <input type="text" id="vertical_spacing" class="input-very-short" name="vertical_spacing" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['vertical_spacing']); ?>" /> | |
| 196 | 214 | <small>Examples: 10px, 50%</small> |
| 197 | 215 | </div><!--yydev_phone_btn_line--> |
| 198 | 216 | |
| 199 | 217 | <div class="yydev_phone_btn_line"> |
| 200 | 218 | <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']; ?>" /> | |
| 219 | + <input type="text" id="background_color" class="input-long" name="background_color" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['background_color']); ?>" /> | |
| 202 | 220 | <small>Example: #09547c</small> |
| 203 | 221 | </div><!--yydev_phone_btn_line--> |
| 204 | 222 | |
| 205 | 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 yydev_phone_btn_html_output($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 yydev_phone_btn_html_output($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"> | |
| 206 | 236 | <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']; ?>" /> | |
| 237 | + <input type="text" id="button_border" class="input-short" name="button_border" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['button_border']); ?>" /> | |
| 208 | 238 | <small>Example: 2px solid #bbdeff, none</small> |
| 209 | 239 | </div><!--yydev_phone_btn_line--> |
| 210 | 240 | |
| 211 | 241 | <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="" /> | |
| 242 | + <img class="yydev_light_img_bg" style="background:<?php echo $plugin_data_array['background_color']; ?>" src="<?php echo esc_url($plugin_data_array['icon_image_url']); ?>" alt="" /> | |
| 213 | 243 | <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']; ?>" /> | |
| 244 | + <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']); ?>" /> | |
| 215 | 245 | <input type="button" name="yydev_upload_image" class="yydev_upload_image button-secondary" value="Choose Image..." /> |
| 216 | 246 | |
| 217 | 247 | <div class="clear"></div> |
| 218 | 248 | </div><!--yydev_phone_btn_line--> |
| @@ -218,21 +248,26 @@ | ||
| 218 | 248 | </div><!--yydev_phone_btn_line--> |
| 219 | 249 | |
| 220 | 250 | |
| 221 | 251 | <br /> |
| 222 | - <h2> Mobile Settings: </h2> | |
| 252 | + <h2> Display Settings: </h2> | |
| 223 | 253 | |
| 224 | 254 | <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> | |
| 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> | |
| 227 | 257 | </div><!--yydev_phone_btn_line--> |
| 228 | 258 | |
| 229 | 259 | <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 | |
| 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> | |
| 232 | 262 | </div><!--yydev_phone_btn_line--> |
| 233 | 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 yydev_phone_btn_html_output($plugin_data_array['mobile_width']); ?>" /> PX | |
| 267 | + </div><!--yydev_phone_btn_line--> | |
| 234 | 268 | |
| 269 | + | |
| 235 | 270 | <br /> |
| 236 | 271 | <h2> Mobile Positioning: </h2> |
| 237 | 272 | |
| 238 | 273 | |
| @@ -249,9 +284,9 @@ | ||
| 249 | 284 | <option value="right" <?php if ($plugin_data_array['mobile_horizontal_position'] == "right") {echo "selected";} ?> >Right</option> |
| 250 | 285 | </select> |
| 251 | 286 | |
| 252 | 287 | <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']; ?>" /> | |
| 288 | + <input type="text" id="mobile_horizontal_spacing" class="input-very-short" name="mobile_horizontal_spacing" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['mobile_horizontal_spacing']); ?>" /> | |
| 254 | 289 | <small>Examples: 10px, 50%</small> |
| 255 | 290 | </div><!--yydev_phone_btn_line--> |
| 256 | 291 | |
| 257 | 292 | |
| @@ -263,17 +298,46 @@ | ||
| 263 | 298 | <option value="bottom" <?php if ($plugin_data_array['mobile_vertical_position'] == "bottom") {echo "selected";} ?> >Bottom</option> |
| 264 | 299 | </select> |
| 265 | 300 | |
| 266 | 301 | <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']; ?>" /> | |
| 302 | + <input type="text" id="mobile_vertical_spacing" class="input-very-short" name="mobile_vertical_spacing" value="<?php echo yydev_phone_btn_html_output($plugin_data_array['mobile_vertical_spacing']); ?>" /> | |
| 268 | 303 | <small>Examples: 10px, 50%</small> |
| 269 | 304 | </div><!--yydev_phone_btn_line--> |
| 270 | 305 | |
| 271 | 306 | <br /> |
| 307 | + <h2> Include/Exclude Pages By ID: </h2> | |
| 272 | 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 yydev_phone_btn_html_output($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 | + | |
| 273 | 335 | <input type="submit" class="edit-form-data yydev-tags-submit" name="insert_top_btn" value="Submit Changes" /> |
| 274 | 336 | |
| 275 | 337 | </form> |
| 276 | 338 | |
| 277 | 339 | <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> | |
| 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>. | |
| 341 | +If you want to help support this FREE plugin <a target="_blank" href="https://www.yydevelopment.com/coffee-break/?plugin=phone-button">buy us a coffee</a>.</span> | |
| 342 | +</span> | |
| 279 | 343 | </div><!--wrap--> |