| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?> |
| 2 |
<?php |
| 3 |
|
| 4 |
// ======================================================================================================== |
| 5 |
// Get all the data and ouput it into the page |
| 6 |
// ======================================================================================================== |
| 7 |
|
| 8 |
$getting_plugin_data = get_option($wp_options_name); |
| 9 |
|
| 10 |
if( !empty($getting_plugin_data) ) { |
| 11 |
|
| 12 |
// ---------------------------------------------- |
| 13 |
// breaking the string into to 2 variables. the array namd and vakue |
| 14 |
// ---------------------------------------------- |
| 15 |
|
| 16 |
$break_array = explode("***", $getting_plugin_data); |
| 17 |
|
| 18 |
$item_name = explode("####", $break_array[0]); |
| 19 |
$key_name = explode("####", $break_array[1]); |
| 20 |
|
| 21 |
$array_count = count($key_name); |
| 22 |
|
| 23 |
// ---------------------------------------------- |
| 24 |
// creating an organized array with all values |
| 25 |
// ---------------------------------------------- |
| 26 |
|
| 27 |
for($count_number = 0; $count_number < $array_count; $count_number++) { |
| 28 |
$plugin_data_array[ $item_name[$count_number] ] = $key_name[$count_number]; |
| 29 |
} // for($count_number = 0; $count_number < $array_count; $count_number++) { |
| 30 |
|
| 31 |
// ---------------------------------------------- |
| 32 |
// gettting all the plugin data |
| 33 |
// ---------------------------------------------- |
| 34 |
|
| 35 |
$display_button_checkbox = $plugin_data_array['display_button_checkbox']; |
| 36 |
$phone_number = $plugin_data_array['phone_number']; |
| 37 |
$button_width = $plugin_data_array['button_width']; |
| 38 |
$button_height = $plugin_data_array['button_height']; |
| 39 |
$border_radius = $plugin_data_array['border_radius']; |
| 40 |
$horizontal_position = $plugin_data_array['horizontal_position']; |
| 41 |
$horizontal_spacing = $plugin_data_array['horizontal_spacing']; |
| 42 |
$vertical_position = $plugin_data_array['vertical_position']; |
| 43 |
$vertical_spacing = $plugin_data_array['vertical_spacing']; |
| 44 |
$background_color = $plugin_data_array['background_color']; |
| 45 |
$button_border = $plugin_data_array['button_border']; |
| 46 |
$icon_image_url = $plugin_data_array['icon_image_url']; |
| 47 |
$mobile_display_checkbox = $plugin_data_array['mobile_display_checkbox']; |
| 48 |
$mobile_width = $plugin_data_array['mobile_width']; |
| 49 |
$mobile_button_position_checkbox = $plugin_data_array['mobile_button_position_checkbox']; |
| 50 |
$mobile_horizontal_position = $plugin_data_array['mobile_horizontal_position']; |
| 51 |
$mobile_horizontal_spacing = $plugin_data_array['mobile_horizontal_spacing']; |
| 52 |
$mobile_vertical_position = $plugin_data_array['mobile_vertical_position']; |
| 53 |
$mobile_vertical_spacing = $plugin_data_array['mobile_vertical_spacing']; |
| 54 |
|
| 55 |
// making sure the back to top button active |
| 56 |
if( $display_button_checkbox == 1 ) { |
| 57 |
|
| 58 |
|
| 59 |
// ---------------------------------------------- |
| 60 |
// create button css code |
| 61 |
// ---------------------------------------------- |
| 62 |
|
| 63 |
$button_html_code = "<a href='tel:" . $phone_number . "' class='yydev-phone-button'><span></span></a>"; |
| 64 |
|
| 65 |
// ---------------------------------------------- |
| 66 |
// create button css code |
| 67 |
// ---------------------------------------------- |
| 68 |
|
| 69 |
$phone_btn_style = ''; |
| 70 |
|
| 71 |
// dealing with button style |
| 72 |
$phone_btn_style .= '<style>'; |
| 73 |
$phone_btn_style .= 'a.yydev-phone-button {'; |
| 74 |
|
| 75 |
$phone_btn_style .= 'background:' . $background_color . ';'; |
| 76 |
$phone_btn_style .= 'width:' . $button_width . 'px;'; |
| 77 |
$phone_btn_style .= 'height:' . $button_height . 'px;'; |
| 78 |
$phone_btn_style .= 'border-radius:' . $border_radius . ';'; |
| 79 |
$phone_btn_style .= $horizontal_position . ':' . $horizontal_spacing . ';'; |
| 80 |
$phone_btn_style .= $vertical_position . ':' . $vertical_spacing . ';'; |
| 81 |
$phone_btn_style .= 'border:' . $button_border . ';'; |
| 82 |
$phone_btn_style .= 'text-indent:-9999px;'; |
| 83 |
$phone_btn_style .= 'position:fixed;'; |
| 84 |
$phone_btn_style .= 'z-index:9999;'; |
| 85 |
|
| 86 |
// if we hide this one desktop |
| 87 |
if($mobile_display_checkbox == 1) { |
| 88 |
$phone_btn_style .= 'display:none;'; |
| 89 |
} // if($mobile_display_checkbox == 1) { |
| 90 |
|
| 91 |
$phone_btn_style .= '}'; |
| 92 |
|
| 93 |
$phone_btn_style .= 'a.yydev-phone-button span {'; |
| 94 |
|
| 95 |
$phone_btn_style .= 'display:block;'; |
| 96 |
$phone_btn_style .= 'height: 100%;'; |
| 97 |
$phone_btn_style .= 'width: 100%;'; |
| 98 |
$phone_btn_style .= 'background: transparent url(' . $icon_image_url .') no-repeat 50% 50%;'; |
| 99 |
|
| 100 |
$phone_btn_style .= '}'; |
| 101 |
|
| 102 |
// dealing with button mobile style |
| 103 |
$phone_btn_style .= '@media only screen and (max-width: ' . $mobile_width . 'px) {'; |
| 104 |
|
| 105 |
$phone_btn_style .= 'a.yydev-phone-button {'; |
| 106 |
|
| 107 |
if($mobile_button_position_checkbox == 1 ) { |
| 108 |
$phone_btn_style .= $mobile_horizontal_position . ':' . $mobile_horizontal_spacing . ';'; |
| 109 |
$phone_btn_style .= $mobile_vertical_position . ':' . $mobile_vertical_spacing . ';'; |
| 110 |
} // if($mobile_button_position_checkbox == 1 ) { |
| 111 |
|
| 112 |
// if the button is showed only on desktop |
| 113 |
if($mobile_display_checkbox == 1) { |
| 114 |
$phone_btn_style .= 'display:block;'; |
| 115 |
} // if($mobile_display_checkbox == 1) { |
| 116 |
|
| 117 |
$phone_btn_style .= '}'; |
| 118 |
|
| 119 |
$phone_btn_style .= '}'; |
| 120 |
$phone_btn_style .= '</style>'; |
| 121 |
|
| 122 |
// ---------------------------------------------- |
| 123 |
// add css and javascript code to header |
| 124 |
// ---------------------------------------------- |
| 125 |
|
| 126 |
add_action( 'wp_head', function() use ($phone_btn_style){ |
| 127 |
|
| 128 |
// echo css code to page |
| 129 |
echo $phone_btn_style; |
| 130 |
|
| 131 |
}); // add_action( 'wp_footer', function() use ($yydev_accessibility_html){ |
| 132 |
|
| 133 |
// ---------------------------------------------- |
| 134 |
// add the button html to footer |
| 135 |
// ---------------------------------------------- |
| 136 |
|
| 137 |
add_action( 'wp_footer', function() use ($button_html_code){ |
| 138 |
|
| 139 |
// echo html button |
| 140 |
echo $button_html_code; |
| 141 |
|
| 142 |
}); // add_action( 'wp_footer', function() use ($button_html_code){ |
| 143 |
|
| 144 |
} // if( $display_button_checkbox == 1 ) { |
| 145 |
|
| 146 |
} // if( !empty($getting_plugin_data) ) { |
| 147 |
|
| 148 |
|