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 / budypress-xprofile-add-states.php
Last active September 28, 2021 01:21
BuddyPress | xprofile add states as user dropdown field
<?php
/*
If you are using BP 2.1+, this will insert a State selectbox.
Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
Remove this function after the field is created.
*/
function bp_add_custom_state_list() {
@Garconis
Garconis / .htaccess
Created October 10, 2016 12:23
.htaccess rewrite HTTP to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@Garconis
Garconis / divi-mobile-submenu-toggles.css
Last active April 3, 2023 10:02
Divi | WordPress Theme | Mobile Menu Collapsible Submenus via Toggles | CSS & jQuery Tweaks in action: https://i.gyazo.com/93557e9ef5d4aad260e22c6d5896de3b.mp4
/* -- HEADER -- */
/* remove pointer event from menu module mobile wrapper */
.et_pb_module.et_pb_menu .et_mobile_nav_menu {
pointer-events: none;
}
/* make menu module hamburger icon and menu links interactive again */
.et_pb_module.et_pb_menu .et_mobile_nav_menu .mobile_menu_bar,
.et_pb_module.et_pb_menu .et_mobile_nav_menu .et_mobile_menu li a {
@Garconis
Garconis / body-time-date-classes.php
Last active August 30, 2017 22:12
WordPress | Add current time, date, and day to body classes via function
<?php
// Add the times and days to the body classes
// e.g., date-day-wednesday date-ymd-20170614 date-month-june time-military-1317 time-pm time-early-afternoon
add_filter( 'body_class', 'add_date_info_to_class_names' );
function add_date_info_to_class_names( $classes ) {
// current day of week name
$classes[] = 'date-day-' . strtolower(date_i18n('l'));
// current full date YYYYMMDD
$classes[] = 'date-ymd-' . strtolower(date_i18n('Ymd'));
@Garconis
Garconis / woocommerce-customer-order-csv-export-hacks.php
Last active August 30, 2017 22:15
WooCommerce Customer / Order CSV Export | random hacks
<?php
// Add Custom Column Headers
function wc_csv_export_modify_column_headers( $column_headers ) {
$new_headers = array(
'carrier' => 'Carrier',
'line_number' => 'Line Number',
// add other column headers here in the format column_key => Column Name
);
@Garconis
Garconis / move-divi-main-header.js
Last active November 17, 2020 06:53
Divi | Move Divi's main header UNDER the page’s slideshow/hero section.
jQuery("#main-header").insertAfter("body.home.desktop #main-content article .entry-content #above-header");
@Garconis
Garconis / post-featured-image-based-on-term.php
Last active August 30, 2017 22:14
WordPress | Set a default featured image (post thumbnail) to each post, based on the term (e.g., Tag) that is assigned to the post. Essentially this sets a featured image for the custom terms you specify (of a specified custom taxonomy).
<?php
function default_category_featured_image() {
global $post;
$featured_image_exists = has_post_thumbnail($post->ID);
$terms = get_the_terms($post->ID, 'jobtype');
$number = sizeof ($terms);
if (!$featured_image_exists) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ($attached_image) {
@Garconis
Garconis / woocommerce-customer-order-csv-export-user-custom-field.php
Last active August 30, 2017 22:09
WooCommerce Customer / Order CSV Export | Add a custom meta field from the User (Customer) associated with a WooCommerce Order
<?php
/**
* Order Export
* Within the Custom Formats > Column Mapping, add your custom column name and set the Data Source to Static, and leave the Value field blank (since we set it here instead anyway)
* This function takes that custom field (based on the name you set it to) and then finds the user associated with the order (based on the customer_id of the order), and then displays the user's custom field you specify.
*/
// Tweak content of certain fields in the order export
function fs_wc_csv_export_trim_data( $order_data ) {
for( $i = 0; $i < count( $order_data ); $i++ ) {
@Garconis
Garconis / woocommerce-customer-order-csv-export-tax-status.php
Last active August 30, 2017 22:07
WooCommerce Customer / Order CSV Export | Add a column to show custom text based on if there was sales tax or not
<?php
/**
* Order Export
* Within the Custom Formats > Column Mapping, add your custom column name and set the Data Source to Static, and leave the Value field blank (since we set it here instead anyway)
* This function sees if your order or line item had any tax, and if so, it fills your custom column with "Taxed". Otherwise, the column will say "Not Taxed".
*/
function fs_wc_csv_export_trim_data( $order_data ) {
for( $i = 0; $i < count( $order_data ); $i++ ) {
if ( isset( $order_data[ $i ]['order_line/tax_id/id'] ) ) {
@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' );