Skip to content

Instantly share code, notes, and snippets.

@everaldomatias
everaldomatias / gist:ec00332ed1b614a91051ca2e1486e51f
Created October 21, 2022 18:55
Add checkbox to WooCommerce login
<?php
add_action( 'woocommerce_register_form', 'custom_add_registration_privacy_policy', 11 );
function custom_add_registration_privacy_policy() {
woocommerce_form_field( 'privacy_policy_reg', array(
'class' => array('form-row privacy'),
'input_class' => array('woocommerce-form__input woocommerce-form__input-checkbox input-checkbox'),
'label_class' => array('woocommerce-form__label woocommerce-form__label-for-checkbox checkbox'),
'label' => 'I\'ve read and accept the Privacy Policy',
for file in es_ES-*.json ; do renamed="jeo-$file" ; mv "$file" "$renamed" ; done
<?php
/*
* Plugin Name: Simple Google reCAPTCHA
* Description: Simply protect your WordPress against spam comments and brute-force attacks, thanks to Google reCAPTCHA!
* Version: 3.8
* Author: Michal Novák
* Author URI: https://www.novami.cz
* License: GPLv3
* Text Domain: simple-google-recaptcha
*/
@everaldomatias
everaldomatias / get-posts-by-month.php
Created October 21, 2021 19:11
Get and separate posts by months
<?php
/**
* @author https://wordpress.stackexchange.com/users/10097/david-gard
* @link https://wordpress.stackexchange.com/questions/176141/display-posts-by-month
*/
$time_start = microtime(true);
/** Set up a date interval object for 6 monts ago (you can change as required) */
$interval = new DateInterval('P6M');
@everaldomatias
everaldomatias / routes.php
Created October 13, 2021 17:00 — forked from zanematthew/routes.php
Custom routes for using WordPress as an Application
<?php
/**
* This file handles redirecting of our templates to our given views
* dir and anything else.
*
* Check if the themer has made a theme file in their
* theme dir, if not load our default.
*
* @uses template_redirect http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect
*/
@everaldomatias
everaldomatias / aspect-ratio.scss
Created September 30, 2021 19:45
Make div with aspect-ratio 16:9 and centered image
.ratio {
// aspect-ratio: 16 / 9;
overflow: hidden;
position: relative;
&::before {
content: "";
padding-top: 56.25%;
float: left;
}
@everaldomatias
everaldomatias / wpml-get-all-terms.php
Created September 15, 2021 23:04
Return all terms, of the all languages, when use WPML plugin
<?php
/**
*
* Use this function when using the WPML plugin on your WordPress,
* to return all terms and all languages
*
* @author https://stackoverflow.com/users/2307600/alin-razvan
* @link https://stackoverflow.com/questions/66062846/wordpress-wpml-plugin-get-terms-returns-data-only-for-current-language-i-wan/#answer-66062847
* @link https://developer.wordpress.org/reference/functions/get_terms/
<?php
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var( 'paged' );
} else if ( get_query_var( 'page' ) ) {
$paged = get_query_var( 'page' );
} else {
$paged = 1;
}
@everaldomatias
everaldomatias / update-registered-taxonomy.php
Created June 23, 2021 18:00
update-registered-taxonomy.php
<?php
/**
* Change `post_tag` to hierarchical example
*
* @author Everaldo Matias <https://everaldo.dev>
*
* @see https://developer.wordpress.org/reference/hooks/init/
* @see https://developer.wordpress.org/reference/functions/get_taxonomy/
* @see https://developer.wordpress.org/reference/functions/register_taxonomy/
@everaldomatias
everaldomatias / cwebp.sh
Created May 13, 2021 02:34
Convert *.png to *.webp with webp linux package
for F in *.png; do cwebp $F -o `basename ${F%.png}`.webp; done