PHP code example of akibatech / wysiwygpreprocessor
1. Go to this page and download the library: Download akibatech/wysiwygpreprocessor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
akibatech / wysiwygpreprocessor example snippets
$textarea = "Check my website http://website.com. Keep in touch at [email protected] !";
use Akibatech\Wysiwyg\Processor;
use Akibatech\Wysiwyg\Modifier;
$processor = new Processor();
$processor->addModifier(new Modifier\UrlToLink)
->addModifier(new Modifier\MailToLink)
->process($textarea);
echo $processor->getOutput();
$textarea = 'Check out my new site: personnal-website.com';
$modifier = new Akibatech\Wysiwyg\Modifier\UrlToLink();
$modifier->setOptions([
'class' => 'custom-link',
'target' => '_blank'
])
$processor = new Akibatech\Wysiwyg\Processor();
$processor->addModifier($modifier)
->process($textarea);
echo $processor->getOutput();
[
// New tag called [yellow]text in yellow[/yellow]
'yellow' => '<span style="color: yellow;">$1</span>',
// Disable default "b" tag
'b' => null
]
[
// My custom delimiter. Vars are parsed in this delimiter. Default is "%".
'in' => '%',
// Accepted vars
'accept' => [
'name' => 'Joe', // %name% => Joe
'email' => '[email protected]' // %email% => [email protected]
]
]
[
// Words list as an array.
'words' => ['word1', 'word2'], // No defaults words.
// Replacement
'replace' => '[censored]' // Wanted replacement, default to [censored]
]
[
// Will replace "@" by "<at>", set to false to disable...
'at' => '<at>',
]
[
// Linebreak symbol to search. Defaults to "\n"
'search' => "\n",
// HTML to replace. Defaults to "<br>"
'replace' => '<br />'
]
[
// Allowed HTML tags (see strip_tags documentation). Defaults, none.
'allow' => "<a>",
]
[
// Add a custom class to all generated tags. No defaults.
'class' => 'link',
// Customize the link target. No defaults.
'target' => '_blank'
]
[
// Custom class added to the player
'class' => 'youtube-iframe',
// Custom width (in px) or null
'width' => 560,
// Custom height (in px) or null
'height' => 315,
// Allow fullscreen
'allow_fullscreen' => true,
// Enable youtube suggestions when video ends
'with_suggestions' => false,
// Display video info
'with_infos' => true,
// Display video controls
'with_controls' => true
]
$processor->addModifier(function($input) {
return str_rot13('hello'); // Will return "uryyb"
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.