version = $_value; } public function get_version() { return $this->version; } public function set_error($_value) { $this->error = $_value; } public function get_error() { return $this->error; } public function set_errortokenname($_value) { $this->errortokenname = $_value; } public function get_errortokenname() { return $this->errortokenname; } public function set_errorhtmlvalue($_value) { $this->errorhtmlvalue = $_value; } public function get_errorhtmlvalue() { return $this->errorhtmlvalue; } public function set_errordescription($_value) { $this->errordescription = $_value; } public function get_errordescription() { return $this->errordescription; } public function set_icon($_value) { $this->icon = $_value; } public function get_icon() { return $this->icon; } public function set_tablenametypes($_value) { $this->tablenametypes = $_value; } public function get_tablenametypes() { return $this->tablenametypes; } public function set_tablenametokens($_value) { $this->tablenametokens = $_value; } public function get_tablenametokens() { return $this->tablenametokens; } // Construct the token add public function __construct() { global $_POST, $wpdb; $this->set_icon(plugin_dir_url( __FILE__ ) . 'icons/icon1_32.png'); $this->set_tablenametypes($wpdb->base_prefix . 'tokenmanagertypes'); $this->set_tablenametokens($wpdb->base_prefix . 'tokenmanager'); $this->init(); } // Initializes the page. function init() { global $_POST, $wpdb, $_GET, $current_site, $blog_id; // Create custom vars $siteid = (isset($current_site) && isset($current_site->id)) ? $current_site->id : '0'; $blogid = $blog_id; $haserror = false; $tid = $_GET['tid']; // Process Form if(isset($_POST['edittoken'])) { // Check required. if(!isset($_POST['tokenname']) || empty($_POST['tokenname'])){ $haserror = true; $this->set_errortokenname('Token Name is a required field!'); } if(empty($_POST['htmlvalue']) && empty($_POST['cssvalue']) && empty($_POST['jsvalue']) && empty($_POST['phpvalue'])){ $haserror = true; $this->set_errorhtmlvalue('Token Value is a required field!'); } if(!isset($_POST['description']) || empty($_POST['description'])){ $haserror = true; $this->set_errordescription('Description is a required field!'); } if(!$haserror) { $tokenname = mysql_real_escape_string($_POST['tokenname']); $tokentype = mysql_real_escape_string($_POST['tokentype']); $htmlvalue = mysql_real_escape_string($_POST['htmlvalue']); $phpvalue = mysql_real_escape_string($_POST['phpvalue']); $cssvalue = mysql_real_escape_string($_POST['cssvalue']); $jsvalue = mysql_real_escape_string($_POST['jsvalue']); $description = mysql_real_escape_string($_POST['description']); $authorid = wp_get_current_user(); $authorid = $authorid->ID; $tablename = $this->get_tablenametokens(); // Check if type already exists $toke = $wpdb->get_var("SELECT count(*) FROM $tablename WHERE tokenname = '$tokenname' AND id!='$tid' AND siteid='$siteid' AND blogid='$blogid' LIMIT 1"); if($toke>0){ $haserror = true; $this->set_errortokenname('Token Name already exists!'); } if(!$haserror) { // Sets the history for the insert $remoteip = $_SERVER['REMOTE_ADDR']; $occurred = date("D, M j, Y G:i:s T"); $history = mysql_real_escape_string(" "); // Setup version $wpdb->query('INSERT INTO ' . $tablename . 'versions (id, tokenid, datecreated, lastupdated, siteid, blogid, tokenname, htmlvalue, phpvalue, cssvalue, jsvalue, description, authorid, typeid, active, version) ' . 'SELECT null, id, datecreated, lastupdated, siteid, blogid, tokenname, htmlvalue, phpvalue, cssvalue, jsvalue, description, authorid, typeid, active, version FROM ' . $tablename . " WHERE id='$tid' AND siteid='$siteid' AND blogid='$blogid' LIMIT 1;"); // Insert into database $wpdb->query("UPDATE $tablename SET lastupdated = UNIX_TIMESTAMP(), tokenname = '$tokenname', htmlvalue = '$htmlvalue', phpvalue = '$phpvalue', cssvalue = '$cssvalue', jsvalue = '$jsvalue', description = '$description', typeid = '$tokentype', history = (SELECT REPLACE(history, '', '$history')), version = version + 1 WHERE id='$tid' AND siteid='$siteid' AND blogid='$blogid';"); } } if($haserror) { $this->set_error('Your form had the following errors!'); } else { $this->set_error('Edited Token Successfully!'); } } else { $tablename = $wpdb->base_prefix . 'tokenmanager'; $items = $wpdb->get_results("SELECT tokenname, htmlvalue, phpvalue, cssvalue, jsvalue, typeid, description, version FROM $tablename WHERE id='$tid' AND siteid='$siteid' AND blogid='$blogid' LIMIT 1;"); foreach ($items as $item) { // Get form fields $_POST['tokenname'] = $item->tokenname; $_POST['htmlvalue'] = $item->htmlvalue; $_POST['phpvalue'] = $item->phpvalue; $_POST['cssvalue'] = $item->cssvalue; $_POST['jsvalue'] = $item->jsvalue; $_POST['tokentype'] = $item->typeid; $_POST['description'] = $item->description; } } // Add Version to page $tablename = $this->get_tablenametokens(); $this->set_version($wpdb->get_var("SELECT version FROM $tablename WHERE id='$tid' LIMIT 1;")); } // Builds the drop downlist function build_dropdownlist($_selected) { global $_POST, $wpdb, $current_site, $blog_id; // Create custom vars $siteid = (isset($current_site) && isset($current_site->id)) ? $current_site->id : '0'; $blogid = $blog_id; // Escape data $results = ''; return $results; } } // Build class $tokenedit = new tokenedit(); $_POST = array_map('stripslashes_deep', $_POST); $_GET = array_map('stripslashes_deep', $_GET); ?> '; include 'sidebar.php'; } else { echo '
'; } ?>

Token Manager - Edit Token (ID: , VER: get_version();?>) View All Tokens

Edits the token in the token manager.

get_error(); ?>
get_errortokenname(); ?>
build_dropdownlist((isset($_POST['tokentype']) && !empty($_POST['tokentype']))?$_POST['tokentype']:''); ?> ( Add New Type )
get_errordescription(); ?>
HTMLPHPCSSJS
get_errorhtmlvalue(); ?>