Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION Using (%%)
#7
(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;

Reply


Messages In This Thread
Using (%%) - by craiga - 2019-02-23, 22:58:57
RE: Using (%%) - by datiswous - 2019-02-27, 23:10:42
RE: Using (%%) - by craiga - 2019-03-01, 22:49:39
RE: Using (%%) - by craiga - 2019-04-23, 00:14:43
RE: Using (%%) - by datiswous - 2019-04-23, 06:56:30
RE: Using (%%) - by craiga - 2019-04-23, 08:05:04
RE: Using (%%) - by smdp-1971 - 2019-04-23, 08:29:54
RE: Using (%%) - by craiga - 2019-04-23, 17:18:40
RE: Using (%%) - by smdp-1971 - 2019-04-23, 22:11:38
RE: Using (%%) - by craiga - 2019-04-23, 20:48:06
RE: Using (%%) - by shawn_a - 2019-04-26, 02:46:42
RE: Using (%%) - by craiga - 2019-04-29, 18:50:02
RE: Using (%%) - by shawn_a - 2019-05-04, 08:51:08



Users browsing this thread: 1 Guest(s)