Skip to content

Instantly share code, notes, and snippets.

View dirtystylus's full-sized avatar

Mark Llobrera dirtystylus

View GitHub Profile
name = Custom Beans
description = My Custom Beans
core = 7.x
files[] = "custom_bean.listing.inc"
<?php
/**
* This snippet adds extra classes to Drupal
* menu leafs (li tags) and menu itself (ul tags).
*/
/**
* Since the standard preprocess function for menu tree, which is
* template_preprocess_menu_tree, located in includes/menu.inc,
# Markdown Lists and Headers
## Single List Item
* ## List Item Header
## Two List Items
* ## List Item Header
* sub-item
@dirtystylus
dirtystylus / Drupal7 Feature Uncheck
Created August 21, 2013 15:14
jQuery call to uncheck all components when re-generating a feature that won’t download properly.
jQuery(".component-included.form-checkbox").removeAttr('checked');
@dirtystylus
dirtystylus / Inline MQs with SASS
Created September 19, 2013 19:26
Inline MQ example for Fran
.mymodule {
/* base style */
@media (min-width: em(300)) {
/* small-screens */
}
@media (min-width: em(700)) {
/* medium screens */
}
@media (min-width: em(1000)) {
@dirtystylus
dirtystylus / Drupal 7: Add Menu Title to LI elements
Last active December 25, 2015 14:39
Add Menu Title to LI elements.
/**
* Add unique class (mlid) to all menu items.
* with Menu title as class
*/
function THEME_menu_link(array $variables) {
$element = $variables['element'];
$sub_menu = '';
$name_id = strtolower(strip_tags($element['#title']));
// remove colons and anything past colons
if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':'));
@dirtystylus
dirtystylus / Drupal 7: Child CSS Class for Parent LI
Last active December 25, 2015 14:39
Pulls the class elements from child <a> element and puts them on the parent <li> item. Useful if you want classes you added with the menu_attributes module to be used on the parent <li>, since those classes are placed on the <a> element itself.
function THEME_preprocess_menu_link(&$variables) {
$element = &$variables['element'];
if (!empty($element['#original_link']['options']['attributes']['class'])) {
foreach($element['#original_link']['options']['attributes']['class'] as $class) {
$element['#attributes']['class'][] = $class;
}
}
}
@dirtystylus
dirtystylus / gist:b8f9bbcc1fce28670b8e
Last active August 29, 2015 14:04
WordPress Custom Login Screen
/**
* Implement Custom Admin Logo
*/
function new_custom_login_logo() {
echo '<style type="text/css">
h1 a { background-image:url('.get_template_directory_uri().'/images/THEME-LOGO.png) !important; width:321px !important; height: 243.56px !important; background-size: 321px 243.56px !important; }
</style>';
}
add_action('login_head', 'new_custom_login_logo');
@dirtystylus
dirtystylus / wp-tinymce-remove
Last active August 29, 2015 14:05
Removing TinyMCE options in WordPress
/*
* This goes in your theme’s functions.php file.
* This will remove EVERY option in the basic WYSIWYG bar in WP. Pull items out of the $remove array if you want to keep them.
*/
function myplugin_tinymce_buttons($buttons)
{
//Remove the format dropdown select and text color selector
$remove = array('bold','italic','blockquote','strikethrough','bullist','numlist','hr','alignleft','aligncenter','alignright','link','unlink','wp_more','spellchecker','wp_fullscreen','wp_adv');
return array_diff($buttons,$remove);
@dirtystylus
dirtystylus / acf-flexible-content-field
Created September 4, 2014 02:15
ACF with Flexible Content Field
<?php
/**
* @package modularcontent
*/
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<?php
// check if the flexible content field has rows of data
if( have_rows('flexible_content') ):