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 / functions.php
Last active October 23, 2018 21:53
Product Open Pricing (Name Your Price) for WooCommerce - Add to cart programmatically
<?php
add_action('wp_loaded',function(){
if( is_admin() ){
return;
}
$product_id = 161;
$quantity = 1;
$variation_id = 0;
WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, array(), array(
'alg_open_price' => 99
@pablo-sg-pacheco
pablo-sg-pacheco / customize-pif-frontend-position.php
Created June 28, 2018 21:49
Customizes frontend position of Product Input field plugin
<?php
/*
Plugin Name: Customize Product Input Field Frontend Position
Description: Customizes frontend position of Product Input Field plugin
Version: 1.0.0
Author: Algoritmika Ltd
Author URI: http://algoritmika.com
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
Text Domain: customize-pif-frontend-position
@pablo-sg-pacheco
pablo-sg-pacheco / functions.php
Last active June 21, 2018 15:58
Replace input field by dropdown using the Product Open Pricing plugin
<?php
// Remove default input
add_filter( 'option_' . 'alg_wc_product_open_pricing_frontend_template', 'popwc_remove_default_input' , 10, 2 );
function popwc_remove_default_input($value){
if(!is_admin()){
$value='';
}
return $value;
}
@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
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 / 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