I have made a custom cms system that works with 'shortcodes'. With some help i came this far, but am stuck on the part to make the shortcode for a specific ID. Can someone point me in the right direction or explain me how to do this?
This is what i got:
/*
example of content stored in database:
$content = "These are my clothes in a slider [plugin-slider] , and these are my shoes [plugin-slider]";
what i would like to to:
$content = "These are my clothes in a slider [plugin-slider id=3] , and these are my shoes [plugin-slider id=5]";
or even better:
$content = "These are my clothes in a slider [plugin-slider name=clothes] , and these are my shoes [plugin-slider name=shoes]";
*/
<?php
$regex = '~\[plugin-([^]]+)]~';
$content = htmlspecialchars_decode($page['content']);//content from db
$parts = preg_split($regex, $content, -1, PREG_SPLIT_DELIM_CAPTURE); //get shortcodes
foreach($parts as $k => $v){
if($k & 1)
include_once('plugins/'.$v.'.php'); //include shortcodes
else
echo htmlspecialchars_decode($v); //rest of content
}
?>
Now lets say i have a plugin slider, and made one for a specific page, but i want to use another slider from the same plugin for another page. Can I include them by ID? like [plugin-slider id=26]?
I am almost sure i need to edit the plugins as well, but i have no clue where to start. All help is appreciated!