Skip to content

Instantly share code, notes, and snippets.

View taciara's full-sized avatar
🏠
Working from home

Taciara Furtado taciara

🏠
Working from home
View GitHub Profile
@luizbills
luizbills / code.php
Last active July 26, 2023 11:10
Button for clear/empty cart in WooCommerce
<?php
add_action( 'woocommerce_cart_coupon', 'lpb_woocommerce_empty_cart_button' );
function lpb_woocommerce_empty_cart_button () {
$cart_url = add_query_arg( 'empty_cart', 'yes', wc_get_cart_url() );
$label = 'Empty cart';
echo '<a href="' . esc_url( $cart_url ) . '" class="button">' . $label . '</a>';
}
add_action( 'wp_loaded', 'lpb_woocommerce_empty_cart_action', 20 );
@taciara
taciara / code.php
Created October 27, 2022 19:25 — forked from luizbills/code.php
Copy custom terms when duplicatin a woocommerce product
<?php
// credits: https://github.com/woocommerce/woocommerce/issues/17487#issuecomment-565433819
add_action( 'woocommerce_product_duplicate', function ( $duplicate, $product ) {
$taxonomies = [ 'taxonomy1', 'taxonomy2' ];
foreach ( $taxonomies as $taxonomy ) {
$terms = get_the_terms( $product->get_id(), $taxonomy );
if ( ! is_wp_error( $terms ) ) {
wp_set_object_terms( $duplicate->get_id(), wp_list_pluck( $terms, 'term_id' ), $taxonomy );
}
@luizbills
luizbills / code.php
Last active October 27, 2022 19:59
Copy custom terms when duplicatin a woocommerce product
<?php
// credits: https://github.com/woocommerce/woocommerce/issues/17487#issuecomment-565433819
add_action( 'woocommerce_product_duplicate', function ( $duplicate, $product ) {
$taxonomies = [ 'taxonomy1', 'taxonomy2' ];
foreach ( $taxonomies as $taxonomy ) {
$terms = get_the_terms( $product->get_id(), $taxonomy );
if ( ! is_wp_error( $terms ) ) {
wp_set_object_terms( $duplicate->get_id(), wp_list_pluck( $terms, 'term_id' ), $taxonomy );
}
@dkvadratu
dkvadratu / http_headers_security.htaccess
Last active June 17, 2024 15:44
{HTACCESS} HTTP headers for security in .htaccess file
# Check your website headers here: https://www.serpworx.com/check-security-headers/ or https://gf.dev/
# This configuration works for WP, WC on LiteSpeed server. Be careful. Test site after installing. All lines are explained are in serpworx.com tester.
# More docs:
# https://www.netsparker.com/whitepaper-http-security-headers/#XFrameOptionsHTTPHeader
# https://owasp.org/www-project-secure-headers/
# https://www.keycdn.com/blog/http-security-headers
# WordPress plugin for Headers setup https://wordpress.org/plugins/http-headers/
# Main security options in .htaccess file:
@brycejacobson
brycejacobson / theme-functions.php
Created August 28, 2018 20:08
Set sizes attribute for responsive images and better performance in WordPress
<?php
/**
* Set sizes attribute for responsive images and better performance
*
* @param array $attr markup attributes.
* @param object $attachment WP_Post image attachment post.
* @param string|array $size named image size or array.
* @return array markup attributes
*/
@sazzadh
sazzadh / Image-Radio-for-Contact form-7.css
Created August 16, 2018 12:16
Image Radio for Contact form 7
/*
Image Radio for Contact form 7
=============================*/
.pf4_form_image_fields{
display:flex;
flex-wrap:wrap;
margin-left: -20px;
margin-right: -20px;
}
.pf4_form_image_field{
@ebetancourt
ebetancourt / wp-disable-plugin-update.php
Last active June 6, 2024 09:57 — forked from rniswonger/wp-disable-plugin-update.php
WordPress - Disable specific plugin update check
<?php
// have to add that opening tag to get syntax highlighting... ¯\_(ツ)_/¯
/**
* Prevent update notification for plugin
* http://www.thecreativedev.com/disable-updates-for-specific-plugin-in-wordpress/
* Place in theme functions.php or at bottom of wp-config.php
*/
function disable_plugin_updates( $value ) {
@taciara
taciara / functions.php
Created May 19, 2018 22:48 — forked from douglasanro/functions.php
Create WordPress settings page For custom options
<?php
// Let’s instantiate this class in our functions.php file:
if( is_admin() ) {
require 'simple_settings_page.php';
new simple_settings_page();
}
@ricardobrg
ricardobrg / woocommerceinstalments.php
Last active November 23, 2020 13:29
Add instalments in product page
<?php
add_action( 'woocommerce_single_product_summary', 'woocommerce_total_product_price', 31 );
function woocommerce_total_product_price() {
global $woocommerce, $product;
// let's setup our divs
echo sprintf('<div id="product_total_price" style="margin-bottom:20px;display:none">%s %s</div>','Total do Produto','<span class="price">'.$product->get_price().'</span>');
echo sprintf('<div id="cart_total_price" style="margin-bottom:20px;display:none">%s %s</div>','Total do Carrinho','<span class="price">'.$product->get_price().'</span>');
?>
<script>
jQuery(function($){
@taciara
taciara / WP - Adicionando Informações no <header>
Last active August 16, 2017 21:38
Wordpress & Woocommerce
<?php
//Inserir Informacoes no Header - Isso você coloca no functions.php ;)
add_action( 'wp_head', 'InformacoesDoHeader', 1 );
function InformacoesDoHeader () { ?>
Aqui você coloca as informações que precisa adicionar header do seu site. Meta, Css....
<?php } ?>