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 / 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) {
@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 / 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 / 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 / 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 / .htaccess
Last active December 11, 2022 08:46
HTACCESS rewrite rule not working on SiteGround
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# don't rewrite anything in docs folder to wordpress
RewriteCond %{REQUEST_URI} !^/(docs/*) [NC]
sudo chown -vR webuser /not/webuser/
@andymagill
andymagill / marketo-form-overrides.scss
Last active May 4, 2022 16:02
Marketo Form Overrides
// marketo form overrides
// from https://jennamolby.com/how-to-create-responsive-marketo-forms/
.mktoForm {
&,
.mktoLabel ,
.mktoHtmlText ,
.mktoFormRow,
// remove terrible experimental layout support
remove_filter( 'render_block', 'wp_render_layout_support_flag', 10, 2 );
function understrap_experimental_layout( $metadata ) {
if ( !empty($metadata['supports']['__experimentalLayout'])) {
$metadata['supports']['__experimentalLayout'] = false;
}
return $metadata;
}
add_filter( 'block_type_metadata', 'understrap_experimental_layout', 10, 1 );