├── README.md ├── html-date-field.sublime-snippet ├── html-dump-field.sublime-snippet ├── html-field.sublime-snippet ├── html-file-field-id.sublime-snippet ├── html-file-field-object.sublime-snippet ├── html-file-field.sublime-snippet ├── html-form-field.sublime-snippet ├── html-header-field.sublime-snippet ├── html-if-field.sublime-snippet ├── html-ifelse-field.sublime-snippet ├── html-image-field-id.sublime-snippet ├── html-image-field-object.sublime-snippet ├── html-image-field.sublime-snippet ├── html-link-field.sublime-snippet ├── html-location-field-map.sublime-snippet ├── html-location-field-staticmap.sublime-snippet ├── html-location-field.sublime-snippet ├── html-option-field.sublime-snippet ├── html-query-field.sublime-snippet ├── html-relationship-field.sublime-snippet ├── html-repeater-field-grid.sublime-snippet ├── html-repeater-field.sublime-snippet ├── html-text-field.sublime-snippet ├── php-dump-field.sublime-snippet ├── php-option-field.sublime-snippet └── php-the-field.sublime-snippet /README.md: -------------------------------------------------------------------------------- 1 | # Sublime ACF (Advanced Custom Fields) Snippets 2 | 3 | The atom version of this package is available at [smilledge/acf-atom-snippets](https://github.com/smilledge/acf-atom-snippets). 4 | 5 | ## Installation 6 | 7 | Clone this repo into your Sublime packages folder. (You may need to update the path if you are using Sublime Text 3) 8 | 9 | ### Mac 10 | ``` 11 | git clone https://github.com/smilledge/acf-sublime-snippets.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/User/ACF-Snippets 12 | ``` 13 | 14 | ### Linux 15 | ``` 16 | git clone https://github.com/smilledge/acf-sublime-snippets.git ~/.config/sublime-text-2/Packages/User/ACF-Snippets 17 | ``` 18 | 19 | ### Windows 20 | ``` 21 | git clone https://github.com/smilledge/acf-sublime-snippets.git [user]\AppData\Roaming\Sublime Text 2\Packages\User\ACF-Snippets 22 | ``` 23 | 24 | 25 | ## Snippets 26 | 27 | All tab triggers follow the following naming convention; `field:{field type}:{type/option}`. All fields also have appropriate tabstops setup, however the first will always be the field name. 28 | 29 | ### Basic Fields 30 | 31 | `field` / `field:header` / `field:text` / `field:link` / `field:option` **(HTML/PHP)** 32 | 33 | Get a field by name. (Header / text / link fields will be wrapped in `` / `

` / `` tags) 34 | 35 | ``` 36 | 37 | 38 | 39 | ``` 40 | 41 | **`field:date` (HTML)** 42 | 43 | Get and format a date field 44 | 45 | ``` 46 | 47 | format('d-m-Y'); ?> 48 | 49 | ``` 50 | 51 | **`field:if` / `field:ifelse` (HTML)** 52 | 53 | Field conditional. Also used for true/false fields. 54 | 55 | ``` 56 | 57 | 58 | ``` 59 | 60 | ### Image Field 61 | 62 | **`field:image` (HTML)** 63 | 64 | Image field with a return value of "Image URL" 65 | 66 | ``` 67 | 68 | <?php the_field(''); ?> 69 | 70 | ``` 71 | 72 | **`field:image:id` (HTML)** 73 | 74 | Image field with a return value of "Image ID" 75 | 76 | ``` 77 | 84 | ``` 85 | 86 | **`field:image:object` (HTML)** 87 | 88 | Image field with a return value of "Image Object" 89 | 90 | ``` 91 | 92 | 93 | 94 | <?php echo $image['alt']; ?> 95 | 96 | 97 | <?php echo $image['alt']; ?> 98 | 99 | 100 | ``` 101 | ### File Field 102 | 103 | **`field:file` (HTML)** 104 | 105 | File field with a return value of "File URL" 106 | 107 | ``` 108 | 109 | Download File 110 | 111 | ``` 112 | 113 | **`field:file:id` (HTML)** 114 | 115 | File field with a return value of "File ID" 116 | 117 | ``` 118 | 124 | 125 | 126 | ``` 127 | 128 | **`field:file:object` (HTML)** 129 | 130 | File field with a return value of "File Object" 131 | 132 | ``` 133 | 134 | 135 | 136 | ``` 137 | ### Relationship Field 138 | 139 | **`field:relationship` (HTML)** 140 | 141 | Get a relationship field and loop over all returned posts. 142 | ``` 143 | 144 | 145 |

152 | 153 | ``` 154 | 155 | ### Location Field 156 | 157 | **`field:location` (HTML)** 158 | 159 | Get the street address from a location field 160 | 161 | ``` 162 | 164 | 165 | 166 | ``` 167 | 168 | **`field:location:staticmap` (HTML)** 169 | 170 | Get a location field and convert it to a static Google Map 171 | 172 | ``` 173 | 176 | 177 | 178 | ``` 179 | 180 | **`field:location:map` (HTML)** 181 | 182 | Get a location field and convert it to an interactive Google Map. Also adds a marker to the location. The CSS is used to prevent rendering issues with map controls caused by most responsive CSS grids. 183 | 184 | ``` 185 | 188 | 189 | 190 | 205 | 206 | 211 | 212 |
213 | 214 | 215 | ``` 216 | 217 | ### Gravity Form Field 218 | 219 | **`field:form` (HTML)** 220 | 221 | Display a gravity form. The parameters for `gravity_form()` are outlined in the [Gravity Forms documentation](http://www.gravityhelp.com/documentation/page/Embedding_A_Form#Function_Call). 222 | 223 | ``` 224 | id, true); 227 | gravity_form($form->id, display_title, display_description, false, field_values, enable_ajax, 1); 228 | } ?> 229 | ``` 230 | 231 | 232 | ### Repeater Field 233 | 234 | **`field:repeater` (HTML)** 235 | 236 | Get and loop over a repeater field 237 | 238 | ``` 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | ``` 249 | 250 | **`field:repeater:grid` (HTML)** 251 | 252 | Loop over a repeater filed and seperate results into rows. The second tabstop is the row length. 253 | 254 | ``` 255 | 256 | 257 |
258 | 259 | 260 |
261 | 262 | 263 |
264 | $5 265 |
266 | 267 | 268 |
269 | 270 | 271 |
272 | 273 | 274 | ``` 275 | 276 | ### Queries 277 | 278 | **`field:query` (HTML)** 279 | 280 | Query a post type on a field value and loop over posts 281 | 282 | ``` 283 | 10, 287 | 'post_type' => 'post', 288 | 'meta_key' => 'field_name', 289 | 'meta_value' => 'field_value' 290 | ); 291 | 292 | $query = new WP_Query( $args ); 293 | 294 | ?> 295 | 296 | have_posts() ) : ?> 297 | 304 | 305 | 306 | 307 | ``` 308 | 309 | 310 | ### Misc 311 | 312 | `ddfield` **(HTML/PHP)** 313 | 314 | `var_dump` the field contents wrapped in `
` tags.
315 | 
316 | ```
317 | 
318 |     
319 | 
320 | ``` 321 | -------------------------------------------------------------------------------- /html-date-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | format('${3:d-m-Y}'); ?> 5 | ]]> 6 | 7 | field:date 8 | ACF date field 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-dump-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
]]> 6 | 7 | ddfield 8 | Dump ACF field 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ]]> 6 | 7 | field 8 | Display ACF field 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-file-field-id.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | ]]> 11 | 12 | field:file:id 13 | ACF file field (ID) 14 | text.html - source.php 15 | 16 | -------------------------------------------------------------------------------- /html-file-field-object.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ]]> 6 | 7 | field:file:object 8 | ACF file field (object) 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-file-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ${2:Download File} 5 | ]]> 6 | 7 | field:file 8 | ACF file field (URL) 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-form-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | id, true); 6 | gravity_form(\$form->id, ${2:display_title}, ${3:display_description}, false, ${4:field_values}, ${5:enable_ajax}, 1); 7 | } ?>]]> 8 | 9 | field:form 10 | ACF gravity forms field 11 | text.html - source.php 12 | 13 | -------------------------------------------------------------------------------- /html-header-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | ]]> 3 | field:header 4 | Display ACF header field 5 | text.html - source.php 6 | 7 | -------------------------------------------------------------------------------- /html-if-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $2 5 | ]]> 6 | 7 | field:if 8 | ACF true/false 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-ifelse-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $2 5 | 6 | $3 7 | ]]> 8 | 9 | field:ifelse 10 | ACF true/false 11 | text.html - source.php 12 | 13 | -------------------------------------------------------------------------------- /html-image-field-id.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | ]]> 10 | 11 | field:image:id 12 | ACF image field (ID) 13 | text.html - source.php 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /html-image-field-object.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | <?${TM_PHP_OPEN_TAG:php} echo \$image['alt']; ?> 7 | 8 | 9 | <?${TM_PHP_OPEN_TAG:php} echo \$image['alt']; ?> 10 | 11 | ]]> 12 | 13 | field:image:object 14 | ACF image field (object) 15 | text.html - source.php 16 | 17 | -------------------------------------------------------------------------------- /html-image-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ${2:<?${TM_PHP_OPEN_TAG:php} the_field(''); ?>} 5 | ]]> 6 | 7 | field:image 8 | ACF image field (URL) 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-link-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $2 5 | ]]> 6 | 7 | field:link 8 | ACF link/page 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-location-field-map.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 23 | 24 | 29 | 30 |
31 | 32 | ]]> 33 |
34 | field:location:map 35 | ACF location field map 36 | text.html - source.php 37 |
38 | -------------------------------------------------------------------------------- /html-location-field-staticmap.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | $3 7 | ]]> 8 | 9 | field:location:staticmap 10 | ACF location field static map 11 | text.html - source.php 12 | 13 | -------------------------------------------------------------------------------- /html-location-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | ]]> 7 | 8 | field:location 9 | ACF address field 10 | text.html - source.php 11 | 12 | -------------------------------------------------------------------------------- /html-option-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ]]> 6 | 7 | field:option 8 | Display ACF option field 9 | text.html - source.php 10 | 11 | -------------------------------------------------------------------------------- /html-query-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10, 7 | 'post_type' => 'post', 8 | 'meta_key' => '${1:field_name}', 9 | 'meta_value' => '${2:field_value}' 10 | ); 11 | 12 | \$query = new WP_Query( \$args ); 13 | 14 | ?> 15 | 16 | have_posts() ) : ?> 17 |
    18 | have_posts() ) : \$query->the_post(); ?> 19 |
  • 20 | 21 |
  • 22 | 23 |
24 | 25 | 26 | ]]> 27 |
28 | field:query 29 | Query on an ACF field 30 | text.html - source.php 31 |
32 | -------------------------------------------------------------------------------- /html-relationship-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
    6 | 7 |
  • 8 | 9 |
  • 10 | 11 |
12 | ]]> 13 |
14 | field:relationship 15 | ACF relationship field 16 | text.html - source.php 17 |
18 | -------------------------------------------------------------------------------- /html-repeater-field-grid.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 |
9 | 10 | 11 |
12 | $5 13 |
14 | 15 | 16 |
17 | 18 | 19 |
20 | 21 | ]]> 22 |
23 | field:repeater:grid 24 | ACF repeater field grid 25 | text.html - source.php 26 |
27 | -------------------------------------------------------------------------------- /html-repeater-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | $4 8 | 9 | 10 | 11 | ]]> 12 | 13 | field:repeater 14 | ACF repeater field 15 | text.html - source.php 16 | 17 | -------------------------------------------------------------------------------- /html-text-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

5 | ]]> 6 |
7 | field:text 8 | Display ACF text field 9 | text.html - source.php 10 |
11 | -------------------------------------------------------------------------------- /php-dump-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | "; 4 | var_dump(get_field('${1:field_name}')); 5 | die();]]> 6 | 7 | ddfield 8 | Dump ACF field 9 | source.php 10 | 11 | -------------------------------------------------------------------------------- /php-option-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | field:option 8 | Display ACF option field 9 | source.php 10 | 11 | -------------------------------------------------------------------------------- /php-the-field.sublime-snippet: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | field 8 | Display ACF field 9 | source.php 10 | 11 | --------------------------------------------------------------------------------