Skip to content

Latest commit

 

History

History
141 lines (123 loc) · 4.23 KB

README.md

File metadata and controls

141 lines (123 loc) · 4.23 KB

WPU ACF Flexible

JS workflow PHP workflow

Quickly generate flexible content in ACF

Add Flexible Content

Display in frontend

echo get_wpu_acf_flexible_content('home-blocks');

Add admin

add_filter('wpu_acf_flexible_content', 'example_wpu_acf_flexible_content', 10, 1);
function example_wpu_acf_flexible_content($contents) {

    $layouts = array();

    $layouts['basique'] = array(
        'label' => 'Basique',
        'sub_fields' => array(
            'title' => array(
                'label' => 'Titre'
            ),
            'content' => array(
                'label' => 'Contenu',
                'type' => 'textarea',
                'wpuacf_hidden_on' => array('post') // Hide this field on post type post
            ),
            'link' => array(
                'label' => 'URL Bouton',
                'type' => 'link'
            )
        )
    );

    $layouts['icons'] = array(
        'label' => 'Icones',
        'sub_fields' => array(
            'title' => array(
                'label' => 'Titre'
            ),
            'icons' => array(
                'label' => 'Icones',
                'type' => 'repeater',
                'sub_fields' => array(
                    'icons_title' => array(
                        'label' => 'Titre'
                    ),
                    'icons_image' => array(
                        'label' => 'Image',
                        'type' => 'image'
                    )
                )
            )
        )
    );

    /* Rich table : A rich table with images and content */
    $layouts['rich_table'] = array(
        'wpuacf_model' => 'rich-table'
    );
    /* Classic content */
    $layouts['content_classic'] = array(
        'wpuacf_model' => 'content-classic'
    );
    /* Features : Columns of content with an image, a text and an optional CTA */
    $layouts['features_list'] = array(
        'wpuacf_model' => 'features'
    );
    /* Downloads : A list of downloadable files */
    $layouts['downloads'] = array(
        'wpuacf_model' => 'downloads'
    );
    /* Logos : A list of clickable logos */
    $layouts['logos'] = array(
        'wpuacf_model' => 'logos'
    );
    /* Video : A simple embed with optional title and content */
    $layouts['video'] = array(
        'wpuacf_model' => 'video'
    );
    /* Image : A simple image with optional title and content */
    $layouts['image'] = array(
        'wpuacf_model' => 'image',
    );
    /* Image - Content : A simple image with title, content and CTA */
    $layouts['image-content'] = array(
        'wpuacf_model' => 'image-content'
    );
    /* Anchor : A quick way to insert an anchor into the content */
    $layouts['anchor'] = array(
        'wpuacf_model' => 'anchor'
    );
    /* Pull Quote : A Quote + Optional Details. */
    $layouts['quote'] = array(
        'wpuacf_model' => 'quote'
    );
    /* Team Quote : A Quote + A Picture + Optional Details. */
    $layouts['team-quote'] = array(
        'wpuacf_model' => 'team-quote'
    );

    $contents['home-blocks'] = array(
        /* Save HTML content in post_content */
        'save_post' => 1,
        /* Create initial layout files */
        'init_files' => 1,
        /* Target post types */
        'post_types' => array('post','page'),
        /* Target page templates */
        # 'page_templates' => array('page-template-flexible.php'),
        /* Target post ids */
        # 'page_ids' => array(1234),
        /* Global Conf */
        'name' => 'Blocks',
        'layouts' => $layouts
    );
    return $contents;
}

Todo

  • Remove Twig/Timber compatibility.

Default blocks

  • JS for default blocks (no dependency).
  • Wrapper DIVs generated by parent.
  • Method to retrieve all blocks at plugin init.
  • Video : Add an option + JS for cover image.

Blocks to create :

  • Slider : Images with title and content ().
  • Tabs : Multiple tabs with content.