Skip to content

Instantly share code, notes, and snippets.

View lordspace's full-sized avatar

Svetoslav Marinov lordspace

View GitHub Profile
@lordspace
lordspace / gist:7853704
Created December 8, 2013 05:29
How to return JSON from a WordPress plugin without an external plugin
<?php
/*
Plugin Name: Orbisius Sample Code
Plugin URI: http://club.orbisius.com/products/
Description: Sample plugin to return JSON
Version: 1.0.0
Author: Svetoslav Marinov (Slavi)
Author URI: http://orbisius.com
License: GPL v2
*/
@lordspace
lordspace / functions.php
Last active December 31, 2015 21:39
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.
<?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() {
}
@lordspace
lordspace / send_mail_delayed.php
Created January 4, 2014 08:31
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
<?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
<?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 / set_up_ssl_for_wp_news_site.txt
Last active December 19, 2016 14:52
These are instructions related to this article (How to Properly Set up an SSL Certificate for a News Site Based on WordPress) http://orbisius.com/wordpress/properly-set-ssl-certificate-news-site-based-wordpress/
How To Setup Let's Encrypt SSL certificate for a news Site and Fix Mixed Content Error
///////////////////////////////////
// put this in wp-config.php
// orbisius.com
// GPL
ob_start( 'orbisius_custom_link_corrector_global' );
/**
* This is used here to correct all links that are not ssl
@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 / orbisius_quick_fix_wc_ext_opt_co_fields.php
Created August 7, 2017 09:51
This code allows you to make some WooCommerce Checkout Fields optional.
<?php
/*
This code allows you to make some WooCommerce Checkout Fields optional.
Blog post http://orbisius.com/link/3710
Author: Svetoslav Marinov (Slavi)
Author URI: http://orbisius.com
*/
/*
Installation
@lordspace
lordspace / openssl.cnf
Created May 7, 2019 12:50
This file is from Apache installation and it's referenced by this tutorial : How to Generate Certificate Authority (CA) Key and SSL Certificate with OpenSSL at https://orbisius.com/4583
#
# OpenSSL example configuration file.
# This is mostly being used for generation of certificate requests.
#
# This definition stops the following lines choking if HOME isn't
# defined.
HOME = .
RANDFILE = $ENV::HOME/.rnd
@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