Skip to content

Instantly share code, notes, and snippets.

View Garconis's full-sized avatar
🐞
Debugging

Jon Fuller Garconis

🐞
Debugging
View GitHub Profile
@Garconis
Garconis / divi-update-font-weights.php
Created September 27, 2017 17:19
Divi | Add more font weights to existing Google Font options
<?php
// add more font weights
add_filter('et_builder_google_fonts', 'my_custom_google_fonts', 10);
function my_custom_google_fonts($google_fonts) {
$google_fonts['Montserrat']['styles'] = '300,300i,400,400i,600,600i,700,700i';
return $google_fonts;
}
@Garconis
Garconis / woocommerce-shipment-tracking-providers.php
Last active October 24, 2017 20:18 — forked from DustinHartzler/shipment_tracking.php
WooCommerce | Remove options from the Shipment Tracking plugin
<?php
add_filter( 'wc_shipment_tracking_get_providers', 'custom_shipment_tracking' );
function custom_shipment_tracking( $providers ) {
// unset all the ones you don't want (e.g., we kept USPS and FedEx set)
unset($providers['Australia']);
unset($providers['Austria']);
unset($providers['Brazil']);
unset($providers['Belgium']);
@Garconis
Garconis / divi-wrap-blurb-with-the-link.js
Last active October 26, 2017 18:52
Divi | Automatically wrap the blurb module with its link if it has one by using custom class
@Garconis
Garconis / display-name-as-username.php
Created November 1, 2017 16:53
WordPress | Change user Display Name to be their username after login
<?php
// Replaces default display name to login name (username). As soon as the user logs in, the setting gets changed.
add_action( 'wp_login', 'fs_format_user_display_name_on_login' );
function fs_format_user_display_name_on_login( $username ) {
$user = get_user_by( 'login', $username );
$userdata = array(
@Garconis
Garconis / functions.php
Last active December 29, 2017 13:42
Divi | Child Theme
<?php
/* Custom functions code goes here. */
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
// enqueue the parent theme stylesheet
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
@Garconis
Garconis / analytics-events.js
Created January 8, 2018 17:41
Add Google Analytics Events via jQuery
// Category > Action > Label
jQuery(document).ready(function() {
//Log GA Event for Sidebar MailChimp form submit click
jQuery('#mk-sidebar #mc-embedded-subscribe').click(function() {
ga('send', 'event', 'Subscribe', 'Click', 'Sidebar');
});
//Log GA Event for Top Bar MailChimp form submit click
jQuery('#mailchimp-top-bar .mctb-button').click(function() {
ga('send', 'event', 'Subscribe', 'Click', 'Header');
});
@Garconis
Garconis / increase-wordpress-memory.php
Created January 9, 2018 13:30
WordPress | Increase available memory for WordPress
<?php
// Add these settings to wp-config.php:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
define( 'WP_MEMORY_LIMIT', '512M' );
@Garconis
Garconis / home-anonymous-redirect.php
Created January 29, 2018 16:54
WordPress | Redirect pages to the homepage, if the user isn't logged in. Good for maintenance mode.
<?php
// if it's not the homepage and they aren't logged in, redirect to the home URL
add_action( 'template_redirect', 'fs_maintance_mode' );
function fs_maintance_mode() {
if ( !is_home() && !is_user_logged_in() ) {
wp_redirect( esc_url_raw( home_url() ) );
exit;
}
}
@Garconis
Garconis / convert-text-to-url-with-anchor.js
Created January 29, 2018 17:50
Find text of an element and change it to an anchor, while checking if it has HTTP or HTTPS protocol
(function($) {
$( ".website .sb_mod_acf_single_item" ).text(function () {
if ( ($(this).text().length >=5) && ($(this).text().substr(0, 5) != 'http:') && ($(this).text().substr(0, 5) != 'https') ) {
$(this).replaceWith( '<a href="http://' + $(this).text() + '" target="_blank">' + $(this).text() + '</a>' );
}
else {
$(this).replaceWith( '<a href="' + $(this).text() + '" target="_blank">' + $(this).text() + '</a>' );
}
});
})(jQuery);
@Garconis
Garconis / nginx-block-files-unless-logged-in.txt
Created February 16, 2018 17:44
WordPress | NGINX server rule to block access to files in a folder unless logged into WP
set $bar 0;
set $becue 0;
if ( $request_uri ~* "wp-content/uploads/private" ) {
set $bar 1;
}
if ($http_cookie ~ "wordpress_logged_in") {
set $becue 1;
}
set $barbecue "$bar:$becue";
if ($barbecue = "1:0") {