Skip to content

Instantly share code, notes, and snippets.

@stompweb
stompweb / gist:11321145
Last active August 29, 2015 14:00
Change menu classes
<?php
function register_my_page() {
global $my_page;
$my_page = add_menu_page( 'My Page', 'My Page', 'edit_pages', 'my_page.php', 'my_page_hook', 'dashicons-groups', 4 );
}
add_action('admin_menu', 'register_my_page');
function highlight_different_menu($parent_file){
<?php
function s17_redirect_single_posts() {
if (is_single() {
wp_redirect( home_url( '/news/' ), 301 )
exit;
}
}
<?php
function woocommerce_free_delivery_fragment( $fragments ) {
global $woocommerce;
ob_start(); ?>
<div class="promo">Show Promo Area</div>
<?php
@stompweb
stompweb / add_image_size
Created July 4, 2015 09:16
add_image_size
<?php add_image_size( 'front-page-blog', 500, 500 ); ?>
<?php add_image_size( 'blog-image-cropped', 800, 600, true ); ?>
How do you add fragments on initial load, such as menus?
How do you use forms to update posts / users?
How do you do authentication so only logged in users can update posts / users
<?php
function sample_mailshot($mailshots) {
$mailshots[] = array(
'slug' => 'mailshot1',
'template' => 'mailshot1.php',
'page_title' => 'Mailshot 1',
);
@stompweb
stompweb / pagination.php
Created June 28, 2012 19:05
WordPress Pagination
<div id="content">
<h1>Ice Creams</h1>
<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 5,
@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;