This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// convert radians into latitude | |
// 90 to -90 | |
function rad2lat(rad) { | |
// first of all get everthing into the range -2pi to 2pi | |
rad = rad % (Math.PI*2); | |
// convert negatives to equivalent positive angle | |
if (rad < 0) | |
rad = 2*Math.PI + rad; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rad = function(x) { | |
return x * Math.PI / 180; | |
}; | |
var getDistance = function(p1, p2) { | |
var R = 6378137; // Earth’s mean radius in meter | |
var dLat = rad(p2.lat() - p1.lat()); | |
var dLong = rad(p2.lng() - p1.lng()); | |
var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + | |
Math.cos(rad(p1.lat())) * Math.cos(rad(p2.lat())) * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getPosition(e) { | |
var posx = 0; | |
var posy = 0; | |
if (!e) var e = window.event; | |
if (e.pageX || e.pageY) { | |
posx = e.pageX; | |
posy = e.pageY; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function ms_users_redirect() { | |
global $pagenow; | |
if( defined('DOING_AJAX') && DOING_AJAX ) { | |
return; | |
} | |
$allowed = [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Heartbeat API Demo | |
Plugin URI: http://www.strangerstudios.com/wp/heartbeat-api-demo | |
Description: Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6. | |
Version: .1 | |
Author: strangerstudios | |
If logged in as a user and viewing the frontend of your website, | |
every 15 seconds you should see the following in your Javascript console: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Plugin Name: Set Heartbeat pulse | |
*/ | |
! defined( 'ABSPATH' ) and exit; | |
add_filter( 'heartbeat_settings', 'fb_heartbeat_settings' ); | |
function fb_heartbeat_settings( $settings = array() ) { | |
$settings['interval'] = 60; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Geo Data Store | |
Plugin URI: http://l3rady.com/projects/geo-data-store/ | |
Description: Stores lng/lat co-ordinates in a better optimized table | |
Author: Scott Cariss | |
Version: 2.0.2 | |
Author URI: http://l3rady.com/ | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set @latitude = xxx; — center latitude | |
set @longitude = xxx; — center longitude | |
set @distance = xx; — search distance | |
select p.ID, p.post_name, ((ACOS(SIN(@latitude * PI() / 180) * SIN(`latitude.meta_value` * PI() / 180) + COS(@latitude * PI() / 180) * COS(`latitude.meta_value` * PI() / 180) * COS((@longitude – `longitude.meta_value`) * PI() / 180)) * 180 / PI()) * 60 * 1.1515) AS distance | |
from wp_posts p | |
left join wp_postmeta latitude on latitude.post_id = p.ID and latitude.meta_key = ‘_latitude’ | |
left join wp_postmeta longitude on longitude.post_id = p.ID and longitude.meta_key = ‘_longitude’ | |
having distance < @distance; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add_subcategories_to_permalink( $category, $categories, $post ) { | |
return end( $categories ); | |
} | |
add_filter( 'post_link_category', 'add_subcategories_to_permalink', 10, 3 ); |
OlderNewer