'paper_css', 'src' => $this->get_base_url() . '/css/style.css', 'version' => $this->_version, 'enqueue' => array( array( 'field_types' => array( 'select' ) ) ) ) ); return array_merge( parent::styles(), $styles ); } public function init_ajax() { parent::init_ajax(); add_action( 'wp_ajax_get_paper_sizes', array($this,'getPaperSizes')); add_action( 'wp_ajax_nopriv_get_paper_sizes', array($this,'getPaperSizes')); add_action( 'wp_ajax_get_paper_cost', array($this,'getPaperCost')); add_action( 'wp_ajax_nopriv_get_paper_cost', array($this,'getPaperCost')); } function getSettings($form){ if (!$this->_fsettings){ $this->_fsettings = $this->get_form_settings( $form ); } if (!$this->_psettings){ $this->_psettings = $this->get_plugin_settings( $form ); } } function form_tag( $ftag, $form ) { ob_start(); include PAPER_PLUGIN_TEMPLATE_PATH."form.php"; $ftag.=ob_get_contents(); ob_end_clean(); return $ftag; } function loadDataFile($type,$shape){ $fname = sprintf("%s_%s.txt",preg_replace('/\s+/i','',strtoupper($type)),strtoupper($shape)); $ret = array(); if (file_exists(PAPER_PLUGIN_DATA_PATH.$fname)){ $data = file(PAPER_PLUGIN_DATA_PATH.$fname); $i=0; $cols = array(); foreach($data as $str){ $str=trim($str); if ($str==''){ continue; } $i++; if ($i==1){ $cols = explode("\t",$str); $ret['header']=array_filter(array_map('trim',$cols)); continue; } $row = explode("\t",$str); $key = trim($row[0]); $ret[$key]=array(); for($j=0;$jarray(),'quantity'=>array()); if ($type!='' && $shape!=''){ $data = $this->loadDataFile($type, $shape); $ret['quantity'] = $data['header']; unset($data['header']); $keys = array_keys($data); foreach($keys as $val){ $ret['size'][] = $val; } } echo json_encode($ret);exit; } function getPaperCost(){ $type = @trim($_REQUEST['type']); $shape = @trim($_REQUEST['shape']); $size = @trim($_REQUEST['size']); $qnt = @trim($_REQUEST['qnt']); $ret=array('cost'=>"$0,00"); if ($type!='' && $shape!='' && $size!='' && $qnt!=''){ $data = $this->loadDataFile($type, $shape); $qnts = array_flip($data['header']); unset($data['header']); $ret['cost']=$data[$size][$qnts[$qnt]]; } echo json_encode($ret);exit; } function modify_price( $value, $entry, $field ) { if ($field->type=='total'){ return floatval($_REQUEST['paper_price']); } return $value; } function createThankYouPage($entry, $form){ //saveLog(print_r($entry,true)); //print_r($entry);exit; //$this->getSettings($form); //exit; } public function form_settings_fields( $form ) { $choices = array(); $settings = $this->get_form_settings( $form ); return array( array( 'title' => esc_html__( 'Form Settings', 'paperaddon' ), 'fields' => array( array( 'label' => esc_html__( 'Thank you page', 'paperaddon' ), 'type' => 'text', 'name' => 'f_thankyou_page', 'tooltip' => esc_html__( 'Url for user redirect', 'paperaddon' ), ) ) ) ); } public function is_valid_setting( $value ) { return (@trim($value)!=''); } } ?>