Skip to content

Instantly share code, notes, and snippets.

@dsmy
dsmy / custom-meta.php
Created July 31, 2018 02:55
Custom Blog meta with author name outside of WordPress loop
if ( ! function_exists( 'atmosphere_posted_on' ) ) :
/**
* Prints HTML with meta information for the current post-date/time and author.
*/
function atmosphere_posted_on() {
global $post;
$author_id = $post->post_author;
$author = get_the_author_meta('display_name', $author_id);
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
@dsmy
dsmy / functions.php
Created October 31, 2017 18:59 — forked from yratof/functions.php
ACF OEmbed with thumbnails
<?php
/* Pull apart OEmbed video link to get thumbnails out*/
function get_video_thumbnail_uri( $video_uri ) {
$thumbnail_uri = '';
// determine the type of video and the video id
$video = parse_video_uri( $video_uri );
// get youtube thumbnail
@dsmy
dsmy / gulpfiles.js
Created October 28, 2016 15:30
roots.io with gulp.js
'use strict';
// TODO: better timing and size informations
// TODO: add sass sourcemaps
// TODO: bower wiredep
var gulp = require('gulp');
var del = require('del');
var $$ = require('gulp-load-plugins')();
@dsmy
dsmy / AutoCopyrightUpdate.php
Created November 16, 2015 16:03
Auto update copyright in footer with error protection
<!--Referenced from https://css-tricks.com/snippets/php/automatic-copyright-year/-->
<!--Start date with error protection-->
<?php function auto_copyright($year = 'auto'){ ?>
<?php if(intval($year) == 'auto'){ $year = date('Y'); } ?>
<?php if(intval($year) == date('Y')){ echo intval($year); } ?>
<?php if(intval($year) < date('Y')){ echo intval($year) . ' - ' . date('Y'); } ?>
<?php if(intval($year) > date('Y')){ echo date('Y'); } ?>
<?php } ?>
@dsmy
dsmy / customwoocartclass.php
Created April 1, 2015 20:16
Custom Class if Item is in Cart Woocommerce
<?php
global $woocommerce;
// Extra post classes
$classes = array();
if ( 0 == ( $woocommerce_loop['loop'] - 1 ) % $woocommerce_loop['columns'] || 1 == $woocommerce_loop['columns'] )
$classes[] = 'first';
if ( 0 == $woocommerce_loop['loop'] % $woocommerce_loop['columns'] )
$classes[] = 'last';
// If item is in cart add this class
foreach($woocommerce->cart->get_cart() as $cart_item_key => $values ) {
@dsmy
dsmy / my_custom_admin_columns.php
Created March 30, 2015 07:43
additional data in admin columns
// Display additional data in admin columns for testimonials section
function my_testimonials_columns($columns)
{
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'testimonialType' => 'Testimonial Type',
'videoID' => 'Video ID',
'author' => 'Author',
'date' => 'Date',
@dsmy
dsmy / acf-dynamicVidrepeater.php
Last active September 8, 2015 17:56
Repeater Field with Dynamic thumbnails from Vimeo/Youtube
// Includes toggle select for either youtube/vimeo
// using foundation 5 (modal, block grid)
<ul class="small-block-grid-1 medium-block-grid-3">
<?php
if ( have_rows( 'academy_video_box' ) ) :
while ( have_rows( 'academy_video_box' ) ) : the_row();
$type = get_sub_field( 'academy_box_video_toggle' );
$video_id = get_sub_field('academy_box_video_id');
if( $type === 'youtube' ): ?>
<?php
// Define the 'Portfolio' post type. This is used to represent galleries
// of photos. This will be our top-level custom post type menu
$args = array(
'labels' => array(
'all_items' => 'Gallery',
'menu_name' => 'Portfolio',
'singular_name' => 'Gallery',
'edit_item' => 'Edit Gallery',
@dsmy
dsmy / wptaxmecheckbox.php
Last active June 26, 2019 10:39
Taxonomy checkbox list
/**
* returns taxonomy lists that have children with checkboxes
*
*/
function get_subject_list($taxonomy){
// Sets the taxonomy to pull a list of terms from.
// Throws them into a nifty object for referencing and counting
$terms = get_terms($taxonomy,array('parent' => 0));
if ($terms) {
// Custom Dashboard widgets
function custom_dashboard_widgets() {
global $wp_meta_boxes;
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'] );
unset( $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now'] );
unset( $wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments'] );