Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Schutzsmith schutzsmith

View GitHub Profile
@schutzsmith
schutzsmith / removeupdates.php
Created Apr 14, 2019
Remove WordPress Updates Notification
View removeupdates.php
// remove update notifications
<?php
function no_update_notification() {
if (!current_user_can('activate_plugins')) remove_action('admin_notices', 'update_nag', 3);
}
add_action('admin_notices', 'no_update_notification', 1);
@schutzsmith
schutzsmith / removemenus.php
Created Apr 14, 2019
remove unnecessary menus in WordPress
View removemenus.php
// remove unnecessary menus
function remove_admin_menus () {
global $menu;
// all users
$restrict = explode(',', 'Links,Comments');
// non-administrator users
$restrict_user = explode(',', 'Media,Profile,Users,Tools,Settings');
@schutzsmith
schutzsmith / removemetaboxes.php
Last active Apr 14, 2019
remove unnecessary page post meta boxes in WordPress
View removemetaboxes.php
// remove unnecessary page/post meta boxes
function remove_meta_boxes() {
// posts
remove_meta_box('postcustom','post','normal');
remove_meta_box('trackbacksdiv','post','normal');
remove_meta_box('commentstatusdiv','post','normal');
remove_meta_box('commentsdiv','post','normal');
remove_meta_box('categorydiv','post','normal');
remove_meta_box('tagsdiv-post_tag','post','normal');
@schutzsmith
schutzsmith / removewidgets.php
Created Apr 14, 2019
Remove unnecessary dashboard widgets in WordPress
View removewidgets.php
// remove unnecessary dashboard widgets
function remove_dashboard_widgets(){
global $wp_meta_boxes;
// only remove "Right Now" for non-administrators
if (!current_user_can('activate_plugins')) {
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
}
View Find all shortcodes on a WordPress website
<?php
/**
* Find Shortcode
*
*/
function be_find_shortcode( $atts = array() ) {
$atts = shortcode_atts( array(
'shortcode' => '',
View htaccess redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
View keybase.md

Keybase proof

I hereby claim:

  • I am schutzsmith on github.
  • I am schutzsmith (https://keybase.io/schutzsmith) on keybase.
  • I have a public key whose fingerprint is C109 8607 AD05 D24F 139F 65A3 87C0 5517 5518 A2A5

To claim this, I am signing this object:

@schutzsmith
schutzsmith / custom-provision.sh
Created Apr 24, 2016 — forked from neilgee/custom-provision.sh
Custom VVV Variable Provisioning for WordPress sites
View custom-provision.sh
# #!/bin/bash
# #
# # provision.sh
# #
# # This file is specified in Vagrantfile and is loaded by Vagrant as the primary
# # provisioning script whenever the commands `vagrant up`, `vagrant provision`,
# # or `vagrant reload` are used. It provides all of the default packages and
# # configurations included with Varying Vagrant Vagrants.
# # By storing the date now, we can calculate the duration of provisioning at the
@schutzsmith
schutzsmith / gulpfile.js
Created Apr 16, 2016 — forked from geelen/gulpfile.js
Harp with BrowserSync! Woo!
View gulpfile.js
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var harp = require('harp');
/**
* Serve the Harp Site from the src directory
*/
gulp.task('serve', function () {
harp.server(__dirname + '/src', {
@schutzsmith
schutzsmith / gist:2d0ea341486af3e545b2
Last active Aug 29, 2015
Change Permalink Based on Custom Field
View gist:2d0ea341486af3e545b2
add_action('init', 'tdd_add_rewrite_rules');
function tdd_add_rewrite_rules()
{
// Register custom rewrite rules
global $wp_rewrite;
$wp_rewrite->add_rewrite_tag('%your_post_type%', '([^/]+)', 'your_post_type=');