Plugin Directory

Changeset 3334735


Ignore:
Timestamp:
07/27/2025 07:55:09 AM (7 months ago)
Author:
havenlytics
Message:

Version 1.0.9 - Added frontend chart widget to display daily and weekly property views using Chart.js. Improved output escaping for security compliance. Enhanced i18n by removing deprecated load_plugin_textdomain(). Minor style updates for chat widget.

Location:
havenlytics
Files:
109 added
13 edited

Legend:

Unmodified
Added
Removed
  • havenlytics/trunk/havenlytics.php

    r3334405 r3334735  
    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.8
     6Version: 1.0.9
    77Author: Havenlytics
    88Author URI: https://havenlytics.com
     
    3030
    3131// Define constants
    32 define('HVNLY_PROPERTY_VERSION', '1.0.8');
     32define('HVNLY_PROPERTY_VERSION', '1.0.9');
    3333define('HVNLY_PROPERTY_URL', plugin_dir_url(__FILE__));
    3434define('HVNLY_PROPERTY_PATH', plugin_dir_path(__FILE__));
     
    4646// Initialize the plugin
    4747Hvnly_Property_Init::get_instance();
    48 
    49 // Load plugin text domain for translations
    50 
    51 function hvnly_property_load_textdomain()
    52 {
    53     load_plugin_textdomain('havenlytics', false, dirname(plugin_basename(__FILE__)) . '/languages');
    54 }
    55 add_action('init', 'hvnly_property_load_textdomain');
  • havenlytics/trunk/includes/class-property-views.php

    r3334405 r3334735  
    3333                $_SESSION['hvnly_viewed_' . $post_id] = true;
    3434
     35                // 1. Total views (as before)
    3536                $views = (int) get_post_meta($post_id, '_hvnly_property_views', true);
    3637                update_post_meta($post_id, '_hvnly_property_views', $views + 1);
     38
     39                // 2. Daily views
     40                $daily_views = get_post_meta($post_id, '_hvnly_property_daily_views', true);
     41                if (!is_array($daily_views)) {
     42                    $daily_views = [];
     43                }
     44
     45                $today = current_time('Y-m-d');
     46
     47                if (isset($daily_views[$today])) {
     48                    $daily_views[$today]++;
     49                } else {
     50                    $daily_views[$today] = 1;
     51                }
     52
     53                update_post_meta($post_id, '_hvnly_property_daily_views', $daily_views);
    3754            }
    3855        }
     56
    3957
    4058        /**
     
    6482            return number_format_i18n($views);
    6583        }
     84
     85
     86        public static function get_daily_views_data($post_id)
     87        {
     88            $daily_views = get_post_meta($post_id, '_hvnly_property_daily_views', true);
     89
     90            if (empty($daily_views) || !is_array($daily_views)) {
     91                // error_log('Fallback triggered for daily views on post ' . $post_id);
     92                // error_log('Current meta: ' . print_r($daily_views, true));
     93                return [
     94                    'labels' => ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
     95                    'data'   => [10, 25, 40, 32, 55, 20, 18], // fallback sample
     96                ];
     97            }
     98
     99            // Sort by date ascending
     100            ksort($daily_views);
     101
     102            // Keep only last 7 days (chronologically)
     103            $daily_views = array_slice(array_reverse($daily_views), 0, 7, true);
     104            $daily_views = array_reverse($daily_views);
     105
     106            $labels = [];
     107            $data = [];
     108
     109            foreach ($daily_views as $date => $count) {
     110                $labels[] = date_i18n('M j', strtotime($date)); // e.g., Jul 26
     111                $data[] = (int) $count;
     112            }
     113
     114            return [
     115                'labels' => $labels,
     116                'data'   => $data,
     117            ];
     118        }
    66119    }
    67120}
  • havenlytics/trunk/public/assets/css/havenlytics-mortgage-calculator.init.css

    r3334405 r3334735  
    428428
    429429.Havenlytics_mortgage_cal-currency select {
    430     background: transparent;
     430    background: transparent !important;
    431431    border: none;
    432432    color: white;
  • havenlytics/trunk/public/assets/css/havenlytics-property-popups.css

    r3334405 r3334735  
    298298/* Map Styles */
    299299.havenlytics_popup_map {
    300     height: 500px;
     300    max-height: 550px;
    301301    background: #f0f0f0;
    302302    border-radius: 10px;
  • havenlytics/trunk/public/assets/css/havenlytics-property-single.css

    r3324509 r3334735  
    10851085    transform: scale(1.3);
    10861086}
     1087
     1088
     1089/* Property view count chart pie css */
     1090.havenlytics-single-property-container .havenlytics-daily-stats-card{    background: var(--havenlytics-cardBg);
     1091    border: var(--havenlytics-cardBorder);
     1092    box-shadow: var(--havenlytics-cardShadow);
     1093    border-radius: var(--havenlytics-cardRadius);
     1094    padding: var(--havenlytics-cardPadding);
     1095    margin-bottom: 0.5rem;
     1096}
  • havenlytics/trunk/public/assets/js/havenlytics-frontend-scripts.js

    r3334405 r3334735  
    723723
    724724
     725        // Havenlytics Daily Views Chart
     726       document.addEventListener("DOMContentLoaded", function () {
     727            const canvas = document.getElementById("havenlyticsDailyViewsChart");
     728
     729            if (typeof Chart === 'undefined' || !canvas || typeof havenlyticsChartData === 'undefined') {
     730                console.warn("Chart.js, canvas element, or chart data is missing.");
     731                return;
     732            }
     733
     734            const ctx = canvas.getContext("2d");
     735            const rootStyles = getComputedStyle(document.documentElement);
     736
     737            new Chart(ctx, {
     738                type: 'line',
     739                data: {
     740                    labels: havenlyticsChartData.labels,
     741                    datasets: [{
     742                        label: 'Views',
     743                        data: havenlyticsChartData.data,
     744                        backgroundColor: rootStyles.getPropertyValue('--havenlytics-primary').trim() + '1A',
     745                        borderColor: rootStyles.getPropertyValue('--havenlytics-primary').trim(),
     746                        borderWidth: 2,
     747                        fill: true,
     748                        tension: 0.3,
     749                        pointRadius: 4,
     750                        pointHoverRadius: 6,
     751                        pointBackgroundColor: rootStyles.getPropertyValue('--havenlytics-primary').trim(),
     752                        pointHoverBackgroundColor: rootStyles.getPropertyValue('--havenlytics-secondary').trim(),
     753                        pointBorderColor: rootStyles.getPropertyValue('--havenlytics-primary').trim(),
     754                        pointHoverBorderColor: rootStyles.getPropertyValue('--havenlytics-secondary').trim(),
     755                    }]
     756                },
     757                options: {
     758                    responsive: true,
     759                    maintainAspectRatio: false,
     760                    plugins: {
     761                        legend: { display: false },
     762                        tooltip: {
     763                            mode: 'index',
     764                            intersect: false,
     765                            backgroundColor: rootStyles.getPropertyValue('--havenlytics-primary').trim(),
     766                            titleColor: rootStyles.getPropertyValue('--havenlytics-bg-white').trim(),
     767                            bodyColor: rootStyles.getPropertyValue('--havenlytics-bg-white').trim(),
     768                        }
     769                    },
     770                    scales: {
     771                        y: {
     772                            beginAtZero: true,
     773                            ticks: {
     774                                color: rootStyles.getPropertyValue('--havenlytics-text-secondary').trim(),
     775                            },
     776                            grid: {
     777                                color: rootStyles.getPropertyValue('--havenlytics-border').trim(),
     778                            }
     779                        },
     780                        x: {
     781                            ticks: {
     782                                color: rootStyles.getPropertyValue('--havenlytics-text-secondary').trim(),
     783                            },
     784                            grid: {
     785                                color: 'transparent',
     786                            }
     787                        }
     788                    }
     789                }
     790            });
     791        });
     792
     793
     794
     795
     796
     797
     798
     799
     800
     801
    725802})(jQuery);
    726803
  • havenlytics/trunk/public/class-frontend-assets.php

    r3334405 r3334735  
    173173
    174174
     175
    175176                // ✅ Havenlytics Map JS
    176177                wp_enqueue_script(
     
    209210            }
    210211
     212
     213            // ✅ Havenlytics chart JS
     214            wp_enqueue_script(
     215                'havenlytics-chart',
     216                HVNLY_PROPERTY_URL . 'public/assets/plugins/chart/chart.js',
     217                [],
     218                HVNLY_PROPERTY_VERSION,
     219                true
     220            );
     221
     222
    211223            // ✅ Front End JS
    212224            wp_enqueue_script(
    213225                'havenlytics-frontend-scripts',
    214226                HVNLY_PROPERTY_URL . 'public/assets/js/havenlytics-frontend-scripts.js',
    215                 ['jquery'],
    216                 HVNLY_PROPERTY_VERSION,
    217                 true
    218             );
     227                ['jquery', 'havenlytics-owl-carousel', 'havenlytics-leaflet', 'havenlytics-chart'],
     228                HVNLY_PROPERTY_VERSION,
     229                true
     230            );
     231
     232            // ✅ Safely prepare data
     233            $chart_data = Hvnly_Property_Views::get_daily_views_data(get_the_ID());
     234
     235            wp_localize_script('havenlytics-frontend-scripts', 'havenlyticsChartData', [
     236                'labels' => !empty($chart_data['labels']) ? $chart_data['labels'] : [],
     237                'data'   => !empty($chart_data['data']) ? $chart_data['data'] : [],
     238            ]);
    219239        }
    220240    }
  • havenlytics/trunk/readme.txt

    r3334405 r3334735  
    66Tested up to: 6.8
    77Requires PHP: 7.2 
    8 Stable tag: 1.0.8
     8Stable tag: 1.0.9
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5959The following pages will be automatically created upon plugin activation (if not already present):
    6060
    61 - [havenlytics_grid]
    62 - [havenlytics_list]
    63 - [havenlytics_mortgage_calculator]
     61- Grid Property
     62- Grid Property
     63- Mortgage Calculator
    6464
    6565= Grid View =
     
    145145
    146146== Changelog ==
    147 
    148 = 1.0.8 =
     147= 1.0.9 (2025-07-27) =
     148* Added new frontend chart widget to track daily and weekly property views
     149* Added dynamic canvas rendering using Chart.js
     150* Improved i18n with proper use of `esc_html__()` and text domain `havenlytics`
     151* Minor UI style enhancements using CSS variables
     152* Ensured WP coding standards with output escaping for JSON/HTML
     153
     154
     155= 1.0.8 (2025-07-26) =
    149156* Added property view counter to track how many users viewed a property
    150157* Automatically create required pages on plugin activation
     
    152159
    153160
    154 = 1.0.7 =
     161= 1.0.7 (2025-07-23) =
    155162* Fixed responsive UI issues across various sections for better mobile experience.
    156163* Organized modal templates into a separate folder for better code structure and maintainability.
     
    159166
    160167
    161 = 1.0.6 =
     168= 1.0.6 (2025-07-22) =
    162169* Introduced dynamic rendering of featured properties in the single property widget carousel.
    163170* Added option to enable or disable "Featured Property" for individual listings via the property edit screen.
     
    165172
    166173
    167 = 1.0.5 =
     174= 1.0.5 (2025-07-13) =
    168175* Added feedback form link in plugin readme
    169176* Improved documentation structure
  • havenlytics/trunk/templates/hvnly_property-single.php

    r3334405 r3334735  
    232232                        <!-- Property Overview -->
    233233                        <div class="property-details-card">
    234                             <h2 class="section-title">Overview</h2>
    235 
     234
     235                            <h2 class="section-title"><?php esc_html_e('Overview', 'havenlytics'); ?></h2>
    236236                            <div class="row">
    237237                                <div class="col-lg-4 col-md-6">
     
    345345                            <!-- Property Summary -->
    346346                            <div class="property-details-card">
    347                                 <h2 class="section-title">Property Summary</h2>
     347                                <h2 class="section-title"><?php esc_html_e('Property Summary', 'havenlytics'); ?></h2>
     348
    348349                                <p class="property-description">
    349350                                    <?php echo esc_html($short_description); ?>
     
    354355                        <!-- Property Details -->
    355356                        <div class="property-details-card">
    356                             <h2 class="section-title">Property Details</h2>
     357                            <h2 class="section-title"><?php esc_html_e('Property Details', 'havenlytics'); ?></h2>
     358
    357359                            <div class="property-description">
    358360                                <?php the_content(); ?>
     
    475477                        <!-- Popup Gallery  -->
    476478                        <div class="property-details-card">
    477                             <h2 class="section-title">Property Gallery</h2>
     479                            <h2 class="section-title"><?php esc_html_e('Property Gallery', 'havenlytics'); ?></h2>
     480
    478481                            <div class="row">
    479482                                <div class="col-md-12 mb-4">
     
    525528                                                    <a href="#" class="havenlytics_gallery_fancybox_property_button"
    526529                                                        target="_blank">
    527                                                         View Property Details <i class="fas fa-arrow-right"></i>
     530                                                        <?php esc_html_e('View Property Details', 'havenlytics'); ?><i
     531                                                            class="fas fa-arrow-right"></i>
    528532                                                    </a>
    529533                                                </div>
     
    549553                            <!-- Amenities Section -->
    550554                            <div class="property-details-card">
    551                                 <h2 class="section-title">Property Amenities</h2>
     555
     556                                <h2 class="section-title"><?php esc_html_e('Property Amenities', 'havenlytics'); ?></h2>
    552557                                <div class="havenlytics-amenities-grid">
    553558                                    <?php
     
    560565                                                <i class="fas fa-calendar"></i>
    561566                                            </div>
    562                                             <h4>Book Property</h4>
     567                                            <h4><?php esc_html_e('Book Property', 'havenlytics'); ?>
     568                                            </h4>
     569
    563570                                        </div>
    564571                                    <?php endif; ?>
     
    573580                                                <i class="fas fa-calculator"></i>
    574581                                            </div>
    575                                             <h4>Mortgage calculator</h4>
     582                                            <h4>
     583                                                <?php esc_html_e('Mortgage calculator', 'havenlytics'); ?></h4>
     584
    576585                                        </div>
    577586                                    <?php endif; ?>
     
    583592                                                <i class="fas fa-vr-cardboard"></i>
    584593                                            </div>
    585                                             <h4>Virtual Tour</h4>
     594                                            <h4><?php esc_html_e('Virtual Tour', 'havenlytics'); ?></h4>
     595
    586596                                        </div>
    587597                                    <?php endif; ?>
     
    592602                                                <i class="fas fa-vector-square"></i>
    593603                                            </div>
    594                                             <h4>Floorplan</h4>
     604                                            <h4><?php esc_html_e('Floorplan', 'havenlytics'); ?></h4>
     605
    595606                                        </div>
    596607                                    <?php endif; ?>
     
    601612                                                <i class="fas fa-file-alt"></i>
    602613                                            </div>
    603                                             <h4>View Brochure</h4>
     614                                            <h4><?php esc_html_e('View Brochure', 'havenlytics'); ?>
     615                                            </h4>
     616
    604617                                        </div>
    605618                                    <?php endif; ?>
     
    610623                                                <i class="fas fa-clipboard"></i>
    611624                                            </div>
    612                                             <h4>View Epc</h4>
     625                                            <h4><?php esc_html_e('View Epc', 'havenlytics'); ?></h4>
     626
    613627                                        </div>
    614628                                    <?php endif; ?>
     
    619633                                                <i class="fas fa-map-marked-alt"></i>
    620634                                            </div>
    621                                             <h4>Map</h4>
     635                                            <h4><?php esc_html_e('Map', 'havenlytics'); ?></h4>
     636
    622637                                        </div>
    623638                                    <?php endif; ?>
     
    628643                                                <i class="fas fa-phone-alt"></i>
    629644                                            </div>
    630                                             <h4>Request Call Back</h4>
     645                                            <h4><?php esc_html_e('Request Call Back', 'havenlytics'); ?>
     646                                            </h4>
     647
    631648                                        </div>
    632649                                    <?php endif; ?>
     
    637654                                                <i class="fas fa-calendar-check"></i>
    638655                                            </div>
    639                                             <h4>Arrange Viewing</h4>
     656                                            <h4><?php esc_html_e('Arrange Viewing', 'havenlytics'); ?>
     657                                            </h4>
     658
    640659                                        </div>
    641660                                    <?php endif; ?>
     
    653672                                <div class="property-details-card">
    654673
    655                                     <h2 class="section-title">Featured Property</h2>
     674
     675                                    <h2 class="section-title"><?php esc_html_e('Featured Property', 'havenlytics'); ?></h2>
    656676
    657677                                    <div class="havenlytics_featured_items-widget">
     
    877897                                </div>
    878898                            <?php endif; ?>
     899
     900                            <!-- Daily View Property Section -->
     901                            <div class="property-details-card">
     902
     903                                <h2 class="section-title"><?php esc_html_e('Property Views This Week', 'havenlytics'); ?>
     904                                </h2>
     905
     906                                <?php
     907                                // Get chart data
     908                                $chart_data = Hvnly_Property_Views::get_daily_views_data(get_the_ID());
     909
     910                                // Prepare and safely encode chart data
     911                                $labels = !empty($chart_data['labels']) ? wp_json_encode($chart_data['labels']) : '[]';
     912                                $data   = !empty($chart_data['data']) ? wp_json_encode($chart_data['data']) : '[]';
     913                                ?>
     914
     915                                <div class="havenlytics-daily-stats-card">
     916
     917                                    <div class="havenlytics-daily-stats-chart-wrapper" style="width: 100%; height: 280px;">
     918                                        <canvas id="havenlyticsDailyViewsChart" style="width: 100%; height: 100%;"></canvas>
     919                                    </div>
     920                                </div>
     921
     922
     923
     924
     925                            </div>
     926
     927
    879928
    880929                        </div>
     
    11301179                                                                </a>
    11311180                                                            </li>
     1181                                                            <li class="havenlytics-property-views-item">
     1182                                                                <div class="havenlytics-property-views-card">
     1183                                                                    <svg class="havenlytics-property-views-icon" viewBox="0 0 24 24"
     1184                                                                        aria-hidden="true">
     1185                                                                        <path fill="currentColor" fill-rule="evenodd"
     1186                                                                            clip-rule="evenodd"
     1187                                                                            d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm-3-5c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z" />
     1188                                                                    </svg>
     1189                                                                    <div class="havenlytics-property-views-count">
     1190                                                                        <?php echo esc_html(Hvnly_Property_Views::get_formatted_views(get_the_ID())); ?>
     1191
     1192                                                                    </div>
     1193                                                                    <!-- Tooltip element -->
     1194                                                                    <div class="havenlytics-property-views-tooltip">
     1195                                                                        <?php esc_html_e('Property Views', 'havenlytics'); ?>
     1196                                                                    </div>
     1197                                                                </div>
     1198                                                            </li>
    11321199                                                        </ul>
    11331200                                                    </div>
  • havenlytics/trunk/templates/property-card-grid.php

    r3334405 r3334735  
    182182                            </div>
    183183                            <!-- Tooltip element -->
    184                             <div class="havenlytics-property-views-tooltip">Property Views</div>
     184                            <div class="havenlytics-property-views-tooltip">
     185                                <?php esc_html_e('Property Views', 'havenlytics'); ?></div>
    185186                        </div>
    186187                    </li>
  • havenlytics/trunk/templates/property-card-list.php

    r3334405 r3334735  
    171171                        </div>
    172172                        <!-- Tooltip element -->
    173                         <div class="havenlytics-property-views-tooltip">Property Views</div>
     173                        <div class="havenlytics-property-views-tooltip">
     174                            <?php esc_html_e('Property Views', 'havenlytics'); ?></div>
    174175                    </div>
    175176                </li>
  • havenlytics/trunk/templates/property-card.php

    r3334405 r3334735  
    176176                            </div>
    177177                            <!-- Tooltip element -->
    178                             <div class="havenlytics-property-views-tooltip">Property Views</div>
     178                            <div class="havenlytics-property-views-tooltip">
     179                                <?php esc_html_e('Property Views', 'havenlytics'); ?></div>
    179180                        </div>
    180181                    </li>
  • havenlytics/trunk/uninstall.php

    r3334405 r3334735  
    5151delete_option('hvnly_property_grid_page_id');
    5252delete_option('hvnly_property_list_page_id');
     53delete_option('hvnly_mortgage_calculator_page_id');
    5354
    5455// Add any other plugin options or custom tables cleanup below as needed
Note: See TracChangeset for help on using the changeset viewer.