Skip to content

Instantly share code, notes, and snippets.

View andymagill's full-sized avatar
👀
Looking for Opportunities

Andrew Magill andymagill

👀
Looking for Opportunities
View GitHub Profile
@andymagill
andymagill / remove_nav_classes.php
Created November 19, 2019 21:42
Remove injected classes and ID's from navigation - WordPress
<?php
// Remove Injected classes, ID's and page ID's from navigation <li> items
function remove_nav_classes( $var ) {
if ( is_array( $var ) ) {
foreach ( $var as $key => $val ) {
if ( strpos( $val, 'item' ) > -1 && $val != 'current-menu-item' ) {
unset( $var[$key] );
}
@andymagill
andymagill / gulpfile.js
Last active November 10, 2019 00:35
Bugged gulp file, generates css in scss folder
var gulp = require("gulp");
var sass = require("gulp-sass");
var sourcemaps = require('gulp-sourcemaps');
function styles() {
return (
gulp.src('scss/**/*.scss')
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(sourcemaps.init())
@andymagill
andymagill / add_page_name_class.php
Last active November 10, 2019 16:57
Add unique class to body tag - WordPress
<?php
// Add page name to body classes
function add_page_name_class($classes)
{
global $post;
if ( is_page() || is_singular() ) {
$classes[] = sanitize_html_class($post->post_name);
}
return $classes;
}
@andymagill
andymagill / message.php
Created October 11, 2018 02:25
Why does $message return as empty string ?
<?php
$message = file_get_contents(__DIR__ . '/confirmation.html');
$replace = array(
'[site_url]' => get_site_url() . '/wp-content/themes/artists-working/img/email/',
'[email]' => $email,
'[event_id]' => $event_id,
'[address]' => $event_address
);
@andymagill
andymagill / gist:60ef259986fff30e71bb7633d763246e
Created October 11, 2018 02:17
Why does this return empty string ?
$message = file_get_contents(__DIR__ . '/confirmation.html');
$replace = array(
'[site_url]' => get_site_url() . '/wp-content/themes/artists-working/img/email/',
'[email]' => $email,
'[event_id]' => $event_id,
'[address]' => $event_address
);
foreach ($replace as $placeholder => $info) {