If your building some custom Google Maps and need to get the distance between two points I got the Math done for ya.

	* Return a distance between two lat/lng points
	* @param int $lat1         REQUIRED; Latitude - Location 1
	* @param int $lon1         REQUIRED; Longitude - Location 1
	* @param int $lat2         REQUIRED; Latitude - Location 2
	* @param int $lon2         REQUIRED; Longitude - Location 2
	* @param string $unit      OPTIONAL; Distance Type (Km / M)
	* @return int
	function getDistance($lat1, $lon1, $lat2, $lon2, $unit) {
	 if($lat1 == $lat2 &amp;&amp; $lon1 == $lon2)
	   return 0;

	 $theta = $lon1 - $lon2;
	 $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +  cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
	 $dist = acos($dist);
	 $dist = rad2deg($dist);
	 $miles = $dist * 60 * 1.1515;
	 $unit = strtoupper($unit);

	 if ($unit == "K") {
	   return ($miles * 1.609344);
	 } else if ($unit == "N") {
	   return ($miles * 0.8684);
	 } else {
	   return $miles;

The function below will return the distance between two Lat/Lng points so for you to use in your code to calculate travel fees or just the distance in miles/kilometers. This is a very handy bit of code.

Need a way to convert Hex code to RGB value programatically with PHP? I got your back.

	* Converts a hex code to the rgb value
	* @param hex                    hex code with or without the # symbol
	* @return string
	hex2rgb($hex) {
	   $hex = str_replace("#", "", $hex);

	   if(strlen($hex) == 3) {
	      $r = hexdec(substr($hex,0,1).substr($hex,0,1));
	      $g = hexdec(substr($hex,1,1).substr($hex,1,1));
	      $b = hexdec(substr($hex,2,1).substr($hex,2,1));
	   } else {
	      $r = hexdec(substr($hex,0,2));
	      $g = hexdec(substr($hex,2,2));
	      $b = hexdec(substr($hex,4,2));
	   $rgb = array($r, $g, $b);
	   return implode(",", $rgb); // returns the rgb values separated by commas
	   //return $rgb; // returns an array with the rgb values

There are not a ton of instances that you might need to do this. Most of the cases I had to use this have been for better support for older browsers.

Have you needed to apply specific CSS styles to a particular web browser (Internet Explorer, FireFox, Chrome, Opera...)? I have a Javascript function that I use in all my site to accomplish this.

I use this function to identify the browser that is viewing a site and using its name as class that I assign the the <body> tag. I find this to beneficial when there are custom styles needed for specific browsers. For those who have had to make sites work for Internet Explorer 11 and lower know what I mean.

getBrowserName() {
		var name = "unknown-browser";
	    if(navigator.userAgent.indexOf("MSIE")!=-1 || navigator.userAgent.indexOf("rv:11.0")!=-1) name = "msie";
	    else if(navigator.userAgent.indexOf("Edge")!=-1) name = "microsoft-edge";
	    else if(navigator.userAgent.indexOf("Firefox")!=-1) name = "firefox";
	    else if(navigator.userAgent.indexOf("Opera")!=-1) name = "opera";
	    else if(navigator.userAgent.indexOf("Chrome") != -1) name = "chrome";
	    else if(navigator.userAgent.indexOf("Safari")!=-1) name = "safari";

		var OSName="unknown-os";
		if (navigator.appVersion.indexOf("Win")!=-1) OSName="windows";
		if (navigator.appVersion.indexOf("Mac")!=-1) OSName="mac-os";
		if (navigator.appVersion.indexOf("X11")!=-1) OSName="unix";
		if (navigator.appVersion.indexOf("Linux")!=-1) OSName="linux";

		var IEVersion="not-ie";
		if(navigator.userAgent.indexOf("rv:11.0")!=-1) IEVersion = "ie ie-11";
		else if(navigator.userAgent.indexOf("MSIE 10.0")!=-1) IEVersion = "ie ie-10";
		else if(navigator.userAgent.indexOf("MSIE 9.0")!=-1) IEVersion = "ie ie-9";
		else if(navigator.userAgent.indexOf("MSIE 8.0")!=-1) IEVersion = "ie ie-8";
		else if(navigator.userAgent.indexOf("MSIE 7.0")!=-1) IEVersion = "ie ie-7";

		var windowsVersion='not-windows';
		if(navigator.userAgent.indexOf("Windows NT 5.0")!=-1) windowsVersion = "windows-2000";
		else if (navigator.userAgent.indexOf("Windows NT 5.1")!=-1) windowsVersion="windows-xp";
		else if(navigator.userAgent.indexOf("Windows NT 6.0")!=-1) windowsVersion = "windows-vista";
		else if(navigator.userAgent.indexOf("Windows NT 6.1")!=-1) windowsVersion = "windows-7";
		else if(navigator.userAgent.indexOf("Windows NT 6.2")!=-1) windowsVersion = "windows-8";
		else if(navigator.userAgent.indexOf("Windows NT 6.3")!=-1) windowsVersion = "windows-8-1";
		else if(navigator.userAgent.indexOf("Windows NT 10.0")!=-1) windowsVersion = "windows-10";

		var device="not-mobile"
		if (navigator.userAgent.match(/Android|BlackBerry|Kindle|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) device="mobile";

		var isKindle="not-kindle"
		if (navigator.userAgent.match(/Kindle|KFTHWI/i)) isKindle="kindle";


If you have your form at the bottom of a page and noticed that when you submit the form you don't see your confirmation message right away, it's not your fault.

Gravity Forms is meant to be very flexible to any type of user/developer, however not all of the bells and whistles are turned on by default. One is the scroll to confirmation message. It's pretty simple to turn on. You can add this filter to your functions.php file in your theme.

add_filter( 'gform_confirmation_anchor', '__return_true' );

More info here: https://www.gravityhelp.com/documentation/article/gform_confirmation_anchor/

Another thing you can do is after the form is submitted take the user to another page with a confirmation message. This can be done in the form settings -> confirmations and change the confirmation type from text to page. Select the page you want your done.

Sometimes one would see references to ‘hard’ style and ‘soft’ style martial arts. To many non-martial artists, these terms may be puzzling. In North America, these terms are used to classify martial art styles into two main categories. Japanese/Okinawan karate and Korean tae kwon do are generally referred to as hard styles. Movements in both karate and tae kwon do are often linear with their forms (traditional sequence of set moves) performed with crisp movements. Chinese kung fu styles are usually referred to as soft styles. The circular motions of kung fu forms give them a more visually graceful or softer appearance especially when many of the movements flow from one to another. Even Korean kuk sool won which is sometimes referred to as ‘Korean kung fu’, is often classified as a soft style since its movements are also more flowing than the stop and go of tae kwon do or karate. This is not to say that hard styles such as karate or tae kwon do are more powerful martial arts than kung fu and other soft styles. The term ‘soft’ is a bit misleading because the power from circular kung fu moves are often hidden. Circular moves can generate just as much power as linear ones.

The terms hard style and soft style came as a result of the evolution of North American martial arts competitions, particularly in forms divisions. For many years, open karate tournaments which allowed all martial arts styles, had competitors from different martial arts backgrounds compete in the same forms divisions. All equivalent level competitors, whether they used a Japanese/Okinawan karate kata, a Korean tae kwon do pattern or a Chinese kung fu form, competed together in the same divisions. This provided a nice martial arts showcase for spectators especially at the bigger tournaments. However, some competitors and judges considered divisions with combined styles to be too complicated. For example, judges who were familiar with only Japanese or Korean styles had a difficult time scoring competitors performing Chinese kung fu forms. Sometimes competitors from different martial art styles felt that judges were being biased against them. Judging a hard style form against a soft style form was often like trying to compare apples to oranges.

To help resolve these issues, many of the larger martial arts tournaments expanded to have separate divisions for hard and soft styles. This was a way to equalize things and add some more fairness to all competitors. The largest tournaments went another step ahead and further separated Japanese karate stylists from Korean Tae Kwon Do stylists by putting them into different divisions too. This still left many Kempo stylists up in the air because their particular forms have both hard and soft style elements since their movements are both linear as well as circular. Some promoters of large tournaments decided to accommodate Kempo stylists by adding in separate forms divisions just for their style too. Of course many smaller local tournaments have not been able to offer separate hard and soft style divisions for martial arts forms competitors mainly because of financial budget restrictions. The terms hard style and soft style are used only in North America and parts of Europe since these are the only regions of the world that have open martial arts competitions. Martial arts competitions in other parts of the world such as Asia are generally restricted to certain specific styles only.

Filling out forms are the worst. Especially if you have to fill it out cause you have a complaint or if it is mandatory for work. You start tabbing through the form filling out only the necessities just so you can get to the end and submit it. And when you think you are finally at the end of it all and hit submit...the page refreshes and you are staring at the form all over again. What makes this worse if the form is super long or heaven forbid multiple pages. If you are lucky you are scrolled right to the error. If you are not so lucky at least you learned that this isn't the way forms should be and you can update forms on your website to fix this.

Insert jQuery to add scrolling after submission

jQuery( document ).bind( 'gform_post_render', function() {
    var firstError = jQuery( 'li.gfield.gfield_error:first' );
    if( firstError.length > 0 ) {
        firstError.find( 'input, select, textarea' ).eq( 0 ).focus();
        document.body.scrollTop = firstError.offset().top;
} );

Add this into your custom JS file or place it in a <script></script> on the template your Gravity Form is located. You can either call this function in a jQuery(document).ready() or wrap it in a function of your own creation and call it.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram