Skip to content

Instantly share code, notes, and snippets.

View dirtystylus's full-sized avatar

Mark Llobrera dirtystylus

View GitHub Profile
@dirtystylus
dirtystylus / wp-remove-text-tab-buttons
Created September 16, 2014 20:35
WordPress Remove Text Tab Buttons
function _remove_quicktags( $qtInit )
{
// Remove only the 'italic', 'bold', and 'block-quote' buttons
$remove_these = array('strong', 'em', 'block', 'link', 'del', 'ins', 'img', 'ul', 'ol', 'li', 'code', 'more', 'close');
// Convert string to array
$buttons = explode(',', $qtInit['buttons']);
// Loop over items to remove and unset them from the buttons
for( $i=0; $i < count($remove_these); $i++ )
{
if( ($key = array_search($remove_these[$i], $buttons)) !== false)
@dirtystylus
dirtystylus / gist:34a65ab232ac21222380
Created September 11, 2014 23:33
Drupal 7: Remove Image Width and Height
function mytheme_preprocess_image(&$variables) {
foreach (array('width', 'height') as $key) {
unset($variables[$key]);
}
}
@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') ):
@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 / 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 / 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 / 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 / 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 / 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');
# Markdown Lists and Headers
## Single List Item
* ## List Item Header
## Two List Items
* ## List Item Header
* sub-item