Skip to content

Instantly share code, notes, and snippets.

@danielcharrua
danielcharrua / functions.php
Last active September 27, 2022 12:05
Block cookies with gdpr-cookie-compliance (Facebook, Analytics, Omnisend)
<?php
// https://wordpress.org/plugins/gdpr-cookie-compliance/
/* disable fbp cookie on gdpr_cookie plugin */
add_filter('facebook_for_woocommerce_integration_pixel_enabled', 'gdpr_cookie_facebook_wc', 20);
function gdpr_cookie_facebook_wc()
{
$enable_fb_wc = true;
if (function_exists('gdpr_cookie_is_accepted')) :
$enable_fb_wc = gdpr_cookie_is_accepted('thirdparty');
@danielcharrua
danielcharrua / necessary_cookies.html
Created August 29, 2022 11:03
Necessary WordPress & GDPR Cookie Consent cookies for RGPD
<table>
<thead>
<tr>
<th>Nombre</th>
<th>Duración</th>
<th>Tipo </th>
<th>Finalidad</th>
</tr>
</thead>
<tbody>
@danielcharrua
danielcharrua / template.html
Last active August 29, 2022 10:58
Active Campaign blank email template
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" lang="es" />
<style type="text/css" media="screen">
body {
margin: 0;
padding: 0;
background-color: #ffffff;
@danielcharrua
danielcharrua / preserve-page-and-taxonomy-hierarchy.php
Created August 18, 2022 11:57
Preserve Page and Taxonomy Hierarchy on Edit Menus Screen
<?php
/*
Plugin Name: Preserve Page and Taxonomy Hierarchy on Edit Menus Screen
Version: 0.1
Plugin URI: https://core.trac.wordpress.org/ticket/18282
Description: Disables paging for hierarchical post types and taxonomies on Edit Menus screen to preserve proper hierarchy in meta boxes.
Author: Sergey Biryukov
Author URI: http://profiles.wordpress.org/sergeybiryukov/
*/
@danielcharrua
danielcharrua / wp_auto_install.sh
Last active October 20, 2022 13:09 — forked from nicomollet/wp_auto_install.sh
WP-CLI auto install script
#!/bin/bash
# Default options
LOCALE="es_ES"
DB_HOST='localhost:3306'
printf "Name of the project? eg My Project: "
read PROJECT_NAME
printf "Slug of the project? eg myproject: "
@danielcharrua
danielcharrua / woocommerce-vat.php
Created March 15, 2022 12:53
Add NIF/CIF to WooCommerce (only as example)
<?php
/*
* Only used for example purposes, for also incluidng VAT validation and calculation
* I recommend using the plugin https://wordpress.org/plugins/wc-apg-nifcifnie-field/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@danielcharrua
danielcharrua / LearnDash_change_tooltip_msg.php
Last active March 10, 2022 18:21
Change default LearDash tooltip message on lesson when course is closed
<?php
/**
* Change lesson tooltip
* https://themespirit.com/kb/learndash-changing-tooltips/
*/
add_filter( 'learndash_lesson_row_atts', function( $data_tooltip, $lesson_id, $course_id, $user_id ) {
if ( ! empty( $data_tooltip ) ) {
@danielcharrua
danielcharrua / wc_sendcloud_tracking.php
Created March 9, 2022 13:35
Set SendCloud tracking on WooCommerce, my account > orders
<?php
/**
* Use this set of functions in functions.php with WooCommerce and SendCloud
* SendCloud plugin adds a note when tracking number is set
*
* If an order is found with the string 'SendCloud shipment' and has a URL,
* This will add the link to the tracking system to an order under my account > orders
*
*/
@danielcharrua
danielcharrua / wp_test_site_health_loopbacks.php
Last active March 10, 2022 13:05
Test WordPress sitehealth loopback
<?php
//
// A very simple PHP example that sends a HTTP POST to a remote site
// Put this file in your project root directory and execute in browser
// If you see an error, probably the Loopback on Site Health will be also failing, solve this and test again.
//
$ch = curl_init();
@danielcharrua
danielcharrua / sidebar-page-childs.php
Created February 3, 2022 11:10
Wordpress Childs in sidebar
<?php
/*
* get_page_depth
* Gets the page depth, calls get_post on every iteration
* https://gist.github.com/1039575
*/
if ( !function_exists( 'get_page_depth' ) ) {
function get_page_depth( $id=0, $depth=0 ) {
global $post;