Skip to content

Instantly share code, notes, and snippets.

View corenominal's full-sized avatar

Philip Newborough corenominal

View GitHub Profile
@corenominal
corenominal / wp_conditional_enqueue_styles_and_scripts.php
Last active January 9, 2017 14:10
Conditionally include additional CSS and JS for page templates in WordPress
<?php
if ( ! defined( 'WPINC' ) ) { die('Direct access prohibited!'); }
/**
* Conditionally include additional CSS and JS for page templates
*/
function conditionally_enqueue_scripts()
{
// Test for page template
if( is_page_template() )
{
@corenominal
corenominal / functions.php
Last active December 7, 2016 15:07
Remove buttons from the WordPress TinyMCE editor to make a simpler interface
<?php
// Remove buttons from TinyMCE to make a simpler interface
function simpler_tinymce_buttons( $buttons )
{
$remove = array(
'aligncenter',
'alignright',
'alignleft',
'hr',
'wp_more',
@corenominal
corenominal / global_is_user_logged_in.php
Created May 6, 2016 20:28
WordPress action rest_api_init hook to set a global variable for testing whether or not the user is logged in
<?php
function global_is_user_logged_in()
{
global $iewp_crunchstats_logged_in;
$is_user_logged_in = false;
if ( is_user_logged_in() == true )
{
$is_user_logged_in = true;
}
}
@corenominal
corenominal / mail-test.sh
Last active February 25, 2016 09:51
A really simple Shell script used for sending a test email
#!/bin/bash
HOST=`cat /etc/hostname`
SUBJECT="Test Email from $HOST"
TO="email@example.com"
MSG="/tmp/mail-test.msg"
echo "This is a test email message from $HOST." > $MSG
echo "Please do not respond to this message." >> $MSG
mail -s "$SUBJECT" "$TO" < $MSG
exit
@corenominal
corenominal / custom_loop.php
Created January 6, 2016 19:40
An example WordPress custom loop to show all custom post types.
<?php
// Set-up the loop with all custom post types
$post_types = array( 'post', 'link', 'snippet', 'doodle' );
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_type' => $post_types,
'paged' => $paged,
'posts_per_page' => 10
);
query_posts( $args );
@corenominal
corenominal / fix_allcustomposts_pagination.php
Last active January 6, 2016 19:30
A WordPress function to fix pagination when combining custom post types in a single loop.
<?php
/**
* WordPress function to fix pagination when combining custom post types in a single loop.
*/
function fix_allcustomposts_pagination($qs)
{
if( !isset( $qs['post_type'] ) && isset($qs['paged']) )
{
$qs['post_type'] = get_post_types($args = array(
'public' => true,

foo logo #02

An animated HTML5 canvas logo. I was toying with the idea of using this for a project, but opted against it.

A Pen by Philip Newborough on CodePen.

License.

foo logo #01

An animated HTML5 canvas logo. I was toying with the idea of using this for a project, but opted against it.

A Pen by Philip Newborough on CodePen.

License.

@corenominal
corenominal / API Key Generator.markdown
Created December 12, 2015 22:40
API Key Generator
@corenominal
corenominal / disable-wp-emoji.php
Created December 12, 2015 13:01
Functions to disable all WordPress emoji. No more smiling faces :)
<?php
/**
* Kill all emojis
* ===============
* See: http://wordpress.stackexchange.com/a/185578
*/
function disable_emojis()
{
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );