Skip to content

Instantly share code, notes, and snippets.

View zoerooney's full-sized avatar

Zoe Rooney zoerooney

View GitHub Profile
@zoerooney
zoerooney / in-page-dropdown.css
Last active December 17, 2015 15:29
Code snippets for a tutorial on drop down sidebar widgets & content blocks in WordPress. See also: https://gist.github.com/zoerooney/5632182 Tutorial link: http://zoerooney.com/blog/tutorials/faqs-lists-and-jquery-how-to-create-drop-down-content-blocks/
.question:hover {
cursor: pointer;
opacity: 0.6;
}
/* Not much to see here - most of the action-oriented code has been moved to the jQuery */
@zoerooney
zoerooney / inline-validation.js
Last active December 17, 2015 21:09
Customized MailChimp code that works inline with WordPress. The JS goes in the footer - make sure to replace the URL on line 9 with the one from YOUR account (you can get it by grabbing the original version of this code - generate a "classic" embedded sign-up form and it'll be in there). There's also a bit you'll need to replace in the form code…
<script type="text/javascript">
var fnames = new Array();var ftypes = new Array();fnames[0]='EMAIL';ftypes[0]='email';fnames[1]='FNAME';ftypes[1]='text';fnames[2]='LNAME';ftypes[2]='text';
jQuery(document).ready( function($) {
var options = { errorClass: 'mce_inline_error', errorElement: 'div', onkeyup: function(){}, onfocusout:function(){}, onblur:function(){} };
var mce_validator = $("#mc-embedded-subscribe-form").validate(options);
$("#mc-embedded-subscribe-form").unbind('submit');//remove the validator so we can get into beforeSubmit on the ajaxform, which then calls the validator
options = { url: 'http://replace-with-your-specific-url', type: 'GET', dataType: 'json', contentType: "application/json; charset=utf-8",
beforeSubmit: function(){
@zoerooney
zoerooney / example.html
Last active December 20, 2015 04:38
quick WP template tag example
<h2>Post Title</h2>
becomes
<h2><?php the_title(); ?></h2>
@zoerooney
zoerooney / no-li-nav-menu-v1.php
Last active February 3, 2020 08:49
Create an arguably cleaner nav menu in WordPress. Version 1 replacing the LI elements in a WordPress menu with SPAN elements, while maintaining classes, etc., while version 2 results in just A elements, still maintaining all the classes, etc. Post: http://zoerooney.com/blog/tutorials/removing-list-items-wordpress-menus/
<?php
// first let's get our nav menu using the regular wp_nav_menu() function with special parameters
$cleanmenu = wp_nav_menu( array(
'theme_location' => 'social', // we've registered a theme location in functions.php
'container' => false, // this is usually a div outside the menu ul, we don't need it
'items_wrap' => '<nav id="%1$s" class="%2$s">%3$s</nav>', // replacing the ul with nav
'echo' => false, // don't display it just yet
) );
@zoerooney
zoerooney / tabs.js
Created December 2, 2013 04:23
Clean tabbed product descriptions in Shopify with jQuery. Just requires that the tabs be entered into the description field with Heading 5 styling applied to each tab, followed by regularly formatted tab content. Tutorial: http://zoerooney.com/blog/tutorials/clean-tabbed-product-descriptions-for-shopify/
jQuery(document).ready(function($){
// This first section is all about formatting the content correctly for tabs
// Add the opening list tag before the first H5 within the description
$('.description h5:first-of-type').before('<ul class="tabs" />');
// Loop through each H5 in the description
$('.description h5').each(function(index, value){
// Assign them each a number, in order
@zoerooney
zoerooney / pluginlist.php
Created December 10, 2013 06:07
Print plugin list in WordPress admin page. Part of this project: http://zoerooney.com/blog/tag/wordpress-reporting-plugin/
<div class="module">
<h3>Currently Installed Plugins</h3>
<?php
// assign get_plugins() to a variable
$current_plugins = get_plugins();
// something should happen if no plugins are installed
if ( empty( $current_plugins ) ) :
echo '<p>Unable to display plugins. This could mean there are no plugins installed, or that the plugins directory is inaccessible.</p>';
@zoerooney
zoerooney / initialize.js
Created December 19, 2013 15:51
Galleriffic + Pin It Button on Hover
jQuery(document).ready(function($){
$('#thumbs').galleriffic({
imageContainerSel: '#slideshow',
controlsContainerSel: '#controls',
loadingContainerSel: '#loading',
numThumbs: 9999,
renderSSControls: false,
onSlideChange: function(prevIndex, nextIndex) {
// get the pin it URL from the next slide
var piniturl = this.find('ul.thumbs li.selected .sm-pinit a').attr('href');
@zoerooney
zoerooney / sass-sticky-footer.scss
Created December 31, 2013 03:55
SASS Sticky Footer Mixin - I didn't find one using my favorite method (this one: http://cleanstickyfooter.herokuapp.com/) so I wrote it up myself.
@zoerooney
zoerooney / wordpress-twitter-cards.php
Last active January 26, 2017 10:35
WordPress Twitter card info (assumes you've already got basic open graph data via a plugin), tutorial here: http://zoerooney.com/blog/tutorials/increase-share-ability-using-twitter-cards/
<?php // Include Twitter IDs for content creator (you, usually) ?>
<meta name="twitter:site" content="@zoe_rooney"/>
<meta name="twitter:creator" content="@zoe_rooney"/>
<?php
// get current post ID
$currentpost = get_the_ID();
// get radio value
$radio = get_field( 'twitter_card_options', $currentpost );