Changeset 3391671
- Timestamp:
- 11/07/2025 10:22:38 AM (5 months ago)
- Location:
- butterfly-button
- Files:
-
- 37 added
- 3 edited
-
tags/0.0.5 (added)
-
tags/0.0.5/.distignore (added)
-
tags/0.0.5/LICENSE.txt (added)
-
tags/0.0.5/README.txt (added)
-
tags/0.0.5/admin (added)
-
tags/0.0.5/admin/class-butterfly-button-admin.php (added)
-
tags/0.0.5/admin/css (added)
-
tags/0.0.5/admin/css/butterfly-button-admin.css (added)
-
tags/0.0.5/admin/index.php (added)
-
tags/0.0.5/admin/js (added)
-
tags/0.0.5/admin/js/butterfly-button-admin.js (added)
-
tags/0.0.5/admin/partials (added)
-
tags/0.0.5/admin/partials/butterfly-button-admin-display.php (added)
-
tags/0.0.5/assets (added)
-
tags/0.0.5/assets/bf-logo.svg (added)
-
tags/0.0.5/assets/butterfly-logo-200.png (added)
-
tags/0.0.5/assets/menu_icon.png (added)
-
tags/0.0.5/butterfly-button.php (added)
-
tags/0.0.5/includes (added)
-
tags/0.0.5/includes/class-butterfly-button-activator.php (added)
-
tags/0.0.5/includes/class-butterfly-button-deactivator.php (added)
-
tags/0.0.5/includes/class-butterfly-button-loader.php (added)
-
tags/0.0.5/includes/class-butterfly-button.php (added)
-
tags/0.0.5/includes/index.php (added)
-
tags/0.0.5/index.php (added)
-
tags/0.0.5/languages (added)
-
tags/0.0.5/languages/butterfly-button.pot (added)
-
tags/0.0.5/public (added)
-
tags/0.0.5/public/class-butterfly-button-public.php (added)
-
tags/0.0.5/public/css (added)
-
tags/0.0.5/public/css/butterfly-button-public.css (added)
-
tags/0.0.5/public/index.php (added)
-
tags/0.0.5/public/js (added)
-
tags/0.0.5/public/js/butterfly-button-public.js (added)
-
tags/0.0.5/public/partials (added)
-
tags/0.0.5/public/partials/butterfly-button-public-display.php (added)
-
tags/0.0.5/uninstall.php (added)
-
trunk/admin/class-butterfly-button-admin.php (modified) (4 diffs)
-
trunk/butterfly-button.php (modified) (1 diff)
-
trunk/public/class-butterfly-button-public.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
butterfly-button/trunk/admin/class-butterfly-button-admin.php
r3385971 r3391671 125 125 'sanitize_callback' => function ($v) { 126 126 $v = sanitize_text_field($v); 127 return in_array($v, ['', 'top_left', 'top_ center', 'top_right', 'center_left', 'center_right', 'bottom_left', 'bottom_center', 'bottom_right'], true) ? $v : '';127 return in_array($v, ['', 'top_left', 'top_right', 'bottom_left', 'bottom_right'], true) ? $v : ''; 128 128 }, 129 129 'default' => '', 130 ]); 131 132 register_setting($option_group, 'butterfly_button_horizontal_space', [ 133 'type' => 'integer', 134 'sanitize_callback' => 'absint', 135 'default' => 20, 136 ]); 137 138 register_setting($option_group, 'butterfly_button_vertical_space', [ 139 'type' => 'integer', 140 'sanitize_callback' => 'absint', 141 'default' => 20, 142 ]); 143 144 register_setting($option_group, 'butterfly_button_horizontal_unit', [ 145 'type' => 'string', 146 'sanitize_callback' => function ($v) { 147 $v = sanitize_text_field($v); 148 return in_array($v, ['px', '%', 'vh', 'vw'], true) ? $v : 'px'; 149 }, 150 'default' => 'px', 151 ]); 152 153 register_setting($option_group, 'butterfly_button_vertical_unit', [ 154 'type' => 'string', 155 'sanitize_callback' => function ($v) { 156 $v = sanitize_text_field($v); 157 return in_array($v, ['px', '%', 'vh', 'vw'], true) ? $v : 'px'; 158 }, 159 'default' => 'px', 130 160 ]); 131 161 … … 172 202 'butterfly_button_main' 173 203 ); 204 205 add_settings_field( 206 'butterfly_button_horizontal_space', 207 __('Horizontal Space', 'butterfly-button'), 208 [$this, 'field_horizontal_space'], 209 'butterfly-button', 210 'butterfly_button_main' 211 ); 212 213 add_settings_field( 214 'butterfly_button_vertical_space', 215 __('Vertical Space', 'butterfly-button'), 216 [$this, 'field_vertical_space'], 217 'butterfly-button', 218 'butterfly_button_main' 219 ); 174 220 } 175 221 … … 199 245 $options = [ 200 246 'top_left' => __('Top Left', 'butterfly-button'), 201 'top_center' => __('Top Center', 'butterfly-button'),202 247 'top_right' => __('Top Right', 'butterfly-button'), 203 'center_left' => __('Center Left', 'butterfly-button'),204 'center_right' => __('Center Right', 'butterfly-button'),205 248 'bottom_left' => __('Bottom Left', 'butterfly-button'), 206 'bottom_center' => __('Bottom Center', 'butterfly-button'),207 249 'bottom_right' => __('Bottom Right', 'butterfly-button'), 208 250 ]; … … 218 260 echo '</select>'; 219 261 echo '<p class="description">' . esc_html__('You can override per page with shortcode attributes.', 'butterfly-button') . '</p>'; 262 } 263 264 public function field_horizontal_space() 265 { 266 $value = (int) get_option('butterfly_button_horizontal_space', 20); 267 $unit = get_option('butterfly_button_horizontal_unit', 'px'); 268 $units = ['px', '%', 'vh', 'vw']; 269 270 echo '<input type="number" min="0" name="butterfly_button_horizontal_space" value="' . esc_attr($value) . '" style="width: 80px;" /> '; 271 echo '<select name="butterfly_button_horizontal_unit">'; 272 foreach ($units as $u) { 273 printf( 274 '<option value="%s" %s>%s</option>', 275 esc_attr($u), 276 selected($unit, $u, false), 277 esc_html($u) 278 ); 279 } 280 echo '</select>'; 281 echo '<p class="description">' . esc_html__('Horizontal distance from the edge (left or right based on alignment).', 'butterfly-button') . '</p>'; 282 } 283 284 public function field_vertical_space() 285 { 286 $value = (int) get_option('butterfly_button_vertical_space', 20); 287 $unit = get_option('butterfly_button_vertical_unit', 'px'); 288 $units = ['px', '%', 'vh', 'vw']; 289 290 echo '<input type="number" min="0" name="butterfly_button_vertical_space" value="' . esc_attr($value) . '" style="width: 80px;" /> '; 291 echo '<select name="butterfly_button_vertical_unit">'; 292 foreach ($units as $u) { 293 printf( 294 '<option value="%s" %s>%s</option>', 295 esc_attr($u), 296 selected($unit, $u, false), 297 esc_html($u) 298 ); 299 } 300 echo '</select>'; 301 echo '<p class="description">' . esc_html__('Vertical distance from the edge (top or bottom based on alignment).', 'butterfly-button') . '</p>'; 220 302 } 221 303 -
butterfly-button/trunk/butterfly-button.php
r3387255 r3391671 17 17 * Plugin URI: https://github.com/TheButterflyButton/wp-butterfly-button 18 18 * Description: The Butterfly Button is a digital safe zone that secretly provides information, assistance and contacts domestic violence victims with experts who will be happy to assist. By adding it to your website, you help to hide the usage of The Butterfly, no one can trace the actions made inside The Butterfly and no entry is saved in the browsing history. With a few finger taps, without leaving traces, everybody can get help, consult and read info about domestic violence. 19 * Version: 0.0. 419 * Version: 0.0.5 20 20 * Author: CAVO - Connecting for a safer world 21 21 * Author URI: https://butterfly-button.com -
butterfly-button/trunk/public/class-butterfly-button-public.php
r3385971 r3391671 176 176 wp_enqueue_script('butterfly-button-sdk-wordpress'); 177 177 178 // Get spacing values with units 179 $h_space = (int) get_option('butterfly_button_horizontal_space', 20); 180 $h_unit = get_option('butterfly_button_horizontal_unit', 'px'); 181 $v_space = (int) get_option('butterfly_button_vertical_space', 20); 182 $v_unit = get_option('butterfly_button_vertical_unit', 'px'); 183 184 $horizontal = $h_space . $h_unit; 185 $vertical = $v_space . $v_unit; 186 178 187 $style = "width: {$size}px; height: {$size}px; cursor: pointer;"; 179 188 $wrapper_style = 'position: fixed; z-index: 9999;'; … … 181 190 switch ($align) { 182 191 case 'top_left': 183 $wrapper_style .= ' top: 20px; left: 20px;'; 184 break; 185 case 'top_center': 186 $wrapper_style .= ' top: 20px; left: 50%; transform: translateX(-50%);'; 192 $wrapper_style .= ' top: ' . $vertical . '; left: ' . $horizontal . ';'; 187 193 break; 188 194 case 'top_right': 189 $wrapper_style .= ' top: 20px; right: 20px;'; 190 break; 191 case 'center_left': 192 $wrapper_style .= ' top: 50%; left: 20px; transform: translateY(-50%);'; 193 break; 194 case 'center_right': 195 $wrapper_style .= ' top: 50%; right: 20px; transform: translateY(-50%);'; 195 $wrapper_style .= ' top: ' . $vertical . '; right: ' . $horizontal . ';'; 196 196 break; 197 197 case 'bottom_left': 198 $wrapper_style .= ' bottom: 20px; left: 20px;'; 199 break; 200 case 'bottom_center': 201 $wrapper_style .= ' bottom: 20px; left: 50%; transform: translateX(-50%);'; 198 $wrapper_style .= ' bottom: ' . $vertical . '; left: ' . $horizontal . ';'; 202 199 break; 203 200 case 'bottom_right': 204 $wrapper_style .= ' bottom: 20px; right: 20px;';201 $wrapper_style .= ' bottom: ' . $vertical . '; right: ' . $horizontal . ';'; 205 202 break; 206 203 }
Note: See TracChangeset
for help on using the changeset viewer.