Skip to content

Instantly share code, notes, and snippets.

View cuxaro's full-sized avatar

Ivan Barreda cuxaro

View GitHub Profile
@cuxaro
cuxaro / gdpr-hooks.php
Created January 17, 2022 20:55
hooks GDPR WordPress
<?php
add_action('init', function () {
if (function_exists('gdpr_cookie_is_accepted')) :
if (gdpr_cookie_is_accepted('thirdparty')) :
//Aquí va el código a ejecutar
@cuxaro
cuxaro / colectiva-woof.css
Last active March 5, 2021 13:43
WOOF CSS La Colectiva
.chosen-container-single .chosen-single {
border: 0;
box-shadow: none;
background: 0;
}
.chosen-container {
font-size: 15px;
}
//https://ivanbarreda.com/wptv-shortcode/
/*
Guide of css elements in plugin
.wptv_novideos
.wptv_container
<?php
//https://es.wordpress.org/plugins/acf-to-rest-api/
//Versión minima para funcione 3
define( 'ACF_TO_REST_API_REQUEST_VERSION', 3 );
// Opción de mostrar o no en RestAPI
add_filter( 'acf/rest_api/field_settings/show_in_rest', '__return_true' );
@cuxaro
cuxaro / wpjson_cambiar_base_slug_full.php
Created May 28, 2020 22:48
WP-JSON.com Cambiar el SLUG Base Full
<?php
/*
Plugin Name: WP-JSON.com Cambiar el SLUG Base
Plugin URI: https://wp-json.com/cammbiar-slug-base
Description: WP-JSON.com Cambiar el SLUG Base
Version: 1.0
Author: Ivan Barreda
Author URI: https://ivanbarreda.com
License: GPL3
@cuxaro
cuxaro / wpjson_cambiar_base_slug_lite.php
Last active May 28, 2020 22:48
WP-JSON.com Cambiar el SLUG Base Lite
<?php
/*
Plugin Name: WP-JSON.com Cambiar el SLUG Base
Plugin URI: https://wp-json.com/cammbiar-slug-base
Description: WP-JSON.com Cambiar el SLUG Base
Version: 1.0
Author: Ivan Barreda
Author URI: https://ivanbarreda.com
License: GPL3
*/
@cuxaro
cuxaro / Extra Field Validation for WP-login.php
Created May 14, 2020 10:29
Add extra text field in login screen of WordPress and compare it with the string in own code
<?php
add_action('login_form', 'ib_extra_field_login_form_func');
function ib_extra_field_login_form_func()
{
?>
<p>
<label for="ib_extra_login_field">My extra field<br>
<input type="text" tabindex="20" size="20" value="" class="input" id="ib_extra_login_field" name="ib_extra_login_field"></label>
//Check if the header HTTP_CF_CONNECTING_IP exist
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
}
/* That's all, stop editing! Happy blogging. */
//bulk_actions- The Hook
//edit-shop The Custom Action
//_order The Post Type
add_filter( 'bulk_actions-force-guest-owner_order', 'buzz_force_guest_owner_woocommerce_order_bulk', 20, 1 );
function buzz_force_guest_owner_woocommerce_order_bulk( $actions ) {
$actions['force_guest_owner'] = __( 'Force Guest Owner', 'woocommerce' );
return $actions;
}
function get_all_orders_that_have_a_product_variation( $variation_id ){
global $wpdb;
// Getting all Order IDs with that variation ID
$order_ids_arr = $wpdb->get_col( $wpdb->prepare( "
SELECT DISTINCT items.order_id
FROM {$wpdb->prefix}woocommerce_order_items AS items
LEFT JOIN {$wpdb->prefix}woocommerce_order_itemmeta AS itemmeta ON items.order_item_id = itemmeta.order_item_id
WHERE meta_key LIKE '_variation_id'