Skip to content

Instantly share code, notes, and snippets.

@tjhole
tjhole / ACF: Options Sub Pages
Created May 27, 2014 11:14
ACF: Options Sub Pages
function my_acf_options_page_settings( $settings )
{
$settings['title'] = 'Global';
$settings['pages'] = array('Header', 'Sidebar', 'Footer');
return $settings;
}
add_filter('acf/options_page/settings', 'my_acf_options_page_settings');
@tjhole
tjhole / PHP: If Mobile
Created June 22, 2014 10:53
PHP: If Mobile
function isMobile() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
@tjhole
tjhole / WORDPRESS: Google Analytics Bouncer
Created June 30, 2014 10:51
WORDPRESS: Google Analytics Bouncer
function lxb_google_analytic_dashboard_bouncer() {
//is the GAD plugin active in the first place?
if(is_plugin_active('google-analytics-dashboard/google-analytics-dashboard.php')) {
//get the current user
$current_user_id=get_current_user_id();
//are you a super admin? if so, great
@tjhole
tjhole / CSS: Transitions
Created July 10, 2014 11:39
CSS: Transitions
-webkit-transition: all 500ms ease-out 1s;
-moz-transition: all 500ms ease-out 1s;
-o-transition: all 500ms ease-out 1s;
transition: all 500ms ease-out 1s;
@tjhole
tjhole / Repeater
Created July 14, 2014 13:19
ACF: Repeater
<?php
// check if the repeater field has rows of data
if( have_rows('repeater_field_name') ):
// loop through the rows of data
while ( have_rows('repeater_field_name') ) : the_row();
// display a sub field value
the_sub_field('sub_field_name');
@tjhole
tjhole / ACF: Flexible Content
Created July 14, 2014 13:20
ACF: Flexible Content
<?php
// check if the flexible content field has rows of data
if( have_rows('flexible_content_field_name') ):
// loop through the rows of data
while ( have_rows('flexible_content_field_name') ) : the_row();
if( get_row_layout() == 'paragraph' ):
@tjhole
tjhole / CSS: Cover Background
Created July 15, 2014 10:15
CSS: Cover Background
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
@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="';
@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: 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;