Skip to content

Instantly share code, notes, and snippets.

View elpuas's full-sized avatar
💻
coding

Alfredo Navas-Fernandini elpuas

💻
coding
View GitHub Profile
@elpuas
elpuas / billing-details-translation.php
Created April 12, 2022 18:31 — forked from helgatheviking/billing-details-translation.php
Change Billing Details text on free checkout
function kia_translate_billing_details_when_free( $translated_text, $untranslated_text, $domain ) {
if ( function_exists( 'wc' ) && 'woocommerce' === $domain ) {
//make the changes to the text
switch( $untranslated_text ) {
case 'Billing details':
if ( ! WC()->cart->needs_shipping() && 0.0 === floatval( WC()->cart->get_total( 'edit' ) ) ) {
$translated_text = __( 'NOT billing details', 'kia_textdomain' );
@elpuas
elpuas / acf.php
Created February 16, 2022 20:31 — forked from khleomix/acf.php
Load icon files dynamically as ACF select options
<?php
/**
* Load icons dynamically into the `icon_picker` select field.
*
* @param array $field field options.
* @return array new field choices.
*
* @author JC Palmes
*/
function acf_load_icon_picker_field_choices( $field ) {
@elpuas
elpuas / functions.php
Last active January 18, 2022 13:58 — forked from noahduncan/functions.php
Automatically Sync ACF Fields on dev environments
<?php
/*
Plugin Name: ACF Auto Sync
Plugin URI:
Description: Plugin that automatically syncs the database with local json
Version: 1.0
Author: Noah Duncan <noah@zingstudios.com>
Updated by: Alfredo Navas <elpuas@gmail.com>
*/
// Turn debugging on
define('WP_DEBUG', true);
// Tell WordPress to log everything to /wp-content/debug.log
define('WP_DEBUG_LOG', true);
// Turn off the display of error messages on your site
define('WP_DEBUG_DISPLAY', false);
// For good measure, you can also add the follow code, which will hide errors from being displayed on-screen
@elpuas
elpuas / functions.php
Created October 25, 2021 16:42 — forked from guydumais/functions.php
WordPress ➧ Change Locale Dynamically in WordPress
/**
* Change Locale Dynamically in WordPress.
*
* @author Guy Dumais.
* @link https://en.guydumais.digital/change-locale-dynamically-in-wordpress/
*/
// Filters all language attributes in the html tag.
add_filter( 'language_attributes', $af = function( $output, $doctype ) {
<?php
/**
* Sort forms in Gravity Forms block in alphabetical order.
*
* @param array $forms A collection of active forms on site.
*/
add_filter( 'gform_block_form_forms', function( $forms ) {
usort( $forms, function( $a, $b ) {
@elpuas
elpuas / get-first-category.php
Created February 25, 2020 17:05 — forked from hslaszlo/get-first-category.php
Get first category name or id from wordpress post
<?php
// in the loop
$category = get_the_category();
$currentcat = $category[0]->cat_ID;
$currentcatname = $category[0]->cat_name;
$currentcatslug = $category[0]->slug;
// outside the loop
global $post;
$categories = get_the_category($post->ID);
@elpuas
elpuas / function.php
Created June 29, 2019 23:42 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
// Add to existing function.php file
// Disable support for comments and trackbacks in post types
function df_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
@elpuas
elpuas / device.css
Created November 20, 2017 20:36 — forked from jsoverson/device.css
Quick css hacks to target android/ios
.visible-android {
display:none;
}
.visible-ios {
display:none;
}
.on-device .visible-android, .on-device .visible-android {
display:inherit;
}
.device-ios .visible-android {
@elpuas
elpuas / carousel-start.js
Created August 26, 2017 20:16 — forked from barbwiredmedia/carousel-start.js
bootstrap slider WordPress Dynamic Content ACF Custom Post Type loop Query Posts or gallery. Credit to Doug for this fantastic solution http://www.lanexa.net/2013/03/update-bootstrap-carousel-wordpress-dynamic-content/