Changeset 3273137
- Timestamp:
- 04/15/2025 08:23:43 AM (11 months ago)
- Location:
- codeart-units-converter/trunk
- Files:
-
- 2 added
- 4 edited
-
codeart-units-converter.php (modified) (2 diffs)
-
include/updates/list-updates.php (modified) (1 diff)
-
include/updates/update-2.0.0.php (modified) (4 diffs)
-
include/updates/update-2.2.0.php (added)
-
include/updates/update-2.3.0.php (added)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
codeart-units-converter/trunk/codeart-units-converter.php
r3273046 r3273137 10 10 * Text Domain: codeart-units-converter 11 11 * Domain Path: /i18n/languages/ 12 * Version: 2. 1.012 * Version: 2.3.0 13 13 * Tested up to: 6.7.2 14 14 */ … … 19 19 } 20 20 21 $codeart_units_converter_version = '2. 1.0';21 $codeart_units_converter_version = '2.3.0'; 22 22 23 23 /** -
codeart-units-converter/trunk/include/updates/list-updates.php
r3271810 r3273137 6 6 return $updates = [ 7 7 '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', 9 10 10 11 ]; -
codeart-units-converter/trunk/include/updates/update-2.0.0.php
r3271810 r3273137 1 1 <?php 2 2 ///////////////////////////////////////////////////////////////////////////////////////////////// 3 // create table codeart_units_converter_units 3 4 function codeart_units_converter_update_2_0_0() 4 5 { … … 6 7 global $wpdb; 7 8 8 /////////////////////////////////////////////////////////////////////////////////////////////////9 // create table codeart_units_converter_units10 9 $query = "CREATE TABLE IF NOT EXISTS {$wpdb->prefix}codeart_units_converter_units( 11 10 id bigint(20) NOT NULL AUTO_INCREMENT, … … 22 21 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 23 22 dbDelta($query); 24 ///////////////////////////////////////////////////////////////////////////////////////////////// 23 } 24 ///////////////////////////////////////////////////////////////////////////////////////////////// 25 25 26 ///////////////////////////////////////////////////////////////////////////////////////////////// 26 ///////////////////////////////////////////////////////////////////////////////////////////////// 27 function codeart_units_converter_insert_area_units_into_db() 28 { 29 global $wpdb; 27 30 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'] 59 72 ); 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 }74 73 } 75 74 } 76 77 ///////////////////////////////////////////////////////////////////////////////////////////////// 75 } 78 76 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 ///////////////////////////////////////////////////////////////////////////////////////////////// 80 function 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'] 114 128 ); 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 }129 129 } 130 130 } 131 132 ///////////////////////////////////////////////////////////////////////////////////////////////// 131 } 133 132 133 ///////////////////////////////////////////////////////////////////////////////////////////////// 134 134 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 ///////////////////////////////////////////////////////////////////////////////////////////////// 136 function 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'] 163 177 ); 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 }178 178 } 179 179 } 180 181 ///////////////////////////////////////////////////////////////////////////////////////////////// 180 } 182 181 183 } 182 ///////////////////////////////////////////////////////////////////////////////////////////////// 184 183 185 184 codeart_units_converter_update_2_0_0(); … … 187 186 codeart_units_converter_insert_weight_units_into_db(); 188 187 codeart_units_converter_insert_speed_units_into_db(); 189 -
codeart-units-converter/trunk/readme.txt
r3273046 r3273137 6 6 Requires PHP: 7.0 7 7 Tested up to: 6.7.2 8 Stable tag: 2. 1.08 Stable tag: 2.3.0 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset
for help on using the changeset viewer.