Skip to content

Instantly share code, notes, and snippets.

View lordspace's full-sized avatar

Svetoslav Marinov lordspace

View GitHub Profile
@lordspace
lordspace / ajax.php
Last active August 29, 2015 14:04
Example: How to Make an Ajax Request when Twitter Bootstrap Alert is Dismissed. More info on: http://slavi.ca/tutorials/make-ajax-request-twitter-bootstrap-alert-dismissed/
<?php
echo 'Ok';
@lordspace
lordspace / dbg_act_log
Created April 23, 2014 01:40
Log plugin activation errors.
<?php
// install it in mu-plugins
add_action('activated_plugin', 'dbg_log_error', 0, 2);
function dbg_log_error($plugin, $network_wide) {
if (ob_get_length() == 0) {
return ;
}
@lordspace
lordspace / jquery ui range slider
Created February 16, 2014 06:36
How to which slider has been dragged in a range slider of jQuery UI using it in WordPress plugin
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-core ' );
wp_enqueue_script( 'jquery-ui-slider' );
wp_register_style('my_jq_ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery.ui.all.css', __FILE__, false);
wp_enqueue_style('my_jq_ui');
<div id="slider-range"></div>
@lordspace
lordspace / str2latlng
Created February 14, 2014 22:14
Convert a string Lat/Long to Google Maps API LatLng Object
// This function accepts lat latitude from a string
// e.g. 123,-234
function getLatLngFromString(ll) {
var lat = ll.replace(/\s*\,.*/, ''); // first 123
var lng = ll.replace(/.*,\s*/, ''); // second ,456
var latLng = new google.maps.LatLng(parseFloat(lat), parseFloat(lng));
return latLng;
};