| 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 = intval($plugin_data_array['display_button_checkbox']); |
| 36 |
$phone_number = $plugin_data_array['phone_number']; |
| 37 |
$button_width = intval($plugin_data_array['button_width']); |
| 38 |
$button_height = intval($plugin_data_array['button_height']); |
| 39 |
$border_radius = esc_attr($plugin_data_array['border_radius']); |
| 40 |
$horizontal_position = esc_attr($plugin_data_array['horizontal_position']); |
| 41 |
$horizontal_spacing = esc_attr($plugin_data_array['horizontal_spacing']); |
| 42 |
$vertical_position = esc_attr($plugin_data_array['vertical_position']); |
| 43 |
$vertical_spacing = esc_attr($plugin_data_array['vertical_spacing']); |
| 44 |
$background_color = esc_attr($plugin_data_array['background_color']); |
| 45 |
$background_position = esc_attr($plugin_data_array['background_position']); |
| 46 |
$button_z_index = intval($plugin_data_array['button_z_index']); |
| 47 |
$button_border = esc_attr($plugin_data_array['button_border']); |
| 48 |
$icon_image_url = esc_url($plugin_data_array['icon_image_url']); |
| 49 |
$hide_button_on_desktop = intval($plugin_data_array['hide_button_on_desktop']); |
| 50 |
$hide_button_on_mobile = intval($plugin_data_array['hide_button_on_mobile']); |
| 51 |
$mobile_width = intval($plugin_data_array['mobile_width']); |
| 52 |
$mobile_button_position_checkbox = intval($plugin_data_array['mobile_button_position_checkbox']); |
| 53 |
$mobile_horizontal_position = esc_attr($plugin_data_array['mobile_horizontal_position']); |
| 54 |
$mobile_horizontal_spacing = esc_attr($plugin_data_array['mobile_horizontal_spacing']); |
| 55 |
$mobile_vertical_position = esc_attr($plugin_data_array['mobile_vertical_position']); |
| 56 |
$mobile_vertical_spacing = esc_attr($plugin_data_array['mobile_vertical_spacing']); |
| 57 |
|
| 58 |
// making sure the back to top button active |
| 59 |
if( $display_button_checkbox == 1 ) { |
| 60 |
|
| 61 |
// ---------------------------------------------- |
| 62 |
// create button css code |
| 63 |
// ---------------------------------------------- |
| 64 |
|
| 65 |
$button_html_code = "<a href='tel:" . $phone_number . "' class='yydev-phone-button activeButtons' data-activevalue='#phone-button'><span></span></a>"; |
| 66 |
|
| 67 |
// ---------------------------------------------- |
| 68 |
// create button css code |
| 69 |
// ---------------------------------------------- |
| 70 |
|
| 71 |
$phone_btn_style = ''; |
| 72 |
|
| 73 |
// dealing with button style |
| 74 |
$phone_btn_style .= '<style>'; |
| 75 |
$phone_btn_style .= 'a.yydev-phone-button {'; |
| 76 |
|
| 77 |
$phone_btn_style .= 'background:' . $background_color . ';'; |
| 78 |
$phone_btn_style .= 'width:' . $button_width . 'px;'; |
| 79 |
$phone_btn_style .= 'height:' . $button_height . 'px;'; |
| 80 |
$phone_btn_style .= 'border-radius:' . $border_radius . ';'; |
| 81 |
$phone_btn_style .= $horizontal_position . ':' . $horizontal_spacing . ';'; |
| 82 |
$phone_btn_style .= $vertical_position . ':' . $vertical_spacing . ';'; |
| 83 |
$phone_btn_style .= 'border:' . $button_border . ';'; |
| 84 |
$phone_btn_style .= 'position:fixed;'; |
| 85 |
$phone_btn_style .= 'text-indent:-9999px;'; |
| 86 |
|
| 87 |
$current_button_z_index = "9999"; |
| 88 |
if(!empty($button_z_index)) { $current_button_z_index = $button_z_index; } |
| 89 |
$phone_btn_style .= 'z-index:' . $current_button_z_index . ';'; |
| 90 |
|
| 91 |
// if we hide this one desktop |
| 92 |
if($hide_button_on_desktop == 1) { |
| 93 |
$phone_btn_style .= 'display:none;'; |
| 94 |
} else { // if($hide_button_on_desktop == 1) { |
| 95 |
$phone_btn_style .= 'display:block;'; |
| 96 |
} // } else { // if($hide_button_on_desktop == 1) { |
| 97 |
|
| 98 |
$phone_btn_style .= '}'; |
| 99 |
|
| 100 |
$phone_btn_style .= 'a.yydev-phone-button span {'; |
| 101 |
|
| 102 |
$phone_btn_style .= 'display:block;'; |
| 103 |
$phone_btn_style .= 'height: 100%;'; |
| 104 |
$phone_btn_style .= 'width: 100%;'; |
| 105 |
$phone_btn_style .= 'background: transparent url(' . $icon_image_url .') no-repeat;'; |
| 106 |
|
| 107 |
$current_background_position = "50% 50%"; |
| 108 |
if(!empty($background_position)) { $current_background_position = $background_position; } |
| 109 |
$phone_btn_style .= 'background-position: ' . $current_background_position . ';'; |
| 110 |
|
| 111 |
$phone_btn_style .= '}'; |
| 112 |
|
| 113 |
// ------------------------------------------- |
| 114 |
// dealing with button mobile style |
| 115 |
// ------------------------------------------- |
| 116 |
$phone_btn_style .= '@media only screen and (max-width: ' . $mobile_width . 'px) {'; |
| 117 |
|
| 118 |
$phone_btn_style .= 'a.yydev-phone-button {'; |
| 119 |
|
| 120 |
if($mobile_button_position_checkbox == 1 ) { |
| 121 |
$phone_btn_style .= $horizontal_position . ':auto;'; |
| 122 |
$phone_btn_style .= $vertical_position . ':auto;'; |
| 123 |
$phone_btn_style .= $mobile_horizontal_position . ':' . $mobile_horizontal_spacing . ';'; |
| 124 |
$phone_btn_style .= $mobile_vertical_position . ':' . $mobile_vertical_spacing . ';'; |
| 125 |
} // if($mobile_button_position_checkbox == 1 ) { |
| 126 |
|
| 127 |
// if the button is showed only on desktop |
| 128 |
if($hide_button_on_mobile == 1) { |
| 129 |
$phone_btn_style .= 'display:none;'; |
| 130 |
} else { // if($hide_button_on_mobile == 0) { |
| 131 |
$phone_btn_style .= 'display:block;'; |
| 132 |
} // } else { // if($hide_button_on_mobile == 0) { |
| 133 |
|
| 134 |
$phone_btn_style .= '}'; |
| 135 |
|
| 136 |
$phone_btn_style .= '}'; |
| 137 |
|
| 138 |
$phone_btn_style .= '</style>'; |
| 139 |
|
| 140 |
// ---------------------------------------------- |
| 141 |
// add css and javascript code to header |
| 142 |
// ---------------------------------------------- |
| 143 |
|
| 144 |
add_action( 'wp_head', function() use ($phone_btn_style){ |
| 145 |
|
| 146 |
// echo css code to page |
| 147 |
echo $phone_btn_style; |
| 148 |
|
| 149 |
}); // add_action( 'wp_footer', function() use ($yydev_accessibility_html){ |
| 150 |
|
| 151 |
// ---------------------------------------------- |
| 152 |
// add the button html to footer |
| 153 |
// ---------------------------------------------- |
| 154 |
|
| 155 |
add_action( 'wp_footer', function() use ($button_html_code){ |
| 156 |
|
| 157 |
// echo html button |
| 158 |
echo $button_html_code; |
| 159 |
|
| 160 |
}); // add_action( 'wp_footer', function() use ($button_html_code){ |
| 161 |
|
| 162 |
} // if( $display_button_checkbox == 1 ) { |
| 163 |
|
| 164 |
} // if( !empty($getting_plugin_data) ) { |
| 165 |
|
| 166 |
|