diff --git a/README.md b/README.md index b49b71e..d0b609a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,27 @@ # d12-moodle-shortcodes A filter that adds WordPress-like shortcodes to Moodle + +## What this filter does +This filter allows you to use a shortcode, such as `[wi]` to dynamically add content to Moodle blocks and activities. + +## How to install this filter +1. Upload the entire directory to the `moodle/filter` directory. +1. Make sure the plugin directory and enclosed files have the same permissions as other filters. (Use their permission scheme as a reference.) +1. Go to Site Administration >> Notifications and upgrade your database. +1. Go to Site Administration >> Plugins >> Filters >> Manage Filters and activate the plugin. + +## How to use this filter +This filter is preset to use `[wi]` to add `
`, and `[/wi]` to add `
`. + +You will need to go to the custom CSS area of your theme and define a style for `.wi` css class. + +## How to adapt this filter +This filter uses the php function `str_replace` to replace the shortcode with your desired text. The basic formula is + + str_replace ( + 'text to replace', + 'text to replace it with', + $string_to_replace_text_in + ) + +Both `text to replace` and `text to replace it with` will accept arrays, so you can define a lot of shortcodes in a single function. I have not yet tested performance when adding many shortcodes. diff --git a/filter.php b/filter.php new file mode 100755 index 0000000..fda7b7d --- /dev/null +++ b/filter.php @@ -0,0 +1,11 @@ +', ''), + $text + ); + } +} diff --git a/lang/en/filter_d12shortcodes.php b/lang/en/filter_d12shortcodes.php new file mode 100644 index 0000000..1156db8 --- /dev/null +++ b/lang/en/filter_d12shortcodes.php @@ -0,0 +1,3 @@ +. + +/** + * Version details + * + * @package filter + * @subpackage censor + * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->version = 2016051500; // The current plugin version (Date: YYYYMMDDXX) +$plugin->requires = 2016050500; // Requires this Moodle version +$plugin->component = 'filter_d12shortcodes'; // Full name of the plugin (used for diagnostics)