Skip to content

Instantly share code, notes, and snippets.

View jeffsebring's full-sized avatar

Jeff Sebring jeffsebring

  • Spokane, Washington USA
View GitHub Profile
#!/bin/bash
##########################
## Check if run as root ##
##########################
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
@jeffsebring
jeffsebring / tenup_dont_publish_pulled_post.php
Created November 22, 2013 01:05
Stop Push Syndication Plugin from Auto Publishing
<?php
// Remove `publish_pulled_post` hook from `syn_pre_pull_posts` filter during cron
add_filter( 'syn_pre_pull_posts', 'tenup_dont_publish_pulled_post' ), 100 );
function tenup_dont_publish_pulled_post( $posts ) {
// Remove auto publish action
if ( class_exists( 'Syndication_WP_XML_Client' ) )
remove_action( 'syn_post_pull_new_post', array( 'Syndication_WP_XML_Client' , 'publish_pulled_post' ), 10, 5 );
@jeffsebring
jeffsebring / pu01_logged_in_redirect.php
Created November 14, 2013 19:46
Logged in Home Page Redirect
<?php
/**
* Logged in Home Page Redirect
**/
add_action( 'template_redirect', 'pu01_logged_in_homepage' );
// Redirect logged in users from home page to admin
function pu01_logged_in_homepage() {
@jeffsebring
jeffsebring / pu01_options_modal_uploader.js
Created September 16, 2013 19:31
WP 3.5 Options Page Modal Uploader
jQuery( document ).ready( function() {
function pu01_show_image() {
var pu01_image_1 = jQuery( '#pu01_image_1' ).val(),
pu01_image_2 = jQuery( '#pu01_image_2' ).val(),
pu01_image_3 = jQuery( '#pu01_image_3' ).val();
jQuery( '#pu01_image_1_preview' ).after( '<div id="pu01_image_1_preview_image"><img width="300" height="140" src="' + pu01_image_1 + '" /></div>' );
jQuery( '#pu01_image_2_preview' ).after( '<div id="pu01_image_2_preview_image"><img width="300" height="140" src="' + pu01_image_2 + '" /></div>' );
@jeffsebring
jeffsebring / pu01_metabox_uploader_modal.html
Last active December 23, 2015 05:09
WP 3.5 Metabox Uploader
<script>
var file_frame;
var wp_media_post_id = wp.media.model.settings.post.id;
var set_to_post_id = <?php echo get_the_ID(); ?>;
jQuery('.upload_image_button').on('click', function( event ){
event.preventDefault();
@jeffsebring
jeffsebring / thumbnail_fallback.php
Created August 1, 2013 16:58
thumbnail size fallback
/**
* Print Selected Thumbnail Images
* @return string|bool thumbnail html or false
*/
function pU01_thumbnail_img( $size = 'secondary_image', $attr = array() ) {
// Fallback to featured image
if ( ! $thumbnail_id = get_post_meta( get_the_ID(), get_post_type() . "_{$size}_thumbnail_id", true ) ) {
if ( ! $thumbnail_id = get_post_meta( get_the_ID(), "_thumbnail_id", true ) )
@jeffsebring
jeffsebring / date-archive-not-found.php
Created July 29, 2013 04:07
Disable Date Based Archives
<?php
// This will redirect all date based archive to a page that does not exist,
// effectively disabling them, with a 404 error code
add_action( 'template_redirect', 'pu01_date_archive_not_found' );
function pu01_date_archive_not_found() {
if ( is_date() ) {
@jeffsebring
jeffsebring / js_metabox_example.php
Last active December 16, 2015 06:49
Simple Metabox Example w/ 20 Character Validation Error
<?php
/**
* Simple Metabox Example
*
* Validates string is under 20 characters
*
* Copyright (C) 2013 Jeff Sebring <http://jeffsebring.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@jeffsebring
jeffsebring / newp.sh
Created November 21, 2012 21:06
New WordPress Install with separated directories
#!/bin/sh
wget http://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
rm latest.tar.gz
mv wordpress __
mv __/wp-content _
echo "<?php" >> index.php
echo "define( 'WP_USE_THEMES', true );" >> index.php
echo "require('./__/wp-blog-header.php');" >> index.php
@jeffsebring
jeffsebring / hide_dashboard_jazz.php
Created November 17, 2012 07:32
Hide Dashboard Jazz
function js_remove_dashboard_widgets() {
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'dashboard_recent_drafts', 'dashboard', 'side' );
remove_meta_box( 'dashboard_primary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_secondary', 'dashboard', 'side' );
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );