Last active
August 29, 2015 14:05
-
-
Save manchumahara/c1ab38508a6e4ff31c38 to your computer and use it in GitHub Desktop.
adding visual editor to kazzo template wordpress plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Kazoo_TemplateEDIT($id) { | |
global $wpdb; | |
$r = null; | |
if ($id > 0) { | |
$q = "SELECT id,name,date,code FROM kazoo_tpl WHERE id=$id"; | |
$r = $wpdb->get_row($q,OBJECT); | |
} | |
//$e = Kazoo_CreateEngine(); | |
//Kazoo_SetAdminState($e); | |
if (is_null($r)) { | |
// $e->putValue('TplID',0); | |
// $e->putValue('TplName',''); | |
// $e->putValue('TplCode',''); | |
// $e->putValue('TplDate',''); | |
// $e->putValue('TplShort',''); | |
// $e->putValue('TplMode','create'); | |
// $e->putValue('TplEditText','Create'); | |
if ( $id > 0 ) { | |
//$e->putValue('TplHasMsg',true); | |
$TplHasMsg = true; | |
//$e->putValue('TplMsg',"ERROR: Template (id=$id) was not found."); | |
$TplMsg = "ERROR: Template (id=".$id.") was not found."; | |
} | |
$TplID = 0; | |
$TplName = ''; | |
$TplCode = ''; | |
$TplDate = ''; | |
$TplShort = ''; | |
$TplMode = 'create'; | |
$TplEditText = 'Create'; | |
} else { | |
// $e->putValue('TplID',$id); | |
// $e->putValue('TplName',stripslashes($r->name)); | |
// $e->putValue('TplCode',stripslashes($r->code)); | |
// $e->putValue('TplDate',$tplDate); | |
// $e->putValue('TplShort',"[Kazoo src='$id' /]"); | |
// $e->putValue('TplMode','update'); | |
// $e->putValue('TplEditText','Update'); | |
// $e->putValue('TplHasMsg',false); | |
// $e->putValue('TplMsg',''); | |
$TplID = $id; | |
$TplName = stripslashes($r->name); | |
$TplCode = stripslashes($r->code); | |
$TplDate = $tplDate; | |
$TplShort = '[Kazoo src="'.$id.'" /]'; | |
$TplMode = 'update'; | |
$TplEditText = 'Update'; | |
$TplHasMsg = false; | |
$TplMsg = ''; | |
} | |
//$e->executeFile(KAZOO_RELPATH.'/tpl/edit.php'); | |
//echo $e->getWriter()->getContent(); | |
?> | |
<div class="wrap"> | |
<p style="margin:0;padding:0;"><div id="icon-options-general" class="icon32"> </div><h2><?php echo KAZOO_NAME ; ?></h2></p> | |
<hr/> | |
<p style="text-align: right;"><a class="button-secondary" href="options-general.php?page=kazoo-templated-content">Back to Template Library</a></p> | |
<?php if($TplHasMsg): ?> | |
<div id="message" class="updated fade"><?php echo $TplMsg; ?></div> | |
<?php endif; ?> | |
<div> | |
<form action="options-general.php?page=kazoo-templated-content&mode=update&id=<?php echo $TplID; ?>" method="post"> | |
<table width="600"> | |
<tr> | |
<td valign="top">Short:</td> | |
<td valign="top"><?php echo $TplShort; ?></td> | |
</tr> | |
<tr> | |
<td>Name:</td> | |
<td><input type="text" id="TplName" name="TplName" maxlength="64" size="48" value="<?php echo $TplName; ?>" /></td> | |
</tr> | |
<tr> | |
<td valign="top">Code:</td> | |
<td valign="top"> | |
<!--textarea id="TplCode" name="TplCode" rows="24" cols="72" style="width:100%;height:100%;"><?php echo $TplCode; ?></textarea--> | |
<?php | |
wp_editor($TplCode, 'TplCode' ); | |
?> | |
</td> | |
</tr> | |
<tr> | |
<td> </td> | |
<td> | |
<table width="100%"> | |
<tr> | |
<td><a class="button-secondary" href="options-general.php?page=kazoo-templated-content">Cancel</a></td> | |
<td align="right"><input class="button-primary" type="submit" value="<?php echo $TplEditText; ?>" /></td> | |
</tr> | |
</table> | |
</td> | |
</tr> | |
</table> | |
</form> | |
</div> | |
</div> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment