Skip to content

Instantly share code, notes, and snippets.

@Sanabria
Sanabria / gist:f9215385d190762dc72607b032d23873
Last active January 23, 2019 13:41
Add sublime to bash profile
add one line alias into your .bash_profile, then you are done:
alias subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl'
use:
subl [YOUR_FILE_PATH_TO_OPEN]
@Sanabria
Sanabria / custom-excerpt.php
Created February 25, 2019 16:05
Custom excerpt
function custom_read_more() {
return '... <a class="read-more" href="'.get_permalink(get_the_ID()).'">more&nbsp;&raquo;</a>';
}
function excerpt($limit) {
return wp_trim_words(get_the_excerpt(), $limit, custom_read_more());
}
@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' );
@Sanabria
Sanabria / Bootstrap4Nav-Sage9.md
Created April 28, 2021 17:07 — forked from smutek/Bootstrap4Nav-Sage9.md
Bootstrap 4 Walker for Sage 9

Credit

This is a frankensteind version of the current Soil nav walker, by the Roots team, and Michael Remoero's Sagextras walker. All credit goes to those good folks. :)

Use

  • Replace the contents of header.blade.php with the attached header.
  • Copy the walker.php file to the /app directory.
  • Add walker.php to the Sage required files array in resources/functions.php - eg. on a stock Sage install the entry would look like:
/**
@Sanabria
Sanabria / .htaccess
Created June 8, 2021 15:12 — forked from fitorec/.htaccess
Un simple .htaccess para wordpress
AddHandler x-httpd-php5 .php
#########################################################################
# Wordpress Base #
#########################################################################
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Stop the MySQL Service

I'm using Homebrew to stop the service

brew services stop mysql

Locate MySQL Data Directory

@Sanabria
Sanabria / woocommerce-sage-template-part-overrides.md
Created June 9, 2021 19:53 — forked from drawcard/woocommerce-sage-template-part-overrides.md
Woocommerce - Using template part overrides in Sage

So, you know how to override a template file in Woocommerce using Sage, but you're having trouble changing something within the deeper level of that template file. For example, you want to change the output HTML structure of a given part of the product page loop, or incorporate a Bootstrap class into a button element without using Jquery to inject it. Here's how you can override deeper level parts, the default WC theme elements.

Prerequisites

Now you're familiar with how to do Sage + Woocommerce templates, it's time to make it happen.

The template page override