Skip to content

Instantly share code, notes, and snippets.

@alhoseany
alhoseany / emails.php
Created May 6, 2019 19:59 — forked from tameemsafi/emails.php
Send an email programmatically in wordpress with wp_mail using the woocommerce transaction emails template.
<?php
// Define a constant to use with html emails
define("HTML_EMAIL_HEADERS", array('Content-Type: text/html; charset=UTF-8'));
// @email - Email address of the reciever
// @subject - Subject of the email
// @heading - Heading to place inside of the woocommerce template
// @message - Body content (can be HTML)
function send_email_woocommerce_style($email, $subject, $heading, $message) {
@alhoseany
alhoseany / sync.sh
Created May 6, 2019 21:54 — forked from santerref/sync.sh
Simple bash script to synchronize your WordPress dev (local) with your staging or production.
#/bin/bash
REMOTE_URL="https://staging.example.com"
LOCAL_URL="http://example.dev"
REMOTE_PATH="/home/staging_example/public_html"
LOCAL_PATH="/var/www/example.dev"
SSH_HOST="user@staging.example.com"
@alhoseany
alhoseany / gist:635ec60c5b36fcf3648a4d7497232957
Created July 25, 2019 02:33 — forked from ozh/gist:8169202
Human readable time difference between 2 dates in PHP
<?php
/**
* Get human readable time difference between 2 dates
*
* Return difference between 2 dates in year, month, hour, minute or second
* The $precision caps the number of time units used: for instance if
* $time1 - $time2 = 3 days, 4 hours, 12 minutes, 5 seconds
* - with precision = 1 : 3 days
* - with precision = 2 : 3 days, 4 hours
@alhoseany
alhoseany / functions.php
Created April 28, 2018 12:21
Example of Use cases for Actions
<?php
/**
* code #1 - removes excess Wordpress header tags from default themes.
*/
function clean_wp_header() {
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'rel_canonical');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'feed_links',2);
@alhoseany
alhoseany / wp-config.php
Created April 5, 2019 17:04
check debug output in wordpress with a get variable
// brought to you by Liam Bailey
// That way if I want to see the output I just add ?dbg_smrand to the url and presto
define('wp_debug', true);
define('wp_debug_log', true);
define('wp_debug_display, isset($_GET['dbg_smrand']));
/* Add custom menu item and endpoint to WooCommerce My-Account page */
function my_custom_endpoints() {
add_rewrite_endpoint( 'refunds-returns', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'my_custom_endpoints' );
// so you can use is_wc_endpoint_url( 'refunds-returns' )
add_filter( 'woocommerce_get_query_vars', 'my_custom_woocommerce_query_vars', 0 );