Plugin Directory

Changeset 3049173


Ignore:
Timestamp:
03/11/2024 01:46:41 PM (2 years ago)
Author:
sminozzi
Message:

Version 4.14

Location:
cardealer/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • cardealer/trunk/cardealer.php

    r3041283 r3049173  
    33Plugin URI: http://cardealerplugin.com
    44Description: Car Dealer Plugin for Car Dealer agency.
    5 Version: 4.13
     5Version: 4.14
    66Text Domain: cardealer
    77Domain Path: /language
  • cardealer/trunk/includes/checkup/bill_class_diagnose.php

    r3041276 r3049173  
    4747        $this->plugin_slug = $plugin_slug;
    4848        $this->global_variable_has_errors = $this->bill_check_errors_today();
     49        //die(gettype($this->global_variable_has_errors));
    4950        $this->global_variable_memory = $this->check_memory();
    5051        $this->global_plugin_slug = $plugin_slug;
    5152        add_action("admin_notices", [$this, "show_dismissible_notification"]);
    5253        add_action("admin_notices", [$this, "show_dismissible_notification2"]);
    53         add_action("admin_bar_menu", [$this, "add_site_health_link_to_admin_toolbar"], 999);
    54         add_action("admin_head", [$this,"custom_help_tab"]);
     54        // 2024
     55        if($this->global_variable_has_errors)
     56           add_action("admin_bar_menu", [$this, "add_site_health_link_to_admin_toolbar"], 999);
     57
     58           add_action("admin_head", [$this,"custom_help_tab"]);
    5559        $memory = $this->global_variable_memory;
    5660        if (
     
    8993    {
    9094        try {
    91 
    92 
     95            // PHP $memory["limit"]
    9396            if(!function_exists('ini_get')){
    9497                $wpmemory["msg_type"] = "notok";
    95                 return;
     98                return $wpmemory;
    9699            }
    97100            else{
    98101                $wpmemory["limit"] = (int) ini_get("memory_limit");
    99102            }
    100 
    101             if(!function_exists('memory_get_usage')){
     103            if (!is_numeric($wpmemory["limit"])) {
    102104                $wpmemory["msg_type"] = "notok";
    103                 return;
    104             }
    105             else{
    106                 $wpmemory["usage"] = memory_get_usage();
    107             }
    108 
    109             if ($wpmemory["usage"] == 0) {
    110                 $wpmemory["msg_type"] = "notok";
    111                 return;
    112             }
    113             else{
    114                 $wpmemory["usage"] = round($wpmemory["usage"] / 1024 / 1024, 0);
    115             }
    116 
    117             /*
    118             $wpmemory["usage"] = function_exists("memory_get_usage")
    119                 ? round(memory_get_usage() / 1024 / 1024, 0)
    120                 : 0;
    121             */
    122 
    123 
    124             if (!defined("WP_MEMORY_LIMIT")) {
    125                 $wpmemory["wp_limit"] = 40;
    126                 define('WP_MEMORY_LIMIT', '40M');
    127             } else {
    128                 $wp_memory_limit = WP_MEMORY_LIMIT;
    129                 $wp_memory_limit = rtrim($wp_memory_limit, 'M');
    130                 $wpmemory["wp_limit"] = (int) $wp_memory_limit;
    131             }
    132 
    133 
     105                return $wpmemory;
     106            }
    134107            if ($wpmemory["limit"] > 9999999) {
    135108                // $wpmemory['msg_type'] = 'notok(5)';
     
    137110                    $wpmemory["wp_limit"] / 1024 / 1024;
    138111            }
    139 
     112            // usage
     113            if(!function_exists('memory_get_usage')){
     114                $wpmemory["msg_type"] = "notok";
     115                return $wpmemory;
     116            }
     117            else{
     118                $wpmemory["usage"] = memory_get_usage();
     119            }
    140120            if ($wpmemory["usage"] < 1) {
    141121                $wpmemory["msg_type"] = "notok";
    142                 return;
    143             }
    144 
    145             /*
    146             if (!defined("WP_MEMORY_LIMIT")) {
    147                 $wpmemory["msg_type"] = "notok";
    148                 return;
    149             }
    150 
    151             $wpmemory["wp_limit"] = trim(WP_MEMORY_LIMIT);
    152 
    153             if ($wpmemory["wp_limit"] > 9999999) {
    154                 $wpmemory["wp_limit"] = $wpmemory["wp_limit"] / 1024 / 1024;
    155             }
    156             */
    157 
    158 
    159 
     122                return $wpmemory;
     123            }
     124            else{
     125                $wpmemory["usage"] = round($wpmemory["usage"] / 1024 / 1024, 0);
     126            }
    160127            if (!is_numeric($wpmemory["usage"])) {
    161128                $wpmemory["msg_type"] = "notok";
    162                 return;
    163             }
    164            
    165 
    166 
    167            
    168             if (!is_numeric($wpmemory["limit"])) {
    169                 $wpmemory["msg_type"] = "notok";
    170                 return;
    171             }
    172 
    173             //if ($wpmemory["limit"] > 9999999) {
    174             //    $wpmemory["limit"] = $wpmemory["limit"] / 1024 / 1024;
    175             // }
    176 
    177 
    178 
    179             if ($wpmemory["usage"] < 1) {
    180                 $wpmemory["msg_type"] = "notok";
    181                 return;
    182             }
    183 
    184             //$wplimit = $wpmemory["wp_limit"];
    185             //$wplimit = substr($wplimit, 0, strlen($wplimit) - 1);
    186             //$wpmemory["wp_limit"] = $wplimit;
    187 
    188 
    189 
     129                return $wpmemory;
     130            }
     131            // WP
     132            if (!defined("WP_MEMORY_LIMIT")) {
     133                $wpmemory["wp_limit"] = 40;
     134               //define('WP_MEMORY_LIMIT', '40M');
     135            } else {
     136                $wp_memory_limit = WP_MEMORY_LIMIT;
     137                // $wp_memory_limit = rtrim($wp_memory_limit, 'M');
     138                $wpmemory["wp_limit"] = (int) $wp_memory_limit;
     139            }
    190140            $wpmemory["percent"] = $wpmemory["usage"] / $wpmemory["wp_limit"];
    191141            $wpmemory["color"] = "font-weight:normal;";
     
    198148            $wpmemory["free"] = $wpmemory["wp_limit"] - $wpmemory["usage"];
    199149            $wpmemory["msg_type"] = "ok";
    200 
    201150        } catch (Exception $e) {
    202151            $wpmemory["msg_type"] = "notok";
    203             return;
     152            return $wpmemory;
    204153        }
    205154        return $wpmemory;
    206155    }
     156   
     157
     158
    207159    public function bill_check_errors_today()
    208160    {
  • cardealer/trunk/includes/functions/functions.php

    r3041276 r3049173  
    100100*/
    101101
    102 
    103 function cardealer_check_memory()
     102function cardealer_check_memory() {
     103    // global $memory;
     104    $memory["color"] = "font-weight:normal;";
     105    try {
     106
     107        // PHP $memory["limit"]
     108        if(!function_exists('ini_get')){
     109            $memory["msg_type"] = "notok";
     110            return $memory;
     111        }
     112        else{
     113            $memory["limit"] = (int) ini_get("memory_limit");
     114        }
     115
     116        if (!is_numeric($memory["limit"])) {
     117            $memory["msg_type"] = "notok";
     118            return $memory;
     119        } else {
     120            if ($memory["limit"] > 9999999) {
     121                $memory["limit"] =
     122                    $memory["limit"] / 1024 / 1024;
     123            }
     124        }
     125
     126
     127        // usage
     128        if(!function_exists('memory_get_usage')){
     129            $memory["msg_type"] = "notok";
     130            return $memory;
     131        }
     132        else{
     133            // $bill_install_memory["usage"] = round(memory_get_usage() / 1024 / 1024, 0);
     134            $memory["usage"] = (int) memory_get_usage();
     135        }
     136
     137
     138        if ($memory["usage"] < 1) {
     139            $memory["msg_type"] = "notok";
     140            return $memory;
     141        }
     142        else{
     143            $memory["usage"] = round($memory["usage"] / 1024 / 1024, 0);
     144
     145        }
     146
     147        if (!is_numeric($memory["usage"])) {
     148            $memory["msg_type"] = "notok";
     149            return $memory;
     150        }
     151
     152
     153        // WP
     154        if (!defined("WP_MEMORY_LIMIT")) {
     155            $memory['wp_limit'] = 40;
     156        } else {
     157            $memory['wp_limit'] = (int) WP_MEMORY_LIMIT;
     158
     159        }       
     160
     161        $memory["percent"] =
     162            $memory["usage"] / $memory["wp_limit"];
     163        $memory["color"] = "font-weight:normal;";
     164        if ($memory["percent"] > 0.7) {
     165            $memory["color"] = "font-weight:bold;color:#E66F00";
     166        }
     167        if ($memory["percent"] > 0.85) {
     168            $memory["color"] = "font-weight:bold;color:red";
     169        }
     170        $memory["msg_type"] = "ok";
     171        return $memory;
     172    } catch (Exception $e) {
     173        $memory["msg_type"] = "notok(7)";
     174        return $memory;
     175    }
     176}
     177
     178
     179function cardealer_check_memory_old()
    104180{
    105181    global $cardealer_memory;
     
    164240        if (!defined("WP_MEMORY_LIMIT")) {
    165241            $cardealer_memory['wp_limit'] = 40;
     242            define('WP_MEMORY_LIMIT', '40M');
    166243        } else {
    167    
    168             $cardealer_memory['wp_limit'] = (int) rtrim(WP_MEMORY_LIMIT, 'M');
     244            $cardealer_memory["wp_limit"] = (int) WP_MEMORY_LIMIT;
     245        }
     246
     247        if (!defined("WP_MEMORY_LIMIT")) {
     248            $memory["wp_limit"] = 40;
     249            define('WP_MEMORY_LIMIT', '40M');
     250        } else {
     251            $wp_memory_limit = WP_MEMORY_LIMIT;
     252            $wp_memory_limit = rtrim($wp_memory_limit, 'M');
     253            $memory["wp_limit"] = (int) $wp_memory_limit;
    169254        }
    170255
  • cardealer/trunk/includes/functions/health.php

    r2818519 r3049173  
    1414    global $cardealer_memory_result;
    1515
    16     $memory['usage'] = function_exists('memory_get_usage') ? round(memory_get_usage() / 1024 / 1024, 0) : 0;
    17     if (!is_numeric($memory['usage'])) {
    18         $sbb_memory = 'Unable to Check!';
     16    $memory = cardealer_check_memory();
     17
     18    if (isset($memory["msg_type"]) && $memory["msg_type"] == "notok"){
     19        $memory = 'Unable to Check!';
    1920        return;
     21     }
     22
     23    if (preg_match('/(\d+)\s*([A-Za-z]+)$/', WP_MEMORY_LIMIT, $matches)) {
     24        $mb = $matches[2];
     25    } else {
     26        $mb = 'M';
    2027    }
    21     if ($memory['usage'] < 1) {
    22         return;
    23     }
    24     $mb = 'MB';
    25     if (defined("WP_MEMORY_LIMIT")) {
    26         $memory['wp_limit'] = trim(WP_MEMORY_LIMIT);
    27         $wplimit = $memory['wp_limit'];
    28         $wplimit = substr($wplimit, 0, strlen($wplimit) - 1);
    29         $memory['wp_limit'] = $wplimit;
    30     } else {
    31         $memory['wp_limit'] = 'Not defined!';
    32         $mb = '';
    33     }
     28
    3429    ob_start();
    3530    echo 'Current memory WordPress Limit: ' . esc_attr($memory['wp_limit']) . esc_attr($mb) .
     
    4742    {
    4843        $tests['direct']['memory_plugin'] = array(
    49             'label' => __('My Memory Test', 'antihacker'),
     44            'label' => esc_attr__('My Memory Test', 'cardealer'),
    5045            'test' => 'cardealer_memory_test',
    5146        );
     
    5651        add_filter('site_status_tests', 'cardealer_add_memory_test');
    5752    }
    58    
    5953    function cardealer_memory_test()
    6054    {
     
    6256        $result = array(
    6357            'badge' => array(
    64                 'label' => __('Critical', 'antihacker'), // Performance
     58                'label' => __('Critical', 'cardealer'), // Performance
    6559                'color' => 'red', // orange',
    6660            ),
    6761            'test' => 'Bill_plugin',
    6862            'status' => 'critical',
    69             'label' => __('Low WordPress Memory Limit in wp-config file', 'antihacker'),
     63            'label' => __('Low WordPress Memory Limit in wp-config file', 'cardealer'),
    7064            'description' => $cardealer_memory_result . '  ' . sprintf(
    7165                '<p>%s</p>',
  • cardealer/trunk/includes/help/help.php

    r2818186 r3049173  
    5959    $myhelpdemo .= esc_attr__("If you want to import demo data, download the demo data from this link:","cardealer");
    6060    $myhelpdemo .= '<br />';
    61     $myhelpdemo .= 'http://cardealerplugin.com/demo-data/download-demo.php';
     61    $myhelpdemo .= 'https://cardealerplugin.com/demo-data/download-demo.php';
    6262    $myhelpdemo .= '<br /><br />';
    6363    $myhelpdemo .= esc_attr__("After download:","cardealer");
  • cardealer/trunk/includes/templates/template-single.php

    r2924372 r3049173  
    44 * @copyright 2017
    55 */
    6 ?>
    7 <script type="text/javascript">
    8 function goBack() {
    9    window.history.back();
     6if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
     7
     8function cardealer_add_custom_js_to_header() {
     9    ?>
     10    <script type="text/javascript">
     11        function goBack() {
     12            window.history.back();
     13        }
     14    </script>
     15    <?php
    1016}
    11 </script>
    12 <?php
    13 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
     17add_action('wp_head', 'cardealer_add_custom_js_to_header');
     18
     19
    1420$my_theme =  strtolower(wp_get_theme());
    1521if ($my_theme == 'twenty fourteen')
  • cardealer/trunk/readme.txt

    r3041283 r3049173  
    44Tags: car Dealer,  car Seller, auto seller, auto dealer, car-dealer
    55Requires at least: 6.0
    6 Tested up to: 6.4
     6Tested up to: 6.5
    77Stable tag: 4.13
    88License: GPLv2 or later
     
    151151
    152152== Changelog ==
     1534.14 2024-03-11   Improvements (memory control) , site errors and Single Car Page.
    1531544.12/13 2024-02-26   Small Improvements (memory control).
    1541554.11 2024-01-09   Added Pesos Chilenos Coin.
Note: See TracChangeset for help on using the changeset viewer.