2019-04-23, 08:29:54
(2019-04-23, 08:05:04)craiga Wrote:(2019-04-23, 06:56:30)datiswous Wrote: What plugin? Or is it your own plugin you make?
It's an idea for a plug-in I'd like to make. I'd really like to know exactly how the process works. For example if I had a contact form or any content (even just a simple div with some text in it ) that I wanted to display in one of the pages. I would like the user to be able to use the process of adding (%whatever%) on any created page to display the form (or any content that I specify.)
Hope I've explained that clearly enough for you. I actually thought at first it was through adding a filter but I'm not sure on it. I've looked at several plugins to see if I could gain any information on how the process works (i18n gallery, po1 contact form).
Thanks
Maybe this can help you.
PHP Code:
add_filter('content','some_names');
In this example I use a table
PHP Code:
function some_names($content) {
$xml = getXML(dpeventGSCONTENT);
$settings = getXML(dpeventGSSETTINGS);
$dateformat = $settings->dateformat;
$out ='<table class="event-content">
<thead>
<tr>
<th>Event</th>
<th colspan="3" style="text-align:center;">Date</th>
<th>Content</th>
<th>Color</th>
</tr>
</thead>';
foreach ($xml->event as $event)
{
$ids = $event['id'];
$name = $event->name;
$startdate = $event->startdate;
$enddate = $event->enddate;
$color = $event->color;
$url = $event->url;
$content = $event->content;
// start content
$out .='<tr>';
if((string)$url ==='') {
$out .='<td>'.$name.'</td>';
} else {
$out .='<td><a href="'.$url.'">'.$name.'</a></td>';
} // end else
$out .='<td>'.date($dateformat,strtotime($startdate)).'</td>';
if((string)$enddate ==='') {
$out .= '<td>No date</td>';
} else {
$out .= '<td>'.date($dateformat,strtotime($enddate)).'</td>';
} // end else
if((string)$content ==='') {
$out .= '<td>NO Content</td>';
} else {
$out .= '<td style="max-width:400px;background:red;">'.$content.'</td>';
} // end else
$out .= '<td style="max-width:400px;background:red;">'.$url.'</td>
<td><div style="width:17px;height:17px;border-radius:3em;background-color:'.$color.'"></div></td>
</tr>';
} // foreach
$out .= '</table>';
// end content
$regex = '(%whatever%)'; // this is what you need
$content = str_replace($regex, $out, $content);
return $content;
}