Skip to content

Instantly share code, notes, and snippets.

@nmec
nmec / wpsc-default.css
Created August 23, 2011 23:13
WP e-Commerce default CSS. The horror, the horror.
/*
Theme Name: Default Theme
Theme URI: http://instinct.co.nz
Description: Default Theme
Version: 3.5
Author: Roy Ho
Author URI: http://instinct.co.nz
*/
/*
@nmec
nmec / no ga.js for wp-admin.phtml
Last active September 29, 2015 00:18
Checks if the current user if has admin privileges, otherwise load ga.js. Don't forget to change your Analytics ID. See http://nmecdesign.com/?p=57 for more info.
<?php if (current_user_can('manage_options')) { ?>
<a href="<?php echo admin_url(); ?>">Admin</a>
<?php } else { ?>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-000000', 'auto');
@nmec
nmec / fixmediaurls.sql
Created December 24, 2011 20:50
Fix media URLs after moving WordPress into a sub-directory: http://nmecdesign.com/?p=212
UPDATE wp_posts SET post_content = REPLACE(post_content, "YourWebsite.com/wp-content", "YourWebsite.com/wp/wp-content");
@nmec
nmec / gist:1518329
Created December 24, 2011 20:57
Disable the internal laptop screen in OS X Lion: http://nmecdesign.com/?p=288 NB You need to restart for the changes to take effect
sudo nvram boot-args="iog=0x0"
@nmec
nmec / gist:2894318
Created June 8, 2012 07:56
Change default WordPress new user notifications
<?php
/**
* Prevent new user email notifications
* This prevents new user email notifications being sent to users and administrators by commenting out the wp_mail functions. You could rewrite it to change the default registration email.
* This should be put in a plugin or your themes functions file.
* @link http://wordpress.org/extend/plugins/disable-wp-new-user-notification/
* @author Jono Warren <jonathan_warren@bcl.co.uk>
*/
if ( !function_exists('wp_new_user_notification') ) {
function wp_new_user_notification($user_id, $plaintext_pass = '') {
@nmec
nmec / WP-3.4.php
Created September 7, 2012 08:27
Sorting a WordPress loop by post__in
<?php
$posts = array(5, 2, 43, 12);
// Get the posts
$my_loop = new WP_Query(array(
'post__in' => $posts,
'post_type' => 'any',
'posts_per_page' => -1,
));
<?php
// Remove SEO menu from Admin bar
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
function mytheme_admin_bar_render() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wpseo-menu');
}
// Remove ‘page analysis’ and annoying SEO columns
add_filter( 'wpseo_use_page_analysis', '__return_false' );
@nmec
nmec / install.php
Last active December 10, 2015 12:28
Prevents generation of 'Hello World' and 'Sample Page' in WordPress, just drop this file in your wp-content folder before running the installation.
<?php
/**
* Prevents generation of 'Hello World' and 'Sample Page'.
* @link http://wordpress.stackexchange.com/a/71867/8872
*/
function wp_install_defaults() {
return null;
}
@nmec
nmec / jsonview-tomorrow-night.css
Created December 26, 2013 14:55
JSONView - Tomorrow Night Theme
body {
white-space: pre;
font-family: Menlo, Monaco, monospace;
font-size: 0.8rem;
background: #1d1f21;
color: #c5c8c6;
}
.property {
@nmec
nmec / no-knab.js
Created January 19, 2014 16:58
Prevent opportunistic image thieves.
jQuery(document).ready(function($){
// Prevent right click on carousel
$('.gallery').on('contextmenu', function(){
return false;
});
// Prevent right click on all image elements
$('img').on('contextmenu', function(){
return false;