Skip to content

Instantly share code, notes, and snippets.

View lordspace's full-sized avatar

Svetoslav Marinov lordspace

View GitHub Profile
@lordspace
lordspace / zzz_sync.php
Created December 15, 2014 09:44
How to Sync Your Plugins with a Staging Server Using WP-CLI
<?php
/**
* This script allows you to sync plugins from development machine with staging/live servers.
* Author: Svetoslav Marinov (SLAVI) | http://orbisius.com
* (c) All Rights Reserved.
* (c) Dec 2014
* License: LGPL
* zzz_sync.php
*/
@lordspace
lordspace / Fake Sendmail Configuration Mandrill
Created August 26, 2014 09:44
Fake Sendmail Configuration for Using it with Mandrill. Uses non-ssl version as the SSL one worked OK on CLI but hanged when accessed via Apache
; configuration for fake sendmail
; if this file doesn't exist, sendmail.exe will look for the settings in
; the registry, under HKLM\Software\Sendmail
[sendmail]
; you must change mail.mydomain.com to your smtp server,
; or to IIS's "pickup" directory. (generally C:\Inetpub\mailroot\Pickup)
; emails delivered via IIS's pickup directory cause sendmail to
@lordspace
lordspace / Windows fake sendmail
Created August 26, 2014 09:39
This is php.ini I used to setup Fake Sendmail on Windows 8
[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 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 / array2attribs
Created July 21, 2014 08:58
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.
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 October 6, 2020 20:32 — forked from jaywilliams/csv_to_array.php
a class to read and write CSV
<?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 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;
};
<?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.