Skip to content

Instantly share code, notes, and snippets.

@Sanabria
Sanabria / random-repeater.php
Created November 1, 2017 22:16 — forked from wesrice/random-repeater.php
Return a random row of data from an ACF repeater field
<?php
// Get the repeater field
$repeater = get_field( 'repeater_field_name' );
// Get a random rows. Change the second parameter in array_rand() to how many rows you want.
$random_rows = array_rand( $repeater, 2 );
// Loop through the random rows if more than one is returned
if( is_array( $random_rows ) ){
@Sanabria
Sanabria / creative-cloud-disable.md
Created December 7, 2017 22:57 — forked from andreibosco/creative-cloud-disable.md
disable creative cloud startup on mac
@Sanabria
Sanabria / ChangeLabelWooCheckout.php
Created December 20, 2017 03:46 — forked from tavomak/ChangeLabelWooCheckout.php
Cambiar Los encabezados del checkout de woocommerce
//Detalles de facturación
function wc_billing_field_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Detalles de facturación' :
$translated_text = __( 'Nuevo Encabezado', 'woocommerce' );
break;
}
return $translated_text;
}
add_filter( 'gettext', 'wc_billing_field_strings', 20, 3 );
@Sanabria
Sanabria / fix-wordpress-permissions.sh
Last active April 21, 2018 18:14 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
# Source for this script: http://www.conigliaro.org/script-to-configure-proper-wordpress-permissions/
#
# To use this script, supply the full path to your wordpress directory
@Sanabria
Sanabria / .gitignore
Created October 29, 2018 03:18 — forked from salcode/.gitignore
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@Sanabria
Sanabria / fade.js
Created January 16, 2019 15:34 — forked from alirezas/fade.js
fadeIn & fadeOut in vanilla js
function fadeOut(el){
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();
@Sanabria
Sanabria / largest-tables-in-mysql-database.sql
Created November 13, 2019 22:52 — forked from Kevinlearynet/largest-tables-in-mysql-database.sql
Find the largest (sized by MB) tables in your MySQL database. Especially useful for diagnosing and fixing a bloated WordPress database.
# Find the largest tables in your MySQL database
SELECT
table_name as "Table",
table_rows as "Rows",
data_length as "Length",
index_length as "Index",
round(((data_length + index_length) / 1024 / 1024),2) as "Size (mb)"
FROM information_schema.TABLES
WHERE table_schema = "%%YOURDATABASE%%"
ORDER BY `Size (mb)` DESC
@Sanabria
Sanabria / sage-google-fonts-config.php
Created April 10, 2020 22:37 — forked from briankompanee/sage-google-fonts-config.php
WordPress: Add Google Font support to the Sage theme for roots.io
<?php
/**
* Add your Google Fonts here.
* This is specifically for the theme Sage from roots.io and goes in config.php
* Change the font name, weights and styles to what you are using as needed.
*/
define('GOOGLE_FONTS', 'Oswald:400,300,700:latin');
@Sanabria
Sanabria / functions.php
Created January 12, 2021 03:54 — forked from aliboy08/functions.php
Woocommerce - Single Product Carousel
// Modify single product images: add carousel functionality
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
add_action( 'woocommerce_before_single_product_summary', function(){
global $product;
$image_ids = [];
// featured image
if( has_post_thumbnail() ) $image_ids[] = get_post_thumbnail_id();
@Sanabria
Sanabria / replace-woocommerce-lightbox-with-lightgallery.php
Created January 12, 2021 04:30 — forked from carasmo/replace-woocommerce-lightbox-with-lightgallery.php
Replace PhotoSwipe Lightbox in WooCommerce with your own, as long as your own is LightGallery (https://github.com/sachinchoolur/lightGallery). Assumes that you've registered your js. Pardon the formatting, it got weird on me.
<?php
//don't add again
// assumes that you have registered your js for the new lightbox and that you understand what a handle is.
// Gallery Support
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-slider' );