Skip to content

Instantly share code, notes, and snippets.

View kaweski's full-sized avatar
👩‍💻
Focusing

Natasha Kaweski kaweski

👩‍💻
Focusing
View GitHub Profile
@kaweski
kaweski / 0_reuse_code.js
Created October 28, 2015 19:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kaweski
kaweski / functions.php
Created October 14, 2016 14:01
Retira o estilo padrão do Woocommerce
// Remove each style one by one
add_filter( 'woocommerce_enqueue_styles', 'jk_dequeue_styles' );
function jk_dequeue_styles( $enqueue_styles ) {
unset( $enqueue_styles['woocommerce-general'] ); // Remove the gloss
unset( $enqueue_styles['woocommerce-layout'] ); // Remove the layout
unset( $enqueue_styles['woocommerce-smallscreen'] ); // Remove the smallscreen optimisation
return $enqueue_styles;
}
// Or just remove them all in one line
@kaweski
kaweski / multiple_custom_field.php
Last active January 11, 2017 19:41
Lista os posts com valor de custom field especificado.
<?php
// args
$args = array(
'numberposts' => -1,
'post_type' => 'event',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => 'location',
@kaweski
kaweski / counter.php
Created October 19, 2016 19:11
Contador de itens que atualiza via AJAX
<?php
// Ensure cart contents update when products are added to the cart via AJAX (place the following in functions.php)
add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' );
function woocommerce_header_add_to_cart_fragment( $fragments ) {
ob_start();
?>
<a class="cart-contents" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf (_n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a>
<?php
$fragments['a.cart-contents'] = ob_get_clean();
@kaweski
kaweski / check.php
Last active January 11, 2017 19:41
Produtos com desconto em destaque.
<?php
/**
* Função que verifica se possui produtos com o desconto especificado
*/
function qwp_check_products( $meta_value_min, $meta_value_max ) {
$custom_field = 'qdwp_product_discount';
$args = array(
'numberposts' => 8,
@kaweski
kaweski / functions.php
Last active January 11, 2017 19:41
Criação de widget
<?php
// Creating the widget
class wpb_widget extends WP_Widget {
function __construct() {
parent::__construct(
// Base ID of your widget
'wpb_widget',
// Widget name will appear in UI
@kaweski
kaweski / functions.php
Created October 24, 2016 18:50
Verifica se a página atual é filha de alguma outra
/*==================================================
= Verifica se é página filha =
==================================================*/
function is_child($pageID) {
global $post;
if( is_page() && ($post->post_parent==$pageID) )
return true;
else
return false;
<?php
/**
*
* Safe Search and Replace on Database with Serialized Data v2.0.1
*
* This script is to solve the problem of doing database search and replace when
* developers have only gone and used the non-relational concept of serializing
* PHP arrays into single database columns. It will search for all matching
* data on the database and change it, even if it's within a serialized PHP
* array.
@kaweski
kaweski / functions.js
Created October 24, 2016 20:13
Números animados
/*========================================
= Números Animados =
========================================*/
$.fn.countTo = function(options) {
// merge the default plugin settings with the custom options
options = $.extend({}, $.fn.countTo.defaults, options || {});
// how many times to update the value, and how much to increment the value on each update
var loops = Math.ceil(options.speed / options.refreshInterval),
@kaweski
kaweski / style.less
Created October 25, 2016 13:20
Efeitinho
.qwp-thumbnail {
border-radius: @border-radius-xs;
position: relative;
overflow: hidden;
z-index: 1;
}
.qvp-video-thumb {
.qwp-thumbnail;
margin-top: 0 0 @margin-sm 0;