Plugin Directory

Changeset 3289489


Ignore:
Timestamp:
05/08/2025 02:21:02 AM (11 months ago)
Author:
dashcommerce
Message:

1.3.5

Location:
dashcommerce/trunk
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • dashcommerce/trunk/dashcommerce.php

    r3286617 r3289489  
    1212 * Plugin Name: DashCommerce - Support, Checkup, Optimization, AI, Reports & Analytics
    1313 * Description: Keep your website healthy and efficient with DashCommerce.
    14  * Version: 1.3.4
     14 * Version: 1.3.5
    1515 * Author: DashCommerce
    1616 * License: GPL v2
     
    7474 */
    7575function dashcommerce_load_text_domain() {
    76     load_plugin_textdomain( 'dashcommerce', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
     76    $supported_languages = array();
     77
     78    $language_dir = plugin_dir_path( __FILE__ ) . 'languages/';
     79
     80    if ( is_dir( $language_dir ) ) {
     81        $files = scandir( $language_dir );
     82
     83        foreach ( $files as $file ) {
     84            $is_mo_language_file = preg_match( '/^dashcommerce-([a-z]{2}_[A-Z]{2})\.po$/', $file, $matches );
     85
     86            $locale = $matches[1];
     87
     88            $language_code = explode( '_', $locale )[0];
     89
     90            if ( $is_mo_language_file ) {
     91                    $supported_languages[ $language_code ] = 'languages/dashcommerce-' . $locale . '.mo';
     92            }
     93        }
     94    }
     95
     96    $current_language = explode( '_', get_locale() )[0]; // Extract base language (e.g., 'en', 'pt').
     97
     98    $target_language = 'en';
     99
     100    if ( array_key_exists( $current_language, $supported_languages ) ) {
     101        $target_language = $current_language;
     102    }
     103
     104    $target_file = plugin_dir_path( __FILE__ ) . $supported_languages[ $target_language ];
     105
     106    load_textdomain( 'dashcommerce', $target_file );
    77107}
    78108
  • dashcommerce/trunk/features/diagnostics/class-diagnostics.php

    r3286617 r3289489  
    210210        </div>
    211211
    212         <!-- this modal will be used for brazilian users only -->
    213212        <div id="dashcommerce-diagnostics-phone-modal" class="dashcommerce-modal">
    214213            <div class="dashcommerce-modal-content" style="position: relative;">
     
    262261                                <div style="height: 140px; display: flex; flex-grow: 1; flex-basis: 0; padding: 20px;">
    263262                                    <?php
    264                                     $diagnosis_list = $this->db->get_diagnosis_list( 1 );
    265 
    266                                     if ( isset( $diagnosis_list ) && isset( $diagnosis_list[0] ) ) {
    267                                         $last_diagnosis = $diagnosis_list[0];
    268 
     263                                    $last_diagnosis = $this->db->get_latest_diagnosis();
     264
     265                                    if ( isset( $last_diagnosis ) ) {
    269266                                        $score = $last_diagnosis['score'];
    270267
     
    303300
    304301                                <div style="display: flex; flex-direction: column; justify-content: center; align-items: center; flex: 0 0 auto; padding-top: 20px;">
    305                                     <div>
    306                                         <?php esc_html_e( 'DIAGNOSE_NOW_DESC', 'dashcommerce' ); ?>
    307                                     </div>
    308 
    309                                     <button class="button dashcommerce-button" id="dashcommerce-diagnostics-request-diagnosis" style="margin: 10px 0;">
    310                                         <?php esc_html_e( 'DIAGNOSE_NOW', 'dashcommerce' ); ?>
    311                                     </button>
     302                                    <?php
     303                                    if ( $this->check_diag_older_12h( $last_diagnosis ) ) {
     304                                        ?>
     305                                        <div>
     306                                            <?php esc_html_e( 'DIAGNOSE_NOW_DESC', 'dashcommerce' ); ?>
     307                                        </div>
     308
     309                                        <button class="button dashcommerce-button" id="dashcommerce-diagnostics-request-diagnosis" style="margin: 10px 0;">
     310                                            <?php esc_html_e( 'DIAGNOSE_NOW', 'dashcommerce' ); ?>
     311                                        </button>
     312                                        <?php
     313                                    } else {
     314                                        ?>
     315                                        <div>
     316                                            <?php esc_html_e( 'DIAGNOSE_NOW_DESC_CANNOT', 'dashcommerce' ); ?>
     317                                        </div>
     318
     319                                        <button class="button dashcommerce-button" id="dashcommerce-diagnostics-request-diagnosis" style="margin: 10px 0;" disabled title="<?php esc_html_e( 'DIAGNOSE_NOW_DESC_CANNOT_TOOLTIP', 'dashcommerce' ); ?>">
     320                                            <?php esc_html_e( 'DIAGNOSE_NOW', 'dashcommerce' ); ?>
     321                                        </button>
     322                                        <?php
     323                                    }
     324                                    ?>
    312325
    313326                                    <div>
     
    600613
    601614    /**
    602      * Returns an assoc with the score history.
     615     * Returns an assoc with the score history for the chart.
    603616     */
    604617    public function get_score_history() {
     
    915928        wp_die();
    916929    }
     930
     931    /**
     932     * Checks if a diagnosis is older than 12 hours.
     933     *
     934     * @param array $diagnosis The diagnosis assoc.
     935     *
     936     * @return bool
     937     */
     938    private function check_diag_older_12h( $diagnosis ) {
     939        if ( ! isset( $diagnosis ) || ! isset( $diagnosis['id'] ) ) {
     940            return true;
     941        }
     942
     943        $now_gmt = time();
     944
     945        $diag_time_gmt = (int) $diagnosis['id'];
     946
     947        $twelve_hours_ago_gmt = $now_gmt - ( 12 * 60 * 60 );
     948
     949        return $diag_time_gmt < $twelve_hours_ago_gmt;
     950    }
    917951}
    918952
  • dashcommerce/trunk/languages/dashcommerce-da_DK.po

    r3275268 r3289489  
    720720msgid "RECEIVE_VIA_WHATSAPP"
    721721msgstr "📞 Modtag via WhatsApp"
     722
     723msgid "DIAGNOSE_NOW_DESC_CANNOT"
     724msgstr "Du har allerede diagnosticeret din hjemmeside i de sidste 12 timer. Kom tilbage senere for at udføre en anden Health Check."
     725
     726msgid "DIAGNOSE_NOW_DESC_CANNOT_TOOLTIP"
     727msgstr "Du kan udføre en Health Check hver 12. time."
  • dashcommerce/trunk/languages/dashcommerce-de_DE.po

    r3275268 r3289489  
    720720msgid "RECEIVE_VIA_WHATSAPP"
    721721msgstr "📞 Über WhatsApp erhalten"
     722
     723msgid "DIAGNOSE_NOW_DESC_CANNOT"
     724msgstr "Sie haben Ihre Website in den letzten 12 Stunden bereits diagnostiziert. Kommen Sie später zurück, um einen weiteren Health Check durchzuführen."
     725
     726msgid "DIAGNOSE_NOW_DESC_CANNOT_TOOLTIP"
     727msgstr "Sie können alle 12 Stunden einen Health Check durchführen."
  • dashcommerce/trunk/languages/dashcommerce-en_US.po

    r3275268 r3289489  
    720720msgid "RECEIVE_VIA_WHATSAPP"
    721721msgstr "📞 Receive via WhatsApp"
     722
     723msgid "DIAGNOSE_NOW_DESC_CANNOT"
     724msgstr "You have already diagnosed your site in the last 12 hours. Please come back later to perform another Health Check."
     725
     726msgid "DIAGNOSE_NOW_DESC_CANNOT_TOOLTIP"
     727msgstr "You can perform a Health Check every 12 hours."
  • dashcommerce/trunk/languages/dashcommerce-es_ES.po

    r3275268 r3289489  
    720720msgid "RECEIVE_VIA_WHATSAPP"
    721721msgstr "📞 Recibir por WhatsApp"
     722
     723msgid "DIAGNOSE_NOW_DESC_CANNOT"
     724msgstr "Ya has diagnosticado tu sitio en las últimas 12 horas. Vuelve más tarde para realizar otro chequeo de salud."
     725
     726msgid "DIAGNOSE_NOW_DESC_CANNOT_TOOLTIP"
     727msgstr "Puedes realizar un chequeo de salud cada 12 horas."
  • dashcommerce/trunk/languages/dashcommerce-it_IT.po

    r3275268 r3289489  
    720720msgid "RECEIVE_VIA_WHATSAPP"
    721721msgstr "📞 Ricevi su WhatsApp"
     722
     723msgid "DIAGNOSE_NOW_DESC_CANNOT"
     724msgstr "Hai già diagnosticato il tuo sito nelle ultime 12 ore. Torna più tardi per eseguire un altro controllo sanitario."
     725
     726msgid "DIAGNOSE_NOW_DESC_CANNOT_TOOLTIP"
     727msgstr "Puoi eseguire un controllo sanitario ogni 12 ore."
  • dashcommerce/trunk/languages/dashcommerce-pt_BR.po

    r3275268 r3289489  
    720720msgid "RECEIVE_VIA_WHATSAPP"
    721721msgstr "📞 Receber no WhatsApp"
     722
     723msgid "DIAGNOSE_NOW_DESC_CANNOT"
     724msgstr "Você já diagnosticou seu site nas últimas 12 horas. Volte mais tarde para realizar outro Health Check."
     725
     726msgid "DIAGNOSE_NOW_DESC_CANNOT_TOOLTIP"
     727msgstr "Você pode realizar um Health Check a cada 12 horas."
  • dashcommerce/trunk/languages/dashcommerce.pot

    r3275268 r3289489  
    719719msgid "RECEIVE_VIA_WHATSAPP"
    720720msgstr ""
     721
     722msgid "DIAGNOSE_NOW_DESC_CANNOT"
     723msgstr ""
     724
     725msgid "DIAGNOSE_NOW_DESC_CANNOT_TOOLTIP"
     726msgstr ""
  • dashcommerce/trunk/options/class-account.php

    r3275268 r3289489  
    148148        global $dashcommerce_table_diagnostics;
    149149
    150         $diagnosis_list = $dashcommerce_table_diagnostics->get_diagnosis_list( 1 );
    151 
    152         if ( isset( $diagnosis_list ) && isset( $diagnosis_list[0] ) ) {
    153             $last_diagnosis = $diagnosis_list[0];
    154 
     150        $last_diagnosis = $dashcommerce_table_diagnostics->get_latest_diagnosis();
     151
     152        if ( isset( $last_diagnosis ) ) {
    155153            $last_diag_score = $last_diagnosis['score'];
    156154            $last_diag_data  = $last_diagnosis['content'];
     
    184182        );
    185183
    186         $a = $this->backend->register_activation( $data );
    187 
    188         null;
     184        $this->backend->register_activation( $data );
    189185    }
    190186
  • dashcommerce/trunk/readme.txt

    r3286617 r3289489  
    44Requires at least: WordPress 5.0
    55Tested up to: 6.8
    6 Stable tag: 1.3.4
     6Stable tag: 1.3.5
    77Requires PHP: 7.0.0
    88License: GPL v2
  • dashcommerce/trunk/tables/class-table-diagnostics.php

    r3275268 r3289489  
    124124            $row['content'] = json_decode( $row['content'], true );
    125125
    126             $latest = $this->get_diagnosis_list( 1 )[0];
     126            $latest = $this->get_latest_diagnosis();
    127127
    128128            if ( $latest['id'] === $row['id'] ) {
     
    175175        return 0 === $results || '0' === $results;
    176176    }
     177
     178    /**
     179     * Gets the latest diagnosis.
     180     *
     181     * @return array|null An associative array with the list of diagnosis, each having the fields `id` and `score`
     182     */
     183    public function get_latest_diagnosis() {
     184        $list = $this->get_diagnosis_list( 1 );
     185
     186        if ( ! isset( $list ) || ! isset( $list[0] ) ) {
     187            return null;
     188        }
     189
     190        return $list[0];
     191    }
    177192}
    178193
Note: See TracChangeset for help on using the changeset viewer.