Skip to content

Instantly share code, notes, and snippets.

@wpflames
wpflames / _header.scss
Last active October 15, 2022 06:41
Hamburger menu for WordPress custom theme
@import "menu/menu";
// Site Header
/************************************/
.site-header {
font-family: $font-primary;
// Mobile menu
.site-header-navigation {
display: flex;
@media (min-width: $md) {
@wpflames
wpflames / async.php
Created October 2, 2022 08:20
Enqueue Scripts Asynchronously
<?php defined( 'ABSPATH' ) || exit;
// =========================================================================
// ASYNC LOAD
// =========================================================================
function my_async_scripts($url){
if ( strpos( $url, '#asyncload') === false )
return $url;
else if ( is_admin() )
return str_replace( '#asyncload', '', $url );
@wpflames
wpflames / functions.php
Created October 2, 2022 07:43
Automatically set the image Title, Alt-Text, Caption & Description upon upload
<?php defined( 'ABSPATH' ) || exit;
/* Automatically set the image Title, Alt-Text, Caption & Description upon upload
--------------------------------------------------------------------------------------*/
function my_set_image_meta_upon_image_upload( $post_ID ) {
// Check if uploaded file is an image, else do nothing
if ( wp_attachment_is_image( $post_ID ) ) {
@wpflames
wpflames / webpack-config.js
Created October 1, 2022 15:41
Changing file entry and output of build scripts
const path = require('path');
const defaultConfig = require("./node_modules/@wordpress/scripts/config/webpack.config");
module.exports = {
...defaultConfig,
entry: {
index: path.resolve( __dirname, 'assets/js', 'index.js' ),
},
output: {
filename: '[name].js',
@wpflames
wpflames / package.json
Created October 1, 2022 14:38
package.json
{
"name": "underscore-theme",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "wp-scripts build",
"start": "wp-scripts start",
"dev": "wp-scripts start",
"devFast": "wp-scripts start",
@wpflames
wpflames / functions.php
Last active October 1, 2022 09:00
File Renaming on Upload without plugin in WordPress
<?php
// =============================================================
// Remove accents from uploaded filenames
// =============================================================
function wpflames_sanitize_file_name( $filename ) {
// Remove chars with accents etc, also replaces € with E.
$sanitized_filename = remove_accents( $filename );
@wpflames
wpflames / functions.php
Created September 7, 2022 17:56
Remove Genesis Admin Warnings
// =============================================================
// Remove Genesis Admin Warnings
// =============================================================
function remove_genesis_admin_warnings() {
echo '<style>
#genesis-page-builder-update,
#genesis-custom-blocks-pro-update{
display: none;
}
</style>';
@wpflames
wpflames / .htaccess
Created July 10, 2022 08:53
Redirect Domain Without Changing URL
RewriteEngine on
RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.OLDDOMAIN\.com$
RewriteRule ^(.*) "https\:\/\/NEWDOMAIN\.com\/$1" [R=301,L]
@wpflames
wpflames / past.php
Last active June 29, 2022 11:48
ACF Query Upcoming and Past Events
<?php
$title = 'Past Events';
$compare_operator = '<';
include('event-query.php');
@wpflames
wpflames / upcoming.php
Last active June 29, 2022 11:48
ACF Query Upcoming and Past Events
<?php
$title = 'Upcoming Events';
$compare_operator = '>=';
include('event-query.php');