PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.7.12
Import WP – CSV & XML Import Export for WordPress v2.7.12
2.15.1 2.15.0 2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 All 144 releases
jc-importer / class / Common / Properties / Properties.php

Properties.php in Import WP – CSV & XML Import Export for WordPress 2.7.12, at class/Common/Properties/Properties.php

111 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImportWP\Common\Properties;
4
5 use ImportWP\Common\Util\Singleton;
6
7 class Properties
8 {
9 use Singleton;
10
11 public $plugin_dir_path;
12 public $plugin_folder_name;
13 public $plugin_basename;
14 public $view_dir;
15 public $plugin_domain;
16 public $plugin_version;
17 public $plugin_file_path;
18 public $encodings;
19 public $chunk_timeout;
20 public $chunk_limit;
21 public $chunk_size;
22 public $file_rotation;
23 public $log_rotation;
24 public $timeout;
25
26 public $rest_version;
27 public $rest_namespace;
28
29 public function __construct()
30 {
31 $this->plugin_file_path = realpath(dirname(__DIR__) . '/../../jc-importer.php');
32 $this->plugin_dir_path = plugin_dir_path($this->plugin_file_path);
33 $this->plugin_folder_name = basename($this->plugin_dir_path);
34 $this->plugin_basename = plugin_basename($this->plugin_file_path);
35 $this->plugin_domain = 'importwp';
36 $this->plugin_version = IWP_VERSION;
37 $this->is_pro = false;
38 $this->encodings = $this->get_available_encodings();
39
40 $this->view_dir = $this->plugin_dir_path . trailingslashit('views');
41
42 $this->rest_namespace = 'iwp';
43 $this->rest_version = 'v1';
44
45 $this->file_rotation = intval(apply_filters('iwp/file_rotation', $this->get_setting('file_rotation')));
46 $this->log_rotation = intval(apply_filters('iwp/log_rotation', $this->get_setting('log_rotation')));
47 $this->timeout = intval(apply_filters('iwp/timeout', $this->get_setting('timeout')));
48 }
49
50 protected function get_available_encodings()
51 {
52 $encodings = mb_list_encodings();
53 $output = [];
54 foreach ($encodings as $encoding) {
55 $output[$encoding] = $encoding;
56 }
57 return $output;
58 }
59
60 public function _default_settings()
61 {
62 return [
63 'debug' => [
64 'type' => 'bool',
65 'value' => false,
66 ],
67 'cleanup' => [
68 'type' => 'bool',
69 'value' => false
70 ],
71 'file_rotation' => [
72 'type' => 'number',
73 'value' => 5
74 ],
75 'log_rotation' => [
76 'type' => 'number',
77 'value' => -1
78 ],
79 'timeout' => [
80 'type' => 'number',
81 'value' => 30
82 ],
83 ];
84 }
85
86 public function get_settings()
87 {
88 $defaults = $this->_default_settings();
89 $settings = get_site_option('iwp_settings', []);
90 $output = [];
91
92 foreach ($defaults as $setting => $default) {
93 $output[$setting] = isset($settings[$setting]) ? $settings[$setting] : $default['value'];
94 }
95
96 return $output;
97 }
98
99 public function get_setting($key)
100 {
101 $defaults = $this->_default_settings();
102 $settings = get_site_option('iwp_settings', []);
103
104 if (!isset($defaults[$key])) {
105 return false;
106 }
107
108 return isset($settings[$key]) ? $settings[$key] : $defaults[$key]['value'];
109 }
110 }
111