Plugin Directory

Changeset 3391671


Ignore:
Timestamp:
11/07/2025 10:22:38 AM (5 months ago)
Author:
butterflybutton
Message:

Deploy version 0.0.5 from GitHub

Location:
butterfly-button
Files:
37 added
3 edited

Legend:

Unmodified
Added
Removed
  • butterfly-button/trunk/admin/class-butterfly-button-admin.php

    r3385971 r3391671  
    125125            'sanitize_callback' => function ($v) {
    126126                $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 : '';
    128128            },
    129129            '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',
    130160        ]);
    131161
     
    172202            'butterfly_button_main'
    173203        );
     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        );
    174220    }
    175221
     
    199245        $options = [
    200246            'top_left' => __('Top Left', 'butterfly-button'),
    201             'top_center' => __('Top Center', 'butterfly-button'),
    202247            'top_right' => __('Top Right', 'butterfly-button'),
    203             'center_left' => __('Center Left', 'butterfly-button'),
    204             'center_right' => __('Center Right', 'butterfly-button'),
    205248            'bottom_left' => __('Bottom Left', 'butterfly-button'),
    206             'bottom_center' => __('Bottom Center', 'butterfly-button'),
    207249            'bottom_right' => __('Bottom Right', 'butterfly-button'),
    208250        ];
     
    218260        echo '</select>';
    219261        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>';
    220302    }
    221303
  • butterfly-button/trunk/butterfly-button.php

    r3387255 r3391671  
    1717 * Plugin URI:        https://github.com/TheButterflyButton/wp-butterfly-button
    1818 * 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.4
     19 * Version:           0.0.5
    2020 * Author:            CAVO - Connecting for a safer world
    2121 * Author URI:        https://butterfly-button.com
  • butterfly-button/trunk/public/class-butterfly-button-public.php

    r3385971 r3391671  
    176176        wp_enqueue_script('butterfly-button-sdk-wordpress');
    177177
     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
    178187        $style = "width: {$size}px; height: {$size}px; cursor: pointer;";
    179188        $wrapper_style = 'position: fixed; z-index: 9999;';
     
    181190        switch ($align) {
    182191            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 . ';';
    187193                break;
    188194            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 . ';';
    196196                break;
    197197            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 . ';';
    202199                break;
    203200            case 'bottom_right':
    204                 $wrapper_style .= ' bottom: 20px; right: 20px;';
     201                $wrapper_style .= ' bottom: ' . $vertical . '; right: ' . $horizontal . ';';
    205202                break;
    206203        }
Note: See TracChangeset for help on using the changeset viewer.