Skip to content

Instantly share code, notes, and snippets.

Avatar

Svetoslav Marinov lordspace

View GitHub Profile
@lordspace
lordspace / Windows fake sendmail
Created Aug 26, 2014
This is php.ini I used to setup Fake Sendmail on Windows 8
View Windows fake sendmail
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = admin+umob@domain.com
@lordspace
lordspace / ajax.php
Last active Aug 29, 2015
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/
View ajax.php
<?php
echo 'Ok';
@lordspace
lordspace / array2attribs
Created Jul 21, 2014
Here is a PHP class that allows you to create HTML attributes from a php array. If you pass the second parameter the key will be prefixed with 'data-' prefix so they can be access via jQuery later.
View array2attribs
Class HTML_Util {
/**
* Usage: HTML_Util::array2attribs();
* @param array $attributes
* @param bool $make_them_data will prefix each key with 'data-' prefix so it's acessible via $('#elem').data();
* @return string
* @see http://stackoverflow.com/questions/18081625/how-do-i-map-an-associative-array-to-html-element-attributes
*/
public static function array2attribs($attributes = array(), $make_them_data = 0) {
$pairs = array();
@lordspace
lordspace / csv.php
Last active Mar 14, 2019 — forked from jaywilliams/csv_to_array.php
a class to read and write CSV
View csv.php
<?php
/**
* This class is used in Orbisius Price Changer for WooCommerce
* This premium WooCommerce extension allows you to change product prices (up/down) for all products or for a selected category and its subcategories.
* You can review them before actually making the changes.
*
* @see http://club.orbisius.com/products/wordpress-plugins/woocommerce-extensions/orbisius-woocommerce-ext-price-changer/
* @author jaywilliams | myd3.com | https://gist.github.com/jaywilliams
* @author Svetoslav Marinov (SLAVI) | http://orbisius.com
@lordspace
lordspace / dbg_act_log
Created Apr 23, 2014
Log plugin activation errors.
View dbg_act_log
<?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 Feb 16, 2014
How to which slider has been dragged in a range slider of jQuery UI using it in WordPress plugin
View jquery ui range slider
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 Feb 14, 2014
Convert a string Lat/Long to Google Maps API LatLng Object
View str2latlng
// 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;
};
View my-spy.php
<?php
/**
* This file will send you alerts when your clients install/uninstall plugins
* Usage: Save this as wp-content/mu-plugins/my-spy.php
*
* License: GPL
* @author orbisius.com
* Use it at your own risk. You may have to disclose this in your terms of service.
* Check with a laywer first.
@lordspace
lordspace / send_mail_delayed.php
Created Jan 4, 2014
This function schedules an email by passing -odd parameters to sendmail. Those emails will be processed depending on: /etc/sysconfig/sendmail (using 1h) if sendmail is running all the time otherwise you may have to start sendmail via cron
View send_mail_delayed.php
<?php
/**
* This function schedules an email by passing -odd paramaters to sendmail.
* Those emails will be processed depending on: /etc/sysconfig/sendmail (using 1h)
* if sendmail is running all the time.
*
* @param string $email recipient
* @param string $subject - subject
* @param string $message - the message
@lordspace
lordspace / functions.php
Last active Dec 31, 2015
Use this snippet as a starting point when overriding functions from the parent theme (functions.php). The snippet might look like it's missing a closing php tag but this is done so there are no extra spaces added.
View functions.php
<?php
/*
Make sure that the function name matches the function name in the parent theme's functions.php file.
Also in the parent theme there must be a block e.g. !function_exists('function_name_that_you_want_to_override')
that will tell you that it is safe to override that function.
*/
function function_name_that_you_want_to_override() {
}
You can’t perform that action at this time.