Skip to content

Instantly share code, notes, and snippets.

@mattboon
mattboon / gist:4045215
Created November 9, 2012 11:21
Update WP user_login via SQL
<?php
// Force update our username (user_login)
global $wpdb;
$tablename = $wpdb->prefix . "users";
// method 1
//$sql = $wpdb->prepare("UPDATE %s SET user_login=%s WHERE ID=%d", $tablename, $user_email, $user_id);
//$wpdb->query($sql);
@WebEndevSnippets
WebEndevSnippets / functions.php
Created October 20, 2012 15:30
WordPress: Add Login In Navigation (w Profile)
// Add Login Link in Navigation
add_filter( 'wp_nav_menu_items', 'we_nav_login_right', 10, 2 );
function we_nav_login_right($menu, $args) {
$args = (array)$args;
$login = wp_loginout( $_SERVER['REQUEST_URI'], false );
$profile = '<a class="profile" href=' . get_edit_profile_url($userid) . '>Profile</a>';
//if not primary, return
//change primary to secondary for secondary menu (though will need some CSS done)
if ( $args['theme_location'] != 'primary' )
@boogah
boogah / wipe_user_activation_key.sql
Created October 16, 2012 19:39
Remove all user_activation_key values in WordPress install
--
-- Note: Make sure `wp_users` matches your user table.
--
update wp_users set user_activation_key='';
@mattboon
mattboon / gist:3853620
Created October 8, 2012 17:02
Fublo Edit Profile function
<?php
function fublo_gf_profile_update( $entry, $form )
{
// make sure that the user is logged in
// we shouldn't get here because the form should check for logged in users...
if ( !is_user_logged_in() )
{
wp_redirect( home_url() );
exit;
@kcleong
kcleong / mediaqueries.css
Created October 7, 2012 09:44
Responsive stylesheet for Plone
/* For devices with narrow screens, phones, tablets, etc. */
/* support these sizes: 320,480, 600, 768, 1024, 1200 Ethan Marcotte */
/* * 1. 1625px and above huge screens * */
/* * 2. 1301px and above huge screens * */
/* * 3. 1025px to 1300px * */
/* * 4. 769px to 1024px * */
/* * 5. 601px to 768px * */
/* * 6. 600px and below * */
/* * 7. 481px to 600px * */
/* * 8. 480px wide and below * */
@michaelaguiar
michaelaguiar / iOS.css
Created September 27, 2012 17:54
iOS Media Queries
/* Non-Retina */
@media screen and (-webkit-max-device-pixel-ratio: 1) {
}
/* Retina */
@media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 3/2), only screen and (min--moz-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio: 1.5) {
}
@jonathonbyrdziak
jonathonbyrdziak / facebook.connect.php
Created September 26, 2012 19:02
FINALLY! A facebook connect mu-plugin that freakin works.
<?php
/**
* @Author Jonathon Byrd
* @link http://www.redrokk.com
* @Package Wordpress
* @SubPackage Red Rokk Library
*
* @version 0.1
*/
defined('ABSPATH') or die('You\'re not supposed to be here.');
@pamelafox
pamelafox / visibleimages.js
Created September 17, 2012 04:22
Load Visible Images
function loadVisibleImages() {
var placeholders = {
'meal': 'img/meal.png',
'avatar': 'img/blankpic.png'
};
$('img').each(function() {
var $img = $(this);
var realUrl = $img.attr('data-src');
if (!realUrl) return;
@bordoni
bordoni / wordpress-upload.php
Created August 24, 2012 17:51
How to upload a file to WordPress
<?php
/**
* Handle file uploading and add attachment.
*
* @return array Uploaded file's details on success, error message on failure
*/
function wp_import_handle_upload() {
if ( !isset($_FILES['filefield_name']) ) {
$file['error'] = __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' );
return $file;
@pamelafox
pamelafox / view.html
Created August 21, 2012 14:30
Google Maps AutoComplete for Profile Location Field
<div class="control-group">
<label class="control-label">Location</label>
<div class="controls">
<input name="location" type="text" placeholder="City, State, Country" value="">
<input name="location_city" type="hidden" value="">
<input name="location_state" type="hidden" value="">
<input name="location_country" type="hidden" value="">
<input name="location_lat" type="hidden">
<input name="location_lng" type="hidden">
</div>