AdhanProcessor.php
1 year ago
CsvProcessor.php
2 months ago
DebugProcessor.php
1 year ago
DigitalScreenProcessor.php
1 month ago
HijriProcessor.php
3 years ago
LanguageProcessor.php
4 years ago
OtherProcessor.php
2 months ago
QuickUpdateProcessor.php
3 years ago
StartTimeProcessor.php
1 year ago
ThemeSettingsProcessor.php
1 year ago
DebugProcessor.php
61 lines
| 1 | <?php |
| 2 | if ( ! class_exists('DPTDebugProcessor')) { |
| 3 | class DPTDebugProcessor |
| 4 | { |
| 5 | /** |
| 6 | * @var array |
| 7 | */ |
| 8 | private $data; |
| 9 | |
| 10 | /** @var string */ |
| 11 | private $filePath = ''; |
| 12 | |
| 13 | /** @var Resource */ |
| 14 | private $fp = null; |
| 15 | |
| 16 | /** @var bool */ |
| 17 | private $isDebug = false; |
| 18 | |
| 19 | /** |
| 20 | * @param array $data |
| 21 | */ |
| 22 | public function __construct(array $data=null) { |
| 23 | $this->data = $data; |
| 24 | // $this->filePath = plugin_dir_path(__FILE__) . '../../Assets/debug.csv'; |
| 25 | $this->filePath = fopen('php://memory', 'rw+'); |
| 26 | |
| 27 | if ($this->fp == null) { |
| 28 | // $this->fp = fopen($this->filePath, 'a'); |
| 29 | $this->fp = $this->filePath; |
| 30 | } |
| 31 | |
| 32 | $this->isDebug = get_option('debugActivated'); |
| 33 | } |
| 34 | |
| 35 | public function process() |
| 36 | { |
| 37 | $activateDebug = sanitize_text_field($this->data['debugLog']); |
| 38 | delete_option('debugActivated'); |
| 39 | add_option('debugActivated', $activateDebug); |
| 40 | } |
| 41 | |
| 42 | public function log($data) |
| 43 | { |
| 44 | $data = date("Y-m-d H:i:s ") . $data . PHP_EOL; |
| 45 | if (!empty($this->isDebug)) { |
| 46 | fwrite($this->fp, $data); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | public function getFilePath() |
| 51 | { |
| 52 | return $this->filePath; |
| 53 | } |
| 54 | |
| 55 | public function resetLog() |
| 56 | { |
| 57 | $this->fp = fopen($this->filePath, 'w'); |
| 58 | fwrite($this->fp, 'starting Log: ' . date("Y-m-d H:i:s ") . "\n"); |
| 59 | } |
| 60 | } |
| 61 | } |