Skip to content

Instantly share code, notes, and snippets.

View Aleksandar-Mitic's full-sized avatar
🏠
Working from home

Aleksandar Mitic Aleksandar-Mitic

🏠
Working from home
View GitHub Profile
@Aleksandar-Mitic
Aleksandar-Mitic / add-product-to-cart.php
Created October 2, 2018 13:50 — forked from sc0ttkclark/add-product-to-cart.php
WooCommerce Automatically add product to cart on site visit
<?php
/*
* This code goes into theme functions.php or a custom plugin
*/
/**
* Add product to cart on page load
*/
function add_product_to_cart() {
@Aleksandar-Mitic
Aleksandar-Mitic / fromfolder.php
Created August 21, 2018 06:03 — forked from projectxcappe/fromfolder.php
Display Images From A Folder with PHP
//Display Images From A Folder with PHP
<?php
$files = glob("images/*.*");
for ($i=1; $i<count($files); $i++)
{
$num = $files[$i];
echo '<img src="'.$num.'" alt="random image">'."&nbsp;&nbsp;";
}
?>
@Aleksandar-Mitic
Aleksandar-Mitic / webdev_online_resources.md
Created July 18, 2018 11:26 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@Aleksandar-Mitic
Aleksandar-Mitic / gist:581e56b093650d7743e8103e427025e2
Created February 26, 2018 14:17 — forked from Yame-/gist:d154d574ee7df2f5b3eb
Retrieving billing_first_name, billing_last_name, ... via Sessions - WooCommerce
<?php
/*
Add this code to your functions.php
*/
add_action('woocommerce_checkout_update_order_review', 'get_customer_details');
function get_customer_details($post_data){
global $woocommerce;
// Details you want injected into WooCommerce session.
@Aleksandar-Mitic
Aleksandar-Mitic / woocommerce-create-order.md
Created January 17, 2018 10:34 — forked from stormwild/woocommerce-create-order.md
WooCommerce Creating Order Programmatically

WooCommerce Creating Order Programmatically

WooCommerce Create Order

creating Woocommerce order with line_item programatically

// http://stackoverflow.com/questions/26581467/creating-woocommerce-order-with-line-item-programatically
$address = array(
            'first_name' => 'Fresher',
@Aleksandar-Mitic
Aleksandar-Mitic / .htaccess
Created December 8, 2017 11:04 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@Aleksandar-Mitic
Aleksandar-Mitic / class-watermark-image.php
Created November 23, 2017 10:39 — forked from tomazzaman/class-watermark-image.php
Watermarking uploads in WordPress with Imagemagick
function register_watermarked_size() {
add_image_size( 'watermarked', 550, 550, true ); // This is what should be uploaded
}
add_action( 'init', 'register_watermarked_size' );
class Watermark_Image {
// The attachment meta array
public $meta = array();
@Aleksandar-Mitic
Aleksandar-Mitic / wp_mail.md
Last active November 3, 2017 07:45 — forked from johnbillion/wp_mail.md
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This is accurate as of WordPress 4.8, and includes some upcoming changes in WordPress 4.9.

There are a few TODOs left. Please bear with me.

@Aleksandar-Mitic
Aleksandar-Mitic / wp-query-ref.php
Created October 5, 2017 10:25 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
@Aleksandar-Mitic
Aleksandar-Mitic / PHP Date converter
Last active October 23, 2017 18:29 — forked from chrisdigital/PHP Date converter
Little date function to convert XX/XX/XXXX into verbose date (e.g. "January 11, 2015")
<?php
function dateConvert($x_date){
$x_date = explode('/', $x_date, 4);
$x_months = array('','January','Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$x_month = intval($x_date[0]);
$x_day = intval($x_date[1]);
$x_year = $x_date[2];
return ($x_months[$x_month]." ".$x_day. ", ".$x_year);
}