Plugin Directory

Changeset 3334985


Ignore:
Timestamp:
07/27/2025 07:49:30 PM (7 months ago)
Author:
havenlytics
Message:

[1.0.11] Added formatted price output with commas and decimals; minor code cleanup.

Location:
havenlytics
Files:
105 added
8 edited

Legend:

Unmodified
Added
Removed
  • havenlytics/trunk/havenlytics.php

    r3334824 r3334985  
    44Plugin URI: https://wordpress.org/plugins/havenlytics/
    55Description: A property listing plugin for WordPress that allows users to easily manage and display property listings.
    6 Version: 1.0.10
     6Version: 1.0.11
    77Author: Havenlytics
    88Author URI: https://havenlytics.com
     
    3030
    3131// Define constants
    32 define('HVNLY_PROPERTY_VERSION', '1.0.10');
     32define('HVNLY_PROPERTY_VERSION', '1.0.11');
    3333define('HVNLY_PROPERTY_URL', plugin_dir_url(__FILE__));
    3434define('HVNLY_PROPERTY_PATH', plugin_dir_path(__FILE__));
  • havenlytics/trunk/public/assets/css/havenlytics-property-list.css

    r3333158 r3334985  
    7070}
    7171.havenlytics-property-title-container {
    72     max-width: 70%;
     72    max-width: 65%;
    7373}
    7474/* Property Card */
  • havenlytics/trunk/public/class-frontend.php

    r3334405 r3334985  
    837837  }
    838838
     839  /**
     840   * Format a property price with proper thousands separator and decimals.
     841   *
     842   * @param mixed  $price           The raw price value to format.
     843   * @param int    $decimals        Number of decimal places (default 2).
     844   * @param string $decimal_point   Decimal point character (default '.').
     845   * @param string $thousands_sep   Thousands separator (default ',').
     846   *
     847   * @return string Formatted price string.
     848   */
     849  private function format_property_price($price, $decimals = 2, $decimal_point = '.', $thousands_sep = ',')
     850  {
     851    // Ensure price is numeric
     852    if (!is_numeric($price)) {
     853      return $price; // Return unformatted if not numeric (fallback)
     854    }
     855
     856    // Convert to float for consistent formatting
     857    $price = floatval($price);
     858
     859    // Format the price using number_format()
     860    return number_format($price, $decimals, $decimal_point, $thousands_sep);
     861  }
     862
     863
     864
    839865
    840866
  • havenlytics/trunk/readme.txt

    r3334824 r3334985  
    66Tested up to: 6.8
    77Requires PHP: 7.2 
    8 Stable tag: 1.0.10
     8Stable tag: 1.0.11
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    145145
    146146== Changelog ==
     147= 1.0.11 (2025-07-28) =
     148* Fix: Minor code issues.
     149* Enhancement: Added helper method to format property price with thousands separator and decimal point for better readability.
     150
     151
     152
    147153= 1.0.10 (2025-07-27) =
    148154* Fix: Minor bug in Owl Carousel JS.
  • havenlytics/trunk/templates/hvnly_property-single.php

    r3334735 r3334985  
    115115        $currency_symbol = isset($currency_symbols[$currency_code]) ? $currency_symbols[$currency_code] : '$';
    116116
     117        function format_property_price($price, $decimals = 2, $decimal_point = '.', $thousands_sep = ',')
     118        {
     119            // Ensure price is numeric
     120            if (!is_numeric($price)) {
     121                return $price; // Return unformatted if not numeric (fallback)
     122            }
     123
     124            // Convert to float for consistent formatting
     125            $price = floatval($price);
     126
     127            // Format the price using number_format()
     128            return number_format($price, $decimals, $decimal_point, $thousands_sep);
     129        }
    117130
    118131
     
    219232
    220233                    <div class="property-price">
     234                        <?php
     235                        $price = format_property_price($price);
     236                        ?>
    221237                        <?php echo esc_html($currency_symbol); ?> <?php echo esc_html($price); ?>
    222238                    </div>
     
    768784                                                                <?php if ($price) : ?>
    769785                                                                    <div class="havenlytics_price">
     786                                                                        <?php
     787                                                                        $price = format_property_price($price);
     788                                                                        ?>
    770789                                                                        <?php echo esc_html($currency_symbol . $price); ?></div>
    771790                                                                <?php endif; ?>
     
    10601079                                                            <?php if ($price) : ?>
    10611080                                                                <div class="havenlytics-property-amount">
     1081                                                                    <?php
     1082                                                                    $price = format_property_price($price);
     1083                                                                    ?>
    10621084                                                                    <h5>
    10631085                                                                        <span>
  • havenlytics/trunk/templates/property-card-grid.php

    r3334735 r3334985  
    7474                    <?php
    7575                    // Get the currency symbol
    76                     $currency_sign = $this->get_currency_symbol($property_id);
     76
     77                    $currency = $this->get_currency_symbol($property_id);
     78                    $price = $this->format_property_price($meta_fields['price']);
    7779                    ?>
    7880                    <div class="havenlytics-property-amount">
    79                         <h5><span><?php echo esc_html($currency_sign); ?> <?php echo esc_html($meta_fields['price']); ?>
     81                        <h5><span><?php echo esc_html($currency); ?> <?php echo esc_html($price); ?>
    8082                            </span></h5>
    8183                    </div>
  • havenlytics/trunk/templates/property-card-list.php

    r3334735 r3334985  
    8585                    // Get the currency symbol
    8686                    $currency_sign = $this->get_currency_symbol($property_id);
     87                    $price = $this->format_property_price($meta_fields['price']);
    8788                    ?>
    8889                    <div class="havenlytics-property-price"><?php echo esc_html($currency_sign); ?>
    89                         <?php echo esc_html($meta_fields['price']); ?></div>
     90                        <?php echo esc_html($price); ?></div>
    9091
    9192                <?php endif; ?>
  • havenlytics/trunk/templates/property-card.php

    r3334735 r3334985  
    7474                    // Get the currency symbol
    7575                    $currency_sign = $this->get_currency_symbol($property_id);
     76                    $price = $this->format_property_price($meta_fields['price']);
    7677                    ?>
    7778                    <div class="havenlytics-property-amount">
    78                         <h5><span><?php echo esc_html($currency_sign); ?> <?php echo esc_html($meta_fields['price']); ?>
     79                        <h5><span><?php echo esc_html($currency_sign); ?> <?php echo esc_html($price); ?>
    7980                            </span></h5>
    8081                    </div>
Note: See TracChangeset for help on using the changeset viewer.