Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

[WIP] Add autoloading, composer, and bump version #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017 Lumen Learning
Copyright (c) 2019 Lumen Learning

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# Candela LTI

A plugin that implements the LTI/Wordpress integration, found [here](https://github.com/lumenlearning/lti).
A plugin that implements the LTI/Wordpress integration found [here](https://github.com/lumenlearning/lti).

## Synopsis

[LTI](https://www.imsglobal.org/activity/learning-tools-interoperability) is a
specification developed by IMS Global Learning Consortium. Candela
LTI is a plugin that extends the core functionality of the
[LTI Wordpress plugin](https://github.com/lumenlearning/lti) for the Candela
technology stack.
[LTI](https://www.imsglobal.org/activity/learning-tools-interoperability) is a specification developed by IMS Global Learning Consortium.
Candela LTI is a plugin that extends the core functionality of the [LTI Wordpress plugin](https://github.com/lumenlearning/lti) for the Candela technology stack.

## Installation

Expand All @@ -18,9 +15,5 @@ Coming soon ...

### Manually

1. Download or clone Candela LTI into your wordpress multisite plugins directory: `/path/to/wordpress/wp-content/plugins`
1. Log in to your Wordpress multisite instance and navigate to `Network Admin > Plugins` and activate the Candela LTI plugin

## License

MIT - See LICENSE for more information
1. Download or clone Candela LTI into your wordpress multisite plugins directory: `/path/to/wordpress/wp-content/plugins`
1. Log in to your Wordpress multisite instance and navigate to `Network Admin > Plugins` and activate the Candela LTI plugin
43 changes: 43 additions & 0 deletions autoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/**
* PSR-4 compliant autoload.
*
* @modified from https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader-examples.md
* @param string $class The fully-qualified class name.
*
* @return void
*/

\spl_autoload_register( function ( $class ) {

// project-specific namespace prefix
$prefix = 'Candela\Lti';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/inc';
// does the class use the namespace prefix?
$len = \strlen( $prefix );

if ( \strncmp( $prefix, $class, $len ) !== 0 ) {
// no, move to the next registered autoloader
return;
}

// get the relative class name
$relative_class = \substr( $class, $len );

if ( false !== ( $last_ns_pos = strripos( $relative_class, '\\' ) ) ) {
$namespace = substr( $relative_class, 0, $last_ns_pos );
$class = substr( $relative_class, $last_ns_pos + 1 );
$file = str_replace( '\\', DIRECTORY_SEPARATOR, $namespace ) . DIRECTORY_SEPARATOR;
}

$file .= 'class-' . str_replace( '_', '-', $class ) . '.php';

$path = $base_dir . strtolower( $file );

// if the file exists, require it
if ( \file_exists( $path ) ) {
require $path;
}
} );
Loading