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
LanguageProcessor.php
81 lines
| 1 | <?php |
| 2 | if ( !class_exists('DPTLanguageProcessor')) { |
| 3 | class DPTLanguageProcessor |
| 4 | { |
| 5 | /** |
| 6 | * @var array |
| 7 | */ |
| 8 | private $data; |
| 9 | |
| 10 | /** |
| 11 | * @param array $data |
| 12 | */ |
| 13 | public function __construct(array $data) { |
| 14 | $this->data = $data; |
| 15 | } |
| 16 | |
| 17 | public function process() |
| 18 | { |
| 19 | if (! empty($this->data['prayersLocal'])) { |
| 20 | $prayersLocal = $this->data['prayersLocal']; |
| 21 | if (is_array($prayersLocal)) { |
| 22 | $prayersLocal = array_map( 'sanitize_text_field', $prayersLocal ); |
| 23 | $prayersLocal = array_map( array($this, 'cleanInput'), $prayersLocal ); |
| 24 | } |
| 25 | |
| 26 | delete_option('prayersLocal'); |
| 27 | add_option('prayersLocal', $prayersLocal); |
| 28 | } |
| 29 | |
| 30 | if (! empty($this->data['headersLocal'])) { |
| 31 | $headersLocal = $this->data['headersLocal']; |
| 32 | if (is_array($headersLocal)) { |
| 33 | $headersLocal = array_map( 'sanitize_text_field', $headersLocal ); |
| 34 | $headersLocal = array_map( array($this, 'cleanInput'), $headersLocal ); |
| 35 | } |
| 36 | |
| 37 | delete_option('headersLocal'); |
| 38 | add_option('headersLocal', $headersLocal); |
| 39 | } |
| 40 | |
| 41 | if (! empty($this->data['monthsLocal'])) { |
| 42 | $monthsLocal = $this->data['monthsLocal']; |
| 43 | if (is_array($monthsLocal)) { |
| 44 | $monthsLocal = array_map( 'sanitize_text_field', $monthsLocal ); |
| 45 | $monthsLocal = array_map( array($this, 'cleanInput'), $monthsLocal ); |
| 46 | } |
| 47 | |
| 48 | delete_option('monthsLocal'); |
| 49 | add_option('monthsLocal', $monthsLocal); |
| 50 | } |
| 51 | |
| 52 | if ( ! empty($this->data['numbersLocal'])) { |
| 53 | $numbersLocal = $this->data['numbersLocal']; |
| 54 | if (is_array($numbersLocal)) { |
| 55 | $numbersLocal = array_map( 'sanitize_text_field', $numbersLocal ); |
| 56 | $numbersLocal = array_map( array($this, 'cleanInput'), $numbersLocal ); |
| 57 | } |
| 58 | |
| 59 | delete_option('numbersLocal'); |
| 60 | add_option('numbersLocal', $numbersLocal); |
| 61 | } |
| 62 | |
| 63 | if ( ! empty($this->data['timesLocal'])) { |
| 64 | $timesLocal = $this->data['timesLocal']; |
| 65 | if (is_array($timesLocal)) { |
| 66 | $timesLocal = array_map( 'sanitize_text_field', $timesLocal ); |
| 67 | $timesLocal = array_map( array($this, 'cleanInput'), $timesLocal ); |
| 68 | } |
| 69 | |
| 70 | delete_option('timesLocal'); |
| 71 | add_option('timesLocal', $timesLocal); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | private function cleanInput($localeData) { |
| 76 | return preg_replace('/[\W] .-/', '', $localeData); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | } |
| 81 |