@@ -21,11 +21,11 @@ |
||
21 | 21 | { |
22 | 22 | protected $zipArchive; |
23 | 23 | protected $filename; |
24 | - /** |
|
25 | - * Class constructor |
|
26 | - * |
|
27 | - * @throws PhpZipProxyException |
|
28 | - */ |
|
24 | + /** |
|
25 | + * Class constructor |
|
26 | + * |
|
27 | + * @throws PhpZipProxyException |
|
28 | + */ |
|
29 | 29 | public function __construct() |
30 | 30 | { |
31 | 31 | if (! class_exists('ZipArchive')) { |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | require_once 'ZipInterface.php'; |
3 | 3 | class PhpZipProxyException extends Exception |
4 | 4 | { } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct() |
30 | 30 | { |
31 | - if (! class_exists('ZipArchive')) { |
|
31 | + if (!class_exists('ZipArchive')) { |
|
32 | 32 | throw new PhpZipProxyException('Zip extension not loaded - check your php settings, PHP5.2 minimum with zip extension |
33 | 33 | is required for using PhpZipProxy'); ; |
34 | 34 | } |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | require_once 'ZipInterface.php'; |
3 | 5 | class PhpZipProxyException extends Exception |
4 | 6 | { } |
@@ -20,115 +20,115 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Odf |
22 | 22 | { |
23 | - protected $config = array( |
|
24 | - 'ZIP_PROXY' => 'PclZipProxy', |
|
25 | - 'DELIMITER_LEFT' => '{', |
|
26 | - 'DELIMITER_RIGHT' => '}', |
|
23 | + protected $config = array( |
|
24 | + 'ZIP_PROXY' => 'PclZipProxy', |
|
25 | + 'DELIMITER_LEFT' => '{', |
|
26 | + 'DELIMITER_RIGHT' => '}', |
|
27 | 27 | 'PATH_TO_TMP' => null |
28 | 28 | ); |
29 | - protected $file; |
|
30 | - protected $contentXml; |
|
31 | - protected $manifestXml; // To store content of manifest.xml file |
|
32 | - protected $tmpfile; |
|
33 | - protected $images = array(); |
|
34 | - protected $vars = array(); |
|
35 | - protected $manif_vars = array(); // array to store image names |
|
36 | - protected $segments = array(); |
|
37 | - const PIXEL_TO_CM = 0.026458333; |
|
38 | - /** |
|
39 | - * Class constructor |
|
40 | - * |
|
41 | - * @param string $filename the name of the odt file |
|
42 | - * @throws OdfException |
|
43 | - */ |
|
44 | - public function __construct($filename, $config = array()) |
|
45 | - { |
|
46 | - if (! is_array($config)) { |
|
47 | - throw new OdfException('Configuration data must be provided as array'); |
|
48 | - } |
|
49 | - foreach ($config as $configKey => $configValue) { |
|
50 | - if (array_key_exists($configKey, $this->config)) { |
|
51 | - $this->config[$configKey] = $configValue; |
|
52 | - } |
|
53 | - } |
|
54 | - if (! class_exists($this->config['ZIP_PROXY'])) { |
|
55 | - throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
|
56 | - } |
|
57 | - $zipHandler = $this->config['ZIP_PROXY']; |
|
58 | - $this->file = new $zipHandler(); |
|
59 | - if ($this->file->open($filename) !== true) { |
|
60 | - throw new OdfException("Error while Opening the file '$filename' - Check your odt file"); |
|
61 | - } |
|
62 | - if (($this->contentXml = $this->file->getFromName('content.xml')) === false) { |
|
63 | - throw new OdfException("Nothing to parse - check that the content.xml file is correctly formed"); |
|
64 | - } |
|
65 | - if (($this->manifestXml = $this->file->getFromName('META-INF/manifest.xml')) === false) { |
|
66 | - throw new OdfException("Something is wrong with META-INF/manifest.xm in source file '$filename'"); |
|
67 | - } |
|
29 | + protected $file; |
|
30 | + protected $contentXml; |
|
31 | + protected $manifestXml; // To store content of manifest.xml file |
|
32 | + protected $tmpfile; |
|
33 | + protected $images = array(); |
|
34 | + protected $vars = array(); |
|
35 | + protected $manif_vars = array(); // array to store image names |
|
36 | + protected $segments = array(); |
|
37 | + const PIXEL_TO_CM = 0.026458333; |
|
38 | + /** |
|
39 | + * Class constructor |
|
40 | + * |
|
41 | + * @param string $filename the name of the odt file |
|
42 | + * @throws OdfException |
|
43 | + */ |
|
44 | + public function __construct($filename, $config = array()) |
|
45 | + { |
|
46 | + if (! is_array($config)) { |
|
47 | + throw new OdfException('Configuration data must be provided as array'); |
|
48 | + } |
|
49 | + foreach ($config as $configKey => $configValue) { |
|
50 | + if (array_key_exists($configKey, $this->config)) { |
|
51 | + $this->config[$configKey] = $configValue; |
|
52 | + } |
|
53 | + } |
|
54 | + if (! class_exists($this->config['ZIP_PROXY'])) { |
|
55 | + throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
|
56 | + } |
|
57 | + $zipHandler = $this->config['ZIP_PROXY']; |
|
58 | + $this->file = new $zipHandler(); |
|
59 | + if ($this->file->open($filename) !== true) { |
|
60 | + throw new OdfException("Error while Opening the file '$filename' - Check your odt file"); |
|
61 | + } |
|
62 | + if (($this->contentXml = $this->file->getFromName('content.xml')) === false) { |
|
63 | + throw new OdfException("Nothing to parse - check that the content.xml file is correctly formed"); |
|
64 | + } |
|
65 | + if (($this->manifestXml = $this->file->getFromName('META-INF/manifest.xml')) === false) { |
|
66 | + throw new OdfException("Something is wrong with META-INF/manifest.xm in source file '$filename'"); |
|
67 | + } |
|
68 | 68 | |
69 | - $this->file->close(); |
|
69 | + $this->file->close(); |
|
70 | 70 | |
71 | - $tmp = tempnam($this->config['PATH_TO_TMP'], md5(uniqid())); |
|
72 | - copy($filename, $tmp); |
|
73 | - $this->tmpfile = $tmp; |
|
74 | - $this->_moveRowSegments(); |
|
75 | - } |
|
76 | - /** |
|
77 | - * Assing a template variable |
|
78 | - * |
|
79 | - * @param string $key name of the variable within the template |
|
80 | - * @param string $value replacement value |
|
81 | - * @param bool $encode if true, special XML characters are encoded |
|
82 | - * @throws OdfException |
|
83 | - * @return odf |
|
84 | - */ |
|
85 | - public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
|
86 | - { |
|
87 | - if (strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']) === false) { |
|
88 | - throw new OdfException("var $key not found in the document"); |
|
89 | - } |
|
90 | - $value = $encode ? htmlspecialchars($value) : $value; |
|
91 | - $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; |
|
92 | - $this->vars[$this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']] = str_replace("\n", "<text:line-break/>", $value); |
|
93 | - return $this; |
|
94 | - } |
|
95 | - /** |
|
96 | - * Assign a template variable as a picture |
|
97 | - * |
|
98 | - * @param string $key name of the variable within the template |
|
99 | - * @param string $value path to the picture |
|
100 | - * @throws OdfException |
|
101 | - * @return odf |
|
102 | - */ |
|
103 | - public function setImage($key, $value) |
|
104 | - { |
|
105 | - $filename = strtok(strrchr($value, '/'), '/.'); |
|
106 | - $file = substr(strrchr($value, '/'), 1); |
|
107 | - $size = @getimagesize($value); |
|
108 | - if ($size === false) { |
|
109 | - throw new OdfException("Invalid image"); |
|
110 | - } |
|
111 | - list ($width, $height) = $size; |
|
112 | - $width *= self::PIXEL_TO_CM; |
|
113 | - $height *= self::PIXEL_TO_CM; |
|
114 | - $xml = <<<IMG |
|
71 | + $tmp = tempnam($this->config['PATH_TO_TMP'], md5(uniqid())); |
|
72 | + copy($filename, $tmp); |
|
73 | + $this->tmpfile = $tmp; |
|
74 | + $this->_moveRowSegments(); |
|
75 | + } |
|
76 | + /** |
|
77 | + * Assing a template variable |
|
78 | + * |
|
79 | + * @param string $key name of the variable within the template |
|
80 | + * @param string $value replacement value |
|
81 | + * @param bool $encode if true, special XML characters are encoded |
|
82 | + * @throws OdfException |
|
83 | + * @return odf |
|
84 | + */ |
|
85 | + public function setVars($key, $value, $encode = true, $charset = 'ISO-8859') |
|
86 | + { |
|
87 | + if (strpos($this->contentXml, $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']) === false) { |
|
88 | + throw new OdfException("var $key not found in the document"); |
|
89 | + } |
|
90 | + $value = $encode ? htmlspecialchars($value) : $value; |
|
91 | + $value = ($charset == 'ISO-8859') ? utf8_encode($value) : $value; |
|
92 | + $this->vars[$this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT']] = str_replace("\n", "<text:line-break/>", $value); |
|
93 | + return $this; |
|
94 | + } |
|
95 | + /** |
|
96 | + * Assign a template variable as a picture |
|
97 | + * |
|
98 | + * @param string $key name of the variable within the template |
|
99 | + * @param string $value path to the picture |
|
100 | + * @throws OdfException |
|
101 | + * @return odf |
|
102 | + */ |
|
103 | + public function setImage($key, $value) |
|
104 | + { |
|
105 | + $filename = strtok(strrchr($value, '/'), '/.'); |
|
106 | + $file = substr(strrchr($value, '/'), 1); |
|
107 | + $size = @getimagesize($value); |
|
108 | + if ($size === false) { |
|
109 | + throw new OdfException("Invalid image"); |
|
110 | + } |
|
111 | + list ($width, $height) = $size; |
|
112 | + $width *= self::PIXEL_TO_CM; |
|
113 | + $height *= self::PIXEL_TO_CM; |
|
114 | + $xml = <<<IMG |
|
115 | 115 | <draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="char" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> |
116 | 116 | IMG; |
117 | - $this->images[$value] = $file; |
|
118 | - $this->manif_vars[] = $file; //save image name as array element |
|
119 | - $this->setVars($key, $xml, false); |
|
120 | - return $this; |
|
121 | - } |
|
122 | - /** |
|
123 | - * Move segment tags for lines of tables |
|
124 | - * Called automatically within the constructor |
|
125 | - * |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - private function _moveRowSegments() |
|
129 | - { |
|
130 | - // Search all possible rows in the document |
|
131 | - $reg1 = "#<table:table-row[^>]*>(.*)</table:table-row>#smU"; |
|
117 | + $this->images[$value] = $file; |
|
118 | + $this->manif_vars[] = $file; //save image name as array element |
|
119 | + $this->setVars($key, $xml, false); |
|
120 | + return $this; |
|
121 | + } |
|
122 | + /** |
|
123 | + * Move segment tags for lines of tables |
|
124 | + * Called automatically within the constructor |
|
125 | + * |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + private function _moveRowSegments() |
|
129 | + { |
|
130 | + // Search all possible rows in the document |
|
131 | + $reg1 = "#<table:table-row[^>]*>(.*)</table:table-row>#smU"; |
|
132 | 132 | preg_match_all($reg1, $this->contentXml, $matches); |
133 | 133 | for ($i = 0, $size = count($matches[0]); $i < $size; $i++) { |
134 | 134 | // Check if the current row contains a segment row.* |
@@ -146,189 +146,189 @@ discard block |
||
146 | 146 | $this->contentXml = str_replace($matches[0][$i], $replacedXML, $this->contentXml); |
147 | 147 | } |
148 | 148 | } |
149 | - } |
|
150 | - /** |
|
151 | - * Merge template variables |
|
152 | - * Called automatically for a save |
|
153 | - * |
|
154 | - * @return void |
|
155 | - */ |
|
156 | - private function _parse() |
|
157 | - { |
|
158 | - $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml); |
|
159 | - } |
|
160 | - /** |
|
161 | - * Add the merged segment to the document |
|
162 | - * |
|
163 | - * @param Segment $segment |
|
164 | - * @throws OdfException |
|
165 | - * @return odf |
|
166 | - */ |
|
167 | - public function mergeSegment(Segment $segment) |
|
168 | - { |
|
169 | - if (! array_key_exists($segment->getName(), $this->segments)) { |
|
170 | - throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
|
171 | - } |
|
172 | - $string = $segment->getName(); |
|
149 | + } |
|
150 | + /** |
|
151 | + * Merge template variables |
|
152 | + * Called automatically for a save |
|
153 | + * |
|
154 | + * @return void |
|
155 | + */ |
|
156 | + private function _parse() |
|
157 | + { |
|
158 | + $this->contentXml = str_replace(array_keys($this->vars), array_values($this->vars), $this->contentXml); |
|
159 | + } |
|
160 | + /** |
|
161 | + * Add the merged segment to the document |
|
162 | + * |
|
163 | + * @param Segment $segment |
|
164 | + * @throws OdfException |
|
165 | + * @return odf |
|
166 | + */ |
|
167 | + public function mergeSegment(Segment $segment) |
|
168 | + { |
|
169 | + if (! array_key_exists($segment->getName(), $this->segments)) { |
|
170 | + throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
|
171 | + } |
|
172 | + $string = $segment->getName(); |
|
173 | 173 | // $reg = '@<text:p[^>]*>\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]<\/text:p>@smU'; |
174 | 174 | $reg = '@\[!--\sBEGIN\s' . $string . '\s--\](.*)\[!--.+END\s' . $string . '\s--\]@smU'; |
175 | - $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); |
|
176 | - return $this; |
|
177 | - } |
|
178 | - /** |
|
179 | - * Display all the current template variables |
|
180 | - * |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - public function printVars() |
|
184 | - { |
|
185 | - return print_r('<pre>' . print_r($this->vars, true) . '</pre>', true); |
|
186 | - } |
|
187 | - /** |
|
188 | - * Display the XML content of the file from odt document |
|
189 | - * as it is at the moment |
|
190 | - * |
|
191 | - * @return string |
|
192 | - */ |
|
193 | - public function __toString() |
|
194 | - { |
|
195 | - return $this->contentXml; |
|
196 | - } |
|
197 | - /** |
|
198 | - * Display loop segments declared with setSegment() |
|
199 | - * |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function printDeclaredSegments() |
|
203 | - { |
|
204 | - return '<pre>' . print_r(implode(' ', array_keys($this->segments)), true) . '</pre>'; |
|
205 | - } |
|
206 | - /** |
|
207 | - * Declare a segment in order to use it in a loop |
|
208 | - * |
|
209 | - * @param string $segment |
|
210 | - * @throws OdfException |
|
211 | - * @return Segment |
|
212 | - */ |
|
213 | - public function setSegment($segment) |
|
214 | - { |
|
215 | - if (array_key_exists($segment, $this->segments)) { |
|
216 | - return $this->segments[$segment]; |
|
217 | - } |
|
218 | - // $reg = "#\[!--\sBEGIN\s$segment\s--\]<\/text:p>(.*)<text:p\s.*>\[!--\sEND\s$segment\s--\]#sm"; |
|
219 | - $reg = "#\[!--\sBEGIN\s$segment\s--\](.*)\[!--\sEND\s$segment\s--\]#sm"; |
|
220 | - if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) { |
|
221 | - throw new OdfException("'$segment' segment not found in the document"); |
|
222 | - } |
|
223 | - $this->segments[$segment] = new Segment($segment, $m[1], $this); |
|
224 | - return $this->segments[$segment]; |
|
225 | - } |
|
226 | - /** |
|
227 | - * Save the odt file on the disk |
|
228 | - * |
|
229 | - * @param string $file name of the desired file |
|
230 | - * @throws OdfException |
|
231 | - * @return void |
|
232 | - */ |
|
233 | - public function saveToDisk($file = null) |
|
234 | - { |
|
235 | - if ($file !== null && is_string($file)) { |
|
236 | - if (file_exists($file) && !(is_file($file) && is_writable($file))) { |
|
237 | - throw new OdfException('Permission denied : can\'t create ' . $file); |
|
238 | - } |
|
239 | - $this->_save(); |
|
240 | - copy($this->tmpfile, $file); |
|
241 | - } else { |
|
242 | - $this->_save(); |
|
243 | - } |
|
244 | - } |
|
245 | - /** |
|
246 | - * Internal save |
|
247 | - * |
|
248 | - * @throws OdfException |
|
249 | - * @return void |
|
250 | - */ |
|
251 | - private function _save() |
|
252 | - { |
|
253 | - $this->file->open($this->tmpfile); |
|
254 | - $this->_parse(); |
|
255 | - if (! $this->file->addFromString('content.xml', $this->contentXml) ) { |
|
256 | - throw new OdfException('Error during file export addFromString'); |
|
257 | - } |
|
175 | + $this->contentXml = preg_replace($reg, $segment->getXmlParsed(), $this->contentXml); |
|
176 | + return $this; |
|
177 | + } |
|
178 | + /** |
|
179 | + * Display all the current template variables |
|
180 | + * |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + public function printVars() |
|
184 | + { |
|
185 | + return print_r('<pre>' . print_r($this->vars, true) . '</pre>', true); |
|
186 | + } |
|
187 | + /** |
|
188 | + * Display the XML content of the file from odt document |
|
189 | + * as it is at the moment |
|
190 | + * |
|
191 | + * @return string |
|
192 | + */ |
|
193 | + public function __toString() |
|
194 | + { |
|
195 | + return $this->contentXml; |
|
196 | + } |
|
197 | + /** |
|
198 | + * Display loop segments declared with setSegment() |
|
199 | + * |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function printDeclaredSegments() |
|
203 | + { |
|
204 | + return '<pre>' . print_r(implode(' ', array_keys($this->segments)), true) . '</pre>'; |
|
205 | + } |
|
206 | + /** |
|
207 | + * Declare a segment in order to use it in a loop |
|
208 | + * |
|
209 | + * @param string $segment |
|
210 | + * @throws OdfException |
|
211 | + * @return Segment |
|
212 | + */ |
|
213 | + public function setSegment($segment) |
|
214 | + { |
|
215 | + if (array_key_exists($segment, $this->segments)) { |
|
216 | + return $this->segments[$segment]; |
|
217 | + } |
|
218 | + // $reg = "#\[!--\sBEGIN\s$segment\s--\]<\/text:p>(.*)<text:p\s.*>\[!--\sEND\s$segment\s--\]#sm"; |
|
219 | + $reg = "#\[!--\sBEGIN\s$segment\s--\](.*)\[!--\sEND\s$segment\s--\]#sm"; |
|
220 | + if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) { |
|
221 | + throw new OdfException("'$segment' segment not found in the document"); |
|
222 | + } |
|
223 | + $this->segments[$segment] = new Segment($segment, $m[1], $this); |
|
224 | + return $this->segments[$segment]; |
|
225 | + } |
|
226 | + /** |
|
227 | + * Save the odt file on the disk |
|
228 | + * |
|
229 | + * @param string $file name of the desired file |
|
230 | + * @throws OdfException |
|
231 | + * @return void |
|
232 | + */ |
|
233 | + public function saveToDisk($file = null) |
|
234 | + { |
|
235 | + if ($file !== null && is_string($file)) { |
|
236 | + if (file_exists($file) && !(is_file($file) && is_writable($file))) { |
|
237 | + throw new OdfException('Permission denied : can\'t create ' . $file); |
|
238 | + } |
|
239 | + $this->_save(); |
|
240 | + copy($this->tmpfile, $file); |
|
241 | + } else { |
|
242 | + $this->_save(); |
|
243 | + } |
|
244 | + } |
|
245 | + /** |
|
246 | + * Internal save |
|
247 | + * |
|
248 | + * @throws OdfException |
|
249 | + * @return void |
|
250 | + */ |
|
251 | + private function _save() |
|
252 | + { |
|
253 | + $this->file->open($this->tmpfile); |
|
254 | + $this->_parse(); |
|
255 | + if (! $this->file->addFromString('content.xml', $this->contentXml) ) { |
|
256 | + throw new OdfException('Error during file export addFromString'); |
|
257 | + } |
|
258 | 258 | |
259 | - $lastpos=strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file |
|
260 | - $manifdata = ""; |
|
259 | + $lastpos=strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file |
|
260 | + $manifdata = ""; |
|
261 | 261 | |
262 | - //Enter all images description in $manifdata variable |
|
262 | + //Enter all images description in $manifdata variable |
|
263 | 263 | |
264 | - foreach ($this->manif_vars as $val) |
|
265 | - { |
|
266 | - $ext = substr(strrchr($val, '.'), 1); |
|
267 | - $manifdata = $manifdata.'<manifest:file-entry manifest:media-type="image/'.$ext.'" manifest:full-path="Pictures/'.$val.'"/>'."\n"; |
|
268 | - } |
|
269 | - //Place content of $manifdata variable in manifest.xml file at appropriate place |
|
270 | - $this->manifestXml = substr_replace($this->manifestXml, "\n".$manifdata, $lastpos+1, 0); |
|
264 | + foreach ($this->manif_vars as $val) |
|
265 | + { |
|
266 | + $ext = substr(strrchr($val, '.'), 1); |
|
267 | + $manifdata = $manifdata.'<manifest:file-entry manifest:media-type="image/'.$ext.'" manifest:full-path="Pictures/'.$val.'"/>'."\n"; |
|
268 | + } |
|
269 | + //Place content of $manifdata variable in manifest.xml file at appropriate place |
|
270 | + $this->manifestXml = substr_replace($this->manifestXml, "\n".$manifdata, $lastpos+1, 0); |
|
271 | 271 | |
272 | - if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
273 | - throw new OdfException('Error during manifest file export'); |
|
274 | - } |
|
275 | - foreach ($this->images as $imageKey => $imageValue) { |
|
276 | - $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
|
277 | - } |
|
278 | - $this->file->close(); // seems to bug on windows CLI sometimes |
|
279 | - } |
|
280 | - /** |
|
281 | - * Export the file as attached file by HTTP |
|
282 | - * |
|
283 | - * @param string $name (optionnal) |
|
284 | - * @throws OdfException |
|
285 | - * @return void |
|
286 | - */ |
|
287 | - public function exportAsAttachedFile($name="") |
|
288 | - { |
|
289 | - $this->_save(); |
|
290 | - if (headers_sent($filename, $linenum)) { |
|
291 | - throw new OdfException("headers already sent ($filename at $linenum)"); |
|
292 | - } |
|
272 | + if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
273 | + throw new OdfException('Error during manifest file export'); |
|
274 | + } |
|
275 | + foreach ($this->images as $imageKey => $imageValue) { |
|
276 | + $this->file->addFile($imageKey, 'Pictures/' . $imageValue); |
|
277 | + } |
|
278 | + $this->file->close(); // seems to bug on windows CLI sometimes |
|
279 | + } |
|
280 | + /** |
|
281 | + * Export the file as attached file by HTTP |
|
282 | + * |
|
283 | + * @param string $name (optionnal) |
|
284 | + * @throws OdfException |
|
285 | + * @return void |
|
286 | + */ |
|
287 | + public function exportAsAttachedFile($name="") |
|
288 | + { |
|
289 | + $this->_save(); |
|
290 | + if (headers_sent($filename, $linenum)) { |
|
291 | + throw new OdfException("headers already sent ($filename at $linenum)"); |
|
292 | + } |
|
293 | 293 | |
294 | - if( $name == "" ) |
|
295 | - { |
|
296 | - $name = md5(uniqid()) . ".odt"; |
|
297 | - } |
|
294 | + if( $name == "" ) |
|
295 | + { |
|
296 | + $name = md5(uniqid()) . ".odt"; |
|
297 | + } |
|
298 | 298 | |
299 | - header('Content-type: application/vnd.oasis.opendocument.text'); |
|
300 | - header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
301 | - readfile($this->tmpfile); |
|
302 | - } |
|
303 | - /** |
|
304 | - * Returns a variable of configuration |
|
305 | - * |
|
306 | - * @return string The requested variable of configuration |
|
307 | - */ |
|
308 | - public function getConfig($configKey) |
|
309 | - { |
|
310 | - if (array_key_exists($configKey, $this->config)) { |
|
311 | - return $this->config[$configKey]; |
|
312 | - } |
|
313 | - return false; |
|
314 | - } |
|
315 | - /** |
|
316 | - * Returns the temporary working file |
|
317 | - * |
|
318 | - * @return string le chemin vers le fichier temporaire de travail |
|
319 | - */ |
|
320 | - public function getTmpfile() |
|
321 | - { |
|
322 | - return $this->tmpfile; |
|
323 | - } |
|
324 | - /** |
|
325 | - * Delete the temporary file when the object is destroyed |
|
326 | - */ |
|
327 | - public function __destruct() { |
|
328 | - if (file_exists($this->tmpfile)) { |
|
329 | - unlink($this->tmpfile); |
|
330 | - } |
|
331 | - } |
|
299 | + header('Content-type: application/vnd.oasis.opendocument.text'); |
|
300 | + header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
301 | + readfile($this->tmpfile); |
|
302 | + } |
|
303 | + /** |
|
304 | + * Returns a variable of configuration |
|
305 | + * |
|
306 | + * @return string The requested variable of configuration |
|
307 | + */ |
|
308 | + public function getConfig($configKey) |
|
309 | + { |
|
310 | + if (array_key_exists($configKey, $this->config)) { |
|
311 | + return $this->config[$configKey]; |
|
312 | + } |
|
313 | + return false; |
|
314 | + } |
|
315 | + /** |
|
316 | + * Returns the temporary working file |
|
317 | + * |
|
318 | + * @return string le chemin vers le fichier temporaire de travail |
|
319 | + */ |
|
320 | + public function getTmpfile() |
|
321 | + { |
|
322 | + return $this->tmpfile; |
|
323 | + } |
|
324 | + /** |
|
325 | + * Delete the temporary file when the object is destroyed |
|
326 | + */ |
|
327 | + public function __destruct() { |
|
328 | + if (file_exists($this->tmpfile)) { |
|
329 | + unlink($this->tmpfile); |
|
330 | + } |
|
331 | + } |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | ?> |
335 | 335 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | require 'zip/PclZipProxy.php'; |
3 | 3 | require 'zip/PhpZipProxy.php'; |
4 | 4 | require 'Segment.php'; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | ); |
29 | 29 | protected $file; |
30 | 30 | protected $contentXml; |
31 | - protected $manifestXml; // To store content of manifest.xml file |
|
31 | + protected $manifestXml; // To store content of manifest.xml file |
|
32 | 32 | protected $tmpfile; |
33 | 33 | protected $images = array(); |
34 | 34 | protected $vars = array(); |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function __construct($filename, $config = array()) |
45 | 45 | { |
46 | - if (! is_array($config)) { |
|
46 | + if (!is_array($config)) { |
|
47 | 47 | throw new OdfException('Configuration data must be provided as array'); |
48 | 48 | } |
49 | 49 | foreach ($config as $configKey => $configValue) { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | $this->config[$configKey] = $configValue; |
52 | 52 | } |
53 | 53 | } |
54 | - if (! class_exists($this->config['ZIP_PROXY'])) { |
|
54 | + if (!class_exists($this->config['ZIP_PROXY'])) { |
|
55 | 55 | throw new OdfException($this->config['ZIP_PROXY'] . ' class not found - check your php settings'); |
56 | 56 | } |
57 | 57 | $zipHandler = $this->config['ZIP_PROXY']; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | <draw:frame draw:style-name="fr1" draw:name="$filename" text:anchor-type="char" svg:width="{$width}cm" svg:height="{$height}cm" draw:z-index="3"><draw:image xlink:href="Pictures/$file" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame> |
116 | 116 | IMG; |
117 | 117 | $this->images[$value] = $file; |
118 | - $this->manif_vars[] = $file; //save image name as array element |
|
118 | + $this->manif_vars[] = $file; //save image name as array element |
|
119 | 119 | $this->setVars($key, $xml, false); |
120 | 120 | return $this; |
121 | 121 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | */ |
167 | 167 | public function mergeSegment(Segment $segment) |
168 | 168 | { |
169 | - if (! array_key_exists($segment->getName(), $this->segments)) { |
|
169 | + if (!array_key_exists($segment->getName(), $this->segments)) { |
|
170 | 170 | throw new OdfException($segment->getName() . 'cannot be parsed, has it been set yet ?'); |
171 | 171 | } |
172 | 172 | $string = $segment->getName(); |
@@ -252,11 +252,11 @@ discard block |
||
252 | 252 | { |
253 | 253 | $this->file->open($this->tmpfile); |
254 | 254 | $this->_parse(); |
255 | - if (! $this->file->addFromString('content.xml', $this->contentXml) ) { |
|
255 | + if (!$this->file->addFromString('content.xml', $this->contentXml)) { |
|
256 | 256 | throw new OdfException('Error during file export addFromString'); |
257 | 257 | } |
258 | 258 | |
259 | - $lastpos=strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file |
|
259 | + $lastpos = strrpos($this->manifestXml, "\n", -15); //find second last newline in the manifest.xml file |
|
260 | 260 | $manifdata = ""; |
261 | 261 | |
262 | 262 | //Enter all images description in $manifdata variable |
@@ -264,12 +264,12 @@ discard block |
||
264 | 264 | foreach ($this->manif_vars as $val) |
265 | 265 | { |
266 | 266 | $ext = substr(strrchr($val, '.'), 1); |
267 | - $manifdata = $manifdata.'<manifest:file-entry manifest:media-type="image/'.$ext.'" manifest:full-path="Pictures/'.$val.'"/>'."\n"; |
|
267 | + $manifdata = $manifdata . '<manifest:file-entry manifest:media-type="image/' . $ext . '" manifest:full-path="Pictures/' . $val . '"/>' . "\n"; |
|
268 | 268 | } |
269 | 269 | //Place content of $manifdata variable in manifest.xml file at appropriate place |
270 | - $this->manifestXml = substr_replace($this->manifestXml, "\n".$manifdata, $lastpos+1, 0); |
|
270 | + $this->manifestXml = substr_replace($this->manifestXml, "\n" . $manifdata, $lastpos + 1, 0); |
|
271 | 271 | |
272 | - if (! $this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
272 | + if (!$this->file->addFromString('META-INF/manifest.xml', $this->manifestXml)) { |
|
273 | 273 | throw new OdfException('Error during manifest file export'); |
274 | 274 | } |
275 | 275 | foreach ($this->images as $imageKey => $imageValue) { |
@@ -284,20 +284,20 @@ discard block |
||
284 | 284 | * @throws OdfException |
285 | 285 | * @return void |
286 | 286 | */ |
287 | - public function exportAsAttachedFile($name="") |
|
287 | + public function exportAsAttachedFile($name = "") |
|
288 | 288 | { |
289 | 289 | $this->_save(); |
290 | 290 | if (headers_sent($filename, $linenum)) { |
291 | 291 | throw new OdfException("headers already sent ($filename at $linenum)"); |
292 | 292 | } |
293 | 293 | |
294 | - if( $name == "" ) |
|
294 | + if ($name == "") |
|
295 | 295 | { |
296 | 296 | $name = md5(uniqid()) . ".odt"; |
297 | 297 | } |
298 | 298 | |
299 | 299 | header('Content-type: application/vnd.oasis.opendocument.text'); |
300 | - header('Content-Disposition: attachment; filename="'.$name.'"'); |
|
300 | + header('Content-Disposition: attachment; filename="' . $name . '"'); |
|
301 | 301 | readfile($this->tmpfile); |
302 | 302 | } |
303 | 303 | /** |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | require 'zip/PclZipProxy.php'; |
3 | 5 | require 'zip/PhpZipProxy.php'; |
4 | 6 | require 'Segment.php'; |
@@ -15,42 +15,42 @@ |
||
15 | 15 | */ |
16 | 16 | class SegmentIterator implements RecursiveIterator |
17 | 17 | { |
18 | - private $ref; |
|
19 | - private $key; |
|
20 | - public function __construct(array $ref) |
|
21 | - { |
|
22 | - $this->ref = $ref; |
|
23 | - $this->key = 0; |
|
24 | - $this->keys = array_keys($this->ref); |
|
25 | - } |
|
26 | - public function hasChildren() |
|
27 | - { |
|
28 | - return $this->valid() && $this->current() instanceof Segment; |
|
29 | - } |
|
30 | - public function current() |
|
31 | - { |
|
32 | - return $this->ref[$this->keys[$this->key]]; |
|
33 | - } |
|
34 | - function getChildren() |
|
35 | - { |
|
36 | - return new self($this->current()->children); |
|
37 | - } |
|
38 | - public function key() |
|
39 | - { |
|
40 | - return $this->key; |
|
41 | - } |
|
42 | - public function valid() |
|
43 | - { |
|
44 | - return array_key_exists($this->key, $this->keys); |
|
45 | - } |
|
46 | - public function rewind() |
|
47 | - { |
|
48 | - $this->key = 0; |
|
49 | - } |
|
50 | - public function next() |
|
51 | - { |
|
52 | - $this->key ++; |
|
53 | - } |
|
18 | + private $ref; |
|
19 | + private $key; |
|
20 | + public function __construct(array $ref) |
|
21 | + { |
|
22 | + $this->ref = $ref; |
|
23 | + $this->key = 0; |
|
24 | + $this->keys = array_keys($this->ref); |
|
25 | + } |
|
26 | + public function hasChildren() |
|
27 | + { |
|
28 | + return $this->valid() && $this->current() instanceof Segment; |
|
29 | + } |
|
30 | + public function current() |
|
31 | + { |
|
32 | + return $this->ref[$this->keys[$this->key]]; |
|
33 | + } |
|
34 | + function getChildren() |
|
35 | + { |
|
36 | + return new self($this->current()->children); |
|
37 | + } |
|
38 | + public function key() |
|
39 | + { |
|
40 | + return $this->key; |
|
41 | + } |
|
42 | + public function valid() |
|
43 | + { |
|
44 | + return array_key_exists($this->key, $this->keys); |
|
45 | + } |
|
46 | + public function rewind() |
|
47 | + { |
|
48 | + $this->key = 0; |
|
49 | + } |
|
50 | + public function next() |
|
51 | + { |
|
52 | + $this->key ++; |
|
53 | + } |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | ?> |
57 | 57 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * Segments iterator |
4 | 4 | * You need PHP 5.2 at least |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | } |
50 | 50 | public function next() |
51 | 51 | { |
52 | - $this->key ++; |
|
52 | + $this->key++; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Segments iterator |
4 | 6 | * You need PHP 5.2 at least |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Author: Christophe DALOZ DE LOS RIOS - Eoxia dev team <[email protected]> |
4 | 6 | */ |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | /** |
3 | 3 | * Author: Christophe DALOZ DE LOS RIOS - Eoxia dev team <[email protected]> |
4 | 4 | */ |
@@ -7,24 +7,24 @@ discard block |
||
7 | 7 | |
8 | 8 | $upload_dir = wp_upload_dir(); |
9 | 9 | |
10 | -DEFINE( 'WPS_BARCODE_VERSION', 1.0 ); |
|
11 | -DEFINE( 'WPS_BARCODE_PATH', str_replace( "\\", "/", plugin_dir_path( __FILE__ ) ) ); |
|
12 | -DEFINE( 'WPS_BARCODE_URL', str_replace( str_replace( "\\", "/", ABSPATH), |
|
13 | - site_url() . '/', WPS_BARCODE_PATH ) ); |
|
14 | -DEFINE( 'WPS_BARCODE_JSCRIPTS', plugins_url('/assets/js', __FILE__) ); |
|
15 | -DEFINE( 'WPS_BARCODE_FONTS', WPS_BARCODE_PATH.'assets/fonts' ); |
|
16 | -DEFINE( 'WPS_BARCODE_UPLOAD', $upload_dir[ 'basedir' ] . '/wps_barcode/'); |
|
10 | +DEFINE('WPS_BARCODE_VERSION', 1.0); |
|
11 | +DEFINE('WPS_BARCODE_PATH', str_replace("\\", "/", plugin_dir_path(__FILE__))); |
|
12 | +DEFINE('WPS_BARCODE_URL', str_replace(str_replace("\\", "/", ABSPATH), |
|
13 | + site_url() . '/', WPS_BARCODE_PATH)); |
|
14 | +DEFINE('WPS_BARCODE_JSCRIPTS', plugins_url('/assets/js', __FILE__)); |
|
15 | +DEFINE('WPS_BARCODE_FONTS', WPS_BARCODE_PATH . 'assets/fonts'); |
|
16 | +DEFINE('WPS_BARCODE_UPLOAD', $upload_dir['basedir'] . '/wps_barcode/'); |
|
17 | 17 | |
18 | 18 | /** Load plugin translation */ |
19 | -load_plugin_textdomain( 'wps_barcode', false, dirname( plugin_basename( __FILE__ ) ).'/languages/' ); |
|
19 | +load_plugin_textdomain('wps_barcode', false, dirname(plugin_basename(__FILE__)) . '/languages/'); |
|
20 | 20 | |
21 | 21 | /** Define the templates directories */ |
22 | -DEFINE( 'WPS_BARCODE_TEMPLATES_TPL_DIR', WPS_BARCODE_PATH . '/templates/'); |
|
22 | +DEFINE('WPS_BARCODE_TEMPLATES_TPL_DIR', WPS_BARCODE_PATH . '/templates/'); |
|
23 | 23 | |
24 | -require_once( WPS_BARCODE_PATH . 'controller/wps_barcode.ctr.php' ); |
|
25 | -require_once( WPS_BARCODE_PATH . 'controller/wps_barcode_settings.ctr.php' ); |
|
26 | -require_once( WPS_BARCODE_PATH . 'controller/wps_barcode_metabox.ctr.php' ); |
|
27 | -require_once( WPS_BARCODE_PATH . 'controller/wps_barcode_ajax.ctr.php' ); |
|
24 | +require_once(WPS_BARCODE_PATH . 'controller/wps_barcode.ctr.php'); |
|
25 | +require_once(WPS_BARCODE_PATH . 'controller/wps_barcode_settings.ctr.php'); |
|
26 | +require_once(WPS_BARCODE_PATH . 'controller/wps_barcode_metabox.ctr.php'); |
|
27 | +require_once(WPS_BARCODE_PATH . 'controller/wps_barcode_ajax.ctr.php'); |
|
28 | 28 | |
29 | 29 | new wps_barcode(); |
30 | 30 | new wps_barcode_settings(); |
@@ -1,9 +1,9 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | class wps_barcode_settings { |
4 | 4 | public function __construct() { |
5 | 5 | add_filter('wpshop_options', array(&$this, 'add_options'), 10); |
6 | - add_action( 'admin_init', array( &$this, 'declare_options' ) ); |
|
6 | + add_action('admin_init', array(&$this, 'declare_options')); |
|
7 | 7 | } |
8 | 8 | |
9 | 9 | /** |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function add_options($option_group) { |
15 | 15 | $option_group['wpshop_barcode_options'] = |
16 | - array( 'label' => __('Barcode', 'wps_barcode'), |
|
16 | + array('label' => __('Barcode', 'wps_barcode'), |
|
17 | 17 | 'subgroups' => array( |
18 | 18 | 'wpshop_barcode_options' => array('class' => |
19 | 19 | ' wpshop_admin_box_options_barcode'), |
@@ -32,16 +32,16 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function declare_options() { |
34 | 34 | register_setting('wpshop_options', 'wps_barcode', |
35 | - array( $this, 'validate_options') ); |
|
35 | + array($this, 'validate_options')); |
|
36 | 36 | |
37 | 37 | add_settings_section('wpshop_barcode_type_options', |
38 | - '<span class="dashicons dashicons-format-chat"></span>'. |
|
38 | + '<span class="dashicons dashicons-format-chat"></span>' . |
|
39 | 39 | __('WPShop Barcode configuration', 'wps_barcode'), |
40 | 40 | array($this, 'welcome_msg'), 'wpshop_barcode_options'); |
41 | 41 | |
42 | 42 | add_settings_field('wpshop_barcode_type_field', |
43 | - __( 'Type of EAN-13 Barcode', 'wps_barcode'), |
|
44 | - array( $this, 'add_type_field'), 'wpshop_barcode_options', |
|
43 | + __('Type of EAN-13 Barcode', 'wps_barcode'), |
|
44 | + array($this, 'add_type_field'), 'wpshop_barcode_options', |
|
45 | 45 | 'wpshop_barcode_type_options'); |
46 | 46 | |
47 | 47 | add_settings_field('wpshop_barcode_display_field', |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | |
53 | 53 | add_settings_section('wpshop_barcode_internal_ccode_options', |
54 | - '<span class="dashicons dashicons-format-chat"></span>'. |
|
54 | + '<span class="dashicons dashicons-format-chat"></span>' . |
|
55 | 55 | __('WPShop Barcode internal code configuration', 'wps_barcode'), |
56 | 56 | array($this, 'internal_code_section'), 'wpshop_barcode_options_internal'); |
57 | 57 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | array($this, 'add_do_provider_field'), 'wpshop_barcode_options_internal', |
101 | 101 | 'wpshop_barcode_internal_ccode_options'); |
102 | 102 | add_settings_section('wpshop_barcode_normal_code_options', |
103 | - '<span class="dashicons dashicons-format-chat"></span>'. |
|
103 | + '<span class="dashicons dashicons-format-chat"></span>' . |
|
104 | 104 | __('WPShop Barcode normal code configuration', 'wps_barcode'), |
105 | 105 | array($this, 'normal_code_section'), 'wpshop_barcode_options_normal'); |
106 | 106 | |
@@ -149,35 +149,35 @@ discard block |
||
149 | 149 | $internal['normal_enterprise_code'] = isset($input['normal_enterprise_code']) ? $input['normal_enterprise_code'] : ''; |
150 | 150 | |
151 | 151 | /*Verifiy if 3 or 2 digits are presents*/ |
152 | - if ( !empty($internal['internal_client']) || !empty($internal['internal_provider']) || !empty($internal['internal_invoice_client']) || !empty($internal['internal_do_client']) || !empty($internal['internal_product']) || !empty($internal['internal_invoice_provider']) || !empty($internal['internal_do_provider']) || !empty($internal['normal_country_code']) || !empty($internal['normal_enterprise_code']) ) { |
|
153 | - $internal['internal_client'] = strlen($internal['internal_client']) === 2 ? '0'.$internal['internal_client'] : ( strlen($internal['internal_client']) === 3 ? $internal['internal_client'] : ''); |
|
152 | + if (!empty($internal['internal_client']) || !empty($internal['internal_provider']) || !empty($internal['internal_invoice_client']) || !empty($internal['internal_do_client']) || !empty($internal['internal_product']) || !empty($internal['internal_invoice_provider']) || !empty($internal['internal_do_provider']) || !empty($internal['normal_country_code']) || !empty($internal['normal_enterprise_code'])) { |
|
153 | + $internal['internal_client'] = strlen($internal['internal_client']) === 2 ? '0' . $internal['internal_client'] : (strlen($internal['internal_client']) === 3 ? $internal['internal_client'] : ''); |
|
154 | 154 | |
155 | - $internal['internal_provider'] = strlen($internal['internal_provider']) === 2 ? '0'.$internal['internal_provider'] : (strlen($internal['internal_provider']) === 3 ? $internal['internal_provider'] : ''); |
|
155 | + $internal['internal_provider'] = strlen($internal['internal_provider']) === 2 ? '0' . $internal['internal_provider'] : (strlen($internal['internal_provider']) === 3 ? $internal['internal_provider'] : ''); |
|
156 | 156 | |
157 | - $internal['internal_invoice_client'] = strlen($internal['internal_invoice_client']) === 2 ? '0'.$internal['internal_invoice_client'] : (strlen($internal['internal_invoice_client']) === 3 ? $internal['internal_invoice_client'] : ''); |
|
157 | + $internal['internal_invoice_client'] = strlen($internal['internal_invoice_client']) === 2 ? '0' . $internal['internal_invoice_client'] : (strlen($internal['internal_invoice_client']) === 3 ? $internal['internal_invoice_client'] : ''); |
|
158 | 158 | |
159 | - $internal['internal_do_client'] = strlen($internal['internal_do_client']) === 2 ? '0'.$internal['internal_do_client'] : (strlen($internal['internal_do_client']) === 3 ? $internal['internal_do_client'] : ''); |
|
159 | + $internal['internal_do_client'] = strlen($internal['internal_do_client']) === 2 ? '0' . $internal['internal_do_client'] : (strlen($internal['internal_do_client']) === 3 ? $internal['internal_do_client'] : ''); |
|
160 | 160 | |
161 | - $internal['internal_product'] = strlen($internal['internal_product']) === 2 ? '0'.$internal['internal_product'] : (strlen($internal['internal_product']) === 3 ? $internal['internal_product'] : ''); |
|
161 | + $internal['internal_product'] = strlen($internal['internal_product']) === 2 ? '0' . $internal['internal_product'] : (strlen($internal['internal_product']) === 3 ? $internal['internal_product'] : ''); |
|
162 | 162 | |
163 | - $internal['internal_assets_client'] = strlen($internal['internal_assets_client']) === 2 ? '0'.$internal['internal_assets_client'] : (strlen($internal['internal_assets_client']) === 3 ? $internal['internal_assets_client'] : ''); |
|
163 | + $internal['internal_assets_client'] = strlen($internal['internal_assets_client']) === 2 ? '0' . $internal['internal_assets_client'] : (strlen($internal['internal_assets_client']) === 3 ? $internal['internal_assets_client'] : ''); |
|
164 | 164 | |
165 | - $internal['internal_coupons'] = strlen($internal['internal_coupons']) === 2 ? '0'.$internal['internal_coupons'] : (strlen($internal['internal_coupons']) === 3 ? $internal['internal_coupons'] : ''); |
|
165 | + $internal['internal_coupons'] = strlen($internal['internal_coupons']) === 2 ? '0' . $internal['internal_coupons'] : (strlen($internal['internal_coupons']) === 3 ? $internal['internal_coupons'] : ''); |
|
166 | 166 | |
167 | - $internal['internal_invoice_provider'] = strlen($internal['internal_invoice_provider']) === 2 ? '0'.$internal['internal_invoice_provider'] : (strlen($internal['internal_invoice_provider']) === 3 ? $internal['internal_invoice_provider'] : ''); |
|
167 | + $internal['internal_invoice_provider'] = strlen($internal['internal_invoice_provider']) === 2 ? '0' . $internal['internal_invoice_provider'] : (strlen($internal['internal_invoice_provider']) === 3 ? $internal['internal_invoice_provider'] : ''); |
|
168 | 168 | |
169 | - $internal['internal_do_provider'] = strlen($internal['internal_do_provider']) === 2 ? '0'.$internal['internal_do_provider'] : (strlen($internal['internal_do_provider']) === 3 ? $internal['internal_do_provider'] : ''); |
|
169 | + $internal['internal_do_provider'] = strlen($internal['internal_do_provider']) === 2 ? '0' . $internal['internal_do_provider'] : (strlen($internal['internal_do_provider']) === 3 ? $internal['internal_do_provider'] : ''); |
|
170 | 170 | |
171 | - $internal['normal_country_code'] = strlen($internal['normal_country_code']) === 2 ? '0'.$internal['normal_country_code'] : (strlen($internal['normal_country_code']) === 3 ? $internal['normal_country_code'] : ''); |
|
171 | + $internal['normal_country_code'] = strlen($internal['normal_country_code']) === 2 ? '0' . $internal['normal_country_code'] : (strlen($internal['normal_country_code']) === 3 ? $internal['normal_country_code'] : ''); |
|
172 | 172 | |
173 | - if ( strlen($internal['normal_enterprise_code']) === 1 ) { |
|
174 | - $internal['normal_enterprise_code'] = '000'.$internal['normal_enterprise_code']; |
|
173 | + if (strlen($internal['normal_enterprise_code']) === 1) { |
|
174 | + $internal['normal_enterprise_code'] = '000' . $internal['normal_enterprise_code']; |
|
175 | 175 | } |
176 | - else if ( strlen($internal['normal_enterprise_code']) === 2 ) { |
|
177 | - $internal['normal_enterprise_code'] = '00'.$internal['normal_enterprise_code']; |
|
176 | + else if (strlen($internal['normal_enterprise_code']) === 2) { |
|
177 | + $internal['normal_enterprise_code'] = '00' . $internal['normal_enterprise_code']; |
|
178 | 178 | } |
179 | - else if ( strlen($internal['normal_enterprise_code']) === 3 ) { |
|
180 | - $internal['normal_enterprise_code'] = '0'.$internal['normal_enterprise_code']; |
|
179 | + else if (strlen($internal['normal_enterprise_code']) === 3) { |
|
180 | + $internal['normal_enterprise_code'] = '0' . $internal['normal_enterprise_code']; |
|
181 | 181 | } |
182 | 182 | else { |
183 | 183 | $internal['normal_enterprise_code'] = $internal['normal_enterprise_code']; |
@@ -185,84 +185,84 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | /*Verify if range respected*/ |
188 | - if ( $internal['internal_client'] !== '') { |
|
188 | + if ($internal['internal_client'] !== '') { |
|
189 | 189 | $val = intval($internal['internal_client']); |
190 | - if ( $val < 40 || $val > 49) { |
|
190 | + if ($val < 40 || $val > 49) { |
|
191 | 191 | unset($internal['internal_client']); |
192 | 192 | unset($input['client']); |
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
196 | - if ( $internal['internal_provider'] !== '') { |
|
196 | + if ($internal['internal_provider'] !== '') { |
|
197 | 197 | $val = intval($internal['internal_provider']); |
198 | - if ( $val < 40 || $val > 49) { |
|
198 | + if ($val < 40 || $val > 49) { |
|
199 | 199 | unset($internal['internal_provider']); |
200 | 200 | unset($input['provider']); |
201 | 201 | } |
202 | 202 | } |
203 | 203 | |
204 | - if ( $internal['internal_invoice_client'] !== '') { |
|
204 | + if ($internal['internal_invoice_client'] !== '') { |
|
205 | 205 | $val = intval($internal['internal_invoice_client']); |
206 | - if ( $val < 40 || $val > 49) { |
|
206 | + if ($val < 40 || $val > 49) { |
|
207 | 207 | unset($internal['internal_invoice_client']); |
208 | 208 | unset($input['invoice_client']); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | - if ( $internal['internal_do_client'] !== '') { |
|
212 | + if ($internal['internal_do_client'] !== '') { |
|
213 | 213 | $val = intval($internal['internal_do_client']); |
214 | - if ( $val < 40 || $val > 49) { |
|
214 | + if ($val < 40 || $val > 49) { |
|
215 | 215 | unset($internal['internal_do_client']); |
216 | 216 | unset($input['do_client']); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | - if ( $internal['internal_product'] !== '') { |
|
220 | + if ($internal['internal_product'] !== '') { |
|
221 | 221 | $val = intval($internal['internal_product']); |
222 | - if ( $val < 40 || $val > 49) { |
|
222 | + if ($val < 40 || $val > 49) { |
|
223 | 223 | unset($internal['internal_product']); |
224 | 224 | unset($input['product']); |
225 | 225 | } |
226 | 226 | } |
227 | 227 | |
228 | - if ( $internal['internal_assets_client'] !== '') { |
|
228 | + if ($internal['internal_assets_client'] !== '') { |
|
229 | 229 | $val = intval($internal['internal_assets_client']); |
230 | - if ( $val < 50 || $val > 59) { |
|
230 | + if ($val < 50 || $val > 59) { |
|
231 | 231 | unset($internal['internal_assets_client']); |
232 | 232 | unset($input['assets_client']); |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - if ( $internal['internal_coupons'] !== '') { |
|
236 | + if ($internal['internal_coupons'] !== '') { |
|
237 | 237 | $val = intval($internal['internal_coupons']); |
238 | - if ( $val < 50 || $val > 59) { |
|
238 | + if ($val < 50 || $val > 59) { |
|
239 | 239 | unset($internal['internal_coupons']); |
240 | 240 | unset($input['coupons']); |
241 | 241 | } |
242 | 242 | } |
243 | 243 | |
244 | - if ( $internal['internal_invoice_provider'] !== '') { |
|
244 | + if ($internal['internal_invoice_provider'] !== '') { |
|
245 | 245 | $val = intval($internal['internal_invoice_provider']); |
246 | - if ( $val < 40 || $val > 49) { |
|
246 | + if ($val < 40 || $val > 49) { |
|
247 | 247 | unset($internal['internal_invoice_provider']); |
248 | 248 | unset($input['invoice_provider']); |
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | - if ( $internal['internal_do_provider'] !== '') { |
|
252 | + if ($internal['internal_do_provider'] !== '') { |
|
253 | 253 | $val = intval($internal['internal_do_provider']); |
254 | - if ( $val < 40 || $val > 49) { |
|
254 | + if ($val < 40 || $val > 49) { |
|
255 | 255 | unset($internal['internal_do_provider']); |
256 | 256 | unset($input['do_provider']); |
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | - if ( $internal['normal_country_code'] === '' ) { |
|
260 | + if ($internal['normal_country_code'] === '') { |
|
261 | 261 | unset($internal['normal_country_code']); |
262 | 262 | unset($input['normal_country_code']); |
263 | 263 | } |
264 | 264 | |
265 | - if ( $internal['normal_enterprise_code'] === '' ) { |
|
265 | + if ($internal['normal_enterprise_code'] === '') { |
|
266 | 266 | unset($internal['normal_enterprise_code']); |
267 | 267 | unset($input['normal_enterprise_code']); |
268 | 268 | } |
@@ -276,8 +276,8 @@ discard block |
||
276 | 276 | * Display message for internal code section |
277 | 277 | */ |
278 | 278 | public function internal_code_section() { |
279 | - _e("Configure your internal codes for automatically generate barcode. The codes are 2 digits, its normal. ". |
|
280 | - "You can put 3 without problems. Please respect the range number following: 040 up to 049.". |
|
279 | + _e("Configure your internal codes for automatically generate barcode. The codes are 2 digits, its normal. " . |
|
280 | + "You can put 3 without problems. Please respect the range number following: 040 up to 049." . |
|
281 | 281 | " For coupons, the range is: 050 up to 059.", 'wps_barcode'); |
282 | 282 | } |
283 | 283 | |
@@ -291,9 +291,9 @@ discard block |
||
291 | 291 | public function add_display_field() { |
292 | 292 | $field = get_option('wps_barcode'); |
293 | 293 | |
294 | - $checked = ( isset($field['generate_barcode']) && $field['generate_barcode'] === 'on') ? 'checked' : ''; |
|
294 | + $checked = (isset($field['generate_barcode']) && $field['generate_barcode'] === 'on') ? 'checked' : ''; |
|
295 | 295 | |
296 | - echo '<input type="checkbox" name="wps_barcode[generate_barcode]" id="barcode_display"'.$checked.'>'; |
|
296 | + echo '<input type="checkbox" name="wps_barcode[generate_barcode]" id="barcode_display"' . $checked . '>'; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | /** |
@@ -307,13 +307,13 @@ discard block |
||
307 | 307 | |
308 | 308 | echo '<select name="wps_barcode[type]" id="barcode_type">'; |
309 | 309 | |
310 | - if ( !empty($field) && ($field['type'] == 'internal') ) { |
|
311 | - echo '<option value="internal" selected>'.__('Internal', 'wps_barcode').'</option>'; |
|
312 | - echo '<option value="normal">'.__('Normal', 'wps_barcode').'</option>'; |
|
310 | + if (!empty($field) && ($field['type'] == 'internal')) { |
|
311 | + echo '<option value="internal" selected>' . __('Internal', 'wps_barcode') . '</option>'; |
|
312 | + echo '<option value="normal">' . __('Normal', 'wps_barcode') . '</option>'; |
|
313 | 313 | } |
314 | - else if ( !empty($field) && ($field['type'] == 'normal') ) { |
|
315 | - echo '<option value="internal">'.__('Internal', 'wps_barcode').'</option>'; |
|
316 | - echo '<option value="normal" selected>'.__('Normal', 'wps_barcode').'</option>'; |
|
314 | + else if (!empty($field) && ($field['type'] == 'normal')) { |
|
315 | + echo '<option value="internal">' . __('Internal', 'wps_barcode') . '</option>'; |
|
316 | + echo '<option value="normal" selected>' . __('Normal', 'wps_barcode') . '</option>'; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | echo '</select>'; |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | */ |
327 | 327 | public function welcome_msg() { |
328 | 328 | //include(WPS_BARCODE_TEMPLATES_MAIN_DIR.'backend/welcome.tpl.php'); |
329 | - require( wpshop_tools::get_template_part(WPS_BARCODE_PATH, |
|
330 | - WPS_BARCODE_TEMPLATES_TPL_DIR, 'backend', 'welcome/welcome') ); |
|
329 | + require(wpshop_tools::get_template_part(WPS_BARCODE_PATH, |
|
330 | + WPS_BARCODE_TEMPLATES_TPL_DIR, 'backend', 'welcome/welcome')); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | public function add_client_field() { |
337 | 337 | $field = get_option('wps_barcode'); |
338 | 338 | |
339 | - echo '<input type="number" name="wps_barcode[internal_client]" '. |
|
340 | - 'min=40 max=49 value="'.$field['internal_client'].'" />'; |
|
339 | + echo '<input type="number" name="wps_barcode[internal_client]" ' . |
|
340 | + 'min=40 max=49 value="' . $field['internal_client'] . '" />'; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | /** |
@@ -346,8 +346,8 @@ discard block |
||
346 | 346 | public function add_provider_field() { |
347 | 347 | $field = get_option('wps_barcode'); |
348 | 348 | |
349 | - echo '<input type="number" name="wps_barcode[internal_provider]" '. |
|
350 | - 'min=40 max=49 value="'.$field['internal_provider'].'" />'; |
|
349 | + echo '<input type="number" name="wps_barcode[internal_provider]" ' . |
|
350 | + 'min=40 max=49 value="' . $field['internal_provider'] . '" />'; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | /** |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | public function add_invoice_client_field() { |
357 | 357 | $field = get_option('wps_barcode'); |
358 | 358 | |
359 | - echo '<input type="number" name="wps_barcode[internal_invoice_client]" '. |
|
360 | - 'min=40 max=49 value="'.$field['internal_invoice_client'].'" />'; |
|
359 | + echo '<input type="number" name="wps_barcode[internal_invoice_client]" ' . |
|
360 | + 'min=40 max=49 value="' . $field['internal_invoice_client'] . '" />'; |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -366,8 +366,8 @@ discard block |
||
366 | 366 | public function add_do_client_field() { |
367 | 367 | $field = get_option('wps_barcode'); |
368 | 368 | |
369 | - echo '<input type="number" name="wps_barcode[internal_do_client]" '. |
|
370 | - 'min=40 max=49 value="'.$field['internal_do_client'].'" />'; |
|
369 | + echo '<input type="number" name="wps_barcode[internal_do_client]" ' . |
|
370 | + 'min=40 max=49 value="' . $field['internal_do_client'] . '" />'; |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | public function add_product_field() { |
377 | 377 | $field = get_option('wps_barcode'); |
378 | 378 | |
379 | - echo '<input type="number" name="wps_barcode[internal_product]" '. |
|
380 | - 'min=40 max=49 value="'.$field['internal_product'].'" />'; |
|
379 | + echo '<input type="number" name="wps_barcode[internal_product]" ' . |
|
380 | + 'min=40 max=49 value="' . $field['internal_product'] . '" />'; |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -386,8 +386,8 @@ discard block |
||
386 | 386 | public function add_assets_client_field() { |
387 | 387 | $field = get_option('wps_barcode'); |
388 | 388 | |
389 | - echo '<input type="number" name="wps_barcode[internal_assets_client]" '. |
|
390 | - 'min=50 max=59 value="'.$field['internal_assets_client'].'" />'; |
|
389 | + echo '<input type="number" name="wps_barcode[internal_assets_client]" ' . |
|
390 | + 'min=50 max=59 value="' . $field['internal_assets_client'] . '" />'; |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -396,8 +396,8 @@ discard block |
||
396 | 396 | public function add_coupons_field() { |
397 | 397 | $field = get_option('wps_barcode'); |
398 | 398 | |
399 | - echo '<input type="number" name="wps_barcode[internal_coupons]" '. |
|
400 | - 'min=50 max=59 value="'.$field['internal_coupons'].'" />'; |
|
399 | + echo '<input type="number" name="wps_barcode[internal_coupons]" ' . |
|
400 | + 'min=50 max=59 value="' . $field['internal_coupons'] . '" />'; |
|
401 | 401 | } |
402 | 402 | |
403 | 403 | /** |
@@ -406,8 +406,8 @@ discard block |
||
406 | 406 | public function add_invoice_provider_field() { |
407 | 407 | $field = get_option('wps_barcode'); |
408 | 408 | |
409 | - echo '<input type="number" name="wps_barcode[internal_invoice_provider]" '. |
|
410 | - 'min=40 max=49 value="'.$field['internal_invoice_provider'].'" />'; |
|
409 | + echo '<input type="number" name="wps_barcode[internal_invoice_provider]" ' . |
|
410 | + 'min=40 max=49 value="' . $field['internal_invoice_provider'] . '" />'; |
|
411 | 411 | } |
412 | 412 | |
413 | 413 | /** |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | public function add_do_provider_field() { |
417 | 417 | $field = get_option('wps_barcode'); |
418 | 418 | |
419 | - echo '<input type="number" name="wps_barcode[internal_do_provider]" '. |
|
420 | - 'min=40 max=49 value="'.$field['internal_do_provider'].'" />'; |
|
419 | + echo '<input type="number" name="wps_barcode[internal_do_provider]" ' . |
|
420 | + 'min=40 max=49 value="' . $field['internal_do_provider'] . '" />'; |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | public function add_country_code_field() { |
427 | 427 | $field = get_option('wps_barcode'); |
428 | 428 | |
429 | - echo '<input type="number" name="wps_barcode[normal_country_code]" '. |
|
430 | - 'value="'.$field['normal_country_code'].'" />'; |
|
429 | + echo '<input type="number" name="wps_barcode[normal_country_code]" ' . |
|
430 | + 'value="' . $field['normal_country_code'] . '" />'; |
|
431 | 431 | } |
432 | 432 | |
433 | 433 | /** |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | public function add_enterprise_code_field() { |
437 | 437 | $field = get_option('wps_barcode'); |
438 | 438 | |
439 | - echo '<input type="number" name="wps_barcode[normal_enterprise_code]" '. |
|
440 | - 'value="'.$field['normal_enterprise_code'].'" />'; |
|
439 | + echo '<input type="number" name="wps_barcode[normal_enterprise_code]" ' . |
|
440 | + 'value="' . $field['normal_enterprise_code'] . '" />'; |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | class wps_barcode_settings { |
4 | 6 | public function __construct() { |
@@ -172,14 +174,11 @@ discard block |
||
172 | 174 | |
173 | 175 | if ( strlen($internal['normal_enterprise_code']) === 1 ) { |
174 | 176 | $internal['normal_enterprise_code'] = '000'.$internal['normal_enterprise_code']; |
175 | - } |
|
176 | - else if ( strlen($internal['normal_enterprise_code']) === 2 ) { |
|
177 | + } else if ( strlen($internal['normal_enterprise_code']) === 2 ) { |
|
177 | 178 | $internal['normal_enterprise_code'] = '00'.$internal['normal_enterprise_code']; |
178 | - } |
|
179 | - else if ( strlen($internal['normal_enterprise_code']) === 3 ) { |
|
179 | + } else if ( strlen($internal['normal_enterprise_code']) === 3 ) { |
|
180 | 180 | $internal['normal_enterprise_code'] = '0'.$internal['normal_enterprise_code']; |
181 | - } |
|
182 | - else { |
|
181 | + } else { |
|
183 | 182 | $internal['normal_enterprise_code'] = $internal['normal_enterprise_code']; |
184 | 183 | } |
185 | 184 | } |
@@ -310,8 +309,7 @@ discard block |
||
310 | 309 | if ( !empty($field) && ($field['type'] == 'internal') ) { |
311 | 310 | echo '<option value="internal" selected>'.__('Internal', 'wps_barcode').'</option>'; |
312 | 311 | echo '<option value="normal">'.__('Normal', 'wps_barcode').'</option>'; |
313 | - } |
|
314 | - else if ( !empty($field) && ($field['type'] == 'normal') ) { |
|
312 | + } else if ( !empty($field) && ($field['type'] == 'normal') ) { |
|
315 | 313 | echo '<option value="internal">'.__('Internal', 'wps_barcode').'</option>'; |
316 | 314 | echo '<option value="normal" selected>'.__('Normal', 'wps_barcode').'</option>'; |
317 | 315 | } |
@@ -1,4 +1,4 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <?php _e("The internal type defines a separate coding and use only internally without any external visibility.", 'wps_barcode'); ?><br /> |
4 | 4 | <?php _e("The external type defined normal coding and requires registration with your organism of regulation.", 'wps_barcode'); ?><br /> |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | ?> |
3 | 5 | <?php _e("The internal type defines a separate coding and use only internally without any external visibility.", 'wps_barcode'); ?><br /> |
4 | 6 | <?php _e("The external type defined normal coding and requires registration with your organism of regulation.", 'wps_barcode'); ?><br /> |
@@ -261,7 +261,7 @@ |
||
261 | 261 | $wps_message->wpshop_prepared_email($email, |
262 | 262 | 'WPSHOP_QUOTATION_UPDATE_MESSAGE', |
263 | 263 | array( 'order_id' => $object['object_id'], |
264 | - 'customer_first_name' => $first_name, |
|
264 | + 'customer_first_name' => $first_name, |
|
265 | 265 | 'customer_last_name' => $last_name, |
266 | 266 | 'order_date' => current_time('mysql', 0), |
267 | 267 | 'order_content' => '', |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | class wps_orders_in_back_office { |
3 | 5 | |
4 | 6 | function __construct() { |
@@ -31,8 +33,9 @@ discard block |
||
31 | 33 | */ |
32 | 34 | function wps_orders_scripts() { |
33 | 35 | global $current_screen; |
34 | - if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) |
|
35 | - return; |
|
36 | + if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) { |
|
37 | + return; |
|
38 | + } |
|
36 | 39 | |
37 | 40 | wp_enqueue_style( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/css/wps_orders.backend.css' ); |
38 | 41 | wp_enqueue_script( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js' ); |
@@ -313,8 +316,7 @@ discard block |
||
313 | 316 | 'order_shipping_address' => '' |
314 | 317 | ) |
315 | 318 | ); |
316 | - } |
|
317 | - else { |
|
319 | + } else { |
|
318 | 320 | $wps_message->wpshop_prepared_email( |
319 | 321 | $email, |
320 | 322 | 'WPSHOP_ORDER_UPDATE_MESSAGE', |
@@ -339,8 +341,9 @@ discard block |
||
339 | 341 | function wpshop_add_private_comment_to_order() { |
340 | 342 | $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
341 | 343 | |
342 | - if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) ) |
|
343 | - wp_die(); |
|
344 | + if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) ) { |
|
345 | + wp_die(); |
|
346 | + } |
|
344 | 347 | |
345 | 348 | $status = false; $result = ''; |
346 | 349 | $order_id = ( ! empty($_POST['oid']) ) ? intval($_POST['oid']) : null; |
@@ -360,8 +363,7 @@ discard block |
||
360 | 363 | ob_end_clean(); |
361 | 364 | $status = true; |
362 | 365 | } |
363 | - } |
|
364 | - else { |
|
366 | + } else { |
|
365 | 367 | $result = __('An error was occured', 'wpshop'); |
366 | 368 | } |
367 | 369 | |
@@ -378,8 +380,9 @@ discard block |
||
378 | 380 | $letter = ( ! empty($_POST['letter']) ) ? sanitize_title( $_POST['letter'] ) : ''; |
379 | 381 | $research = ! empty( $_POST['research'] ) ? sanitize_text_field( $_POST['research'] ) : ''; |
380 | 382 | |
381 | - if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) ) |
|
382 | - wp_die(); |
|
383 | + if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) ) { |
|
384 | + wp_die(); |
|
385 | + } |
|
383 | 386 | |
384 | 387 | $status = false; $response = ''; |
385 | 388 | $oid = ! empty( $_POST['oid'] ) ? (int) $_POST['oid'] : 0; |
@@ -424,8 +427,7 @@ discard block |
||
424 | 427 | $have_variations_checking = wpshop_products::get_variation( $product_id ); |
425 | 428 | if( ! empty($have_variations_checking) ) { |
426 | 429 | $product_have_variations = true; |
427 | - } |
|
428 | - else { |
|
430 | + } else { |
|
429 | 431 | // Get Metadatas |
430 | 432 | $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
431 | 433 | // Calcul cart informations |
@@ -510,8 +512,9 @@ discard block |
||
510 | 512 | function wps_order_load_product_variations() { |
511 | 513 | $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
512 | 514 | |
513 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) ) |
|
514 | - wp_die(); |
|
515 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) ) { |
|
516 | + wp_die(); |
|
517 | + } |
|
515 | 518 | |
516 | 519 | $product_id = ( ! empty($_GET['pid']) ) ? intval( $_GET['pid']) : null; |
517 | 520 | $order_id = ( ! empty($_GET['oid']) ) ? intval( $_GET['oid']) : null; |
@@ -526,8 +529,9 @@ discard block |
||
526 | 529 | function wps_orders_update_cart_informations() { |
527 | 530 | $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
528 | 531 | |
529 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) ) |
|
530 | - wp_die(); |
|
532 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) ) { |
|
533 | + wp_die(); |
|
534 | + } |
|
531 | 535 | |
532 | 536 | $status = false; |
533 | 537 | $order_id = ( ! empty($_POST['order_id']) ) ? intval($_POST['order_id']) : ''; |
@@ -558,14 +562,16 @@ discard block |
||
558 | 562 | function wps_reverify_payment_invoice_ref() { |
559 | 563 | $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
560 | 564 | |
561 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) ) |
|
562 | - wp_die(); |
|
565 | + if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) ) { |
|
566 | + wp_die(); |
|
567 | + } |
|
563 | 568 | |
564 | 569 | $status = true; |
565 | 570 | $inputs = ! empty( $_POST['inputs'] ) ? (array) $_POST['inputs'] : false; |
566 | 571 | |
567 | - if (!$inputs) |
|
568 | - $status = false; |
|
572 | + if (!$inputs) { |
|
573 | + $status = false; |
|
574 | + } |
|
569 | 575 | |
570 | 576 | if( $status ) { |
571 | 577 | $inputs_clone = $inputs; |
@@ -1,26 +1,26 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | class wps_orders_in_back_office { |
3 | 3 | |
4 | 4 | function __construct() { |
5 | 5 | // Template loading |
6 | 6 | $this->template_dir = WPS_ORDERS_PATH . WPS_ORDERS_DIR . "/templates/"; |
7 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes') ); |
|
7 | + add_action('add_meta_boxes', array($this, 'add_meta_boxes')); |
|
8 | 8 | |
9 | 9 | // Ajax actions |
10 | - add_action('wp_ajax_wpshop_add_private_comment_to_order', array( $this, 'wpshop_add_private_comment_to_order' ) ); |
|
11 | - add_action('wp_ajax_wps_order_refresh_product_listing', array( $this, 'refresh_product_list' ) ); |
|
12 | - add_action('wp_ajax_wps_add_product_to_order_admin', array( $this, 'wps_add_product_to_order_admin' ) ); |
|
13 | - add_action('wp_ajax_wps_refresh_cart_order', array( $this, 'refresh_cart_order' ) ); |
|
14 | - add_action('wp_ajax_wps_refresh_payments_order', array( $this, 'refresh_payments_order' ) ); |
|
15 | - add_action('wp_ajax_wps_update_product_qty_in_admin', array( $this, 'wps_update_product_qty_in_admin' ) ); |
|
16 | - add_action('wp_ajax_wps_order_load_product_variations', array( $this, 'wps_order_load_product_variations' ) ); |
|
17 | - add_action('wp_ajax_wps-orders-update-cart-informations', array( $this, 'wps_orders_update_cart_informations' ) ); |
|
18 | - add_action('wp_ajax_wps_reverify_payment_invoice_ref', array( $this, 'wps_reverify_payment_invoice_ref' ) ); |
|
10 | + add_action('wp_ajax_wpshop_add_private_comment_to_order', array($this, 'wpshop_add_private_comment_to_order')); |
|
11 | + add_action('wp_ajax_wps_order_refresh_product_listing', array($this, 'refresh_product_list')); |
|
12 | + add_action('wp_ajax_wps_add_product_to_order_admin', array($this, 'wps_add_product_to_order_admin')); |
|
13 | + add_action('wp_ajax_wps_refresh_cart_order', array($this, 'refresh_cart_order')); |
|
14 | + add_action('wp_ajax_wps_refresh_payments_order', array($this, 'refresh_payments_order')); |
|
15 | + add_action('wp_ajax_wps_update_product_qty_in_admin', array($this, 'wps_update_product_qty_in_admin')); |
|
16 | + add_action('wp_ajax_wps_order_load_product_variations', array($this, 'wps_order_load_product_variations')); |
|
17 | + add_action('wp_ajax_wps-orders-update-cart-informations', array($this, 'wps_orders_update_cart_informations')); |
|
18 | + add_action('wp_ajax_wps_reverify_payment_invoice_ref', array($this, 'wps_reverify_payment_invoice_ref')); |
|
19 | 19 | |
20 | 20 | // WP General actions |
21 | - add_action( 'admin_enqueue_scripts', array( $this, 'wps_orders_scripts' ) ); |
|
22 | - add_action( 'admin_enqueue_scripts', array( $this, 'wps_orders_scripts_texts' ), 20 ); |
|
23 | - add_action( 'save_post', array( $this, 'save_order_custom_informations' ), 10, 2 ); |
|
21 | + add_action('admin_enqueue_scripts', array($this, 'wps_orders_scripts')); |
|
22 | + add_action('admin_enqueue_scripts', array($this, 'wps_orders_scripts_texts'), 20); |
|
23 | + add_action('save_post', array($this, 'save_order_custom_informations'), 10, 2); |
|
24 | 24 | |
25 | 25 | // WP Filters |
26 | 26 | //add_filter( 'wps_order_saving_admin_extra_action', array( $this, 'wps_notif_user_on_order_saving'), 100, 2 ); |
@@ -31,52 +31,52 @@ discard block |
||
31 | 31 | */ |
32 | 32 | function wps_orders_scripts() { |
33 | 33 | global $current_screen; |
34 | - if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_ORDER ), true ) ) |
|
34 | + if (!in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_ORDER), true)) |
|
35 | 35 | return; |
36 | 36 | |
37 | - wp_enqueue_style( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/css/wps_orders.backend.css' ); |
|
38 | - wp_enqueue_script( 'wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js' ); |
|
37 | + wp_enqueue_style('wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/css/wps_orders.backend.css'); |
|
38 | + wp_enqueue_script('wps_orders_backend', WPS_ORDERS_URL . WPS_ORDERS_DIR . '/assets/backend/js/wps_orders.js'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | function wps_orders_scripts_texts() { |
42 | - wp_localize_script( 'wps_orders_backend', 'message_confirm_reload', __( 'Are you sure you want to refresh your browser?', 'wpshop' ) ); |
|
43 | - wp_localize_script( 'wps_orders_backend', 'message_error_reverify_payment_invoice_ref', __( 'Error detected.', 'wpshop' ) ); |
|
42 | + wp_localize_script('wps_orders_backend', 'message_confirm_reload', __('Are you sure you want to refresh your browser?', 'wpshop')); |
|
43 | + wp_localize_script('wps_orders_backend', 'message_error_reverify_payment_invoice_ref', __('Error detected.', 'wpshop')); |
|
44 | 44 | } |
45 | 45 | /** |
46 | 46 | * Add meta boxes |
47 | 47 | */ |
48 | 48 | function add_meta_boxes() { |
49 | 49 | global $post; |
50 | - $order_meta = get_post_meta( $post->ID, '_order_postmeta', true ); |
|
50 | + $order_meta = get_post_meta($post->ID, '_order_postmeta', true); |
|
51 | 51 | /** Box Order Payments **/ |
52 | - if( !in_array( $post->post_status, array( 'auto-draft' ) ) ) { |
|
53 | - add_meta_box('wpshop_order_payment', '<span class="dashicons dashicons-money"></span> '.__('Order payment', 'wpshop'),array($this, 'display_order_payments_box'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
|
52 | + if (!in_array($post->post_status, array('auto-draft'))) { |
|
53 | + add_meta_box('wpshop_order_payment', '<span class="dashicons dashicons-money"></span> ' . __('Order payment', 'wpshop'), array($this, 'display_order_payments_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
|
54 | 54 | } |
55 | 55 | /** Box for customer order comment */ |
56 | - if ( ! empty( $post->post_excerpt ) ) { |
|
57 | - add_meta_box('wpshop_order_customer_comment', '<span class="dashicons dashicons-format-status"></span> '.__('Order customer comment', 'wpshop'),array( $this, 'order_customer_comment_box'),WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
|
56 | + if (!empty($post->post_excerpt)) { |
|
57 | + add_meta_box('wpshop_order_customer_comment', '<span class="dashicons dashicons-format-status"></span> ' . __('Order customer comment', 'wpshop'), array($this, 'order_customer_comment_box'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'side', 'low'); |
|
58 | 58 | } |
59 | 59 | /** Historic sales **/ |
60 | - add_meta_box('wpshop_product_order_historic', __('Sales informations', 'wpshop'), array( $this, 'meta_box_product_sale_informations'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low'); |
|
60 | + add_meta_box('wpshop_product_order_historic', __('Sales informations', 'wpshop'), array($this, 'meta_box_product_sale_informations'), WPSHOP_NEWTYPE_IDENTIFIER_PRODUCT, 'normal', 'low'); |
|
61 | 61 | /** Box with the complete order content */ |
62 | 62 | $payment_started = false; |
63 | - if ( ! empty( $order_meta['order_payment'] ) && ! empty( $order_meta['order_payment']['received'] ) ) { |
|
64 | - foreach ( $order_meta['order_payment']['received'] as $received ) { |
|
65 | - if ( empty( $received['received_amount'] ) ) { |
|
63 | + if (!empty($order_meta['order_payment']) && !empty($order_meta['order_payment']['received'])) { |
|
64 | + foreach ($order_meta['order_payment']['received'] as $received) { |
|
65 | + if (empty($received['received_amount'])) { |
|
66 | 66 | continue; |
67 | 67 | } |
68 | 68 | $payment_started = true; |
69 | 69 | break; |
70 | 70 | } |
71 | 71 | } |
72 | - if ( ! $payment_started ) { |
|
73 | - add_meta_box( 'wpshop_product_list', '<span class="dashicons dashicons-archive"></span> ' . __( 'Product List', 'wpshop' ), array( $this, 'wps_products_listing_for_quotation' ), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low' ); |
|
72 | + if (!$payment_started) { |
|
73 | + add_meta_box('wpshop_product_list', '<span class="dashicons dashicons-archive"></span> ' . __('Product List', 'wpshop'), array($this, 'wps_products_listing_for_quotation'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
74 | 74 | } |
75 | 75 | /** Box with the complete order content */ |
76 | - add_meta_box( 'wpshop_order_content', '<span class="dashicons dashicons-cart"></span> '.__('Order content', 'wpshop'), array( $this, 'meta_box_order_content'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
76 | + add_meta_box('wpshop_order_content', '<span class="dashicons dashicons-cart"></span> ' . __('Order content', 'wpshop'), array($this, 'meta_box_order_content'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
77 | 77 | /** Box Private order comments **/ |
78 | - if( !in_array( $post->post_status, array( 'auto-draft' ) ) ) { |
|
79 | - add_meta_box('wpshop_order_private_comments', '<span class="dashicons dashicons-format-chat"></span> '.__('Comments', 'wpshop'), array( $this, 'meta_box_private_comment'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
78 | + if (!in_array($post->post_status, array('auto-draft'))) { |
|
79 | + add_meta_box('wpshop_order_private_comments', '<span class="dashicons dashicons-format-chat"></span> ' . __('Comments', 'wpshop'), array($this, 'meta_box_private_comment'), WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'normal', 'low'); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
@@ -84,65 +84,65 @@ discard block |
||
84 | 84 | * METABOX CONTENT - Display Customer comments on order in administration panel |
85 | 85 | * @param object $order |
86 | 86 | */ |
87 | - function order_customer_comment_box( $order ) { |
|
88 | - if ( ! empty($order) && ! empty($order->ID) ) { |
|
89 | - require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "customer_comment_on_order_box") ); |
|
87 | + function order_customer_comment_box($order) { |
|
88 | + if (!empty($order) && !empty($order->ID)) { |
|
89 | + require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "customer_comment_on_order_box")); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
94 | 94 | * METABOX CONTENT - Display an order historic of product in administration product panel |
95 | 95 | */ |
96 | - function meta_box_product_sale_informations () { |
|
96 | + function meta_box_product_sale_informations() { |
|
97 | 97 | global $post; |
98 | 98 | $product_id = $post->ID; |
99 | - $variations = wpshop_products::get_variation( $product_id ); |
|
100 | - $order_status = unserialize( WPSHOP_ORDER_STATUS ); |
|
101 | - $color_label = array( 'awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu'); |
|
99 | + $variations = wpshop_products::get_variation($product_id); |
|
100 | + $order_status = unserialize(WPSHOP_ORDER_STATUS); |
|
101 | + $color_label = array('awaiting_payment' => 'jaune', 'canceled' => 'rouge', 'partially_paid' => 'orange', 'incorrect_amount' => 'orange', 'denied' => 'rouge', 'shipped' => 'bleu', 'payment_refused' => 'rouge', 'completed' => 'vert', 'refunded' => 'rouge', 'pos' => 'bleu'); |
|
102 | 102 | // Get datas |
103 | 103 | $sales_informations = array(); |
104 | 104 | /** Query **/ |
105 | - $data_to_compare = '"item_id";s:' .strlen($product_id). ':"' .$product_id. '";'; |
|
106 | - $query_args = array( 'posts_per_page' => 10, 'paged' => absint( isset( $_GET['paged_sales'] ) ? $_GET['paged_sales'] : 1 ), 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array( array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE') ) ); |
|
107 | - $orders = new WP_Query( $query_args ); |
|
108 | - if ( ! empty($orders) && ! empty($orders->posts) ) { |
|
109 | - foreach( $orders->posts as $order ) { |
|
110 | - $order_meta = get_post_meta( $order->ID, '_order_postmeta', true ); |
|
111 | - $order_info = get_post_meta( $order->ID, '_order_info', true ); |
|
105 | + $data_to_compare = '"item_id";s:' . strlen($product_id) . ':"' . $product_id . '";'; |
|
106 | + $query_args = array('posts_per_page' => 10, 'paged' => absint(isset($_GET['paged_sales']) ? $_GET['paged_sales'] : 1), 'post_type' => WPSHOP_NEWTYPE_IDENTIFIER_ORDER, 'meta_query' => array(array('key' => '_order_postmeta', 'value' => $data_to_compare, 'compare' => 'LIKE'))); |
|
107 | + $orders = new WP_Query($query_args); |
|
108 | + if (!empty($orders) && !empty($orders->posts)) { |
|
109 | + foreach ($orders->posts as $order) { |
|
110 | + $order_meta = get_post_meta($order->ID, '_order_postmeta', true); |
|
111 | + $order_info = get_post_meta($order->ID, '_order_info', true); |
|
112 | 112 | $sales_informations[] = array( |
113 | - 'order_key' => ( ! empty($order_meta) && ! empty($order_meta['order_key']) ) ? $order_meta['order_key'] : '', |
|
114 | - 'order_date' => ( ! empty($order_meta) && ! empty($order_meta['order_date']) ) ? $order_meta['order_date'] : '', |
|
115 | - 'customer_firstname' => ( ! empty($order_info) && ! empty($order_info['billing']) && ! empty($order_info['billing']['address']) && ! empty($order_info['billing']['address']['address_first_name']) ) ? $order_info['billing']['address']['address_first_name'] : '', |
|
116 | - 'customer_name' => ( ! empty($order_info) && ! empty($order_info['billing']) && ! empty($order_info['billing']['address']) && ! empty($order_info['billing']['address']['address_last_name']) ) ? $order_info['billing']['address']['address_last_name'] : '', |
|
117 | - 'customer_email' => ( ! empty($order_info) && ! empty($order_info['billing']) && ! empty($order_info['billing']['address']) && ! empty($order_info['billing']['address']['address_user_email']) ) ? $order_info['billing']['address']['address_user_email'] : '', |
|
113 | + 'order_key' => (!empty($order_meta) && !empty($order_meta['order_key'])) ? $order_meta['order_key'] : '', |
|
114 | + 'order_date' => (!empty($order_meta) && !empty($order_meta['order_date'])) ? $order_meta['order_date'] : '', |
|
115 | + 'customer_firstname' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_first_name'])) ? $order_info['billing']['address']['address_first_name'] : '', |
|
116 | + 'customer_name' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_last_name'])) ? $order_info['billing']['address']['address_last_name'] : '', |
|
117 | + 'customer_email' => (!empty($order_info) && !empty($order_info['billing']) && !empty($order_info['billing']['address']) && !empty($order_info['billing']['address']['address_user_email'])) ? $order_info['billing']['address']['address_user_email'] : '', |
|
118 | 118 | 'order_id' => $order->ID, |
119 | 119 | 'order_status' => $order_meta['order_status'] |
120 | 120 | ); |
121 | 121 | } |
122 | 122 | } |
123 | 123 | // Display results |
124 | - require_once( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product_order_historic") ); |
|
124 | + require_once(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product_order_historic")); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * METABOX CONTENT - Payments Box in Orders panel |
129 | 129 | * @param string $order |
130 | 130 | */ |
131 | - function display_order_payments_box( $order ) { |
|
131 | + function display_order_payments_box($order) { |
|
132 | 132 | $order_status = unserialize(WPSHOP_ORDER_STATUS); |
133 | 133 | $order_postmeta = get_post_meta($order->ID, '_order_postmeta', true); |
134 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "wps_order_payment_box") ); |
|
134 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "wps_order_payment_box")); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * METABOX CONTENT - Display an lsiting of products to make quotation in backend |
139 | 139 | */ |
140 | - function wps_products_listing_for_quotation( $post ) { |
|
141 | - $letters = array( 'ALL', 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); |
|
142 | - $current_letter = sanitize_title( $letters[0] ); |
|
140 | + function wps_products_listing_for_quotation($post) { |
|
141 | + $letters = array('ALL', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); |
|
142 | + $current_letter = sanitize_title($letters[0]); |
|
143 | 143 | $wps_product_mdl = new wps_product_mdl(); |
144 | - $products = $wps_product_mdl->get_products_by_letter( $current_letter ); |
|
145 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing") ); |
|
144 | + $products = $wps_product_mdl->get_products_by_letter($current_letter); |
|
145 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing")); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | function meta_box_private_comment() { |
152 | 152 | global $post; |
153 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_private_comments") ); |
|
153 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_private_comments")); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | */ |
159 | 159 | function meta_box_order_content() { |
160 | 160 | global $post_id; |
161 | - unset( $_SESSION['cart'] ); |
|
162 | - echo do_shortcode( '[wps_cart oid="' .$post_id. '" cart_type="admin-panel"]'); |
|
161 | + unset($_SESSION['cart']); |
|
162 | + echo do_shortcode('[wps_cart oid="' . $post_id . '" cart_type="admin-panel"]'); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | |
@@ -171,72 +171,72 @@ discard block |
||
171 | 171 | * @param integer $post_id The current saved post id / L'identifiant post qui vient d'être sauvegardé. |
172 | 172 | * @param WP_Post $post The entire post currently saved / Le post qui vient d'être sauvegardé. |
173 | 173 | */ |
174 | - public function save_order_custom_informations( $post_id, $post ) { |
|
175 | - if ( ( WPSHOP_NEWTYPE_IDENTIFIER_ORDER !== $post->post_type ) || ( 'auto-draft' === $post->post_status ) || wp_is_post_revision( $post_id ) ) { |
|
174 | + public function save_order_custom_informations($post_id, $post) { |
|
175 | + if ((WPSHOP_NEWTYPE_IDENTIFIER_ORDER !== $post->post_type) || ('auto-draft' === $post->post_status) || wp_is_post_revision($post_id)) { |
|
176 | 176 | return; |
177 | 177 | } |
178 | 178 | |
179 | 179 | $user_id = get_current_user_id(); |
180 | - $customer_id = ( ! empty( $_REQUEST['wps_customer_id'] ) ) ? (int) $_REQUEST['wps_customer_id'] : wps_customer_ctr::get_customer_id_by_author_id( $user_id ); |
|
180 | + $customer_id = (!empty($_REQUEST['wps_customer_id'])) ? (int)$_REQUEST['wps_customer_id'] : wps_customer_ctr::get_customer_id_by_author_id($user_id); |
|
181 | 181 | |
182 | 182 | // Récupération des informations actuelles de la commande / Get order's current information. |
183 | - $order_meta = get_post_meta( $post_id, '_order_postmeta', true ); |
|
183 | + $order_meta = get_post_meta($post_id, '_order_postmeta', true); |
|
184 | 184 | |
185 | 185 | // Affectation du client de la commande / Affect customer to order. |
186 | - remove_action( 'save_post', array( $this, 'save_order_custom_informations' ) ); |
|
187 | - wp_update_post( array( 'ID' => $post_id, 'post_parent' => $customer_id ) ); |
|
188 | - if ( empty( $order_meta['customer_id'] ) ) { |
|
189 | - update_post_meta( $post_id, '_wpshop_order_customer_id', $user_id ); |
|
186 | + remove_action('save_post', array($this, 'save_order_custom_informations')); |
|
187 | + wp_update_post(array('ID' => $post_id, 'post_parent' => $customer_id)); |
|
188 | + if (empty($order_meta['customer_id'])) { |
|
189 | + update_post_meta($post_id, '_wpshop_order_customer_id', $user_id); |
|
190 | 190 | $order_meta['customer_id'] = $user_id; |
191 | 191 | } |
192 | 192 | |
193 | - if ( empty( $order_meta['order_key'] ) ) { |
|
194 | - $order_meta['order_key'] = ! empty( $order_meta['order_key'] ) ? $order_meta['order_key'] : ( ! empty( $order_meta['order_status'] ) && ( $order_meta['order_status'] != 'awaiting_payment' ) ? wpshop_orders::get_new_order_reference() : ''); |
|
195 | - $order_meta['order_temporary_key'] = ( isset( $order_meta['order_temporary_key'] ) && ( $order_meta['order_temporary_key'] != '') ) ? $order_meta['order_temporary_key'] : wpshop_orders::get_new_pre_order_reference(); |
|
193 | + if (empty($order_meta['order_key'])) { |
|
194 | + $order_meta['order_key'] = !empty($order_meta['order_key']) ? $order_meta['order_key'] : (!empty($order_meta['order_status']) && ($order_meta['order_status'] != 'awaiting_payment') ? wpshop_orders::get_new_order_reference() : ''); |
|
195 | + $order_meta['order_temporary_key'] = (isset($order_meta['order_temporary_key']) && ($order_meta['order_temporary_key'] != '')) ? $order_meta['order_temporary_key'] : wpshop_orders::get_new_pre_order_reference(); |
|
196 | 196 | } |
197 | 197 | $order_meta['order_status'] = (isset($order_meta['order_status']) && ($order_meta['order_status'] != '')) ? $order_meta['order_status'] : 'awaiting_payment'; |
198 | 198 | $order_meta['order_date'] = (isset($order_meta['order_date']) && ($order_meta['order_date'] != '')) ? $order_meta['order_date'] : current_time('mysql', 0); |
199 | - $order_meta['order_currency'] = wpshop_tools::wpshop_get_currency( true ); |
|
199 | + $order_meta['order_currency'] = wpshop_tools::wpshop_get_currency(true); |
|
200 | 200 | |
201 | - $billing_adress_id = ( ! empty( $_REQUEST['wps_order_selected_address'] ) && ! empty( $_REQUEST['wps_order_selected_address']['billing'] ) ) ? (int) $_REQUEST['wps_order_selected_address']['billing'] : 0; |
|
201 | + $billing_adress_id = (!empty($_REQUEST['wps_order_selected_address']) && !empty($_REQUEST['wps_order_selected_address']['billing'])) ? (int)$_REQUEST['wps_order_selected_address']['billing'] : 0; |
|
202 | 202 | |
203 | - if ( ! empty( $billing_adress_id ) ) { |
|
204 | - $order_informations = get_post_meta( $post_id, '_order_info', true ); |
|
205 | - $order_informations = ( ! empty( $order_informations ) ) ? $order_informations : array(); |
|
206 | - $billing_address_option = get_option( 'wpshop_billing_address' ); |
|
207 | - $billing_address_option = ( ! empty( $billing_address_option ) && ! empty( $billing_address_option['choice'] ) ) ? $billing_address_option['choice'] : ''; |
|
203 | + if (!empty($billing_adress_id)) { |
|
204 | + $order_informations = get_post_meta($post_id, '_order_info', true); |
|
205 | + $order_informations = (!empty($order_informations)) ? $order_informations : array(); |
|
206 | + $billing_address_option = get_option('wpshop_billing_address'); |
|
207 | + $billing_address_option = (!empty($billing_address_option) && !empty($billing_address_option['choice'])) ? $billing_address_option['choice'] : ''; |
|
208 | 208 | |
209 | 209 | // Billing datas |
210 | - $order_informations['billing'] = array( 'id' => $billing_address_option, |
|
210 | + $order_informations['billing'] = array('id' => $billing_address_option, |
|
211 | 211 | 'address_id' => $billing_adress_id, |
212 | - 'address' => get_post_meta( $billing_adress_id, '_wpshop_address_metadata', true ) |
|
212 | + 'address' => get_post_meta($billing_adress_id, '_wpshop_address_metadata', true) |
|
213 | 213 | ); |
214 | 214 | // Shipping datas |
215 | - $shipping_adress_id = ( ! empty( $_REQUEST['wps_order_selected_address'] ) && ! empty( $_REQUEST['wps_order_selected_address']['shipping'] ) ) ? (int) $_REQUEST['wps_order_selected_address']['shipping'] : 0; |
|
215 | + $shipping_adress_id = (!empty($_REQUEST['wps_order_selected_address']) && !empty($_REQUEST['wps_order_selected_address']['shipping'])) ? (int)$_REQUEST['wps_order_selected_address']['shipping'] : 0; |
|
216 | 216 | |
217 | - if( ! empty( $shipping_adress_id ) ) { |
|
218 | - $shipping_address_option = get_option( 'wpshop_shipping_address_choice' ); |
|
219 | - $shipping_address_option = ( ! empty($shipping_address_option) && ! empty($shipping_address_option['choice']) ) ? $shipping_address_option['choice'] : ''; |
|
220 | - $order_informations['shipping'] = array( 'id' => $shipping_address_option, |
|
217 | + if (!empty($shipping_adress_id)) { |
|
218 | + $shipping_address_option = get_option('wpshop_shipping_address_choice'); |
|
219 | + $shipping_address_option = (!empty($shipping_address_option) && !empty($shipping_address_option['choice'])) ? $shipping_address_option['choice'] : ''; |
|
220 | + $order_informations['shipping'] = array('id' => $shipping_address_option, |
|
221 | 221 | 'address_id' => $shipping_adress_id, |
222 | - 'address' => get_post_meta( $shipping_adress_id, '_wpshop_address_metadata', true ) |
|
222 | + 'address' => get_post_meta($shipping_adress_id, '_wpshop_address_metadata', true) |
|
223 | 223 | ); |
224 | 224 | } |
225 | - update_post_meta( $post_id, '_order_info', $order_informations ); |
|
225 | + update_post_meta($post_id, '_order_info', $order_informations); |
|
226 | 226 | } |
227 | 227 | |
228 | - $wpshop_admin_order_payment_received = ! empty( $_REQUEST['wpshop_admin_order_payment_received'] ) ? (array) $_REQUEST['wpshop_admin_order_payment_received'] : array(); |
|
229 | - $wpshop_admin_order_payment_received['method'] = ! empty( $wpshop_admin_order_payment_received['method'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['method'] ) : ''; |
|
230 | - $wpshop_admin_order_payment_received['payment_reference'] = ! empty( $wpshop_admin_order_payment_received['payment_reference'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['payment_reference'] ) : ''; |
|
231 | - $wpshop_admin_order_payment_received['date'] = ! empty( $wpshop_admin_order_payment_received['date'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['date'] ) : ''; |
|
232 | - $wpshop_admin_order_payment_received['received_amount'] = ! empty( $wpshop_admin_order_payment_received['received_amount'] ) ? sanitize_text_field( $wpshop_admin_order_payment_received['received_amount'] ) : ''; |
|
233 | - $action_triggered_from = ! empty( $_REQUEST['action_triggered_from'] ) ? sanitize_text_field( $_REQUEST['action_triggered_from'] ) : ''; |
|
234 | - $wshop_admin_order_payment_reference = ! empty( $_REQUEST['wpshop_admin_order_payment_reference'] ) ? sanitize_text_field( $_REQUEST['wpshop_admin_order_payment_reference'] ) : ''; |
|
228 | + $wpshop_admin_order_payment_received = !empty($_REQUEST['wpshop_admin_order_payment_received']) ? (array)$_REQUEST['wpshop_admin_order_payment_received'] : array(); |
|
229 | + $wpshop_admin_order_payment_received['method'] = !empty($wpshop_admin_order_payment_received['method']) ? sanitize_text_field($wpshop_admin_order_payment_received['method']) : ''; |
|
230 | + $wpshop_admin_order_payment_received['payment_reference'] = !empty($wpshop_admin_order_payment_received['payment_reference']) ? sanitize_text_field($wpshop_admin_order_payment_received['payment_reference']) : ''; |
|
231 | + $wpshop_admin_order_payment_received['date'] = !empty($wpshop_admin_order_payment_received['date']) ? sanitize_text_field($wpshop_admin_order_payment_received['date']) : ''; |
|
232 | + $wpshop_admin_order_payment_received['received_amount'] = !empty($wpshop_admin_order_payment_received['received_amount']) ? sanitize_text_field($wpshop_admin_order_payment_received['received_amount']) : ''; |
|
233 | + $action_triggered_from = !empty($_REQUEST['action_triggered_from']) ? sanitize_text_field($_REQUEST['action_triggered_from']) : ''; |
|
234 | + $wshop_admin_order_payment_reference = !empty($_REQUEST['wpshop_admin_order_payment_reference']) ? sanitize_text_field($_REQUEST['wpshop_admin_order_payment_reference']) : ''; |
|
235 | 235 | |
236 | 236 | // Ajout des informations de paiements / Add payment informations. |
237 | - if ( ! empty( $wpshop_admin_order_payment_received ) && ! empty( $wpshop_admin_order_payment_received['method'] ) |
|
238 | - && ! empty( $wpshop_admin_order_payment_received['date'] ) && ! empty( $wpshop_admin_order_payment_received['received_amount'] ) && |
|
239 | - ( ( 'add_payment' == $action_triggered_from ) || ! empty( $wshop_admin_order_payment_reference ) ) ) { |
|
237 | + if (!empty($wpshop_admin_order_payment_received) && !empty($wpshop_admin_order_payment_received['method']) |
|
238 | + && !empty($wpshop_admin_order_payment_received['date']) && !empty($wpshop_admin_order_payment_received['received_amount']) && |
|
239 | + (('add_payment' == $action_triggered_from) || !empty($wshop_admin_order_payment_reference))) { |
|
240 | 240 | |
241 | 241 | $received_payment_amount = $wpshop_admin_order_payment_received['received_amount']; |
242 | 242 | |
@@ -247,40 +247,40 @@ discard block |
||
247 | 247 | 'status' => 'payment_received', |
248 | 248 | 'author' => $user_id, |
249 | 249 | 'payment_reference' => $wpshop_admin_order_payment_received['payment_reference'], |
250 | - 'date' => current_time( 'mysql', 0 ), |
|
250 | + 'date' => current_time('mysql', 0), |
|
251 | 251 | 'received_amount' => $received_payment_amount, |
252 | 252 | ); |
253 | - $order_meta = wpshop_payment::check_order_payment_total_amount( $post_id, $params_array, 'completed', $order_meta, false ); |
|
253 | + $order_meta = wpshop_payment::check_order_payment_total_amount($post_id, $params_array, 'completed', $order_meta, false); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | //Round final amount |
257 | - $order_meta['order_grand_total'] = number_format( round($order_meta['order_grand_total'], 2), 2, '.', ''); |
|
258 | - $order_meta['order_total_ttc'] = number_format( round($order_meta['order_total_ttc'], 2), 2, '.', ''); |
|
259 | - $order_meta['order_amount_to_pay_now'] = number_format( round($order_meta['order_amount_to_pay_now'], 2), 2, '.', ''); |
|
257 | + $order_meta['order_grand_total'] = number_format(round($order_meta['order_grand_total'], 2), 2, '.', ''); |
|
258 | + $order_meta['order_total_ttc'] = number_format(round($order_meta['order_total_ttc'], 2), 2, '.', ''); |
|
259 | + $order_meta['order_amount_to_pay_now'] = number_format(round($order_meta['order_amount_to_pay_now'], 2), 2, '.', ''); |
|
260 | 260 | |
261 | 261 | // Payment Pre-Fill |
262 | - if ( empty( $order_meta['order_payment'] ) ) { |
|
262 | + if (empty($order_meta['order_payment'])) { |
|
263 | 263 | $order_meta['order_payment']['customer_choice']['method'] = ''; |
264 | - $order_meta['order_payment']['received'][] = array('waited_amount' => ( ! empty($order_meta) && ! empty($order_meta['order_grand_total']) ) ? number_format($order_meta['order_grand_total'],2,'.', '') : 0 ); |
|
264 | + $order_meta['order_payment']['received'][] = array('waited_amount' => (!empty($order_meta) && !empty($order_meta['order_grand_total'])) ? number_format($order_meta['order_grand_total'], 2, '.', '') : 0); |
|
265 | 265 | } |
266 | 266 | |
267 | - $data['post_ID'] = ! empty( $_REQUEST['post_ID'] ) ? (int) $_REQUEST['post_ID'] : 0; |
|
268 | - $data['markascanceled_order_hidden_indicator'] = ! empty( $_REQUEST['markascanceled_order_hidden_indicator' ] ) ? sanitize_text_field( $_REQUEST['markascanceled_order_hidden_indicator'] ) : ''; |
|
269 | - $data['resendordertocustomer_order_hidden_indicator'] = ! empty( $_REQUEST['resendordertocustomer_order_hidden_indicator' ] ) ? sanitize_text_field( $_REQUEST['resendordertocustomer_order_hidden_indicator'] ) : ''; |
|
270 | - $data['action_triggered_from'] = ! empty( $_REQUEST['action_triggered_from' ] ) ? sanitize_text_field( $_REQUEST['action_triggered_from'] ) : ''; |
|
271 | - $data['notif_the_customer'] = ! empty( $_REQUEST['notif_the_customer' ] ) ? sanitize_text_field( $_REQUEST['notif_the_customer'] ) : ''; |
|
267 | + $data['post_ID'] = !empty($_REQUEST['post_ID']) ? (int)$_REQUEST['post_ID'] : 0; |
|
268 | + $data['markascanceled_order_hidden_indicator'] = !empty($_REQUEST['markascanceled_order_hidden_indicator']) ? sanitize_text_field($_REQUEST['markascanceled_order_hidden_indicator']) : ''; |
|
269 | + $data['resendordertocustomer_order_hidden_indicator'] = !empty($_REQUEST['resendordertocustomer_order_hidden_indicator']) ? sanitize_text_field($_REQUEST['resendordertocustomer_order_hidden_indicator']) : ''; |
|
270 | + $data['action_triggered_from'] = !empty($_REQUEST['action_triggered_from']) ? sanitize_text_field($_REQUEST['action_triggered_from']) : ''; |
|
271 | + $data['notif_the_customer'] = !empty($_REQUEST['notif_the_customer']) ? sanitize_text_field($_REQUEST['notif_the_customer']) : ''; |
|
272 | 272 | |
273 | 273 | // Apply a filter to make credit, notificate the customer and generate billing actions |
274 | - $order_meta = apply_filters( 'wps_order_saving_admin_extra_action', $order_meta, $data ); |
|
274 | + $order_meta = apply_filters('wps_order_saving_admin_extra_action', $order_meta, $data); |
|
275 | 275 | |
276 | 276 | // Save Shipping informations & Order status. |
277 | - if ( isset( $order_meta['order_shipping_date'] ) ) { |
|
278 | - update_post_meta( $post_id, '_wpshop_order_shipping_date', $order_meta['order_shipping_date'] ); |
|
277 | + if (isset($order_meta['order_shipping_date'])) { |
|
278 | + update_post_meta($post_id, '_wpshop_order_shipping_date', $order_meta['order_shipping_date']); |
|
279 | 279 | } |
280 | - update_post_meta( $post_id, '_wpshop_order_status', $order_meta['order_status'] ); |
|
280 | + update_post_meta($post_id, '_wpshop_order_status', $order_meta['order_status']); |
|
281 | 281 | |
282 | 282 | // Save Metadata |
283 | - update_post_meta( $post_id, '_order_postmeta', $order_meta ); |
|
283 | + update_post_meta($post_id, '_order_postmeta', $order_meta); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param array $posted_datas |
291 | 291 | * @return array |
292 | 292 | */ |
293 | - function wps_notif_user_on_order_saving( $order_metadata, $posted_datas ) { |
|
294 | - if( ! empty($posted_datas['notif_the_customer']) && $posted_datas['notif_the_customer']=='on' ) { |
|
293 | + function wps_notif_user_on_order_saving($order_metadata, $posted_datas) { |
|
294 | + if (!empty($posted_datas['notif_the_customer']) && $posted_datas['notif_the_customer'] == 'on') { |
|
295 | 295 | $wps_message = new wps_message_ctr(); |
296 | 296 | /* Get order current content */ |
297 | 297 | $user = get_post_meta($posted_datas['post_ID'], '_order_info', true); |
@@ -300,12 +300,12 @@ discard block |
||
300 | 300 | $first_name = $user['billing']['address']['address_first_name']; |
301 | 301 | $last_name = $user['billing']['address']['address_last_name']; |
302 | 302 | |
303 | - $object = array('object_type'=>'order','object_id'=>(int)$_REQUEST['post_ID']); |
|
303 | + $object = array('object_type'=>'order', 'object_id'=>(int)$_REQUEST['post_ID']); |
|
304 | 304 | /* Envoie du message de confirmation de commande au client */ |
305 | - if ( empty( $order_metadata['order_key'] ) ) { |
|
305 | + if (empty($order_metadata['order_key'])) { |
|
306 | 306 | $wps_message->wpshop_prepared_email($email, |
307 | 307 | 'WPSHOP_QUOTATION_UPDATE_MESSAGE', |
308 | - array( 'order_id' => $object['object_id'], |
|
308 | + array('order_id' => $object['object_id'], |
|
309 | 309 | 'customer_first_name' => $first_name, |
310 | 310 | 'customer_last_name' => $last_name, |
311 | 311 | 'order_date' => current_time('mysql', 0), |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $wps_message->wpshop_prepared_email( |
321 | 321 | $email, |
322 | 322 | 'WPSHOP_ORDER_UPDATE_MESSAGE', |
323 | - array( 'customer_first_name' => $first_name, |
|
323 | + array('customer_first_name' => $first_name, |
|
324 | 324 | 'customer_last_name' => $last_name, |
325 | 325 | 'order_key' => $order_metadata['order_key'], |
326 | 326 | 'order_billing_address' => '', |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | 'order_addresses' => '', |
329 | 329 | 'order_addresses' => '', |
330 | 330 | 'order_billing_address' => '', |
331 | - 'order_shipping_address' => '' ), |
|
331 | + 'order_shipping_address' => ''), |
|
332 | 332 | $object); |
333 | 333 | } |
334 | 334 | } |
@@ -339,25 +339,25 @@ discard block |
||
339 | 339 | * AJAX - Add a private comment to order |
340 | 340 | */ |
341 | 341 | function wpshop_add_private_comment_to_order() { |
342 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
342 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
343 | 343 | |
344 | - if ( !wp_verify_nonce( $_wpnonce, 'wpshop_add_private_comment_to_order' ) ) |
|
344 | + if (!wp_verify_nonce($_wpnonce, 'wpshop_add_private_comment_to_order')) |
|
345 | 345 | wp_die(); |
346 | 346 | |
347 | 347 | $status = false; $result = ''; |
348 | - $order_id = ( ! empty($_POST['oid']) ) ? intval($_POST['oid']) : null; |
|
349 | - $comment = ( ! empty($_POST['comment']) ) ? wpshop_tools::varSanitizer($_POST['comment']) : null; |
|
350 | - $send_email = ( ! empty($_POST['send_email']) ) ? wpshop_tools::varSanitizer($_POST['send_email']) : null; |
|
351 | - $copy_to_administrator = ( ! empty($_POST['copy_to_administrator']) ) ? wpshop_tools::varSanitizer($_POST['copy_to_administrator']) : null; |
|
348 | + $order_id = (!empty($_POST['oid'])) ? intval($_POST['oid']) : null; |
|
349 | + $comment = (!empty($_POST['comment'])) ? wpshop_tools::varSanitizer($_POST['comment']) : null; |
|
350 | + $send_email = (!empty($_POST['send_email'])) ? wpshop_tools::varSanitizer($_POST['send_email']) : null; |
|
351 | + $copy_to_administrator = (!empty($_POST['copy_to_administrator'])) ? wpshop_tools::varSanitizer($_POST['copy_to_administrator']) : null; |
|
352 | 352 | |
353 | - if ( ! empty($comment) && ! empty($order_id) ) { |
|
353 | + if (!empty($comment) && !empty($order_id)) { |
|
354 | 354 | $wps_back_office_orders_mdl = new wps_back_office_orders_mdl(); |
355 | - $new_comment = $wps_back_office_orders_mdl->add_private_comment($order_id, $comment, $send_email, false, $copy_to_administrator ); |
|
356 | - if($new_comment) { |
|
357 | - $order_private_comment = get_post_meta( $order_id, '_order_private_comments', true ); |
|
355 | + $new_comment = $wps_back_office_orders_mdl->add_private_comment($order_id, $comment, $send_email, false, $copy_to_administrator); |
|
356 | + if ($new_comment) { |
|
357 | + $order_private_comment = get_post_meta($order_id, '_order_private_comments', true); |
|
358 | 358 | $oid = $order_id; |
359 | 359 | ob_start(); |
360 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments") ); |
|
360 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "order-private-comments/wps_orders_sended_private_comments")); |
|
361 | 361 | $result = ob_get_contents(); |
362 | 362 | ob_end_clean(); |
363 | 363 | $status = true; |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | $result = __('An error was occured', 'wpshop'); |
368 | 368 | } |
369 | 369 | |
370 | - $response = array( 'status' => $status, 'response' => $result ); |
|
371 | - echo json_encode( $response ); |
|
370 | + $response = array('status' => $status, 'response' => $result); |
|
371 | + echo json_encode($response); |
|
372 | 372 | wp_die(); |
373 | 373 | } |
374 | 374 | |
@@ -376,34 +376,34 @@ discard block |
||
376 | 376 | * AJAX - Refresh product listing in order back-office |
377 | 377 | */ |
378 | 378 | function refresh_product_list() { |
379 | - $_wpnonce = ! empty( $_POST['_wpnonce'] ) ? sanitize_text_field( $_POST['_wpnonce'] ) : ''; |
|
380 | - $letter = ( ! empty($_POST['letter']) ) ? sanitize_title( $_POST['letter'] ) : ''; |
|
381 | - $research = ! empty( $_POST['research'] ) ? sanitize_text_field( $_POST['research'] ) : ''; |
|
379 | + $_wpnonce = !empty($_POST['_wpnonce']) ? sanitize_text_field($_POST['_wpnonce']) : ''; |
|
380 | + $letter = (!empty($_POST['letter'])) ? sanitize_title($_POST['letter']) : ''; |
|
381 | + $research = !empty($_POST['research']) ? sanitize_text_field($_POST['research']) : ''; |
|
382 | 382 | |
383 | - if ( !wp_verify_nonce( $_wpnonce, 'refresh_product_list_'.strtolower($letter) ) ) |
|
383 | + if (!wp_verify_nonce($_wpnonce, 'refresh_product_list_' . strtolower($letter))) |
|
384 | 384 | wp_die(); |
385 | 385 | |
386 | 386 | $status = false; $response = ''; |
387 | - $oid = ! empty( $_POST['oid'] ) ? (int) $_POST['oid'] : 0; |
|
387 | + $oid = !empty($_POST['oid']) ? (int)$_POST['oid'] : 0; |
|
388 | 388 | |
389 | - if( ! empty($oid) ) { |
|
390 | - $post = get_post( $oid ); |
|
389 | + if (!empty($oid)) { |
|
390 | + $post = get_post($oid); |
|
391 | 391 | } |
392 | - if( ! empty($letter) ) { |
|
392 | + if (!empty($letter)) { |
|
393 | 393 | $current_letter = $letter; |
394 | 394 | $wps_product_mdl = new wps_product_mdl(); |
395 | - if( ! empty( $research ) ) { |
|
396 | - $products = $wps_product_mdl->get_products_by_title_or_barcode( $research, strlen( $research ) >= 8 && ctype_digit( $research ) ); |
|
395 | + if (!empty($research)) { |
|
396 | + $products = $wps_product_mdl->get_products_by_title_or_barcode($research, strlen($research) >= 8 && ctype_digit($research)); |
|
397 | 397 | } else { |
398 | - $products = $wps_product_mdl->get_products_by_letter( $letter ); |
|
398 | + $products = $wps_product_mdl->get_products_by_letter($letter); |
|
399 | 399 | } |
400 | 400 | ob_start(); |
401 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table") ); |
|
401 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "backend", "product-listing/wps_orders_product_listing_table")); |
|
402 | 402 | $response = ob_get_contents(); |
403 | 403 | ob_end_clean(); |
404 | 404 | $status = true; |
405 | 405 | } |
406 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
406 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
407 | 407 | wp_die(); |
408 | 408 | } |
409 | 409 | |
@@ -411,38 +411,38 @@ discard block |
||
411 | 411 | * AJAX - Add product to order in back-office panel |
412 | 412 | */ |
413 | 413 | function wps_add_product_to_order_admin() { |
414 | - check_ajax_referer( 'wps_add_product_to_order_admin' ); |
|
414 | + check_ajax_referer('wps_add_product_to_order_admin'); |
|
415 | 415 | |
416 | 416 | $status = false; $response = ''; $product_have_variations = false; |
417 | 417 | // Sended vars |
418 | - $product_id = ( ! empty($_POST['pid']) ) ? intval( $_POST['pid']) : null; |
|
419 | - $order_id = ( ! empty($_POST['oid']) ) ? intval( $_POST['oid']) : null; |
|
420 | - $product_qty = ( ! empty($_POST['qty']) ) ? intval( $_POST['qty']) : 1; |
|
418 | + $product_id = (!empty($_POST['pid'])) ? intval($_POST['pid']) : null; |
|
419 | + $order_id = (!empty($_POST['oid'])) ? intval($_POST['oid']) : null; |
|
420 | + $product_qty = (!empty($_POST['qty'])) ? intval($_POST['qty']) : 1; |
|
421 | 421 | |
422 | - if( ! empty($order_id) && ! empty($product_id) ) { |
|
422 | + if (!empty($order_id) && !empty($product_id)) { |
|
423 | 423 | $wps_orders = new wps_orders_ctr(); |
424 | 424 | $product_datas = wpshop_products::get_product_data($product_id, false, '"publish", "free_product"'); |
425 | 425 | // Check if product have variations |
426 | - $have_variations_checking = wpshop_products::get_variation( $product_id ); |
|
427 | - if( ! empty($have_variations_checking) ) { |
|
426 | + $have_variations_checking = wpshop_products::get_variation($product_id); |
|
427 | + if (!empty($have_variations_checking)) { |
|
428 | 428 | $product_have_variations = true; |
429 | 429 | } |
430 | 430 | else { |
431 | 431 | // Get Metadatas |
432 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
432 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
433 | 433 | // Calcul cart informations |
434 | 434 | $wps_cart = new wps_cart(); |
435 | - $order_metadata = $wps_cart->calcul_cart_information( array( $product_id => array( 'product_id' => $product_id, 'product_qty' => $product_qty ) ), '', $order_metadata, true, false ); |
|
435 | + $order_metadata = $wps_cart->calcul_cart_information(array($product_id => array('product_id' => $product_id, 'product_qty' => $product_qty)), '', $order_metadata, true, false); |
|
436 | 436 | // Update Metadatas |
437 | - update_post_meta( $order_id, '_order_postmeta', $order_metadata ); |
|
437 | + update_post_meta($order_id, '_order_postmeta', $order_metadata); |
|
438 | 438 | $status = true; |
439 | 439 | } |
440 | 440 | $status = true; |
441 | 441 | } |
442 | 442 | |
443 | - $_wpnonce = wp_create_nonce( 'wps_order_load_product_variations' ); |
|
443 | + $_wpnonce = wp_create_nonce('wps_order_load_product_variations'); |
|
444 | 444 | |
445 | - echo json_encode( array( '_wpnonce' => $_wpnonce, 'status' => $status, 'response' => $response, 'variations_exist' => $product_have_variations ) ); |
|
445 | + echo json_encode(array('_wpnonce' => $_wpnonce, 'status' => $status, 'response' => $response, 'variations_exist' => $product_have_variations)); |
|
446 | 446 | wp_die(); |
447 | 447 | } |
448 | 448 | |
@@ -450,15 +450,15 @@ discard block |
||
450 | 450 | * AJAX - Refresh cart in administration |
451 | 451 | */ |
452 | 452 | function refresh_cart_order() { |
453 | - check_ajax_referer( 'wps_reload_cart' ); |
|
453 | + check_ajax_referer('wps_reload_cart'); |
|
454 | 454 | |
455 | 455 | $status = false; $response = ''; |
456 | - $order_id = ( ! empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null; |
|
457 | - if( ! empty($order_id) ) { |
|
458 | - $response = do_shortcode( '[wps_cart oid="' .$order_id. '" cart_type="admin-panel"]'); |
|
456 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
457 | + if (!empty($order_id)) { |
|
458 | + $response = do_shortcode('[wps_cart oid="' . $order_id . '" cart_type="admin-panel"]'); |
|
459 | 459 | $status = true; |
460 | 460 | } |
461 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
461 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
462 | 462 | wp_die(); |
463 | 463 | } |
464 | 464 | |
@@ -466,17 +466,17 @@ discard block |
||
466 | 466 | * AJAX - Refresh cart in administration |
467 | 467 | */ |
468 | 468 | function refresh_payments_order() { |
469 | - check_ajax_referer( 'wps_reload_cart' ); |
|
469 | + check_ajax_referer('wps_reload_cart'); |
|
470 | 470 | $status = false; $response = ''; |
471 | - $order_id = ( ! empty($_POST['order_id']) ) ? intval($_POST['order_id']) : null; |
|
472 | - if( ! empty($order_id) ) { |
|
471 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
472 | + if (!empty($order_id)) { |
|
473 | 473 | ob_start(); |
474 | - echo $this->display_order_payments_box( get_post( $order_id ) ); |
|
474 | + echo $this->display_order_payments_box(get_post($order_id)); |
|
475 | 475 | $response = ob_get_contents(); |
476 | 476 | ob_end_clean(); |
477 | 477 | $status = true; |
478 | 478 | } |
479 | - echo json_encode( array( 'status' => $status, 'response' => $response ) ); |
|
479 | + echo json_encode(array('status' => $status, 'response' => $response)); |
|
480 | 480 | wp_die(); |
481 | 481 | } |
482 | 482 | |
@@ -484,25 +484,25 @@ discard block |
||
484 | 484 | * AJAX - Update product Quantity in Back-office Panel |
485 | 485 | */ |
486 | 486 | function wps_update_product_qty_in_admin() { |
487 | - check_ajax_referer( 'wps_reload_cart' ); |
|
487 | + check_ajax_referer('wps_reload_cart'); |
|
488 | 488 | |
489 | 489 | $status = false; $response = ''; |
490 | - $product_id = ( ! empty($_POST['product_id']) ) ? wpshop_tools::varSanitizer( $_POST['product_id'] ) : null; |
|
491 | - $order_id = ( ! empty($_POST['order_id']) ) ? intval( $_POST['order_id'] ) : null; |
|
492 | - $product_qty = ( ! empty($_POST['qty']) ) ? intval( $_POST['qty'] ) : 0; |
|
490 | + $product_id = (!empty($_POST['product_id'])) ? wpshop_tools::varSanitizer($_POST['product_id']) : null; |
|
491 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : null; |
|
492 | + $product_qty = (!empty($_POST['qty'])) ? intval($_POST['qty']) : 0; |
|
493 | 493 | |
494 | - if( ! empty($product_id) && ! empty($order_id) ) { |
|
494 | + if (!empty($product_id) && !empty($order_id)) { |
|
495 | 495 | // Get Metadatas |
496 | - $order_metadata = get_post_meta( $order_id, '_order_postmeta', true ); |
|
496 | + $order_metadata = get_post_meta($order_id, '_order_postmeta', true); |
|
497 | 497 | // Calcul cart informations |
498 | 498 | $wps_cart = new wps_cart(); |
499 | - $order_metadata = $wps_cart->calcul_cart_information( array( $product_id => array( 'product_id' => $product_id, 'product_qty' => $product_qty ) ), '', $order_metadata, true, false ); |
|
499 | + $order_metadata = $wps_cart->calcul_cart_information(array($product_id => array('product_id' => $product_id, 'product_qty' => $product_qty)), '', $order_metadata, true, false); |
|
500 | 500 | // Update Metadatas |
501 | - update_post_meta( $order_id, '_order_postmeta', $order_metadata ); |
|
501 | + update_post_meta($order_id, '_order_postmeta', $order_metadata); |
|
502 | 502 | $status = true; |
503 | 503 | } |
504 | 504 | |
505 | - echo json_encode( array( 'status' => $status ) ); |
|
505 | + echo json_encode(array('status' => $status)); |
|
506 | 506 | wp_die(); |
507 | 507 | } |
508 | 508 | |
@@ -510,15 +510,15 @@ discard block |
||
510 | 510 | * AJAX - Load Product Variations in ThickBox on Add product to order action |
511 | 511 | */ |
512 | 512 | function wps_order_load_product_variations() { |
513 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
513 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
514 | 514 | |
515 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_order_load_product_variations' ) ) |
|
515 | + if (!wp_verify_nonce($_wpnonce, 'wps_order_load_product_variations')) |
|
516 | 516 | wp_die(); |
517 | 517 | |
518 | - $product_id = ( ! empty($_GET['pid']) ) ? intval( $_GET['pid']) : null; |
|
519 | - $order_id = ( ! empty($_GET['oid']) ) ? intval( $_GET['oid']) : null; |
|
520 | - $qty = ( ! empty($_GET['qty']) ) ? intval( $_GET['qty']) : 1; |
|
521 | - echo '<div class="wps-boxed"><span class="wps-h5">'.__( 'Select your variations', 'wpshop' ).'</span>'.wpshop_products::wpshop_variation($product_id, true, $order_id, $qty ).'<a href="#" class="wps-bton-first-mini-rounded alignRight wps-orders-add_variation_product"><i class="wps-icon-basket"></i> ' .__( 'Add to cart', 'wpshop' ). '</a>'.'</div>'; |
|
518 | + $product_id = (!empty($_GET['pid'])) ? intval($_GET['pid']) : null; |
|
519 | + $order_id = (!empty($_GET['oid'])) ? intval($_GET['oid']) : null; |
|
520 | + $qty = (!empty($_GET['qty'])) ? intval($_GET['qty']) : 1; |
|
521 | + echo '<div class="wps-boxed"><span class="wps-h5">' . __('Select your variations', 'wpshop') . '</span>' . wpshop_products::wpshop_variation($product_id, true, $order_id, $qty) . '<a href="#" class="wps-bton-first-mini-rounded alignRight wps-orders-add_variation_product"><i class="wps-icon-basket"></i> ' . __('Add to cart', 'wpshop') . '</a>' . '</div>'; |
|
522 | 522 | wp_die(); |
523 | 523 | } |
524 | 524 | |
@@ -526,67 +526,67 @@ discard block |
||
526 | 526 | * AJAX - Update cart informations |
527 | 527 | */ |
528 | 528 | function wps_orders_update_cart_informations() { |
529 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
529 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
530 | 530 | |
531 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_orders_update_cart_informations' ) ) |
|
531 | + if (!wp_verify_nonce($_wpnonce, 'wps_orders_update_cart_informations')) |
|
532 | 532 | wp_die(); |
533 | 533 | |
534 | 534 | $status = false; |
535 | - $order_id = ( ! empty($_POST['order_id']) ) ? intval($_POST['order_id']) : ''; |
|
535 | + $order_id = (!empty($_POST['order_id'])) ? intval($_POST['order_id']) : ''; |
|
536 | 536 | $shipping_cost = isset($_POST['shipping_cost']) ? wpshop_tools::varSanitizer($_POST['shipping_cost']) : ''; |
537 | 537 | $discount_value = isset($_POST['discount_amount']) ? wpshop_tools::varSanitizer($_POST['discount_amount']) : ''; |
538 | 538 | $discount_type = isset($_POST['discount_type']) ? wpshop_tools::varSanitizer($_POST['discount_type']) : ''; |
539 | 539 | |
540 | 540 | |
541 | - if( ! empty($order_id) ) { |
|
542 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
541 | + if (!empty($order_id)) { |
|
542 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
543 | 543 | $order_meta['order_shipping_cost'] = $shipping_cost; |
544 | 544 | |
545 | 545 | //Add discounts if exists |
546 | - if( isset($discount_value) && ! empty($discount_type) ) { |
|
546 | + if (isset($discount_value) && !empty($discount_type)) { |
|
547 | 547 | $order_meta['order_discount_type'] = $discount_type; |
548 | 548 | $order_meta['order_discount_value'] = $discount_value; |
549 | 549 | } |
550 | 550 | $wps_cart = new wps_cart(); |
551 | - $order_meta = $wps_cart->calcul_cart_information( array(), '', $order_meta, true ); |
|
552 | - update_post_meta( $order_id, '_order_postmeta', $order_meta ); |
|
551 | + $order_meta = $wps_cart->calcul_cart_information(array(), '', $order_meta, true); |
|
552 | + update_post_meta($order_id, '_order_postmeta', $order_meta); |
|
553 | 553 | $status = true; |
554 | 554 | } |
555 | 555 | |
556 | - echo json_encode( array( 'status' => $status) ); |
|
556 | + echo json_encode(array('status' => $status)); |
|
557 | 557 | wp_die(); |
558 | 558 | } |
559 | 559 | |
560 | 560 | function wps_reverify_payment_invoice_ref() { |
561 | - $_wpnonce = ! empty( $_REQUEST['_wpnonce'] ) ? sanitize_text_field( $_REQUEST['_wpnonce'] ) : ''; |
|
561 | + $_wpnonce = !empty($_REQUEST['_wpnonce']) ? sanitize_text_field($_REQUEST['_wpnonce']) : ''; |
|
562 | 562 | |
563 | - if ( !wp_verify_nonce( $_wpnonce, 'wps_reverify_payment_invoice_ref' ) ) |
|
563 | + if (!wp_verify_nonce($_wpnonce, 'wps_reverify_payment_invoice_ref')) |
|
564 | 564 | wp_die(); |
565 | 565 | |
566 | 566 | $status = true; |
567 | - $inputs = ! empty( $_POST['inputs'] ) ? (array) $_POST['inputs'] : false; |
|
567 | + $inputs = !empty($_POST['inputs']) ? (array)$_POST['inputs'] : false; |
|
568 | 568 | |
569 | 569 | if (!$inputs) |
570 | 570 | $status = false; |
571 | 571 | |
572 | - if( $status ) { |
|
572 | + if ($status) { |
|
573 | 573 | $inputs_clone = $inputs; |
574 | 574 | $inputs = array(); |
575 | - foreach( $inputs_clone as $var ) { |
|
576 | - if( isset( $var['key'] ) && isset( $var['value'] ) ) { |
|
575 | + foreach ($inputs_clone as $var) { |
|
576 | + if (isset($var['key']) && isset($var['value'])) { |
|
577 | 577 | $inputs[$var['key']] = $var['value']; |
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
581 | - ( isset( $inputs['order_id'] ) ) ? $order_id = $inputs['order_id'] : $status = $order_id = false; |
|
582 | - ( isset( $inputs['index_payment'] ) ) ? $index_payment = $inputs['index_payment'] : $status = $index_payment = false; |
|
581 | + (isset($inputs['order_id'])) ? $order_id = $inputs['order_id'] : $status = $order_id = false; |
|
582 | + (isset($inputs['index_payment'])) ? $index_payment = $inputs['index_payment'] : $status = $index_payment = false; |
|
583 | 583 | } |
584 | 584 | |
585 | - if( $status ) { |
|
586 | - $status = wpshop_payment::reverify_payment_invoice_ref( $order_id, $index_payment ); |
|
585 | + if ($status) { |
|
586 | + $status = wpshop_payment::reverify_payment_invoice_ref($order_id, $index_payment); |
|
587 | 587 | } |
588 | 588 | |
589 | - echo json_encode( array( 'status' => $status ) ); |
|
589 | + echo json_encode(array('status' => $status)); |
|
590 | 590 | wp_die(); |
591 | 591 | } |
592 | 592 |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | if ( !empty($orders) ) : |
3 | 5 | $permalink_option = get_option( 'permalink_structure' ); |
4 | 6 | $account_page_id = get_option('wpshop_myaccount_page_id'); |
@@ -25,8 +27,11 @@ discard block |
||
25 | 27 | require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "frontend", "order_row_in_account") ); |
26 | 28 | } ?> |
27 | 29 | </div> |
28 | -<?php else : ?> |
|
29 | -<div class="wps-alert-info"><?php _e( 'No order have been created for the moment', 'wpshop'); ?></div> |
|
30 | +<?php else { |
|
31 | + : ?> |
|
32 | +<div class="wps-alert-info"><?php _e( 'No order have been created for the moment', 'wpshop'); |
|
33 | +} |
|
34 | +?></div> |
|
30 | 35 | <?php endif; ?> |
31 | 36 | |
32 | 37 |
@@ -1,28 +1,28 @@ |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | -if ( !empty($orders) ) : |
|
3 | - $permalink_option = get_option( 'permalink_structure' ); |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | +if (!empty($orders)) : |
|
3 | + $permalink_option = get_option('permalink_structure'); |
|
4 | 4 | $account_page_id = get_option('wpshop_myaccount_page_id'); |
5 | 5 | ?> |
6 | -<?php if ( ! is_admin() ): ?> |
|
7 | -<span class="wps-h5"><?php _e( 'My last orders', 'wpshop'); ?></span> |
|
6 | +<?php if (!is_admin()): ?> |
|
7 | +<span class="wps-h5"><?php _e('My last orders', 'wpshop'); ?></span> |
|
8 | 8 | <?php endif; ?> |
9 | 9 | |
10 | 10 | <div class="wps-table"> |
11 | 11 | <div class="wps-table-header wps-table-row"> |
12 | - <div class="wps-table-cell"><?php _e( 'Date', 'wpshop'); ?></div> |
|
13 | - <div class="wps-table-cell"><?php _e( 'Reference', 'wpshop'); ?></div> |
|
14 | - <div class="wps-table-cell"><?php _e( 'Total', 'wpshop'); ?></div> |
|
15 | - <div class="wps-table-cell"><?php _e( 'Status', 'wpshop'); ?></div> |
|
16 | - <?php if ( true === $shipping_addresses_activated ) : ?><div class="wps-table-cell"><?php _e( 'Tracking number', 'wpshop'); ?></div><?php endif; ?> |
|
17 | - <div class="wps-table-cell"><?php _e( 'Actions', 'wpshop'); ?></div> |
|
12 | + <div class="wps-table-cell"><?php _e('Date', 'wpshop'); ?></div> |
|
13 | + <div class="wps-table-cell"><?php _e('Reference', 'wpshop'); ?></div> |
|
14 | + <div class="wps-table-cell"><?php _e('Total', 'wpshop'); ?></div> |
|
15 | + <div class="wps-table-cell"><?php _e('Status', 'wpshop'); ?></div> |
|
16 | + <?php if (true === $shipping_addresses_activated) : ?><div class="wps-table-cell"><?php _e('Tracking number', 'wpshop'); ?></div><?php endif; ?> |
|
17 | + <div class="wps-table-cell"><?php _e('Actions', 'wpshop'); ?></div> |
|
18 | 18 | </div> |
19 | 19 | <?php |
20 | - foreach( $orders as $order ) { |
|
20 | + foreach ($orders as $order) { |
|
21 | 21 | $order_id = $order->ID; |
22 | - $order_meta = get_post_meta( $order_id, '_order_postmeta', true ); |
|
23 | - require( wpshop_tools::get_template_part( WPS_ORDERS_DIR, $this->template_dir, "frontend", "order_row_in_account") ); |
|
22 | + $order_meta = get_post_meta($order_id, '_order_postmeta', true); |
|
23 | + require(wpshop_tools::get_template_part(WPS_ORDERS_DIR, $this->template_dir, "frontend", "order_row_in_account")); |
|
24 | 24 | } ?> |
25 | 25 | </div> |
26 | 26 | <?php else : ?> |
27 | -<div class="wps-alert-info"><?php _e( 'No order have been created for the moment', 'wpshop'); ?></div> |
|
27 | +<div class="wps-alert-info"><?php _e('No order have been created for the moment', 'wpshop'); ?></div> |
|
28 | 28 | <?php endif; ?> |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
2 | -if( !empty($order_metadata) ) : |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | +if (!empty($order_metadata)) : |
|
3 | 3 | ?> |
4 | 4 | <div class="wps-gridwrapper3-padded"> |
5 | 5 | <div> |
@@ -9,13 +9,13 @@ discard block |
||
9 | 9 | |
10 | 10 | <div> |
11 | 11 | <div class="wps-boxed summary_shipping_boxed"> |
12 | - <div class="wps-h5"><?php _e( 'Billing address', 'wpshop')?></div> |
|
12 | + <div class="wps-h5"><?php _e('Billing address', 'wpshop')?></div> |
|
13 | 13 | <?php |
14 | - if( !empty($billing_address_content) ) : |
|
14 | + if (!empty($billing_address_content)) : |
|
15 | 15 | echo $billing_address_content; |
16 | 16 | else : |
17 | 17 | ?> |
18 | - <div class="wps-alert-error"><?php _e( 'No billing address informations are found', 'wpshop'); ?></div> |
|
18 | + <div class="wps-alert-error"><?php _e('No billing address informations are found', 'wpshop'); ?></div> |
|
19 | 19 | <?php |
20 | 20 | endif; |
21 | 21 | ?> |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | </div> |
24 | 24 | <div> |
25 | 25 | <div class="wps-boxed summary_shipping_boxed"> |
26 | - <div class="wps-h5"><?php _e( 'Shipping address', 'wpshop')?></div> |
|
26 | + <div class="wps-h5"><?php _e('Shipping address', 'wpshop')?></div> |
|
27 | 27 | <?php |
28 | - if( !empty($shipping_address_content) ) : |
|
28 | + if (!empty($shipping_address_content)) : |
|
29 | 29 | echo $shipping_address_content; |
30 | 30 | else : |
31 | 31 | ?> |
32 | - <div class="wps-alert-error"><?php _e( 'No shipping address informations are found', 'wpshop'); ?></div> |
|
32 | + <div class="wps-alert-error"><?php _e('No shipping address informations are found', 'wpshop'); ?></div> |
|
33 | 33 | <?php |
34 | 34 | endif; |
35 | 35 | ?> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | <?php |
42 | 42 | else : |
43 | 43 | ?> |
44 | -<div class="wps-alert-info"><?php _e( 'Please choose a customer or create one', 'wpshop'); ?></div> |
|
44 | +<div class="wps-alert-info"><?php _e('Please choose a customer or create one', 'wpshop'); ?></div> |
|
45 | 45 | <?php |
46 | 46 | endif; |
47 | 47 | ?> |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | if( !empty($order_metadata) ) : |
3 | 5 | ?> |
4 | 6 | <div class="wps-gridwrapper3-padded"> |
@@ -13,9 +15,12 @@ discard block |
||
13 | 15 | <?php |
14 | 16 | if( !empty($billing_address_content) ) : |
15 | 17 | echo $billing_address_content; |
16 | - else : |
|
18 | + else { |
|
19 | + : |
|
17 | 20 | ?> |
18 | - <div class="wps-alert-error"><?php _e( 'No billing address informations are found', 'wpshop'); ?></div> |
|
21 | + <div class="wps-alert-error"><?php _e( 'No billing address informations are found', 'wpshop'); |
|
22 | + } |
|
23 | + ?></div> |
|
19 | 24 | <?php |
20 | 25 | endif; |
21 | 26 | ?> |
@@ -27,9 +32,12 @@ discard block |
||
27 | 32 | <?php |
28 | 33 | if( !empty($shipping_address_content) ) : |
29 | 34 | echo $shipping_address_content; |
30 | - else : |
|
35 | + else { |
|
36 | + : |
|
31 | 37 | ?> |
32 | - <div class="wps-alert-error"><?php _e( 'No shipping address informations are found', 'wpshop'); ?></div> |
|
38 | + <div class="wps-alert-error"><?php _e( 'No shipping address informations are found', 'wpshop'); |
|
39 | + } |
|
40 | + ?></div> |
|
33 | 41 | <?php |
34 | 42 | endif; |
35 | 43 | ?> |
@@ -39,9 +47,12 @@ discard block |
||
39 | 47 | </div> |
40 | 48 | |
41 | 49 | <?php |
42 | -else : |
|
50 | +else { |
|
51 | + : |
|
43 | 52 | ?> |
44 | -<div class="wps-alert-info"><?php _e( 'Please choose a customer or create one', 'wpshop'); ?></div> |
|
53 | +<div class="wps-alert-info"><?php _e( 'Please choose a customer or create one', 'wpshop'); |
|
54 | +} |
|
55 | +?></div> |
|
45 | 56 | <?php |
46 | 57 | endif; |
47 | 58 | ?> |