{"id":104246,"date":"2019-06-08T09:28:36","date_gmt":"2019-06-08T09:28:36","guid":{"rendered":"https:\/\/wordpress.org\/plugins\/advanced-custom-fields-snippets\/"},"modified":"2019-06-08T10:35:06","modified_gmt":"2019-06-08T10:35:06","slug":"acf-snippets","status":"publish","type":"plugin","link":"https:\/\/kal.wordpress.org\/plugins\/acf-snippets\/","author":16190395,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0.0","stable_tag":"trunk","tested":"5.2.24","requires":"4.8","requires_php":"5.4","requires_plugins":"","header_name":"Advanced Custom Fields: Snippets","header_author":"Tom\u00e1\u0161 Langer","header_description":"Adds useful function for rendering image fields, link fields, repeater fields and flexible content for the Advanced Custom Fields plugin.","assets_banners_color":"","last_updated":"2019-06-08 10:35:06","external_support_url":"","external_repository_url":"","donate_link":"https:\/\/www.paypal.com\/cgi-bin\/webscr?cmd=_s-xclick&hosted_button_id=M2L5UJG9JEWXU&source=url","header_plugin_uri":"https:\/\/bitbucket.org\/tomekthewo\/acf-snippets\/","header_author_uri":"http:\/\/tomekthewo.cz\/","rating":0,"author_block_rating":0,"active_installs":0,"downloads":1367,"num_ratings":0,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","changelog"],"tags":[],"upgrade_notice":[],"ratings":[],"assets_icons":{"icon-128x128.png":{"filename":"icon-128x128.png","revision":"2102604","resolution":"128x128","location":"assets","locale":""},"icon-256x256.png":{"filename":"icon-256x256.png","revision":"2102604","resolution":"256x256","location":"assets","locale":""}},"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":[],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[2211,2217],"plugin_category":[59],"plugin_contributors":[172564],"plugin_business_model":[],"class_list":["post-104246","plugin","type-plugin","status-publish","hentry","plugin_tags-acf","plugin_tags-advanced-custom-fields","plugin_category-utilities-and-tools","plugin_contributors-tomekthewo","plugin_committers-tomekthewo"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/ps.w.org\/acf-snippets\/assets\/icon-128x128.png?rev=2102604","icon_2x":"https:\/\/ps.w.org\/acf-snippets\/assets\/icon-256x256.png?rev=2102604","generated":false},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Adds useful functions for rendering image fields, link fields, repeater fields and flexible content for the Advanced Custom Fields plugin. For <a href=\"https:\/\/bitbucket.org\/tomekthewo\/advanced-custom-fields-snippets\/src\/master\/\">detailed info look on Bitbucket<\/a>.<\/p>\n\n<h3>Main advantages<\/h3>\n\n<ul>\n<li>write less code (do not repet same blocks of the code when writing down ACF custom fields)<\/li>\n<li>built-in filters<\/li>\n<li>works also for Gutenberg ACF Blocks<\/li>\n<li>no init hooks etc (no impact on performance)<\/li>\n<\/ul>\n\n<p><strong>Usage<\/strong><\/p>\n\n<h4>Link<\/h4>\n\n<p>Returns the snippet of a specific link field.<\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_get_link($selector, [$postId], [$args]);\n?&gt;\n<\/code><\/pre>\n\n<p>Displays the snippet of a specific link field.<\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_the_link($selector, [$postId], [$args]);\n?&gt;\n<\/code><\/pre>\n\n<p><strong>Parameters<\/strong>\n    $selector  <em>(string) (Required)<\/em> ACF field name or ACF field key. Based on <a href=\"https:\/\/www.advancedcustomfields.com\/resources\/get_field\/\">ACF get_field function<\/a>.\n    $postId  <em>(integer|bool) (Optional)<\/em>  The post ID where the value is saved. Use <code>true<\/code> for getting sub field.  Default value: <code>false<\/code> (current post).\n    $args  <em>(array) (Optional)<\/em> Array of link output arguments.  Default value: <code>null<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'class'<\/strong> <em>(string)<\/em> <code>class<\/code> attribute of the anchor.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'id'<\/strong> <em>(string)<\/em> <code>id<\/code> attribute of the anchor.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'title'<\/strong> <em>(string)<\/em> <code>title<\/code> attribute text of the anchor.<\/p>\n\n<h4>Image<\/h4>\n\n<p>Returns the snippet of a specific image field.<\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_get_image($selector, [$postId], [$args]);\n?&gt;\n<\/code><\/pre>\n\n<p>Displays the snippet of a specific image field.<\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_the_image($selector, [$postId], [$args]);\n?&gt;\n<\/code><\/pre>\n\n<p><strong>Parameters<\/strong>\n    $selector  <em>(string) (Required)<\/em> ACF field name or ACF field key. Based on <a href=\"https:\/\/www.advancedcustomfields.com\/resources\/get_field\/\">ACF get_field function<\/a>.\n    $postId  <em>(integer|bool) (Optional)<\/em>  The post ID where the value is saved. Use <code>true<\/code> for getting sub field.  Default value: <code>false<\/code> (current post).\n    $args  <em>(array) (Optional)<\/em> Array of image output arguments. Default value: <code>null<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'size'<\/strong> <em>(string)<\/em> Image size to use. Accepts any valid image size. Default value is <code>full<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'alt'<\/strong> <em>(string)<\/em> <code>alt<\/code> attribute of the image.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'id'<\/strong> <em>(string)<\/em> <code>id<\/code> attribute of the image.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'class'<\/strong> <em>(string)<\/em> <code>class<\/code> attribute of the image.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'title'<\/strong> <em>(string)<\/em> <code>title<\/code> attribute of the image.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'srcset'<\/strong> <em>(bool)<\/em> Use <code>true<\/code> for retrieving image's <code>srcset<\/code> attribute. Default  value: <code>false<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'loading'<\/strong> <em>(string)<\/em> <code>loading<\/code> attribute of the image. Default value: <code>lazy<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'link'<\/strong> <em>(bool|array)<\/em> Array of attributes for anchor wrapped around the image. Default value: <code>false<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>'href'<\/strong> <em>(string)<\/em> <code>href<\/code> attribute of the link.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>'target'<\/strong> <em>(string)<\/em> <code>target<\/code> attribute of the link.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>'class'<\/strong> <em>(string)<\/em> <code>class<\/code> attribute of the link.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>'id'<\/strong> <em>(string)<\/em> <code>id<\/code> attribute of the link.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>'title'<\/strong> <em>(string)<\/em> <code>title<\/code> attribute of the link.<\/p>\n\n<h4>Repeater<\/h4>\n\n<p>Displays the snippet of a specific repeater field.<\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_the_repeater($selector, [$postId], [$args]);\n?&gt;\n<\/code><\/pre>\n\n<p><strong>Parameters<\/strong>\n    $selector  <em>(string) (Required)<\/em> ACF field name or ACF field key. Based on <a href=\"https:\/\/www.advancedcustomfields.com\/resources\/get_field\/\">ACF get_field function<\/a>.\n    $postId  <em>(integer|bool) (Optional)<\/em>  The post ID where the value is saved. Default value: <code>false<\/code> (current post).\n    $args  <em>(array) (Optional)<\/em> Array of repeater output arguments.  Default value: <code>null<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'template'<\/strong> <em>(string|array)<\/em> Template for items inside the loop. Arguments of <code>get_template_part<\/code> function. In the template use standard <code>get_sub_field function<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'wrap_before'<\/strong> <em>(string)<\/em> Text (HTML) before repeater items while have rows.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'wrap_after'<\/strong> <em>(string)<\/em> Text (HTML) after repeater items while have rows\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'empty_html'<\/strong> <em>(string)<\/em> Text (HTML) in case there are no rows in repeater.<\/p>\n\n<h4>Flexible content<\/h4>\n\n<p>Displays the snippet of a specific flexible field.<\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_the_flexible_content($selector, [$postId], [$args]);\n?&gt;\n<\/code><\/pre>\n\n<p><strong>Parameters<\/strong>\n    $selector  <em>(string) (Required)<\/em> ACF field name or ACF field key. Based on <a href=\"https:\/\/www.advancedcustomfields.com\/resources\/get_field\/\">ACF get_field function<\/a>.\n    $postId  <em>(integer|bool) (Optional)<\/em>  The post ID where the value is saved. Default value: <code>false<\/code> (current post).\n    $args  <em>(array) (Optional)<\/em> Array of flexible content output arguments.  Default value: <code>null<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;<strong>'templates'<\/strong> <em>(array)<\/em> Array of templates for flexible content layouts.  In the templates use standard <code>get_sub_field function<\/code>.\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key <em>(string)<\/em> - layout name\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value <em>(string|array)<\/em> arguments for <code>get_template_part<\/code> function.<\/p>\n\n<p><em>Requires Advanced Custom Fields (Pro)<\/em><\/p>\n\n<h4>Examples<\/h4>\n\n<p><strong>Link field<\/strong><\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_the_link('more_info_link', false, [\n        'class'=&gt; 'link__out',\n        ]\n    );\n?&gt;\n<\/code><\/pre>\n\n<p><strong>Image field<\/strong><\/p>\n\n<pre><code>&lt;?php\n    echo acf_snippet_get_image('logo', 'option', [\n        'size' =&gt; 'medium',\n        'alt' =&gt; 'company name',\n        'title' =&gt; false,\n        'class' =&gt; 'header__logo',\n        'id' =&gt; 'company-logo',\n        'loading' =&gt; 'fetch',\n        'link' =&gt; [\n            'href' =&gt; get_home_url()\n            ]\n        ]\n    );\n?&gt;\n<\/code><\/pre>\n\n<p><strong>Repeater field<\/strong><\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_the_repeater( 'team_members', false, [\n        'template'    =&gt; [ 'templates\/loops\/loop', 'team-member' ],\n        'wrap_before' =&gt; '&lt;ul class=\"about__team\"&gt;',\n        'wrap_after'  =&gt; '&lt;\/ul&gt;',\n        'empty_html'  =&gt; '&lt;p&gt;' . __( 'No team members to show.', 'web' ) . '&lt;\/p&gt;'\n        ]\n    );\n?&gt;\n<\/code><\/pre>\n\n<p><strong>Flexible content field<\/strong><\/p>\n\n<pre><code>&lt;?php\n    acf_snippet_the_flexible_content( 'fp_content', false, [\n    'templates' =&gt; [\n        'slider'          =&gt; [ 'templates\/homepage\/snippet', 'slider' ],\n        'counters' =&gt; [ 'templates\/homepage\/snippet', 'counters' ],\n        'text_block'    =&gt; [ 'templates\/homepage\/snippet', 'text_block' ]\n        ]\n    ] \n);\n<\/code><\/pre>\n\n<p>?&gt;\n`<\/p>\n\n<!--section=changelog-->\n<h4>1.0<\/h4>\n\n<ul>\n<li>init<\/li>\n<\/ul>","raw_excerpt":"Adds useful functions for rendering image fields, link fields, repeater fields and flexible content for the Advanced Custom Fields plugin.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/104246","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=104246"}],"author":[{"embeddable":true,"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/tomekthewo"}],"wp:attachment":[{"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=104246"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=104246"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=104246"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=104246"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=104246"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/kal.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=104246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}