Skip to content

Instantly share code, notes, and snippets.

View tharmann's full-sized avatar

Tate Harmann tharmann

View GitHub Profile
@tharmann
tharmann / functions.php
Created March 2, 2020 20:29 — forked from lukecav/functions.php
Set cart expiration interval to 72 hours in WooCommerce
add_filter('wc_session_expiring', 'filter_ExtendSessionExpiring' );
add_filter('wc_session_expiration' , 'filter_ExtendSessionExpired' );
function filter_ExtendSessionExpiring($seconds) {
return 60 * 60 * 71;
}
function filter_ExtendSessionExpired($seconds) {
return 60 * 60 * 72;
}
@tharmann
tharmann / woocommerce-optimize-scripts.php
Created June 7, 2019 14:21 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
CREATE TABLE `wp_yoast_seo_links` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`url` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
`post_id` bigint(20) unsigned NOT NULL,
`target_post_id` bigint(20) unsigned NOT NULL,
`type` varchar(8) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
KEY `link_direction` (`post_id`,`type`)
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
@tharmann
tharmann / fix-wordpress-permissions.sh
Created May 30, 2019 18:45 — 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>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@tharmann
tharmann / extractcss.js
Created January 30, 2019 16:27 — forked from renoirb/extractcss.js
Extract CSS for a given element
/**
* Based on work from krasimirtsonev
*
* http://krasimirtsonev.com/blog/article/csssteal-chrome-extension-that-extracts-css
*/
// helper function for transforming
// node.children to Array
function toArray (obj, ignoreFalsy) {
var arr = [], i;
@tharmann
tharmann / functions.php
Created February 15, 2018 15:20 — forked from mantismamita/functions.php
Force SSL for media library
function have_https_for_media( $url ) {
if ( is_ssl() )
$url = str_replace( 'http://', 'https://', $url );
return $url;
}
add_filter( 'wp_get_attachment_url', 'have_https_for_media' );
@tharmann
tharmann / gw-gravity-forms-populate-field-value-into-subsequent-field.php
Created December 21, 2017 20:03 — forked from spivurno/gw-gravity-forms-populate-field-value-into-subsequent-field.php
Gravity Wiz // Gravity Forms // Populate Field Value from One Page to Field in Subsequent Page
/**
* Gravity Wiz // Gravity Forms // Populate Field from One Page to Field in Subsequent Page
* http://gravitywiz.com/
*/
// update "1074" to the ID of your form
add_filter( 'gform_pre_render_1074', function( $form ) {
foreach( $form['fields'] as &$field ) {
// update "2" to the field ID on the later page
<?php
function mail_from() {
$emailaddress = 'contact@1stwebdesigner.com';
return $emailaddress;
}
function mail_from_name() {
$sendername = "1stWebDesigner.com - Dainis";
return $sendername;
}
<?php
function clear_jetpack_published() {
if(empty($_REQUEST['post'])) {
wp_die(__('Invalid post ID or action'));
}
global $wpdb;
$id = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : '';