Skip to content

Instantly share code, notes, and snippets.

@trevorgreenleaf
trevorgreenleaf / remove_dashboard_widgets
Last active December 17, 2015 15:09
remove_dashboard_widgets - Remove the dashboard widgets for all users
// remove_dashboard_widgets - Remove the dashboard widgets for all users
//===================================================================================================
function remove_dashboard_widgets()
{
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
@trevorgreenleaf
trevorgreenleaf / remove_menu_items
Created May 22, 2013 17:55
Modify the admin menus for all users
/remove_menu_items - Modify the menus for all users
//==================================================================
function remove_menu_items()
{
global $menu;
$restricted = array(
__('Links'),
//__('Posts'),
//__('Comments'),
//__('Media'),
<?php
/* create a function to get the values from this page load */
function wpct_track_content() {
/* call the global post variable to gain access to post data */
global $post;
/* setup an array to store all our values */
$wpct_post_values = array();
<?php
/**
Plugin Name: User Switching in Admin Bar
Plugin URI: http://markwilkinson.me
Description: Build upon the User Switching plugin (http://wordpress.org/extend/plugins/user-switching/) by John Blackbourn and adds a dropdown list of users in the WordPress admin bar with a link to switch to that user.
Author: Mark Wilkinson
Author URI: http://markwilkinson.me
Version: 1.0
*/
// Add Twitter, Facebook and Google+ field to contact methods, remove AIM, YIM and Jabber
add_filter( 'user_contactmethods', 'ts_add_contact_fields' );
function ts_add_contact_fields( $contactmethods ) {
$contactmethods['linkedin'] = 'LinkedIn';
$contactmethods['twitter'] = 'Twitter';
$contactmethods['facebook'] = 'Facebook';
$contactmethods['googleplus'] = 'Google+';
@trevorgreenleaf
trevorgreenleaf / PHP Image upload
Last active June 10, 2019 09:54
PHP Image upload with date appended.
<?php
/* Image Uploading Script
* ========================================================================================
Process images and moves them into a uploads folder, each image will have the date of upload
appended to its url to prevent replacing.
- Trevor 06/29/13
*/
// only allow the following formats
foreach($_SESSION as $key => $value)
{
unset($_SESSION[$key]);
}
// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies"))
{
$params = session_get_cookie_params();
@trevorgreenleaf
trevorgreenleaf / gist:5989014
Created July 13, 2013 01:31
Quick Way to Take Your WordPress Site Down For Maintenance
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance/$
RewriteCond %{REMOTE_ADDR} !^111.111.111.111
RewriteRule $ /maintenance/index.html [R=302,L]
@trevorgreenleaf
trevorgreenleaf / Benchmark Testing Php
Created July 27, 2013 14:08
Benchmark Testing Php Fucntions
<?php
function my_function(){
$start_time = microtime()*1000;
// sleep(1);
$end_time = microtime()*1000;
@trevorgreenleaf
trevorgreenleaf / gist:6106038
Created July 29, 2013 17:35
Remove menu items from wordpress menues
<?php
function mytheme_admin_bar_render() {
global $wp_admin_bar;
// we can remove a menu item, like the Comments link, just by knowing the right $id
$wp_admin_bar->remove_menu('comments');
// or we can remove a submenu, like New Link.
$wp_admin_bar->remove_menu('new-link', 'new-content');
// we can add a submenu item too
$wp_admin_bar->add_menu( array(
'parent' => 'new-content',