Skip to content

Instantly share code, notes, and snippets.

<?php
function sample_mailshot($mailshots) {
$mailshots[] = array(
'slug' => 'mailshot1',
'template' => 'mailshot1.php',
'page_title' => 'Mailshot 1',
);
@stompweb
stompweb / variables.less
Created October 31, 2015 17:32
Variables.less
@body-font: "Georgia", serif;
@header-font: "Helvetica", sans-serif;
/* Colours */
@brand-red: #b23636;
@brand-blue: #257eb1;
@stompweb
stompweb / style-guide.less
Created October 31, 2015 17:39
Style Guide
.style-guide() {
font-family: @body-font;
h2,
h3 {
font-family: @header-font;
}
h2 {
font-weight: 300;
@stompweb
stompweb / style.less
Last active October 31, 2015 18:22
Styles
@import "style-guide.less";
@import "variables.less";
body {
font-size: 15px;
}
h1,
h2,
h3 {
@stompweb
stompweb / editor-style.less
Created October 31, 2015 17:56
Editor Style
@import "style-guide.less";
@import "variables.less";
#tinymce {
.style-guide();
}
@stompweb
stompweb / gulpfile.js
Created October 31, 2015 18:02
gulpfile
gulp.task('editor-style', function() {
return gulp
.src('css/editor-style.less')
.pipe(less())
.pipe(autoprefixer('last 2 version', "> 1%", "ie 8"))
.pipe(minify())
.pipe(gulp.dest('css'))
.pipe(notify({ message: 'Editor Style Compiled'}));
@stompweb
stompweb / add-editor-style.php
Created October 31, 2015 18:10
add editor style
<?php
function stomp_add_editor_styles() {
add_editor_style( 'css/editor-style.css' );
}
add_action( 'admin_init', 'stomp_add_editor_styles' );
@stompweb
stompweb / issue.md
Last active November 4, 2015 19:40
WP adds -2 to end of slugs with just numbers in the title of hierarchical CPTs

Steps

  1. Create a hierarchical post type
  2. Add a post under that post type called '1990'
  3. Slug is created with -2 on the end even if a similar post doesn't already exist i.e. 1990-2

Doesn't happen for non-hierarchical post types

<?php
function maybe_filter_content() {
if ('' != sanitize_text_field($_GET['op'])) {
add_filter("the_content", "rc_content_handler");
}
}
add_action('init', 'maybe_filter_content');
@stompweb
stompweb / dont-load-yoast.php
Created February 17, 2016 19:35
Don't load Yoast
<?php
function rmt_exclude_yoast_resource_centre( $plugins ) {
if ('' == sanitize_text_field($_GET['op'])) {
return $plugins;
}
$key = array_search('wordpress-seo/wp-seo.php', $plugins);
unset( $plugins[$key] );