1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| <?php $_LW->REGISTERED_APPS['my_app']=[ 'title'=>'My App', 'handlers'=>['onOutput'], ];
class LiveWhaleApplicationMyApp {
public function onOutput($buffer) { global $_LW; if ($_LW->page == 'news_edit') { $new_content='<div class="fields"> My custom instruction text goes here. </div>'; $buffer=preg_replace('~(<!-- START TAGS -->)~s', $new_content.'\\1', $buffer); }
if ($_LW->page==='dashboard') { $buffer=str_replace('Need help?','Do you need help?',$buffer); };
if (strpos($buffer, 'class="directory_location"')!==false) { $buffer = str_replace('class="directory_location"', 'class="directory_location updated"', $buffer); }
$matches=[]; preg_match('~<title>(.+?)</title>~s', $buffer, $matches); if (!empty($matches[1])) { if ($title=explode(' | ',$matches[1])) { if (sizeof($title)>1) { $title=array_unique($title); foreach($title as $key=>$val) { if (empty($val)) { unset($title[$key]); }; }; $title=implode(' | ',$title); if (!empty($title) && $title!=$matches[1]) { $buffer=preg_replace('~<title>.+?</title>~', '<title>'.$title.'</title>', $buffer,1); }; }; }; };
return $buffer; }
} ?>
|