Changeset 3169971
- Timestamp:
- 10/16/2024 09:14:05 AM (18 months ago)
- Location:
- donation-thermometer/trunk
- Files:
-
- 4 edited
-
donation_therm.php (modified) (4 diffs)
-
includes/therm_settings.php (modified) (2 diffs)
-
includes/therm_svg.php (modified) (5 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
donation-thermometer/trunk/donation_therm.php
r3018257 r3169971 4 4 Plugin URI: https://rhewlif.xyz/thermometer 5 5 Description: 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. 56 Version: 2.2.6 7 7 Author: Henry Patton 8 8 Text Domain: donation-thermometer … … 41 41 $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'); 42 42 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;'); 44 44 45 45 function set_plugin_meta_dt($links, $file) { … … 190 190 191 191 192 // Function to reset options to default values 193 function set_default_therm_style_options() { 194 delete_option('thermometer_style'); 195 } 196 197 function 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 205 add_action('admin_init', 'thermometer_style_handle_reset'); 206 192 207 // Display the admin options page 193 208 function options_page_fn() { … … 219 234 settings_fields( 'thermometer_style' ); 220 235 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;')); 222 238 add_filter('admin_footer_text', 'remove_footer_admin'); 223 239 echo '</form>'; -
donation-thermometer/trunk/includes/therm_settings.php
r2967764 r3169971 14 14 $value = (isset(get_option('thermometer_style')[$options['type']])) ? esc_html(get_option('thermometer_style')[$options['type']]) : $options['default']; 15 15 echo "<div class='form-item'><label for='svgStyle'></label>"; 16 echo '<textarea id="'.$options['type'].'" style="width: 400px;" name="thermometer_style['.$options['type'].']" placeholder="'.__('C lass namefor 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>"; 17 17 echo '<br/>'.__('Default','donation-thermometer').': <code>'.sanitize_text_field($options['default']).'</code></div>'; 18 18 } … … 174 174 echo '<p>'; 175 175 $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); 177 177 echo '</p>'; 178 178 -
donation-thermometer/trunk/includes/therm_svg.php
r3018257 r3169971 130 130 $legendStep = 15; 131 131 132 // transforms to svg depending what is shown133 132 if($thermProperties['orientation'] == 'landscape'){ 134 133 $transformY = 0; … … 152 151 153 152 $targetLen = mb_strlen($tValue); 154 if ( !empty($tickM) && $tickM== $rightM){ // left or right ticks153 if ($tickM === $rightM){ // left or right ticks 155 154 if($thermProperties['orientation'] != 'landscape'){ 156 155 $viewboxX1 = ($targetLen > 7) ? ($targetLen * -2.5) + 7 : 0; … … 331 330 } 332 331 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>'; 334 333 } 335 334 … … 347 346 if($thermProperties['orientation'] == 'landscape'){ 348 347 //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.'"/>'; 350 349 //minor 351 350 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.'"/>'; … … 552 551 if($thermProperties['orientation'] == 'landscape'){ 553 552 //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"/>'; 555 554 //minor 556 555 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 5 5 Requires at least: 4.6 6 6 Tested up to: 6.6.2 7 Stable tag: 2.2. 57 Stable tag: 2.2.6 8 8 Requires PHP: 5.2 9 9 License: GPL3 … … 80 80 81 81 == 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. 82 87 83 88 = 2.2.5 =
Note: See TracChangeset
for help on using the changeset viewer.