Skip to content

Instantly share code, notes, and snippets.

View petenelson's full-sized avatar

Pete Nelson petenelson

View GitHub Profile
@petenelson
petenelson / gga-wp-remove-meta-feeds-pagination.php
Created July 26, 2012 15:25
WordPress: Remove generator and feed links meta tags
/*
Remove meta tags for generator, feed links, and pagination
Useful for landing pages or static, stand-alone sites/pages.
*/
remove_action( 'wp_head', 'wp_generator');
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'rsd_link'); // EditURI
remove_action( 'wp_head', 'wlwmanifest_link'); // Windows Live Writer
@petenelson
petenelson / customized-wordpress-login-page.php
Last active October 7, 2015 18:48
WordPress: Customized Login Page
// customized login page CSS
// from http://www.wpsyntax.com/wordpress/7-functions-white-label-wordpress
add_action('login_head', 'my_theme_custom_login');
function my_theme_custom_login() {
echo '<style type="text/css">
h1 a { background-image:url('.get_stylesheet_directory_uri().'/img/logo-login-274-63.png) !important; }
</style>';
}
// link login page logo to the site's URL instead of wordpress.org
@petenelson
petenelson / remove_unwanted_menu_and_toolbar_items_wordpress.php
Created July 30, 2012 19:58 — forked from BronsonQuick/remove_unwanted_menu_and_toolbar_items_wordpress.php
WordPress: Remove unwanted menu items from the Menu Bar and Toolbar
<?php
/* Remove unwanted menus in WordPress e.g. Posts, Comments and Links */
/* Inspired by http://wordpress.org/extend/plugins/white-label-cms/ */
function ctm_remove_admin_menus() {
global $menu, $submenu;
$exclude[0] = '';
array_push($exclude,__('Posts','default'));
array_push($exclude,__('Comments','default'));
array_push($exclude,__('Links','default'));
unset($exclude[0]);
@petenelson
petenelson / wp-auth-cookie-expiration.php
Created August 8, 2012 15:45
WordPress filter to extend the expiration of the login auth cookie
@petenelson
petenelson / wordpress-body-classes.php
Last active October 8, 2015 18:38
WordPress: Add additional body classes based on the post meta
// extra body classes based on the post meta
add_filter('body_class','theme_body_class');
function theme_body_class($classes) {
$body_classes = get_post_meta(get_the_id(), 'body-class');
if (false !== $body_classes && count($body_classes) > 0)
$classes = array_merge($classes, $body_classes);
return $classes;
@petenelson
petenelson / admin_head_post_edit_check.php
Created November 1, 2012 17:03
WordPress admin action hooks for listing/adding/editing posts or pages
/* actions fired when listing/adding/editing posts or pages */
/* admin_head-(hookname) */
add_action( 'admin_head-post.php', 'admin_head_post_editing' );
add_action( 'admin_head-post-new.php', 'admin_head_post_new' );
add_action( 'admin_head-edit.php', 'admin_head_post_listing' );
function admin_head_post_editing() {
echo 'you are editing a post';
}
@petenelson
petenelson / custom-permalink-from-meta.php
Created November 5, 2012 21:32
WordPress permalink for custom post type based on post meta
@petenelson
petenelson / document.php
Created November 16, 2012 15:50
WordPress: Custom post type (my-document) for docs (PDFs, etc)
<?php
/*
Plugin Name: My Document Permalink
Description: Custom post type (my-document) for docs (PDFs, etc)
Version: 1.0
Author: Pete Nelson
*/
add_action('init', 'my_register_document_post_type');
@petenelson
petenelson / gga-import-joomla-articles.php
Created January 22, 2013 22:23
WordPress: GGA Joomla Content Importer - Imports articles from a Joomla database as WordPress posts
<?php
/*
Plugin Name: GGA Joomla Content Importer
Description: Imports articles from Joomla 1.5x into WordPress
Author: <a href="https://twitter.com/GunGeekATX" target="_blank">@GunGeekATX</a>
Version: 1.1
*/
class ggaJoomlaArticleImporter
@petenelson
petenelson / gga-marketing-request.php
Last active March 25, 2018 21:51
WordPress: Expands upon the Custom Meta Boxes library to provide a user-facing input form, list and detail page of submitted forms for custom post types.
<?php
/*
Author: Pete Nelson @GunGeekATX
Expands upon the Custom Meta Boxes library to provide a user-facing input form,
list & detail page of custom post types. This code sample doesn't include all the libraries
such as jQuery tablesorter or validate but can be found elsewhere easily enough.
*/