Author: nertblox

Elementor #31652

Read more
PHP Functions

How to Sort an Array with PHP

Create the function sortArray() public function sortArray(&$array, $subkey=”id”, $sort_ascending=true) { if (count($array)) $temp_array[key($array)] = array_shift($array); foreach($array as $key => $val){ $offset = 0; $found = false; foreach($temp_array as $tmp_key => $tmp_val) { if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey])) { $temp_array = array_merge( (array)array_slice($temp_array,0,$offset), array($key => $val), array_slice($temp_array,$offset) ); $found = true; } $offset++; } if(!$found) $temp_array […]

Read more

Woocommerce Javascript events

Woocommerce Checkout JS events $( document.body ).trigger( ‘init_checkout’ ); $( document.body ).trigger( ‘payment_method_selected’ ); $( document.body ).trigger( ‘update_checkout’ ); $( document.body ).trigger( ‘updated_checkout’ ); $( document.body ).trigger( ‘checkout_error’ ); $( document.body ).trigger( ‘applied_coupon_in_checkout’ ); $( document.body ).trigger( ‘removed_coupon_in_checkout’ ); Woocommerce cart page JS events $( document.body ).trigger( ‘wc_cart_emptied’ ); $( document.body ).trigger( ‘update_checkout’ ); $( […]

Read more
PHP Functions

Plesk PHP Version Not Matching Command Line

echo “PATH=/opt/plesk/php/7.1/bin:$PATH” >> ~/.bash_profile Replace the version number with the one you have set. Then close out the terminal and reopen.  Run php -v and you should see the correct version.   php -v PHP 7.4.27 (cli) (built: Dec 23 2021 14:48:17) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) […]

Read more

Reset and Reload Fabric Canvas

  var json = canvas.toJSON(); canvas.clear(); canvas.loadFromJSON(json, canvas.renderAll.bind(canvas));  

Read more

Resize Fabric js Canvas

  canvas.setWidth( <desired width> ); canvas.setHeight( <desired height> ); canvas.calcOffset();  

Read more

Order Array By Int, Float, Text Value Javascript

  var arrayVar = [ { name: ‘Bobby’, someValue: 123123 }, { name: ‘Phillip’, someValue: 123 } ]; arrayVar = arrayVar.sort((a, b) => {return a.someValue – b.someValue}); // save the sort result // (a – b) = Ascending sort, (b – a) = Descending sort console.log(arrayVar);

Read more

How To Get Public IP Address from Command line

  curl http://ipecho.net/plain  

Read more

Speech Recognition With Javascript

  var grammar = ‘#JSGF V1.0; grammar colors; public <color> = aqua | azure | beige | bisque | black | blue | brown | chocolate | coral | crimson | cyan | fuchsia | ghostwhite | gold | goldenrod | gray | green | indigo | ivory | khaki | lavender | lime | […]

Read more

Books Without Batteries

Read more