Skip to content

Instantly share code, notes, and snippets.

@nashvillegeek
nashvillegeek / geomywp-single.sublime-snippet
Created February 28, 2014 01:29
Sublime Text 2 snippet - Creates shortcode for single map display
<snippet>
<content><![CDATA[
/*'map_height' => '250px',
'map_width' => '250px',
'map_type' => 'ROADMAP',
'zoom_level' => 13,
'additional_info' => 'address,phone,fax,email,website',
'post_id' => 0,
'directions' => 1*/
@nashvillegeek
nashvillegeek / acf-repeater-subfield.sublime-snippet
Created November 19, 2013 14:51
Sublime Text 2 Snippet: Advanced Custom Fields Repeater subfield with conditional
<snippet>
<content><![CDATA[
if( \$row['${1:subfield_slug}'])
{
echo '<li>${1:subfield_slug}: ' . \$row['${1:subfield_slug}'] . '</li>';
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>acfrepeatersubfield</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
@nashvillegeek
nashvillegeek / acf-repeater-loop.sublime-snippet
Created November 19, 2013 14:50
Sublime Text 2 Snippet: Advanced Custom Fields repeater loop with conditional
<snippet>
<content><![CDATA[
\$rows = get_field('${1:repeater-slug}');
if($rows)
{ ?>
<?php foreach(\$rows as \$row)
{ ?>
@nashvillegeek
nashvillegeek / switch-to-blog-get-post.sublime-snippet
Created August 27, 2013 13:59
Wordpress Multisite switch blog and get archive Sublime Text 2 snippet
<snippet>
<content><![CDATA[
/* <?php */
global \$switched;
switch_to_blog(${1:1}); //input blog to switch to
// Get latest Post
\$latest_posts = get_posts('category=${2:-3}&numberposts=${3:5}&orderby=${4:post_name}&order=DSC');
?>
<ul>
@nashvillegeek
nashvillegeek / switch-to-blog-get-page.sublime-snippet
Created August 27, 2013 13:58
Wordpress Multisite Switch Blog and Get Page Sublime Text 2 snippet
<snippet>
<content><![CDATA[
/* <?php */
global \$switched;
switch_to_blog(${1:1}); //input blog to switch to
// Get latest Post
\$${2:PageVarName} = get_post(${3:PageID}, ARRAY_A);
\$title = \$${2:PageVarName}['post_title'];
@nashvillegeek
nashvillegeek / p2p_function.sublime-snippet
Created June 18, 2013 21:17
Wordpress post-2-post function Sublime Text 2 Snippet
<snippet>
<content><![CDATA[
//post 2 post connections for ${1:post_type_1}_to_${2:post_type_2}
function ${1:post_type_1}_to_${2:post_type_2}() {
p2p_register_connection_type( array(
'name' => '${1:post_type_1}-to-${2:post_type_2}',
'from' => '${1:post_type_1}',
'to' => '${2:post_type_2}'
) );
}
@nashvillegeek
nashvillegeek / cpt.sublime-snippet
Created June 10, 2013 19:00
Sublime Text 2 - Register Custom Post Type for Bones
<snippet>
<content><![CDATA[
// let's create the function for the custom type
function ng_cpt_${1:function_name}() {
// creating (registering) the custom type
register_post_type( 'cpt_${2:custom_type_plural}', /* (http://codex.wordpress.org/Function_Reference/register_post_type) */
// let's now add all the options for this post type
array('labels' => array(
'name' => __('${3:custom_type_plural_capital}', 'bonestheme'), /* This is the Title of the Group */
@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>
@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-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">',