Skip to content

Instantly share code, notes, and snippets.

@DenisLeblanc
DenisLeblanc / gist:11264087
Last active August 29, 2015 14:00
Collapse your tables into list items on smaller devices
<?php
// Collapse your tables into list items on smaller devices.
@media only screen and (max-width: 600px) {
table {
thead {display: none;}
td {
display: list-item;
width: 100%;
@DenisLeblanc
DenisLeblanc / gist:11264169
Created April 24, 2014 18:14
Automatically login users with Gravity Forms Registration Addon
<?php
add_action("gform_user_registered", "autologin", 10, 4);
function autologin($user_id, $config, $entry, $password) {
wp_set_auth_cookie($user_id, false, '');
}
?>
@DenisLeblanc
DenisLeblanc / gist:f9d8d0e283ec6b0c2421
Created June 12, 2014 23:27
Rich Text Editor for Excerpts
<?php
function lb_editor_remove_meta_box() {
global $post_type;
// Check to see if the global $post_type variable exists
// and then check to see if the current post_type supports
// excerpts. If so, remove the default excerpt meta box
// provided by the WordPress core. If you would like to only
// change the excerpt meta box for certain post types replace
// $post_type with the post_type identifier.
@DenisLeblanc
DenisLeblanc / gist:905df17b8882952b034b
Created June 17, 2014 23:29
Filter Posts by Post Format
<?php
function wpse26032_admin_posts_filter( &$query )
{
if (
is_admin()
AND 'edit.php' === $GLOBALS['pagenow']
AND isset( $_GET['p_format'] )
AND '-1' != $_GET['p_format']
)
{
@DenisLeblanc
DenisLeblanc / gist:2bdca22e3e4aa9e5cdf0
Created June 19, 2014 21:07
Placeholder Text in GravityForm Fields
// USE PLACEHOLDER TEXT IN FORM FIELDS
var inner_form_labels = function() {
$('.gform_fields input').each(function() {
var el = $(this);
var placeholder = el.val();
el.attr({
value : null,
@DenisLeblanc
DenisLeblanc / gist:18dafa4813fea2144fa7
Last active August 29, 2015 14:03
Equal Height Columns
// MAKE CERTAIN COLUMNS EQUAL HEIGHTS
// source: http://codepen.io/micahgodbolt/pen/FgqLc
equalheight = function(container){
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
@DenisLeblanc
DenisLeblanc / gist:37090b00048be5ae373a
Created July 1, 2014 23:23
Allow clicking instead of hover for dropdown menus
//Allow clicking instead of hover for dropdown menus
$(document).ready( function(){
$('li.has_children > a').click( function(event){
event.stopPropagation();
$('.sub-menu').toggle();
});
});
@DenisLeblanc
DenisLeblanc / gist:0067cbd9dc451df30da2
Created July 10, 2014 20:54
Fix Blog Tab Classes on Custom Post Type Pages
<?php
// FIX BLOG TAB CLASSSES ON CUSTOM POST TYPES
function fix_blog_tab_on_cpt( $classes, $item, $args ) {
if( !is_singular( 'post' ) && !is_category() && !is_tag() ) {
$blog_page_id = intval( get_option( 'page_for_posts' ) );
if( $blog_page_id != 0 ) {
if( $item->object_id == $blog_page_id ) {
unset( $classes[ array_search( 'current_page_parent', $classes ) ] );
}
}
@DenisLeblanc
DenisLeblanc / gist:f3f526153e0ce3c3bf7f
Created July 10, 2014 20:57
Add 'current-menu-parent' class to post type menus
<?php
// Add 'current-menu-parent' CLASS TO CUSTOM POST TYPE MENUS
// make sure to add the registered custom post type to the menu 'Title Attribute'
add_filter('nav_menu_css_class', 'current_type_nav_class', 10, 2);
function current_type_nav_class($classes, $item) {
// Get post_type for this post
$post_type = get_query_var('post_type');
// Go to Menus and add a menu class named: {custom-post-type}-menu-item
// This adds a 'current_page_parent' class to the parent menu item
@DenisLeblanc
DenisLeblanc / gist:207e14de484f368c48d2
Created August 16, 2014 06:00
Detect Mobile Visitors in WordPress
<?php
if( wp_is_mobile() ) {
} else {
}
?>