Skip to content

Instantly share code, notes, and snippets.

View itsHall's full-sized avatar
💭
Living

Tyler Hall itsHall

💭
Living
View GitHub Profile
@itsHall
itsHall / gulpfile.js
Last active September 27, 2019 20:57
Gulpfile with Sourcemaps and File Minification
'use strict';
var config = {
project: 'bta',
stylePaths: [
'./scss/style.scss'
],
jsPaths: [
'./js/*'
]
@itsHall
itsHall / *.svg.html
Last active November 24, 2020 16:44
XML Tag to Allow SVG Upload | WordPress
// SVG files must include below line before the opening <svg> tag to pass validation when uploading to the WordPress Media Gallery.
<?xml version="1.0" encoding="utf-8"?>
@itsHall
itsHall / cleanup-wpml-translations.txt
Last active January 5, 2021 15:19 — forked from vanpariyar/gist:3112c09a9582cc9c356c32adb6ffa5e9
[Solved] Fatal error: Uncaught TypeError: Argument 1 passed to WPML_Media_Post_Images_Translation::translate_images_in_post_content()
Fatal error: Uncaught TypeError: Argument 1 passed to WPML_Media_Post_Images_Translation::translate_images_in_post_content() must be an instance of WP_Post, null given, called in /www/htdocs/w0184db4/helmut-kostner.it/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php on line 107 and defined in /www/htdocs/w0184db4/helmut-kostner.it/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php:130 Stack trace: #0 /www/htdocs/w0184db4/helmut-kostner.it/wp-content/plugins/wpml-media-translation/classes/media-translation/class-wpml-media-post-images-translation.php(107): WPML_Media_Post_Images_Translation->translate_images_in_post_content(NULL, Object(WPML_Post_Element)) #1 /www/htdocs/w0184db4/helmut-kostner.it/wp-includes/class-wp-hook.php(288): WPML_Media_Post_Images_Translation->translate_images(5) #2 /www/htdocs/w0184db4/helmut-kostner.it/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:01
Change Search Path | WP
<?php
// Changes /s/ search path to /search/
function wpb_change_search_url() {
if ( is_search() && ! empty( $_GET['s'] ) ) {
wp_redirect( home_url( "/search/" . urlencode( get_query_var( 's' ) ) ) );
exit();
}
}
add_action( 'template_redirect', 'wpb_change_search_url' );
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:01
Remove Gutenberg Block Library CSS from loading on the frontend
<?php
function mpc_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-block-style' ); // Remove WooCommerce block CSS
}
add_action( 'wp_enqueue_scripts', 'mpc_remove_wp_block_library_css', 100 );
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:01
Disable RSS Feed and Show Message
<?php
function itsme_disable_feed() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'itsme_disable_feed', 1);
add_action('do_feed_rdf', 'itsme_disable_feed', 1);
add_action('do_feed_rss', 'itsme_disable_feed', 1);
add_action('do_feed_rss2', 'itsme_disable_feed', 1);
add_action('do_feed_atom', 'itsme_disable_feed', 1);
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:01
Set Page Parents of CPT | WP
<?php
// Set page parents of Custom Post Types - in the Organisation Setting ACF Options page
// Based upon Joe Sexton's blog post http://www.webtipblog.com/setting-wordpress-custom-post-type-parent-specific-page/
function mpc_cpt_parent_page( $data, $postarr ) {
global $post;
// Verify if this is an auto save routine.
// If it is, our form has not been submitted - so we don't want to do anything
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:02
Allow Upload of WebP to WordPress Media Gallery
<?php
function webp_upload_mimes( $existing_mimes ) {
// add webp to the list of mime types
$existing_mimes['webp'] = 'image/webp';
// return the array back to the function with our added mime type
return $existing_mimes;
}
add_filter( 'mime_types', 'webp_upload_mimes' );
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:02
Sort Repeater By Sub Field Alphabetically | Timber/Twig/WordPress
<?php
// Get repeater value
$repeater = get_field('team', [--POST ID--]);
// Obtain sub fields
foreach ($repeater as $key => $row) {
$the_image[$key] = $row['image'];
$the_first_name[$key] = $row['first_name'];
$the_last_name[$key] = $row['last_name'];
}
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:03
Remove Unused hreflang Tags | WPML
<?php
function remove_unneeded_hreflang( $hreflang_items ){
global $post;
global $sitepress;
$t_post_id = $sitepress->get_element_trid( $post->ID, 'post_page' );
$translations = $sitepress->get_element_translations($t_post_id, 'post_page', false, true);
if(count($translations)==1){
unset($hreflang_items['es']);