Skip to content

Instantly share code, notes, and snippets.

@tjhole
tjhole / gist:205630e73a76f826733f
Created September 11, 2014 09:08
WORDPRESS: Zip
function zip_gallery()
{
global $post;
$images = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_mime_type' => 'image', ));
if ($images) {
$save = $post->post_title;
$zip = new ZipArchive;
if ($zip->open($save . '.zip', ZIPARCHIVE::CREATE) === true) {
@tjhole
tjhole / CSS: Remove iOS input formatting
Created September 5, 2014 11:32
CSS: Remove iOS input formatting
input {
-webkit-appearance: none;
@include border-radius(0);
border-radius: none;
-webkit-border-radius:0px;
}
@tjhole
tjhole / WORDPRESS: Jetpack Subscription Form
Last active August 29, 2015 14:05
WORDPRESS: Jetpack Subscription
<?php $status = isset( $_REQUEST['subscribe'] ) ? $_REQUEST['subscribe'] : false; ?>
<?php if ( $status == 'invalid_email' ) : ?>
<p>You have entered an invalid e-mail, please try again!</p>
<?php elseif ( $status == 'success' ) : ?>
<p>Thank you for subscribing! Please check your e-mail to confirm.</p>
<?php else : ?>
<form method="POST">
<input type="hidden" name="my-form-action" value="subscribe" />
<input name="my-email" value="" placeholder="Enter your e-mail" />
<input type="submit" />
@tjhole
tjhole / ACF: Create Menu
Created August 14, 2014 10:32
ACF: Create Menu
<?php
// check if the repeater field has rows of data
if( have_rows('main_menu','options') ): ?>
<ul>
<?php
// loop through the rows of data
while ( have_rows('main_menu','options') ) : the_row();
$link = get_sub_field('page');
@tjhole
tjhole / ACF: Options Page Enable
Created August 14, 2014 10:22
ACF: Options Page Enable
if(function_exists('acf_add_options_page')) {
acf_add_options_page();
acf_add_options_sub_page('Header');
acf_add_options_sub_page('Footer');
}
@tjhole
tjhole / WORDPRESS: Dynamic SiteURL
Created August 12, 2014 07:49
WORDPRESS: Dynamic SiteURL
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] );
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME'] );
@tjhole
tjhole / WORDPRESS: Custom Post Type Front Page - 2014 (b)
Created July 23, 2014 11:07
WORDPRESS: Custom Post Type Front Page - 2014 (b)
function enable_front_page_stacks( $query ){
if('' == $query->query_vars['post_type'] && 0 != $query->query_vars['page_id'])
$query->query_vars['post_type'] = array( 'page', 'stack' );
}
add_action( 'pre_get_posts', 'enable_front_page_stacks' );
@tjhole
tjhole / WORDPRESS: Custom Post Type Front Page - 2014
Created July 23, 2014 11:05
WORDPRESS: Custom Post Type Front Page - 2014
function wpa18013_add_pages_to_dropdown( $pages, $r ){
if('page_on_front' == $r['name']){
$args = array(
'post_type' => 'stack'
);
$stacks = get_posts($args);
$pages = array_merge($pages, $stacks);
}
return $pages;
@tjhole
tjhole / WORDPRESS: Custom Post Type Front Page
Created July 23, 2014 11:04
WORDPRESS: Custom Post Type Front Page
/**
* Adds CPTs to the list of available pages for a static front page.
*
* @param string $select Existing select list.
* @return string
*/
function add_cpt_to_front_page_dropdown( $select )
{
if ( FALSE === strpos( $select, '<select name="page_on_front"' ) )
{
@tjhole
tjhole / WORDPRESS: Call Function Catch first image
Created July 18, 2014 11:58
WORDPRESS: Get first image from post
if ( get_the_post_thumbnail($post_id) != '' ) {
echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
the_post_thumbnail();
echo '</a>';
} else {
echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
echo '<img src="';