Skip to content

Instantly share code, notes, and snippets.

View cezarpopa's full-sized avatar
:shipit:
A bit of this and a bit of that.

Cezar Popa cezarpopa

:shipit:
A bit of this and a bit of that.
View GitHub Profile
@cezarpopa
cezarpopa / Prerequisite
Last active August 29, 2015 13:57
Portfolio sort with Isotope & non clickable links for empty terms
jquery.isotope.min.js
jquery-latest.js
@cezarpopa
cezarpopa / tricksy
Created May 7, 2014 13:52
remove the custom post slug @ Wordpress
/**
* Based @ Wordpress VIP
* Remove the slug from published post permalinks. Only affect our CPT though.
*/
function remove_cpt_slug( $post_link, $post, $leavename ) {
if ( ! in_array( $post->post_type, array( 'tours', 'services' ) ) || 'publish' != $post->post_status )
return $post_link;
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
@cezarpopa
cezarpopa / remove-query-strings
Created May 7, 2014 13:56
Remove query strings from static resources like CSS & JS files.
/**
Remove query strings from static resources like CSS & JS files. This plugin will improve your scores in services like PageSpeed, YSlow, Pingdoom and GTmetrix.
*/
function _remove_query_strings_1( $src ){
$rqs = explode( '?ver', $src );
return $rqs[0];
}
function _remove_query_strings_2( $src ){
@cezarpopa
cezarpopa / mimo_query
Created June 6, 2014 12:03
Wordpress Query posts - custom posts with different background for each post using count++
<?php
$mimo_query = new WP_Query(
array(
'post_type' => 'petreceri',
//'showposts' => 8,
'no_found_rows' => true,
)
);
if( $mimo_query->posts ) { ?>
@cezarpopa
cezarpopa / gist:946f4f6e4b5f9596c937
Last active August 29, 2015 14:02
Woocommerce query products and set different thumbnail using count
<ul class="products">
<?php
global $product;
$mimo_product_query = new WP_Query(
array(
'post_type' => 'product',
'orderby' => 'date',
'order' => 'desc',
'posts_per_page' => 2
)
<?php /* This function attaches the image to the post in the database, add it to functions.php */
function insert_attachment($file_handler,$post_id,$setthumb='false') {
// check to make sure its a successful upload
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false();
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'variable_fields_process', 10, 1 );
function variable_fields( $loop, $variation_data ) {
?>
<tr>
<?php
// Just require() this class via your theme's functions.php file.
/* Then instantiate this at the top of your 404.php file with:
if ( class_exists( 'Clean_404_Email' ) )
new Clean_404_Email;
*/
class Clean_404_Email {
var $time, $request, $blog, $email, $theme, $theme_data, $site, $referer, $string, $address, $remote, $agent, $message;
@cezarpopa
cezarpopa / functions
Created February 16, 2015 09:19
custom field single & variation
/*-----------------------------------------------------------*/
/* WooCommerce : add custom fields to product variations
/* https://gist.github.com/corsonr/9152652#file-gistfile1-php
/*----------------------------------------------------------*/
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 2 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
@cezarpopa
cezarpopa / woocoomerce-payment-custom-field
Created March 3, 2015 08:33
Add the title of the payment and custom field from payment in woocoomerce emails
/**
* This function will add the Payment title method to the emails
*/
add_action( 'woocommerce_email_before_order_table', 'add_payment_method_to_new_order', 10, 2 );
function add_payment_method_to_new_order( $order) {
$method = get_post_meta( $order->id, '_payment_method', true );
$method_1 = "directdebit";
$method_2 = "cecdebit";