Skip to content

Instantly share code, notes, and snippets.

@ryandemmer
Last active January 20, 2017 09:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryandemmer/d34bd48bd7539e87f0d262f51f6ad0fc to your computer and use it in GitHub Desktop.
Save ryandemmer/d34bd48bd7539e87f0d262f51f6ad0fc to your computer and use it in GitHub Desktop.
OnContentBeforeSave example
<?php
class PlgContentExample extends JPlugin
{
public function onContentBeforeSave($context, $article, $isNew)
{
if ($context != 'com_content.form') {
return true;
}
$text = $article->text;
// make URL protocol relative
$text = preg_replace('#http:\/\/#i', '://', $text);
$article->text = $text;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment