Skip to content

Instantly share code, notes, and snippets.

@linuslundahl
linuslundahl / remove-wp-attachment-thumbs.php
Created November 28, 2010 19:27
Remove generated attachment thumbnails from wordpress database.
global $wpdb;
$query = "SELECT meta_value, meta_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attachment_metadata'";
$result = $wpdb->get_results($query);
foreach ($result as $item) {
$meta = unserialize($item->meta_value);
unset($meta['sizes']);
$wpdb->update( 'wp_vira_postmeta', array('meta_value' => serialize($meta)), array('meta_id' => $item->meta_id) );
}
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .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/
@justinwhall
justinwhall / WP.Pagination.php
Created March 6, 2012 23:24
PHP: Function WordPress Pagination
//PAGINATION//
/* Function that Rounds To The Nearest Value.
Needed for the pagenavi() function */
function round_num($num, $to_nearest) {
/*Round fractions down (http://php.net/manual/en/function.floor.php)*/
return floor($num/$to_nearest)*$to_nearest;
}
/* Function that performs a Boxed Style Numbered Pagination (also called Page Navigation).
Function is largely based on Version 2.4 of the WP-PageNavi plugin */
@appastair
appastair / jsonp.js
Last active August 23, 2020 17:52
Cross-domain JSONP Example (jQuery/PHP)
jQuery(function($){
$.ajax({
type: 'GET',
url: '//remote.org/jsonp.php',
data: {
field: 'value'
},
dataType: 'jsonp'
crossDomain: true,
}).done(function(response){
@jareware
jareware / SCSS.md
Last active July 1, 2024 09:25
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@chrisdigital
chrisdigital / Frontend user profile in WordPress
Created May 6, 2013 13:27
Setting up a editable user profile in WordPress on the frontend.
//How to edit a user profile on the front end?
//http://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end
//Forcing nickname as display_name in custom edit profile template
//http://wordpress.stackexchange.com/questions/35403/forcing-nickname-as-display-name-in-custom-edit-profile-template
///////
<?php
@strangerstudios
strangerstudios / heartbeat-api-demo.php
Last active April 30, 2024 17:08
Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
<?php
/*
Plugin Name: Heartbeat API Demo
Plugin URI: http://www.strangerstudios.com/wp/heartbeat-api-demo
Description: Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
Version: .1
Author: strangerstudios
If logged in as a user and viewing the frontend of your website,
every 15 seconds you should see the following in your Javascript console:
@BFTrick
BFTrick / woocommerce-remove-virtual-billing-fields.php
Last active February 19, 2024 17:23
Remove the billing address fields for free virtual orders in WooCommerce
<?php
/**
* Plugin Name: WooCommerce Remove Billing Fields for Free Virtual Products
* Plugin URI: https://gist.github.com/BFTrick/7873168
* Description: Remove the billing address fields for free virtual orders
* Author: Patrick Rauland
* Author URI: http://patrickrauland.com/
* Version: 2.0
*
* This program is free software: you can redistribute it and/or modify
@tjFogarty
tjFogarty / class.vimeothumbnail.php
Last active January 26, 2018 03:12
Get Vimeo thumbnail from video URL
<?php
/**
* Vimeo class to fetch thumbnails
* @example
* $video = new VimeoThumbnail(array(
* 'video_url' => $url
* ));
* echo $video->thumbnail;
*/
@renventura
renventura / gf-create-edd-coupons.php
Created October 4, 2014 03:36
Create randomly generated discount codes for Easy Digital Downloads on Gravity Forms submission
<?php //* Mind this opening php tag and header information below
/*
Plugin Name: Create EDD Discounts with Gravity Forms
Plugin URI: http://engagewp.com/create-random-discount-codes-edd-gravity-forms
Description: Allows discount codes for Easy Digital Downloads to be randomly generated on Gravity Forms submissions. Code credit to David Smith of GravityWiz.com. Modified and put into plugin format by Ren Ventura.
Author: David Smith / Ren Ventura
Version: 1.0
*/