Plugin Directory

Changeset 512360


Ignore:
Timestamp:
02/29/2012 02:15:58 PM (14 years ago)
Author:
WhiteCubes
Message:

Possibility to choose decimal and thousand separator

Location:
worldcurrency/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • worldcurrency/trunk/readme.txt

    r512117 r512360  
    55Requires at least: 2.8.0
    66Tested up to: 3.3.1
    7 Stable tag: 1.8
     7Stable tag: 1.9
    88
    99Recognises users by IP address and shows them converted values in their local currency, you can write post/pages in multiple currencies.
     
    3434* Is possible to choose to hide conversion if target and origin currency are the same
    3535* Is possible to choose to make ajax calls over SSL
     36* Is possible to choose the decimal and thousands separator for the output format
    3637
    3738= How To Use (once plugin is installed) =
     
    9192== Changelog ==
    9293
     94= 1.9 (29th February 2012) =
     95* Added: is now possible to choose the decimal and thousands separator for the output formatting
     96
    9397= 1.8 (29th February 2012) =
    9498* Fix: ajax was not working if wordpress admin is under forced SSL with: define('FORCE_SSL_LOGIN', true);
  • worldcurrency/trunk/worldcurrency-admin.php

    r512117 r512360  
    2121            $dt_wc_options['plugin_priority']       = absint($_POST['plugin_priority']);
    2222            $dt_wc_options['output_format']         = $_POST['output_format'];
     23            $dt_wc_options['thousands_separator']   = $_POST['thousands_separator'];
     24            $dt_wc_options['decimal_separator']     = $_POST['decimal_separator'];
    2325            $dt_wc_options['additional_css']        = $_POST['additional_css'];
    2426            $dt_wc_options['bottom_select']         = isset($_POST['bottom_select']) ? 'true' : 'false';
     
    5355            <div id="poststuff">
    5456           
    55                 <div class="stuffbox">
     57                <form name="worldcurrency_options_form" action="" method="post">           
    5658               
     59                <div class="stuffbox">
    5760                    <h3>General Settings</h3>
    5861                    <div class="inside">
    59                    
    60                         <form name="worldcurrency_options_form" action="" method="post">
     62   
    6163                        <?php if (function_exists('wp_nonce_field')) {wp_nonce_field('worldcurrency_admin_page_submit'); }?>
    6264                   
     
    7880                            Does not show the conversion if the origin value currency and the user local currency are the same
    7981                        </p>
    80                        
    81                         <p>
    82                             <h4>
    83                                 Plugin Link:
    84                                 <input type="checkbox" name="plugin_link" id="plugin_link" <?php if ($dt_wc_options['plugin_link']=='true') {echo 'checked="checked"';}?> />
    85                             </h4>
    86                             By default, a link to the plugin home page is included near the currency select box.<br />
    87                             Deselect this parameter if you want to disable the link, but <u>keep in mind that leaving the link is one the best ways to support this plugin</u>.
    88                         </p>
    89                        
    90                         <p>
    91                             <h4>
    92                                 Yahoo Link:
    93                                 <input type="checkbox" name="yahoo_link" id="yahoo_link" <?php if ($dt_wc_options['yahoo_link']=='true') {echo 'checked="checked"';}?> />
    94                             </h4>
    95                             By legal requirement a link to Yahoo! Finance will be shown near the currency select box.<br />
    96                             Disable this only if you want to put this link elsewhere (ie: footer).
    97                         </p>
    98                        
     82
    9983                        <p>
    10084                            <h4>
     
    116100                            </ul>
    117101                        </p>
     102
     103                        <p>
     104                            <h4>
     105                                Thousands separator:
     106                                <input type="text" size="80" name="thousands_separator" value="<?php echo isset($dt_wc_options['thousands_separator']) ? $dt_wc_options['thousands_separator'] : '.'; ?>" />
     107                            </h4>
     108                            The character used to separate the tousands in the output (usually , or .)
     109                        </p>
     110                       
     111                        <p>
     112                            <h4>
     113                                Decimals separator:
     114                                <input type="text" size="80" name="decimal_separator" value="<?php echo isset($dt_wc_options['decimal_separator']) ? $dt_wc_options['decimal_separator'] : ','; ?>" />
     115                            </h4>
     116                            The character used to separate the decimal numbers in the output (usually , or .)
     117                        </p>
    118118                       
    119119                        <p>
     
    125125                        </p>
    126126                       
     127                        <p>
     128                            <h4>
     129                                Plugin Link:
     130                                <input type="checkbox" name="plugin_link" id="plugin_link" <?php if ($dt_wc_options['plugin_link']=='true') {echo 'checked="checked"';}?> />
     131                            </h4>
     132                            By default, a link to the plugin home page is included near the currency selection box.<br />
     133                            Deselect this parameter if you want to disable the link, but <u>keep in mind that leaving the link is one the best ways to support this plugin</u>.
     134                        </p>
     135                       
     136                        <p>
     137                            <h4>
     138                                Yahoo Link:
     139                                <input type="checkbox" name="yahoo_link" id="yahoo_link" <?php if ($dt_wc_options['yahoo_link']=='true') {echo 'checked="checked"';}?> />
     140                            </h4>
     141                            By legal requirement a link to Yahoo! Finance will be shown near the currency selection box.<br />
     142                            Disable this only if you want to put this link elsewhere (ie: footer).
     143                        </p>
     144                                               
     145                        <p>
     146                            <h4>
     147                                Additional CSS styles:<br />
     148                                <textarea name="additional_css" style="width:90%;height:250px;"><?php echo $dt_wc_options['additional_css']; ?></textarea>
     149                            </h4>
     150                            It is possible to change/set the styles of the converted values (.worldcurrency) and of the selection box (.worldcurrency_selection_box). Only for advanced users ;)
     151                        </p>
     152
     153                        <div style="clear:both"></div>
     154                    </div>
     155                </div>
     156
     157
     158                <!-- Usage Section -->
     159                <div class="stuffbox">
     160                    <h3>Technical Settings</h3>
     161                    <div class="inside">
     162
    127163                        <p>
    128164                            <h4>
     
    159195                        </p>
    160196                                           
    161                         <p>
    162                             <h4>
    163                                 Additional CSS styles:<br />
    164                                 <textarea name="additional_css" style="width:90%;height:250px;"><?php echo $dt_wc_options['additional_css']; ?></textarea>
    165                             </h4>
    166                             It is possible to change/set the styles of the converted values (.worldcurrency) and of the selection box (.worldcurrency_selection_box). Only for advanced users ;)
    167                         </p>
    168 
    169                         <!-- Show Update Button -->
    170                         <div class="submit">
    171                         <input type="submit" name="dt_wc_options_submit" value="Update Options &raquo;"/>
    172                         <input type="submit" name="dt_wc_options_reset" value="Reset Options &raquo;"/>
    173                         </div> 
    174 
    175 
    176                         </form>
    177                         <div style="clear:both"></div>
    178                     </div>
    179                 </div>
    180 
    181 
     197                    </div>
     198                </div>
     199               
     200                <!-- Show Update Button -->
     201                <div class="submit">
     202                    <input type="submit" name="dt_wc_options_submit" value="Update Options &raquo;"/>
     203                    <input type="submit" name="dt_wc_options_reset" value="Reset Options &raquo;"/>
     204                </div> 
     205
     206                </form>
     207               
    182208                <!-- Usage Section -->
    183209                <div class="stuffbox">
     
    200226                        </p>
    201227                        <p>
    202                             You can also put this shorttag:<br /><br />
     228                            You can also put this shorttag in pages/posts:<br /><br />
    203229                            <code style="padding:5px;margin:10px;">
    204230                                [worldcurrencybox]
    205231                            </code><br /><br />
    206                             Or this HTML code:<br /><br />
     232                            Or this HTML code anywhere else:<br /><br />
    207233                            <code style="padding:5px;margin:10px;">
    208234                                &lt;div class="worldcurrency_selection_box_placeholder"&gt;&lt;/div&gt;
    209235                            </code><br /><br />
    210                             wherever you want the selection box to be shown (or select the option above to show it automatically at the bottom of the post)
     236                            wherever you want the <b>currency selection box</b> to be shown (or select the option above to show it automatically at the bottom of the post)<br />
     237                            <br />
     238                            There is also a <b>Widget</b> (for the sidebar) wich shows the Currency Selection Box only if there are currencies on the page.
    211239                    </div>
    212240                </div>
  • worldcurrency/trunk/worldcurrency.php

    r512117 r512360  
    44Plugin URI: http://www.cometicucinoilweb.it/blog/en/worldcurrency-plugin-for-wordpress/
    55Description: Recognises users by IP address and shows them converted values in their local currency, you can write post/pages in multiple currencies.
    6 Version: 1.8
     6Version: 1.9
    77Date: 29th February 2012
    88Author: Daniele Tieghi
     
    5858            $dt_wc_options = get_option('$dt_wc_options');
    5959   
    60             if ($force || !isset($dt_wc_options['plugin_link']))        $dt_wc_options['plugin_link'] = 'true';
    61             if ($force || !isset($dt_wc_options['yahoo_link']))         $dt_wc_options['yahoo_link'] = 'true';
    62             if ($force || !isset($dt_wc_options['cache_rates']))        $dt_wc_options['cache_rates'] = null;
    63             if ($force || !isset($dt_wc_options['cache_time']))         $dt_wc_options['cache_time'] = 0;
    64             if ($force || !isset($dt_wc_options['historic_rates']))     $dt_wc_options['historic_rates'] = 'false';
    65             if ($force || !isset($dt_wc_options['hide_if_same']))       $dt_wc_options['hide_if_same'] = 'true';
    66             if ($force || !isset($dt_wc_options['output_format']))      $dt_wc_options['output_format'] = '(~%to_value%%to_symbol% %to_code%)';
    67             if ($force || !isset($dt_wc_options['bottom_select']))      $dt_wc_options['bottom_select'] = 'true';
    68             if ($force || !isset($dt_wc_options['include_jquery']))     $dt_wc_options['include_jquery'] = 'true';
    69             if ($force || !isset($dt_wc_options['jquery_no_conflict'])) $dt_wc_options['jquery_no_conflict'] = 'false';
    70             if ($force || !isset($dt_wc_options['ajax_over_ssl']))      $dt_wc_options['ajax_over_ssl'] = 'false';
    71             if ($force || !isset($dt_wc_options['plugin_priority']))    $dt_wc_options['plugin_priority'] = 10;
    72             if ($force || !isset($dt_wc_options['additional_css']))     $dt_wc_options['additional_css'] = <<<EOT
     60            if ($force || !isset($dt_wc_options['plugin_link']))            $dt_wc_options['plugin_link'] = 'true';
     61            if ($force || !isset($dt_wc_options['yahoo_link']))             $dt_wc_options['yahoo_link'] = 'true';
     62            if ($force || !isset($dt_wc_options['cache_rates']))            $dt_wc_options['cache_rates'] = null;
     63            if ($force || !isset($dt_wc_options['cache_time']))             $dt_wc_options['cache_time'] = 0;
     64            if ($force || !isset($dt_wc_options['historic_rates']))         $dt_wc_options['historic_rates'] = 'false';
     65            if ($force || !isset($dt_wc_options['hide_if_same']))           $dt_wc_options['hide_if_same'] = 'true';
     66            if ($force || !isset($dt_wc_options['output_format']))          $dt_wc_options['output_format'] = '(~%to_value%%to_symbol% %to_code%)';
     67            if ($force || !isset($dt_wc_options['thousands_separator']))    $dt_wc_options['thousands_separator'] = '.';
     68            if ($force || !isset($dt_wc_options['decimal_separator']))      $dt_wc_options['decimal_separator'] = ',';
     69            if ($force || !isset($dt_wc_options['output_format']))          $dt_wc_options['output_format'] = '(~%to_value%%to_symbol% %to_code%)';
     70            if ($force || !isset($dt_wc_options['bottom_select']))          $dt_wc_options['bottom_select'] = 'true';
     71            if ($force || !isset($dt_wc_options['include_jquery']))         $dt_wc_options['include_jquery'] = 'true';
     72            if ($force || !isset($dt_wc_options['jquery_no_conflict']))     $dt_wc_options['jquery_no_conflict'] = 'false';
     73            if ($force || !isset($dt_wc_options['ajax_over_ssl']))          $dt_wc_options['ajax_over_ssl'] = 'false';
     74            if ($force || !isset($dt_wc_options['plugin_priority']))        $dt_wc_options['plugin_priority'] = 10;
     75            if ($force || !isset($dt_wc_options['additional_css']))         $dt_wc_options['additional_css'] = <<<EOT
    7376.worldcurrency {
    7477    color: #888;
     
    374377        }
    375378       
     379        // Get the separators format
     380        $thousands_separator = isset($dt_wc_options['thousands_separator']) ? $dt_wc_options['thousands_separator'] : '.';
     381        $decimals_separator = isset($dt_wc_options['decimal_separator']) ? $dt_wc_options['decimal_separator'] : ',';
     382
     383       
    376384        // Load the quotes obtained
    377385            $YahooFinance->loadSerializedQuotes($serializedQuotes);
     
    393401        // Round the numbers
    394402            $exchange_rate = number_format($exchange_rate,2,',','.');
    395             $from_value = $from_value > 100 ? number_format($from_value,0,',','.') : number_format($from_value, 2,',','.');
    396             $to_value = $to_value > 100 ? number_format($to_value,0,',','.') : number_format($to_value, 2,',','.');
     403            $from_value = $from_value > 100 ? number_format($from_value,0,$decimals_separator,$thousands_separator) : number_format($from_value, 2,$decimals_separator,$thousands_separator);
     404            $to_value = $to_value > 100 ? number_format($to_value,0,$decimals_separator,$thousands_separator) : number_format($to_value, 2,$decimals_separator,$thousands_separator);
    397405       
    398406        // Do not show conversions to the same currency
Note: See TracChangeset for help on using the changeset viewer.