Skip to content

Instantly share code, notes, and snippets.

@joseadrian
Forked from hereswhatidid/acf-fields.php
Created April 4, 2017 22:21
Show Gist options
  • Save joseadrian/e65fe61994595b8089b8b95a85c80d2c to your computer and use it in GitHub Desktop.
Save joseadrian/e65fe61994595b8089b8b95a85c80d2c to your computer and use it in GitHub Desktop.

Revisions

  1. @hereswhatidid hereswhatidid revised this gist Aug 5, 2015. 1 changed file with 101 additions and 0 deletions.
    101 changes: 101 additions & 0 deletions acf-fields.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,101 @@
    <?php
    if( function_exists('acf_add_local_field_group') ):

    acf_add_local_field_group(array (
    'key' => 'acf_product_options',
    'title' => 'Product Options',
    'fields' => array (
    array (
    'key' => 'acf_product_options_tabbedcontent_label',
    'label' => 'Tabbed Content',
    'name' => '',
    'type' => 'tab',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array (
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'placement' => 'top',
    'endpoint' => 0,
    ),
    array (
    'key' => 'acf_product_options_tabbedcontent_tabs',
    'label' => 'Tabs',
    'name' => 'tabs',
    'type' => 'repeater',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array (
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'min' => '',
    'max' => '',
    'layout' => 'row',
    'button_label' => 'Add Tab',
    'sub_fields' => array (
    array (
    'key' => 'acf_product_options_tabbedcontent_tab_title',
    'label' => 'Tab Title',
    'name' => 'tab_title',
    'type' => 'text',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array (
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'default_value' => '',
    'placeholder' => '',
    'prepend' => '',
    'append' => '',
    'maxlength' => '',
    'readonly' => 0,
    'disabled' => 0,
    ),
    array (
    'key' => 'acf_product_options_tabbedcontent_tab_content',
    'label' => 'Tab Content',
    'name' => 'tab_content',
    'type' => 'wysiwyg',
    'instructions' => '',
    'required' => 0,
    'conditional_logic' => 0,
    'wrapper' => array (
    'width' => '',
    'class' => '',
    'id' => '',
    ),
    'default_value' => '',
    'tabs' => 'all',
    'toolbar' => 'full',
    'media_upload' => 1,
    ),
    ),
    ),
    ),
    'location' => array (
    array (
    array (
    'param' => 'post_type',
    'operator' => '==',
    'value' => 'product',
    ),
    ),
    ),
    'menu_order' => 0,
    'position' => 'normal',
    'style' => 'default',
    'label_placement' => 'top',
    'instruction_placement' => 'label',
    'hide_on_screen' => '',
    ));

    endif;
  2. @hereswhatidid hereswhatidid revised this gist Aug 5, 2015. No changes.
  3. @hereswhatidid hereswhatidid revised this gist Aug 5, 2015. 1 changed file with 7 additions and 6 deletions.
    13 changes: 7 additions & 6 deletions custom-woo-acf-tabs.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,9 @@
    function load_custom_tab( $tab_key, $tab_info ) {
    <?php
    function hwid_load_custom_tab( $tab_key, $tab_info ) {
    echo apply_filters( 'the_content', $tab_info['tabContent'] );
    }

    add_filter( 'woocommerce_product_tabs', 'add_content_tabs' );

    function add_content_tabs( $tabs ) {
    function hwid_add_content_tabs( $tabs ) {

    global $post;

    @@ -15,9 +14,11 @@ function add_content_tabs( $tabs ) {
    'title' => $tab['tab_title'],
    'priority' => 20 + $index,
    'tabContent' => $tab['tab_content'],
    'callback' => 'load_custom_tab'
    'callback' => 'hwid_load_custom_tab'
    );
    }

    return $tabs;
    }
    }

    add_filter( 'woocommerce_product_tabs', 'hwid_add_content_tabs' );
  4. @hereswhatidid hereswhatidid created this gist Aug 5, 2015.
    23 changes: 23 additions & 0 deletions custom-woo-acf-tabs.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    function load_custom_tab( $tab_key, $tab_info ) {
    echo apply_filters( 'the_content', $tab_info['tabContent'] );
    }

    add_filter( 'woocommerce_product_tabs', 'add_content_tabs' );

    function add_content_tabs( $tabs ) {

    global $post;

    $custom_tabs = get_field( 'tabs', $post->ID );

    foreach( $custom_tabs as $index => $tab ) {
    $tabs['customTab-' . $index] = array(
    'title' => $tab['tab_title'],
    'priority' => 20 + $index,
    'tabContent' => $tab['tab_content'],
    'callback' => 'load_custom_tab'
    );
    }

    return $tabs;
    }