/** * Generate Button HTML * * This function generates the necessary HTML to render the button. * */ public function getButtonHTML($button_type = 'blue_rect_sm') { if (!$this->validate()) { $this->addError('product data is invalid'); return $this->getErrorsHTML(); } $parent = GiveItSdk::getInstance(); $crypt = GiveItSdkCrypt::getInstance(); if ($parent == false) { $this->addError('SDK must be instantiated to render buttons'); return false; } $encrypted = $crypt->encode(Tools::jsonEncode($this->data), $parent->data_key); if ($encrypted == false) { if (!$this->render_errors) { return false; } $this->addError($crypt->errors()); return $this->getErrorsHTML(); } // $encrypted = urlencode($encrypted); $html = "<span class='giveit-button' data-giveit-buttontype='{$button_type}' data-giveit-data='{$encrypted}'></span>"; return $html; }
public function __construct() { $this->parent = GiveItSdk::getInstance(); $this->crypt = GiveItSdkCrypt::getInstance(); }