Plugin Directory

Changeset 3273137


Ignore:
Timestamp:
04/15/2025 08:23:43 AM (11 months ago)
Author:
codeisartnet
Message:

update

Location:
codeart-units-converter/trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • codeart-units-converter/trunk/codeart-units-converter.php

    r3273046 r3273137  
    1010 * Text Domain: codeart-units-converter
    1111 * Domain Path: /i18n/languages/
    12  * Version: 2.1.0
     12 * Version: 2.3.0
    1313 * Tested up to: 6.7.2
    1414 */
     
    1919}
    2020
    21 $codeart_units_converter_version = '2.1.0';
     21$codeart_units_converter_version = '2.3.0';
    2222
    2323/**
  • codeart-units-converter/trunk/include/updates/list-updates.php

    r3271810 r3273137  
    66    return $updates = [
    77        '2.0.0' => 'update-2.0.0.php',
    8         // '2.1.0' => 'update-2.1.0.php',
     8        '2.2.0' => 'update-2.2.0.php',
     9        '2.3.0' => 'update-2.3.0.php',
    910
    1011    ];
  • codeart-units-converter/trunk/include/updates/update-2.0.0.php

    r3271810 r3273137  
    11<?php
    2 
     2/////////////////////////////////////////////////////////////////////////////////////////////////
     3// create table codeart_units_converter_units
    34function codeart_units_converter_update_2_0_0()
    45{
     
    67    global $wpdb;
    78
    8     /////////////////////////////////////////////////////////////////////////////////////////////////
    9     // create table codeart_units_converter_units
    109    $query = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}codeart_units_converter_units(
    1110    id bigint(20) NOT NULL AUTO_INCREMENT,
     
    2221    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
    2322    dbDelta($query);
    24     /////////////////////////////////////////////////////////////////////////////////////////////////
     23}
     24/////////////////////////////////////////////////////////////////////////////////////////////////
    2525
    26     /////////////////////////////////////////////////////////////////////////////////////////////////
     26/////////////////////////////////////////////////////////////////////////////////////////////////
     27function codeart_units_converter_insert_area_units_into_db()
     28{
     29    global $wpdb;
    2730
    28     function codeart_units_converter_insert_area_units_into_db() {
    29         global $wpdb;
    30    
    31         $table_name = $wpdb->prefix . 'codeart_units_converter_units';
    32    
    33         $area_units = [
    34             'nm2'       => ['name' => 'Square Nanometer',    'abbreviation' => 'nm²'],
    35             'µm2'       => ['name' => 'Square Micrometer',   'abbreviation' => 'µm²'],
    36             'mm2'       => ['name' => 'Square Millimeter',   'abbreviation' => 'mm²'],
    37             'cm2'       => ['name' => 'Square Centimeter',   'abbreviation' => 'cm²'],
    38             'dm2'       => ['name' => 'Square Decimeter',    'abbreviation' => 'dm²'],
    39             'm2'        => ['name' => 'Square Meter',        'abbreviation' => 'm²'],
    40             'a'         => ['name' => 'Are',                 'abbreviation' => 'a'],
    41             'ha'        => ['name' => 'Hectare',             'abbreviation' => 'ha'],
    42             'km2'       => ['name' => 'Square Kilometer',    'abbreviation' => 'km²'],
    43             'in2'       => ['name' => 'Square Inch',         'abbreviation' => 'in²'],
    44             'ft2'       => ['name' => 'Square Foot',         'abbreviation' => 'ft²'],
    45             'yd2'       => ['name' => 'Square Yard',         'abbreviation' => 'yd²'],
    46             'ac'        => ['name' => 'Acre',                'abbreviation' => 'ac'],
    47             'mi2'       => ['name' => 'Square Mile',         'abbreviation' => 'mi²'],
    48             'rod2'      => ['name' => 'Square Rod',          'abbreviation' => 'rod²'],
    49             'rood'      => ['name' => 'Rood',                'abbreviation' => 'rood'],
    50             'homestead' => ['name' => 'Homestead',           'abbreviation' => 'homestead'],
    51             'township'  => ['name' => 'Township',            'abbreviation' => 'township'],
    52         ];
    53    
    54         foreach ($area_units as $unit_code => $data) {
    55             $code_name = strtolower(str_replace(' ', '_', preg_replace('/[^a-zA-Z0-9 ]/', '', $data['name'])));
    56    
    57             $exists = $wpdb->get_var(
    58                 $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE code_name = %s", $code_name)
     31    $table_name = $wpdb->prefix . 'codeart_units_converter_units';
     32
     33    $area_units = [
     34        'nm2'       => ['name' => 'Square Nanometer', 'abbreviation' => 'nm²'],
     35        'µm2'       => ['name' => 'Square Micrometer', 'abbreviation' => 'µm²'],
     36        'mm2'       => ['name' => 'Square Millimeter', 'abbreviation' => 'mm²'],
     37        'cm2'       => ['name' => 'Square Centimeter', 'abbreviation' => 'cm²'],
     38        'dm2'       => ['name' => 'Square Decimeter', 'abbreviation' => 'dm²'],
     39        'm2'        => ['name' => 'Square Meter', 'abbreviation' => 'm²'],
     40        'a'         => ['name' => 'Are', 'abbreviation' => 'a'],
     41        'ha'        => ['name' => 'Hectare', 'abbreviation' => 'ha'],
     42        'km2'       => ['name' => 'Square Kilometer', 'abbreviation' => 'km²'],
     43        'in2'       => ['name' => 'Square Inch', 'abbreviation' => 'in²'],
     44        'ft2'       => ['name' => 'Square Foot', 'abbreviation' => 'ft²'],
     45        'yd2'       => ['name' => 'Square Yard', 'abbreviation' => 'yd²'],
     46        'ac'        => ['name' => 'Acre', 'abbreviation' => 'ac'],
     47        'mi2'       => ['name' => 'Square Mile', 'abbreviation' => 'mi²'],
     48        'rod2'      => ['name' => 'Square Rod', 'abbreviation' => 'rod²'],
     49        'rood'      => ['name' => 'Rood', 'abbreviation' => 'rood'],
     50        'homestead' => ['name' => 'Homestead', 'abbreviation' => 'homestead'],
     51        'township'  => ['name' => 'Township', 'abbreviation' => 'township'],
     52    ];
     53
     54    foreach ($area_units as $unit_code => $data) {
     55        $code_name = strtolower(str_replace(' ', '_', preg_replace('/[^a-zA-Z0-9 ]/', '', $data['name'])));
     56
     57        $exists = $wpdb->get_var(
     58            $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE code_name = %s", $code_name)
     59        );
     60
     61        if (! $exists) {
     62            $wpdb->insert(
     63                $table_name,
     64                [
     65                    'unit'         => $unit_code,
     66                    'name'         => $data['name'],
     67                    'code_name'    => $code_name,
     68                    'abbreviation' => $data['abbreviation'],
     69                    'type'         => 'area',
     70                ],
     71                ['%s', '%s', '%s', '%s', '%s']
    5972            );
    60    
    61             if (!$exists) {
    62                 $wpdb->insert(
    63                     $table_name,
    64                     [
    65                         'unit'         => $unit_code,
    66                         'name'         => $data['name'],
    67                         'code_name'    => $code_name,
    68                         'abbreviation' => $data['abbreviation'],
    69                         'type'         => 'area',
    70                     ],
    71                     ['%s', '%s', '%s', '%s', '%s']
    72                 );
    73             }
    7473        }
    7574    }
    76    
    77     /////////////////////////////////////////////////////////////////////////////////////////////////
     75}
    7876
    79     /////////////////////////////////////////////////////////////////////////////////////////////////
    80     function codeart_units_converter_insert_weight_units_into_db() {
    81         global $wpdb;
    82    
    83         $table_name = $wpdb->prefix . 'codeart_units_converter_units';
    84    
    85         $weight_units = [
    86             'cg'    => ['name' => 'Centigram',        'abbreviation' => 'cg'],
    87             'ct'    => ['name' => 'Carat',            'abbreviation' => 'ct'],
    88             'dr'    => ['name' => 'Dram',             'abbreviation' => 'dr'],
    89             'g'     => ['name' => 'Gram',             'abbreviation' => 'g'],
    90             'gr'    => ['name' => 'Grain',            'abbreviation' => 'gr'],
    91             'gr t'  => ['name' => 'Troy Grain',       'abbreviation' => 'gr t'],
    92             'hg'    => ['name' => 'Hectogram',        'abbreviation' => 'hg'],
    93             'kg'    => ['name' => 'Kilogram',         'abbreviation' => 'kg'],
    94             'kN'    => ['name' => 'Kilonewton (mass)','abbreviation' => 'kN'],
    95             'lb'    => ['name' => 'Pound',            'abbreviation' => 'lb'],
    96             'lb t'  => ['name' => 'Troy Pound',       'abbreviation' => 'lb t'],
    97             'lo tn' => ['name' => 'Long Ton',         'abbreviation' => 'lo tn'],
    98             'mg'    => ['name' => 'Milligram',        'abbreviation' => 'mg'],
    99             'ng'    => ['name' => 'Nanogram',         'abbreviation' => 'ng'],
    100             'oz'    => ['name' => 'Ounce',            'abbreviation' => 'oz'],
    101             'oz t'  => ['name' => 'Troy Ounce',       'abbreviation' => 'oz t'],
    102             'sh tn' => ['name' => 'Short Ton',        'abbreviation' => 'sh tn'],
    103             'st'    => ['name' => 'Stone',            'abbreviation' => 'st'],
    104             't'     => ['name' => 'Ton',              'abbreviation' => 't'],
    105             'tr ct' => ['name' => 'Troy Carat',       'abbreviation' => 'tr ct'],
    106             'μg'    => ['name' => 'Microgram',        'abbreviation' => 'μg'],
    107         ];
    108    
    109         foreach ($weight_units as $unit_code => $data) {
    110             $code_name = strtolower(str_replace(' ', '_', preg_replace('/[^a-zA-Z0-9 ]/', '', $data['name'])));
    111    
    112             $exists = $wpdb->get_var(
    113                 $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE code_name = %s", $code_name)
     77/////////////////////////////////////////////////////////////////////////////////////////////////
     78
     79/////////////////////////////////////////////////////////////////////////////////////////////////
     80function codeart_units_converter_insert_weight_units_into_db()
     81{
     82    global $wpdb;
     83
     84    $table_name = $wpdb->prefix . 'codeart_units_converter_units';
     85
     86    $weight_units = [
     87        'cg'    => ['name' => 'Centigram', 'abbreviation' => 'cg'],
     88        'ct'    => ['name' => 'Carat', 'abbreviation' => 'ct'],
     89        'dr'    => ['name' => 'Dram', 'abbreviation' => 'dr'],
     90        'g'     => ['name' => 'Gram', 'abbreviation' => 'g'],
     91        'gr'    => ['name' => 'Grain', 'abbreviation' => 'gr'],
     92        'gr t'  => ['name' => 'Troy Grain', 'abbreviation' => 'gr t'],
     93        'hg'    => ['name' => 'Hectogram', 'abbreviation' => 'hg'],
     94        'kg'    => ['name' => 'Kilogram', 'abbreviation' => 'kg'],
     95        'kN'    => ['name' => 'Kilonewton (mass)', 'abbreviation' => 'kN'],
     96        'lb'    => ['name' => 'Pound', 'abbreviation' => 'lb'],
     97        'lb t'  => ['name' => 'Troy Pound', 'abbreviation' => 'lb t'],
     98        'lo tn' => ['name' => 'Long Ton', 'abbreviation' => 'lo tn'],
     99        'mg'    => ['name' => 'Milligram', 'abbreviation' => 'mg'],
     100        'ng'    => ['name' => 'Nanogram', 'abbreviation' => 'ng'],
     101        'oz'    => ['name' => 'Ounce', 'abbreviation' => 'oz'],
     102        'oz t'  => ['name' => 'Troy Ounce', 'abbreviation' => 'oz t'],
     103        'sh tn' => ['name' => 'Short Ton', 'abbreviation' => 'sh tn'],
     104        'st'    => ['name' => 'Stone', 'abbreviation' => 'st'],
     105        't'     => ['name' => 'Ton', 'abbreviation' => 't'],
     106        'tr ct' => ['name' => 'Troy Carat', 'abbreviation' => 'tr ct'],
     107        'μg'    => ['name' => 'Microgram', 'abbreviation' => 'μg'],
     108    ];
     109
     110    foreach ($weight_units as $unit_code => $data) {
     111        $code_name = strtolower(str_replace(' ', '_', preg_replace('/[^a-zA-Z0-9 ]/', '', $data['name'])));
     112
     113        $exists = $wpdb->get_var(
     114            $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE code_name = %s", $code_name)
     115        );
     116
     117        if (! $exists) {
     118            $wpdb->insert(
     119                $table_name,
     120                [
     121                    'unit'         => $unit_code,
     122                    'name'         => $data['name'],
     123                    'code_name'    => $code_name,
     124                    'abbreviation' => $data['abbreviation'],
     125                    'type'         => 'weight',
     126                ],
     127                ['%s', '%s', '%s', '%s', '%s']
    114128            );
    115    
    116             if (!$exists) {
    117                 $wpdb->insert(
    118                     $table_name,
    119                     [
    120                         'unit'         => $unit_code,
    121                         'name'         => $data['name'],
    122                         'code_name'    => $code_name,
    123                         'abbreviation' => $data['abbreviation'],
    124                         'type'         => 'weight',
    125                     ],
    126                     ['%s', '%s', '%s', '%s', '%s']
    127                 );
    128             }
    129129        }
    130130    }
    131    
    132     /////////////////////////////////////////////////////////////////////////////////////////////////
     131}
    133132
     133/////////////////////////////////////////////////////////////////////////////////////////////////
    134134
    135     /////////////////////////////////////////////////////////////////////////////////////////////////
    136     function codeart_units_converter_insert_speed_units_into_db() {
    137         global $wpdb;
    138    
    139         $table_name = $wpdb->prefix . 'codeart_units_converter_units';
    140    
    141         $speed_units = [
    142             'cm_per_s'    => ['name' => 'Centimeter per second',    'abbreviation' => 'cm/s'],
    143             'm_per_s'     => ['name' => 'Meter per second',         'abbreviation' => 'm/s'],
    144             'km_per_s'    => ['name' => 'Kilometer per second',     'abbreviation' => 'km/s'],
    145             'km_per_h'    => ['name' => 'Kilometer per hour',       'abbreviation' => 'km/h'],
    146             'm_per_h'     => ['name' => 'Meter per hour',           'abbreviation' => 'm/h'],
    147             'cm_per_h'    => ['name' => 'Centimeter per hour',      'abbreviation' => 'cm/h'],
    148             'mm_per_s'    => ['name' => 'Millimeter per second',    'abbreviation' => 'mm/s'],
    149             'ft_per_s'    => ['name' => 'Foot per second',          'abbreviation' => 'ft/s'],
    150             'yd_per_s'    => ['name' => 'Yard per second',          'abbreviation' => 'yd/s'],
    151             'mi_per_h'    => ['name' => 'Mile per hour',            'abbreviation' => 'mi/h'],
    152             'mi_per_s'    => ['name' => 'Mile per second',          'abbreviation' => 'mi/s'],
    153             'knot'        => ['name' => 'Knot',                     'abbreviation' => 'kn'],
    154             'speed_of_light' => ['name' => 'Speed of light',        'abbreviation' => 'c'],
    155             'speed_of_sound' => ['name' => 'Speed of sound',        'abbreviation' => 'v_sound'],
    156         ];
    157    
    158         foreach ($speed_units as $unit_code => $data) {
    159             $code_name = strtolower(str_replace(' ', '_', preg_replace('/[^a-zA-Z0-9 ]/', '', $data['name'])));
    160    
    161             $exists = $wpdb->get_var(
    162                 $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE code_name = %s", $code_name)
     135/////////////////////////////////////////////////////////////////////////////////////////////////
     136function codeart_units_converter_insert_speed_units_into_db()
     137{
     138    global $wpdb;
     139
     140    $table_name = $wpdb->prefix . 'codeart_units_converter_units';
     141
     142    $speed_units = [
     143        'cm_per_s'       => ['name' => 'Centimeter per second', 'abbreviation' => 'cm/s'],
     144        'm_per_s'        => ['name' => 'Meter per second', 'abbreviation' => 'm/s'],
     145        'km_per_s'       => ['name' => 'Kilometer per second', 'abbreviation' => 'km/s'],
     146        'km_per_h'       => ['name' => 'Kilometer per hour', 'abbreviation' => 'km/h'],
     147        'm_per_h'        => ['name' => 'Meter per hour', 'abbreviation' => 'm/h'],
     148        'cm_per_h'       => ['name' => 'Centimeter per hour', 'abbreviation' => 'cm/h'],
     149        'mm_per_s'       => ['name' => 'Millimeter per second', 'abbreviation' => 'mm/s'],
     150        'ft_per_s'       => ['name' => 'Foot per second', 'abbreviation' => 'ft/s'],
     151        'yd_per_s'       => ['name' => 'Yard per second', 'abbreviation' => 'yd/s'],
     152        'mi_per_h'       => ['name' => 'Mile per hour', 'abbreviation' => 'mi/h'],
     153        'mi_per_s'       => ['name' => 'Mile per second', 'abbreviation' => 'mi/s'],
     154        'knot'           => ['name' => 'Knot', 'abbreviation' => 'kn'],
     155        'speed_of_light' => ['name' => 'Speed of light', 'abbreviation' => 'c'],
     156        'speed_of_sound' => ['name' => 'Speed of sound', 'abbreviation' => 'v_sound'],
     157    ];
     158
     159    foreach ($speed_units as $unit_code => $data) {
     160        $code_name = strtolower(str_replace(' ', '_', preg_replace('/[^a-zA-Z0-9 ]/', '', $data['name'])));
     161
     162        $exists = $wpdb->get_var(
     163            $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE code_name = %s", $code_name)
     164        );
     165
     166        if (! $exists) {
     167            $wpdb->insert(
     168                $table_name,
     169                [
     170                    'unit'         => $unit_code,
     171                    'name'         => $data['name'],
     172                    'code_name'    => $code_name,
     173                    'abbreviation' => $data['abbreviation'],
     174                    'type'         => 'speed',
     175                ],
     176                ['%s', '%s', '%s', '%s', '%s']
    163177            );
    164    
    165             if (!$exists) {
    166                 $wpdb->insert(
    167                     $table_name,
    168                     [
    169                         'unit'         => $unit_code,
    170                         'name'         => $data['name'],
    171                         'code_name'    => $code_name,
    172                         'abbreviation' => $data['abbreviation'],
    173                         'type'         => 'speed',
    174                     ],
    175                     ['%s', '%s', '%s', '%s', '%s']
    176                 );
    177             }
    178178        }
    179179    }
    180    
    181     /////////////////////////////////////////////////////////////////////////////////////////////////
     180}
    182181
    183 }
     182/////////////////////////////////////////////////////////////////////////////////////////////////
    184183
    185184codeart_units_converter_update_2_0_0();
     
    187186codeart_units_converter_insert_weight_units_into_db();
    188187codeart_units_converter_insert_speed_units_into_db();
    189 
  • codeart-units-converter/trunk/readme.txt

    r3273046 r3273137  
    66Requires PHP: 7.0
    77Tested up to: 6.7.2
    8 Stable tag: 2.1.0
     8Stable tag: 2.3.0
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset for help on using the changeset viewer.