Skip to content

Instantly share code, notes, and snippets.

@nashvillegeek
nashvillegeek / acf-option.sublime-snippet
Created April 12, 2013 17:34
Sublime Text 2 snippet to get Advanced Custom Fields Options value
<snippet>
<content><![CDATA[
\$${1:varname} = get_field('${2:field_name}', 'option');
if (\$${1:varname} != '') {
echo \$${1:varname};
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>acfoption</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@nashvillegeek
nashvillegeek / acf-get-field.sublime-snippet
Created April 22, 2013 18:03
Sublime Text 2 snippet for Advanced Custom Fields 'get field'
<snippet>
<content><![CDATA[
\$${1:varname} = get_field('${2:field_name}', '${3:\$post_id}');
if (\$${1:varname} != '') {
echo \$${1:varname};
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>acfgetfield</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@nashvillegeek
nashvillegeek / acf-option-numeric.sublime-snippet
Created April 22, 2013 18:05
Sublime Text 2 snippet for Advanced Custom fields - variation of acf-option for numeric entries conditional
<snippet>
<content><![CDATA[
\$${1:varname} = get_field('${2:field_name}', 'option');
if ((\$${1:varname} != '') && ((\$${1:varname} != '0'))) {
echo \$${1:varname};
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>acfoption-numeric</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@nashvillegeek
nashvillegeek / wp-taxonomy-by-taxonomy.sublime-snippet
Created April 22, 2013 18:08
Sublime Text 2 snippet for Advanced Custom Fields - Create section element
<snippet>
<content><![CDATA[
<section class="tax-${1:tax-slug}-block">
<?php
\$myterms = get_terms('${2:tax_name}', 'orderby=${3:title}&order=${4:ASC}&hide_empty');
foreach (\$myterms as \$term) : ?>
<div class='tax-${1:tax-slug}-item'>
<h2><a href="<?php echo \$term->slug; ?>"><?php echo \$term->name; ?></a></h2>
@nashvillegeek
nashvillegeek / wp-recent-posts.sublime-snippet
Created April 22, 2013 18:14
Wordpress: Recent Posts Script
<snippet>
<content><![CDATA[
<div class="recentPost widget">
<h2>Recent Posts:</h2>
<?php
global \$post;
\$args = array( 'numberposts' => ${1:5},'category' => ${2:'uncategorized'} );
\$myposts = get_posts( \$args );
foreach( \$myposts as \$post ) : setup_postdata(\$post); ?>
<div class="recentPostItem">
@nashvillegeek
nashvillegeek / WP-Protect-htaccess.sublime-snippet
Created April 22, 2013 18:15
Wordpress: htaccess mods to help lockdown wp
<snippet>
<content><![CDATA[
<files wp-config.php>
order allow,deny
deny from all
</files>
# Block the include-only files.
RewriteEngine On
RewriteBase /
@nashvillegeek
nashvillegeek / acf-show-field.sublime-snippet
Created April 22, 2013 18:20
Sublime Text 2 Snippet: Advanced Custom Fields get_field with conditional
<snippet>
<content><![CDATA[
if( get_field( '${1:field_name}' ) ): ?>
<p><?php the_field( '${1:field_name}' ); ?></p>
<?php endif; ?>
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>acfthefield</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@nashvillegeek
nashvillegeek / wp-register-widget.sublime-snippet
Created April 22, 2013 18:25
Wordpress: Register Widget
<snippet>
<content><![CDATA[
// Declare sidebar widget zone
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => '${1}',
'id' => '${2}',
'description' => '${3}',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
@nashvillegeek
nashvillegeek / WP-Disallow-file-edits.sublime-snippet
Created April 22, 2013 18:27
Wordpress: Config - Disallow file edits from admin area
<snippet>
<content><![CDATA[
define('DISALLOW_FILE_EDIT', true);
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>WPDisallow</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.php</scope> -->
</snippet>
@nashvillegeek
nashvillegeek / wp-show-sidebar.sublime-snippet
Created April 22, 2013 18:29
Wordpress: Display Sidebar
<snippet>
<content><![CDATA[
<?php if (function_exists('dynamic_sidebar') && dynamic_sidebar(' ${1:Sidebar Widgets} ')) : else : ?>
<!-- All this stuff in here only shows up if you DON'T have any widgets active in this zone -->
<p>Please activate some widgets</p>
<?php endif; ?>
]]></content>