Skip to content

Instantly share code, notes, and snippets.

View media317's full-sized avatar

Alan Smith media317

View GitHub Profile
@media317
media317 / copyboard instantiate script
Created March 8, 2017 16:26
activate the script for the post or page
<script type="text/javascript">
var clipboard = new Clipboard('.btn');
</script>
@media317
media317 / clipboard HTML
Created March 8, 2017 16:21
HTML structure for clipboard.js
<div id="clipboard">
<p>Your Text to be copied</p>
</div>
<button class="btn" data-clipborad-action="copy" data-clipboard-target="#clipboard">Copy to Clipboard</button>
</div>
@media317
media317 / clipboard enqueue
Created March 8, 2017 16:14
Code to enqueue clipboard.js to WordPress functions.php
//* Enqueue Scripts
add_action( 'wp_enqueue_scripts', 'load_responsive_javascript' );
function load_responsive_javascript() {
wp_enqueue_script( 'clipboard', get_stylesheet_directory_uri() . '/js/clipboard.js', array( 'jquery' ), '1.0.0' );
}
@media317
media317 / FAQ toggle HTML
Created March 8, 2017 03:55
FAQ Toggle HTML
<ul class="faq-list">
<li><a href="#" class="question">Question One</a>
<div class="answer">
<p>Answer to Question One.</p>
</div>
</li>
<li><a href="#" class="question">Question Two</a>
<div class="answer">
<p>Answer to Question Two.</p>
</div>
@media317
media317 / FAQ Toggle Enqueue
Last active March 8, 2017 03:51
FAW Enqueue script in functions.php of WordPress
//* Enqueue Scripts
add_action( 'wp_enqueue_scripts', 'load_toggle_javascript' );
function load_toggle_javascript() {
wp_enqueue_style( 'dashicons' );
wp_enqueue_script( 'toggle', get_stylesheet_directory_uri() . '/js/toggle.js', array( 'jquery' ), '1.0.0' );
}
@media317
media317 / FAQ toggle css
Created March 8, 2017 03:50
FAQ toggle CSS
/* # FAQ
--------------------------------------------- */
.entry-content .faq-list,
.entry-content .faq-list li {
list-style: none;
margin: 0;
padding: 0;
}
@media317
media317 / FAQ Toggle js
Created March 8, 2017 03:47
FAQ Toggle javascript of question and answer
jQuery(function( $ ){
$('.faq-list .question').click( function(){
$(this).parent().find('.answer').slideToggle('fast');
$(this).toggleClass('on');
return false;
});
});
@media317
media317 / multi-meta-boxes
Created December 16, 2013 21:33
Multiple Meta Boxes
<?php
/**
* Metaboxes
*
* This file registers any custom metaboxes
*
* @package Core_Functionality
* @since 1.0.0
* @link https://github.com/billerickson/Core-Functionality
* @author Bill Erickson <bill@billerickson.net>
@media317
media317 / UNIX format in WP loop
Created October 27, 2013 22:51
Getting UNIX date formated properly in loop
/** Loop for Projects **/
$loop = new WP_Query( $args );
if( $loop->have_posts() ):
echo '<div id="container">';
while( $loop->have_posts() ): $loop->the_post();
echo '<div class="projects one-third '.genesis_get_custom_field('program') . ' ' .genesis_get_custom_field('project_type') . ' ' .genesis_get_custom_field('country') . '">';
echo '<h2><a href="' . get_permalink() . '">' . get_the_title() . '</a></h2>';
echo '<a href="' . get_permalink() . '">' . get_the_post_thumbnail( $post_id, 'project' ). '</a>';
echo '<h3 class="mmi-country ' . genesis_get_custom_field('country') . '">' . genesis_get_custom_field('country') . '</h3>';
@media317
media317 / StartDate timestamp from UNIX
Created October 27, 2013 22:28
Change UNIX timestamp to M/D/Y
add_action( 'genesis_before_entry_content', 'mmi_sing_project_top');
function mmi_sing_project_top() {
global $post;
$begindate = genesis_get_custom_field('startdate');
$enddate = genesis_get_custom_field('finishdate');
echo '<div class="sing-project">';
. . . .