Skip to content

bornfight-studio/bf-modal

Repository files navigation

BF MODAL

WordPress plugin for converting pages and post types to modals

Table of Contents

Features

  • converting pages to modal
  • converting default post type to modal
  • converting custom post types to modal
  • registering custom modal templates
  • custom js events

Usage

  1. Converting Pages to modals

Edit Page -> Is Modal (Yes)

Choose archive page (page that opens in background of modal)

  1. Converting Post Types to modal

BF Modal Options -> Choose post type to convert

  1. Registering modal templates

Use bfml_register_modal_templates( array $templates ) {}

$templates = array('Default Modal Template', 'Test Modal Template');

if ( function_exists( 'bfml_register_modal_templates' ) ) {
    bfml_register_modal_templates( array( 'Default Template', 'Test Modal Template' ) );
 }

Name of templates are created with WordPress function sanitize_title_with_dashes()

Example: Default Modal Template -> default-modal-template

  1. Opening popups
  • add class js-bfml-modal-trigger -> it triggers endpoint to populate modal
  • data-post-data-id (required) -> id of post/page to pull content from
  • data-return-url(optional) -> returning URL, by default returns to current URL modal is opened from
<a href="<?php echo get_permalink( $post_id ); ?>" class="js-bfml-modal-trigger" data-post-data-id="12">
    This is a test post type Link
</a>
  1. Custom JS Events
    • bfml:init-modal
    • bfml:open-modal
    • bfml:close-modal
    • bfml:populate-modal
    • bfml:after-populate-modal

License