Skip to content

Instantly share code, notes, and snippets.

View cezarpopa's full-sized avatar
:bowtie:

Cezar Popa cezarpopa

:bowtie:
View GitHub Profile
@cezarpopa
cezarpopa / gist:1b3f32bf2b7798cbf86c
Created March 17, 2015 13:45
standard template
<?php
class WCBulkOrderForm_Standard_Template {
private static $add_script;
/**
* Construct.
*/
public function __construct() {
$this->includes();
$this->options = get_option('wcbulkorderform_standard_template');
//print_r($this->options);
<?php
/**
* WordPress function for redirecting users on login based on user role
*/
function my_login_redirect( $url, $request, $user ){
if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
if( $user->has_cap( 'administrator' ) ) {
$url = admin_url();
} else {
<?php
/**
* Plugin Name: WooCommerce Add CSS to Emails
* Plugin URI: https://gist.github.com/BFTrick/01cc414ee56ce93715ec
* Description: Add CSS styles to WooCommerce emails
* Author: Patrick Rauland
* Author URI: http://speakinginbytes.com/
* Version: 1.0
*
* This program is free software: you can redistribute it and/or modify
#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/
/**
* Create Custom Meta Boxes for WooCommerce Product CPT
*
* Using Custom Metaboxes and Fields for WordPress library from
* Andrew Norcross, Jared Atchinson, and Bill Erickson
*
* @link http://blackhillswebworks.com/?p=5453
* @link https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress
*/
@cezarpopa
cezarpopa / irsz.js
Last active August 29, 2015 14:27 — forked from numist/irsz.js
dynamically resize images to fit viewport (intelligently!)
/*
* Copyright © 2012 by Scott Perry
* Released under the MIT License; its terms are at the end of this file.
*
* This file depends on:
* • jQuery (tested against 1.7.1)
* http://jquery.com/
*
* Basic logic of this file:
* + if irsz_auto is true
@cezarpopa
cezarpopa / add_url_to_body
Last active November 14, 2015 12:49
add url / slug from page/pages to body WordPress
/**
* Adds custom classes to the array of body classes.
* Based @Underscores.me
* @param array $classes Classes for the body element.
* @return array
*/
function ks_body_classes( $classes ) {
// Adds a class of group-blog to blogs with more than 1 published author.
if ( is_multi_author() ) {
$classes[] = 'group-blog';
@cezarpopa
cezarpopa / csv.php
Created January 16, 2016 09:18 — forked from lordspace/csv.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
@cezarpopa
cezarpopa / gist:1a13254ae69781c64884
Created March 8, 2016 10:28
View screen size / viewport
<script type="text/javascript">
document.write(screen.width+'x'+screen.height);
</script>
@cezarpopa
cezarpopa / woocommerce_mysql
Created May 3, 2016 18:18
Woocommerce to MailPoet userinfo import
UPDATE (
SELECT
u.ID as ID,
u.user_email as email,
max( CASE WHEN um.meta_key = 'billing_first_name' and u.ID = um.user_id THEN um.meta_value END ) as billing_first_name,
max( CASE WHEN um.meta_key = 'billing_last_name' and u.ID = um.user_id THEN um.meta_value END ) as billing_last_name,
max( CASE WHEN um.meta_key = 'billing_address_1' and u.ID = um.user_id THEN um.meta_value END ) as billing_address_1
FROM awp_users as u
INNER JOIN