Plugin Directory

Changeset 3169971


Ignore:
Timestamp:
10/16/2024 09:14:05 AM (18 months ago)
Author:
henryp
Message:
  • Changed default font styling from sans-serif to inherit the theme's default font.
  • Added button on settings page to reset all styling entries to default values.
  • Various small typos and code fixes.
Location:
donation-thermometer/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • donation-thermometer/trunk/donation_therm.php

    r3018257 r3169971  
    44Plugin URI: https://rhewlif.xyz/thermometer
    55Description: Displays customisable thermometers for tracking donations using the shortcode <code>[thermometer raised=?? target=??]</code>. Shortcodes for raised/target/percentage text values are also available for posts/pages/text widgets: <code>[therm_r]</code> / <code>[therm_t]</code> / <code>[therm_%]</code>.
    6 Version: 2.2.5
     6Version: 2.2.6
    77Author: Henry Patton
    88Text Domain: donation-thermometer
     
    4141$thermDefaults = array('colour_picker1'=>'#d7191c', 'colour_picker6'=>'#eb7e80', 'therm_shadow'=>'false', 'therm_filltype'=>'uniform', 'therm_orientation'=>'portrait', 'chkbox1'=>'true', 'colour_picker2'=>'#000000', 'chkbox2'=>'true', 'colour_picker3'=>'#000000', 'chkbox3'=>'true', 'colour_picker4'=>'#000000', 'currency'=>'£','target_string'=>'500', 'raised_string'=>'250', 'thousands'=>', (comma)', 'decsep'=>'. (point)', 'decimals'=>'0', 'trailing'=>'false', 'tick_align'=>'right', 'color_ramp'=>'#d7191c; #fdae61; #abd9e9; #2c7bb6', 'targetlabels'=>'true', 'colour_picker5'=>'#8a8a8a', 'swapValues'=>'0');
    4242
    43 $thermDefaultStyle = array('thermometer_svg'=>'', 'therm_target_style'=>'font-size: 16px; font-family: sans-serif;','therm_raised_style'=>'font-size: 14px; font-family: sans-serif;', 'therm_subTarget_style'=>'font-size: 14px; font-family: sans-serif;', 'therm_percent_style'=>'font-family: sans-serif; text-anchor: middle; font-weight: bold;','therm_legend_style'=>'font-size: 12px; font-family: sans-serif;','therm_majorTick_style'=>'stroke-width: 2.5px; stroke: #000;','therm_minorTick_style'=>'stroke-width: 2.5px; stroke: #000;', 'therm_border_style'=>'stroke-width: 1.5px; stroke: #000; fill: transparent;','therm_fill_style'=>'fill: transparent;','therm_arrow_style'=>'stroke: #000; stroke-width: 0.2px; fill: #000;','therm_subArrow_style'=>'stroke: #8a8a8a; stroke-width: 0.2px; fill: #8a8a8a;','therm_raisedLevel_style'=>'stroke-width: 1px; stroke: #000;','therm_subRaisedLevel_style'=>'stroke-width: 1px; stroke: #000;','therm_subTargetLevel_style'=>'stroke-width: 2.5px; stroke: #8a8a8a;');
     43$thermDefaultStyle = array('thermometer_svg'=>'', 'therm_target_style'=>'font-size: 16px; font-family: inherit; text-anchor: middle;','therm_raised_style'=>'font-size: 14px; font-family: inherit;', 'therm_subTarget_style'=>'font-size: 14px; font-family: inherit;', 'therm_percent_style'=>'font-family: inherit; text-anchor: middle; font-weight: bold;','therm_legend_style'=>'font-size: 12px; font-family: inherit;','therm_majorTick_style'=>'stroke-width: 2.5px; stroke: #000;','therm_minorTick_style'=>'stroke-width: 2.5px; stroke: #000;', 'therm_border_style'=>'stroke-width: 1.5px; stroke: #000; fill: transparent;','therm_fill_style'=>'fill: transparent;','therm_arrow_style'=>'stroke: #000; stroke-width: 0.2px; fill: #000;','therm_subArrow_style'=>'stroke: #8a8a8a; stroke-width: 0.2px; fill: #8a8a8a;','therm_raisedLevel_style'=>'stroke-width: 1px; stroke: #000;','therm_subRaisedLevel_style'=>'stroke-width: 1px; stroke: #000;','therm_subTargetLevel_style'=>'stroke-width: 2.5px; stroke: #8a8a8a;');
    4444
    4545function set_plugin_meta_dt($links, $file) {
     
    190190
    191191
     192// Function to reset options to default values
     193function set_default_therm_style_options() {
     194    delete_option('thermometer_style');
     195}
     196
     197function thermometer_style_handle_reset() {
     198    // Check if the reset button was clicked
     199    if (isset($_POST['thermometer_style_reset'])) {
     200        set_default_therm_style_options(); // Call the function to reset options
     201        add_settings_error('thermometer_style_messages', 'thermometer_style_message', __('CSS styling reset to default values', 'thermometer_style'), 'updated');
     202    }
     203}
     204
     205add_action('admin_init', 'thermometer_style_handle_reset');
     206
    192207// Display the admin options page
    193208function options_page_fn() {
     
    219234        settings_fields( 'thermometer_style' );
    220235        do_settings_sections( 'thermometer_style' );
    221         submit_button();
     236        submit_button('Save Changes', 'primary', 'submit', false);
     237        submit_button('Reset styling to default', 'secondary', 'thermometer_style_reset', false, array('style' => 'margin-left: 10px;'));
    222238        add_filter('admin_footer_text', 'remove_footer_admin');
    223239        echo '</form>';
  • donation-thermometer/trunk/includes/therm_settings.php

    r2967764 r3169971  
    1414    $value = (isset(get_option('thermometer_style')[$options['type']])) ? esc_html(get_option('thermometer_style')[$options['type']]) : $options['default'];
    1515    echo "<div class='form-item'><label for='svgStyle'></label>";
    16     echo '<textarea id="'.$options['type'].'" style="width: 400px;" name="thermometer_style['.$options['type'].']" placeholder="'.__('Class name for the entire thermometer svg','donation-thermometer').'">'.sanitize_text_field($value)."</textarea>";
     16    echo '<textarea id="'.$options['type'].'" style="width: 400px;" name="thermometer_style['.$options['type'].']" placeholder="'.__('CSS styling for the entire thermometer svg','donation-thermometer').'">'.sanitize_text_field($value)."</textarea>";
    1717    echo '<br/>'.__('Default','donation-thermometer').': <code>'.sanitize_text_field($options['default']).'</code></div>';
    1818}
     
    174174    echo '<p>';
    175175    $thermShort = '<code>[thermometer]</code>';
    176     printf(/* translators: 1: <code>[thermometer]</code> */__('Based on the plugin settings defined on this options page, the shortcode %1$s will produce an SVG image like this:', 'donation-thermometer'), $thermShort);
     176    printf(/* translators: 1: <code>[thermometer]</code> */__('Based on the plugin settings defined on this options page, the default shortcode %1$s will produce an SVG image like this:', 'donation-thermometer'), $thermShort);
    177177    echo '</p>';
    178178
  • donation-thermometer/trunk/includes/therm_svg.php

    r3018257 r3169971  
    130130    $legendStep = 15;
    131131
    132     // transforms to svg depending what is shown
    133132    if($thermProperties['orientation'] == 'landscape'){
    134133        $transformY = 0;
     
    152151
    153152    $targetLen = mb_strlen($tValue);
    154     if (!empty($tickM) && $tickM == $rightM){   // left or right ticks
     153    if ($tickM === $rightM){    // left or right ticks
    155154        if($thermProperties['orientation'] != 'landscape'){
    156155            $viewboxX1 = ($targetLen > 7) ? ($targetLen * -2.5) + 7 : 0;
     
    331330        }
    332331        else{
    333             echo '<text x="38" y="20" class="therm_target" fill="'.esc_html($targetColor).'" dominant-baseline="baseline" text-anchor="middle">'.esc_html($tValue).'</text>';
     332            echo '<text x="38" y="20" class="therm_target" fill="'.esc_html($targetColor).'" dominant-baseline="auto" text-anchor="middle">'.esc_html($tValue).'</text>';
    334333        }
    335334
     
    347346        if($thermProperties['orientation'] == 'landscape'){
    348347            //major
    349             echo '<path d="M '.$maxH.' '.$tickM.' L '.$maxH.' '.$majorTickL.' M  '.($maxH-($tickStep*1)).' '.$tickM.' L '.($maxH-($tickStep*1)).' '.$majorTickL.' M '.($maxH-($tickStep*2)).' '.$tickM.' L '.($maxH-($tickStep*2)).' '.$majorTickL.' M'.($maxH-($tickStep*3)).' '.$tickM.' L '.($maxH-($tickStep*3)).' '.$majorTickL.' M '.($maxH-($tickStep*4)).' '.$tickM.' L '.($maxH-($tickStep*4)).' '.$majorTickL.' M '.$minH.' '.$tickM.' L '.$minH.' '.$majorTickL.'" class="therm_majorTick" filter="'.$basicShadow.'"/>';
     348            echo '<path d="M '.$maxH.' '.$tickM.' L '.$maxH.' '.$majorTickL.' M  '.($maxH-($tickStep)).' '.$tickM.' L '.($maxH-($tickStep)).' '.$majorTickL.' M '.($maxH-($tickStep*2)).' '.$tickM.' L '.($maxH-($tickStep*2)).' '.$majorTickL.' M'.($maxH-($tickStep*3)).' '.$tickM.' L '.($maxH-($tickStep*3)).' '.$majorTickL.' M '.($maxH-($tickStep*4)).' '.$tickM.' L '.($maxH-($tickStep*4)).' '.$majorTickL.' M '.$minH.' '.$tickM.' L '.$minH.' '.$majorTickL.'" class="therm_majorTick" filter="'.$basicShadow.'"/>';
    350349            //minor
    351350            echo '<path d="M '.($maxH-$tickStep*0.5).' '.$tickM.' L '.($maxH-$tickStep*0.5).' '.$minorTickL.' M '.($maxH-$tickStep*1.5).' '.$tickM.' L '.($maxH-$tickStep*1.5).' '.$minorTickL.' M '.($maxH-$tickStep*2.5).' '.$tickM.' L '.($maxH-$tickStep*2.5).' '.$minorTickL.' M '.($maxH-$tickStep*3.5).' '.$tickM.' L '.($maxH-$tickStep*3.5).' '.$minorTickL.' M '.($maxH-$tickStep*4.5).' '.$tickM.' L '.($maxH-$tickStep*4.5).' '.$minorTickL.'" class="therm_minorTick" filter="'.$basicShadow.'"/>';
     
    552551    if($thermProperties['orientation'] == 'landscape'){
    553552        //major
    554         echo '<path d="M '.$maxH.' '.$tickM.' L '.$maxH.' '.$majorTickL.' M  '.($maxH-($tickStep*1)).' '.$tickM.' L '.($maxH-($tickStep*1)).' '.$majorTickL.' M '.($maxH-($tickStep*2)).' '.$tickM.' L '.($maxH-($tickStep*2)).' '.$majorTickL.' M'.($maxH-($tickStep*3)).' '.$tickM.' L '.($maxH-($tickStep*3)).' '.$majorTickL.' M '.($maxH-($tickStep*4)).' '.$tickM.' L '.($maxH-($tickStep*4)).' '.$majorTickL.' M '.$minH.' '.$tickM.' L '.$minH.' '.$majorTickL.'" class="therm_majorTick"/>';
     553        echo '<path d="M '.$maxH.' '.$tickM.' L '.$maxH.' '.$majorTickL.' M  '.($maxH-($tickStep)).' '.$tickM.' L '.($maxH-($tickStep)).' '.$majorTickL.' M '.($maxH-($tickStep*2)).' '.$tickM.' L '.($maxH-($tickStep*2)).' '.$majorTickL.' M'.($maxH-($tickStep*3)).' '.$tickM.' L '.($maxH-($tickStep*3)).' '.$majorTickL.' M '.($maxH-($tickStep*4)).' '.$tickM.' L '.($maxH-($tickStep*4)).' '.$majorTickL.' M '.$minH.' '.$tickM.' L '.$minH.' '.$majorTickL.'" class="therm_majorTick"/>';
    555554        //minor
    556555        echo '<path d="M '.($maxH-$tickStep*0.5).' '.$tickM.' L '.($maxH-$tickStep*0.5).' '.$minorTickL.' M '.($maxH-$tickStep*1.5).' '.$tickM.' L '.($maxH-$tickStep*1.5).' '.$minorTickL.' M '.($maxH-$tickStep*2.5).' '.$tickM.' L '.($maxH-$tickStep*2.5).' '.$minorTickL.' M '.($maxH-$tickStep*3.5).' '.$tickM.' L '.($maxH-$tickStep*3.5).' '.$minorTickL.' M '.($maxH-$tickStep*4.5).' '.$tickM.' L '.($maxH-$tickStep*4.5).' '.$minorTickL.'" class="therm_minorTick"/>';
  • donation-thermometer/trunk/readme.txt

    r3149667 r3169971  
    55Requires at least: 4.6
    66Tested up to: 6.6.2
    7 Stable tag: 2.2.5
     7Stable tag: 2.2.6
    88Requires PHP: 5.2
    99License: GPL3
     
    8080
    8181== Changelog ==
     82
     83= 2.2.6 =
     84* Changed default font styling from sans-serif to inherit the theme's default font.
     85* Added button on settings page to reset all styling entries to default values.
     86* Various small typos and code fixes.
    8287
    8388= 2.2.5 =
Note: See TracChangeset for help on using the changeset viewer.