Skip to content

Instantly share code, notes, and snippets.

View pablo-sg-pacheco's full-sized avatar

Pablo dos Santos Gonçalves Pacheco pablo-sg-pacheco

View GitHub Profile
@pablo-sg-pacheco
pablo-sg-pacheco / index.php
Last active June 20, 2018 18:50
Add compatibility with WOOF plugin and More Sorting Options for WooCommerce regarding title sorting option
<?php
// Add these cases on get_catalog_orderby() function on index.php
case 'title-desc':
$orderby = "title";
$order = 'DESC';
break;
case 'title-asc':
$orderby = "title";
$order = 'ASC';
@pablo-sg-pacheco
pablo-sg-pacheco / style.css
Last active May 8, 2018 20:55
Charity Theme - Move the mobile menu icon to center
/*
* Move the mobile menu icon to center
*
* Theme Name: HB Charity
* Theme URI: http://hummingbirdthemes.com/themes/hb-charity-wordpress-theme/
*/
.menu .visible-xs{
text-align:center;
}
.menu #showbutton{
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active May 8, 2018 20:24
Charity Theme - Add content before moving articles on header
add_action( 'hb_charity_top_header', function(){
?>
<div class="topheader" style="color:#fff;">
<div class="container">
<div class="row">
<div class="col-lg-12">
<?php echo __( 'My Articles', 'hb-charity' ); ?>
</div>
</div>
</div>
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Created April 5, 2018 17:25
Make "Color or Image Variation Swatches for WooCommerce" plugin compatible with Savoy theme
<?php
add_action( 'wp_head', function () {
?>
<style>
.label.alg-wc-civs-term {
width: auto !important;
padding: 0 !important;
border: 2px solid #ccc !important;
line-height: auto !important;
}
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active February 23, 2018 20:12
Add Pinterest meta on HB Charity theme
<?php
add_action('wp_head',function(){
?>
<?php //Add your meta here ?>
<meta />
<?php
});
?>
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active January 31, 2018 19:11 — forked from jnlsn/functions.php
WP Query Orderby Taxonomy Term Name
<?php
add_filter('posts_clauses', 'posts_clauses_with_tax', 10, 2);
function posts_clauses_with_tax( $clauses, $wp_query ) {
global $wpdb;
//array of sortable taxonomies
$taxonomies = array('example-taxonomy', 'other-taxonomy');
if (isset($wp_query->query['orderby']) && in_array($wp_query->query['orderby'], $taxonomies)) {
$clauses['join'] .= "
LEFT OUTER JOIN {$wpdb->term_relationships} AS rel2 ON {$wpdb->posts}.ID = rel2.object_id
LEFT OUTER JOIN {$wpdb->term_taxonomy} AS tax2 ON rel2.term_taxonomy_id = tax2.term_taxonomy_id
@pablo-sg-pacheco
pablo-sg-pacheco / query.sql
Created December 14, 2017 13:11
Get WooCommerce product type
SELECT p.ID, p.post_title, t.name AS product_type
FROM wp_posts AS p
JOIN wp_term_relationships AS tr ON tr.object_id = p.id
JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id=tt.term_taxonomy_id
JOIN wp_terms AS t ON t.term_id = tt.term_id
WHERE p.id = 111 AND tt.taxonomy = 'product_type'
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active April 10, 2018 22:28
Make the plugin Wish list for WooCommerce compatible with Yith Infinite scrolling
/**
* Makes the plugin Wish list for WooCommerce compatible with Yith Infinite scrolling
*/
add_action('wp_footer',function(){
?>
<script>
jQuery(document).on('yith_infs_added_elem',function(){
jQuery('.alg-wc-wl-btn').addClass('ajax-loading');
var alg_wc_wl_show = function(){
jQuery('.alg-wc-wl-btn.ajax-loading').removeClass('ajax-loading');
@pablo-sg-pacheco
pablo-sg-pacheco / wishlist-update.js
Last active November 24, 2017 18:06
Update the whole wishlist every time an item is added or removed, considering the wishlist is always present in all pages
/**
* Update the whole wishlist every time an item is added or removed, considering the wishlist is always present in all pages
* Plugin: Wish list for WooCommerce
*/
jQuery(document).ready(function($){
//Get your wish list element first (Replace it by your wish list css class)
var wish_list_div = '.wish-list';
@pablo-sg-pacheco
pablo-sg-pacheco / function.php
Last active April 19, 2017 17:40 — forked from hlashbrooke/function.php
WooCommerce - Check if you are running a specified WooCommerce version (or higher)
<?php
function woocommerce_version_check( $version = '3.0' ) {
if ( class_exists( 'WooCommerce' ) ) {
global $woocommerce;
if( version_compare( $woocommerce->version, $version, ">=" ) ) {
return true;
}
}
return false;
}