/**
  * Loads profile options from database and creates options object
  * @return boolean true if profile was found, false otherwise
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 1.0.0
  */
 private function loadProfileOptions()
 {
     if (empty($this->profile)) {
         return false;
     }
     erpPROPaths::requireOnce(erpPROPaths::$erpPROShortCodeOpts);
     $profiles = get_option(erpPROShortCodeOpts::$shortCodeProfilesArrayName);
     if (empty($profiles) || empty($profiles[$this->profile])) {
         return false;
     }
     $erpOptions = erpPRODefaults::$comOpts + erpPRODefaults::$shortCodeOpts;
     $this->optObj = new erpPROShortCodeOpts();
     $this->optObj->loadOptions($this->profile);
     return $this->optObj->isProfileLoaded();
 }
 /**
  * Saves shortcode profile in DB
  *
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 1.0.0
  */
 public function saveShortcodeProfile()
 {
     if (!current_user_can('edit_posts')) {
         echo json_encode(array('error' => 'Action not allowed'));
         die;
     }
     if (!isset($_POST['profileName']) || empty($_POST['profileName'])) {
         echo json_encode(array('error' => 'You must set a profile name and define all options'));
         die;
     }
     $profileName = wp_strip_all_tags($_POST['profileName']);
     unset($_POST['profileName']);
     $profileOptions = $_POST;
     erpPROPaths::requireOnce(erpPROPaths::$erpPROShortCodeOpts);
     $scOpts = new erpPROShortCodeOpts();
     $scOpts->loadOptions($profileName);
     $res = $scOpts->saveOptions($profileOptions);
     echo json_encode(array('result' => $res, 'profileName' => $profileName));
     die;
 }