Skip to content

Instantly share code, notes, and snippets.

@actual-saurabh
Last active September 27, 2018 04:00
Show Gist options
  • Save actual-saurabh/4e5c5b24940b9fa70da8b8343da6ec4f to your computer and use it in GitHub Desktop.
Save actual-saurabh/4e5c5b24940b9fa70da8b8343da6ec4f to your computer and use it in GitHub Desktop.
Complex Micro Example - Dummy Functionality
<?php
/**
* This can override the LifterLMS Class
* However, then we'll have to hook this one before loading LifterLMS itself
* This file can be included by LifterLMS by filtering the autoloader
* Include Override: lifterlms/includes/forms/controllers/class.llms.controller.login.php
*/
<?php
/**
* This file will just be included as it is into micro.php
*/
defined( 'ABSPATH' ) || exit;
// write php here
{
"name": "llms/dummy-micro",
"title": "Dummy Micro",
"version": "1.0.0",
"description": "This Dummy Micro adds a dancing baboon to your site.",
"homepage": "https://lifterlms.com",
"author": "saurabhshukla",
"tags": [ "onboarding", "membership", "course" ],
"plugins": [ "llms-woocommerce-integration", "woocommerce" ],
"themes": [ "lifterlms-launchpad", "wp-astra" ],
"template_overrides": [
{
"template": "global/sidebar.php",
"override": "sidebar.php"
}
],
"include_overrides": [
{
"include": "lifterlms/includes/forms/controllers/class.llms.controller.login.php",
"override": "class.llms.controller.login.php"
}
],
}
<?php
/**
* The main file that is included and run on the "plugins_loaded" action
* - Write some PHP Code
* - Include other files
* - Enqueue custom css and js
* - See LLMS Micros Developer API Documentation for more:
*/
defined( 'ABSPATH' ) || exit;
function_exists( 'llms_dummy_enqueue_script' ) && exit;
// global $llms_micros;
add_action( 'wp_enqueue_scripts', 'llms_dummy_enqueue_script' );
function llms_dummy_enqueue_script() {
global $llms_micros;
$options = $llms_micros[ 'dummy-micro' ];
wp_enqueue_script( 'dummy-micro-handle', $options->url . "public.js", array('llms'), $options->version );
}
include_once( $llms_micros[ 'dummy-micro' ]->path . 'include.php' );
<?php
/**
* Retrive sidebar
* Template Override: global/sidebar.php
*/
defined( 'ABSPATH' ) || exit;
get_sidebar( 'llms_shop' );
get_sidebar( 'llms_narration' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment