Skip to content

Instantly share code, notes, and snippets.

View teolopez's full-sized avatar
🤓

Teodoro Lopez teolopez

🤓
View GitHub Profile
@teolopez
teolopez / gist:7482961
Created November 15, 2013 11:30 — forked from max/gist:5708466
// I needed flatuicolors.com as Sass variables...
// In your console, run:
$('.color').get().map(function(el) { return "$" + el.classList[1] + ": " + el.getAttribute('data-clipboard-text') + ';' }).join('\r\n');
// Output:
// $turquoise: #1abc9c;
// $emerland: #2ecc71;
// $peter-river: #3498db;
// $amethyst: #9b59b6;
// $wet-asphalt: #34495e;
@teolopez
teolopez / gist:7436121
Created November 12, 2013 18:25
Remove Paragraph Tags From Around Images
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
// -----------
// Debugger that shows view port size. Helps when making responsive designs.
// -----------
function showViewPortSize(display) {
if(display) {
var height = jQuery(window).height();
var width = jQuery(window).width();
jQuery('body').prepend('<div id="viewportsize" style="z-index:9999;position:fixed;top:40px;left:5px;color:#fff;background:#000;padding:10px">Height: '+height+'<br>Width: '+width+'</div>');
jQuery(window).resize(function() {
@teolopez
teolopez / login_error_message_change
Created July 31, 2013 14:01
change error message for incorrect login credentials.
add_filter( 'login_errors', 'rs_custom_login_error' );
/*
* @desc Filter Wordpress admin error message
*/
function rs_custom_login_error(){
return $error = "Oops!, sorry you have inputted wrong credentials.";
}
@teolopez
teolopez / gist:6085298
Created July 26, 2013 01:24
Custom login form and site lock down
<?php
// ----------------------------------------------------------------------------------------
// Redirect all non-logged-in users to the login page (private site). Add to functions.php.
// ----------------------------------------------------------------------------------------
function admin_redirect() {
if ( !is_user_logged_in()) {
wp_redirect( home_url('/wp-login.php/') );
exit;
@teolopez
teolopez / customlogin.css
Last active December 20, 2015 06:19
customlogin.css
body.login { background-color: black;}
body.login div#login {}
body.login div#login h1 {margin-bottom: 20px;}
/* ------ UPDATE LOGO IMAGE - NOTE: must declare background size of image ------ */
body.login div#login h1 a {background-position: top center; background-repeat: no-repeat;background-image: url(img/logo.png);height: 109px; background-size: 209px 109px; height: 80px;}
body.login div#login form#loginform { background-color: black; border: none; box-shadow: none;}
body.login div#login form#loginform p {}
body.login div#login form#loginform p label { color: white;}
body.login div#login form#loginform input {}
body.login div#login form#loginform input#user_login {}
@teolopez
teolopez / loop-for-custom-post-type
Created July 23, 2013 06:43
victor - use the force i mean this loop =)
<?php
// The Query
$args = array(
'post_type' => 'my_custom_post_type',
'order' => 'DESC', // DESC or ASC
'posts_per_page' => -1,
// Call custom taxonomy
@teolopez
teolopez / style.css
Created July 5, 2013 18:20
WordPress Theme Stylesheet General Header
/*
Theme Name: Bear Necessities
Theme URI: http://teolopez.com/themes
Description: Bear Necessities Starter Theme
Author: Teo Lopez
Author URI: http://teolopez.com/
Version: 1.0
Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional)
License: GNU General Public License v2 or later
@teolopez
teolopez / html5_wp_header.php
Last active December 19, 2015 09:28
html5 boilerplate WordPress header combo
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html <?php language_attributes(); ?> class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php wp_title(); ?></title>
@teolopez
teolopez / WordPress-add new post to user when registering
Created June 30, 2013 05:37
When a new user registers a new post is auto created and assigned to the new user as a draft.
// -----------------------------------------------------------------
// Add Post On New User Registration and Assign to User Registration
// -----------------------------------------------------------------
add_action( 'user_register', 'gamma_new_user_post' );
/**
* Add a new post when user registers.
*/
function gamma_new_user_post( $user_id ) {