Created
September 14, 2015 10:56
-
-
Save AaronRutley/94cc46cd8240c320627f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WP, ACF and PHP snippets | |
'.text.html.php:not(.source)': | |
'ACF Field': | |
'prefix': 'acf' | |
'body': ''' | |
<?php the_field( '${1:field_name}' ); ?> | |
''' | |
'ACF Image': | |
'prefix': 'acfi' | |
'body': ''' | |
<?php \$thumb = wp_get_attachment_image_src(get_sub_field('${1}'), 'thumb-${2}'); ?> | |
<img src="<?php echo \$thumb[0]; ?>" /> | |
''' | |
'ACF Option': | |
'prefix': 'acfo' | |
'body': ''' | |
<?php the_field('${1}','options'); ?> | |
''' | |
'ACF Repeater': | |
'prefix': 'acfr' | |
'body': ''' | |
<?php if(get_field('${1}')): ?> | |
<?php while(the_repeater_field('${1}')): ?> | |
<?php the_sub_field('${2}'); ?> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
''' | |
'ACF relationship': | |
'prefix': 'acfrel' | |
'body': """ | |
<?php // custom relationship query | |
\$posts = get_field('${1}'); | |
if( \$posts ): foreach( \$posts as \$post): setup_postdata(\$post);?> | |
<?php the_title(); ?> | |
<?php endforeach; wp_reset_postdata(); endif;?> | |
""" | |
'ACF sub field': | |
'prefix': 'acfsub' | |
'body': ''' | |
<?php the_sub_field('${1}'); ?> | |
''' | |
'php dump': | |
'prefix': 'phpdump' | |
'body': ''' | |
echo '<pre>'.vardump(${1}).'</pre>'; | |
''' | |
'section class': | |
'prefix': 'sc' | |
'body': ''' | |
<section class="${1}"> | |
${2} | |
</section><!-- .${1} --> | |
''' | |
'div class': | |
'prefix': 'dc' | |
'body': ''' | |
<div class="${1}"> | |
${2} | |
</div><!-- .${1} --> | |
''' | |
'div class container': | |
'prefix': 'dcc' | |
'body': ''' | |
<div class="container"> | |
${1} | |
</div><!-- .container --> | |
''' | |
'WP Config': | |
'prefix': 'wpconfig' | |
'body': ''' | |
define('WP_HOME','http://${1}); | |
define('WP_SITEURL','http://${1}'); | |
define('WP_POST_REVISIONS', 5); | |
''' | |
'WP Local': | |
'prefix': 'wplocal' | |
'body': ''' | |
define('LOCAL_URL', 'http://aaronrutley.dev'); | |
define('REMOTE_URL', 'http://aaronrutley.com'); | |
define('LOCAL_LIVE_RELOAD', true); | |
define('LOCAL_IMAGE_PROXY', true); | |
''' | |
'WP Dir': | |
'prefix': 'wpdir' | |
'body': ''' | |
<?php bloginfo('template_directory'); ?>/assets/images/${1} | |
''' | |
'WP Get template part': | |
'prefix': 'wpgtp' | |
'body': ''' | |
<?php get_template_part('${1}'); ?> | |
''' | |
'WP List pages': | |
'prefix': 'wplp' | |
'body': ''' | |
<?php wp_list_pages("depth=1&title_li="); ?> | |
''' | |
'WP Permalink': | |
'prefix': 'wpp' | |
'body': ''' | |
<?php the_permalink() ?> | |
''' | |
'WP Shortcode': | |
'prefix': 'wpp' | |
'body': ''' | |
<?php echo do_shortcode('[gravityform id=${1} title=false description=false]'); ?> | |
''' | |
'WP Title': | |
'prefix': 'wpt' | |
'body': ''' | |
<?php the_title(); ?> | |
''' | |
'WP url': | |
'prefix': 'wpurl' | |
'body': ''' | |
<?php bloginfo('url'); ?> | |
''' | |
'WP Query': | |
'prefix': 'wpq' | |
'body': ''' | |
<?php | |
${1} | |
// wp query | |
// https://gist.github.com/AaronRutley/5654937 | |
// \$page_id = \$post->ID; | |
// \$parent_page_id = \$post->post_parent; | |
//args | |
\$args = array( | |
'post_type' => 'any', | |
//'post_parent' => 1, | |
'posts_per_page' => '-1', | |
'orderby' => 'menu_order', | |
'order' => 'DESC' | |
); | |
// new query | |
\$the_query = new WP_Query( \$args ); | |
if ( \$the_query->have_posts() ) : | |
while ( \$the_query->have_posts() ) : \$the_query->the_post();?> | |
<?php endwhile; endif;wp_reset_postdata();?> | |
''' | |
# Scss snippets | |
'.source.scss': | |
'Break from small': | |
'prefix': 'bfs' | |
'body': ''' | |
@include breakpoint(from-small) { | |
@include grid(${1}); | |
} | |
''' | |
'Break from medium': | |
'prefix': 'bfm' | |
'body': ''' | |
@include breakpoint(from-medium) { | |
@include grid(${1}); | |
} | |
''' | |
'Break from large': | |
'prefix': 'bfl' | |
'body': ''' | |
@include breakpoint(from-large) { | |
@include grid(${1}); | |
} | |
''' | |
'Extend clearfix': | |
'prefix': 'ecf' | |
'body': ''' | |
@extend %clearfix; | |
''' | |
'Extend grid-container': | |
'prefix': 'egc' | |
'body': ''' | |
@extend %grid-container; | |
''' | |
'Extend grid-block': | |
'prefix': 'egb' | |
'body': ''' | |
@extend %grid-block; | |
''' | |
'Extend grid-block-collapse': | |
'prefix': 'egbc' | |
'body': ''' | |
@extend %grid-block-collapse; | |
''' | |
'Grid block': | |
'prefix': 'grid' | |
'body': ''' | |
@include grid(${1}); | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment