PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.15.0
Import WP – CSV & XML Import Export for WordPress v2.15.0
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.15.0, at class/Common/Properties/Properties.php

122 lines 3.3 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 #[\AllowDynamicProperties]
8 class Properties
9 {
10 use Singleton;
11
12 public $plugin_dir_path;
13 public $plugin_folder_name;
14 public $plugin_basename;
15 public $view_dir;
16 public $plugin_domain;
17 public $plugin_version;
18 public $plugin_file_path;
19 public $encodings;
20 public $chunk_timeout;
21 public $chunk_limit;
22 public $chunk_size;
23 public $file_rotation;
24 public $log_rotation;
25 public $timeout;
26 public $is_pro;
27
28 public $mu_plugin_version;
29 public $mu_plugin_dir;
30 public $mu_plugin_source;
31 public $mu_plugin_dest;
32
33 public $rest_version;
34 public $rest_namespace;
35
36 public function __construct()
37 {
38 $this->plugin_file_path = realpath(dirname(__DIR__) . '/../../jc-importer.php');
39 $this->plugin_dir_path = plugin_dir_path($this->plugin_file_path);
40 $this->plugin_folder_name = basename($this->plugin_dir_path);
41 $this->plugin_basename = plugin_basename($this->plugin_file_path);
42 $this->plugin_domain = 'importwp';
43 $this->plugin_version = IWP_VERSION;
44 $this->is_pro = false;
45 $this->encodings = $this->get_available_encodings();
46
47 $this->view_dir = $this->plugin_dir_path . trailingslashit('views');
48
49 $this->rest_namespace = 'iwp';
50 $this->rest_version = 'v1';
51
52 $this->file_rotation = intval(apply_filters('iwp/file_rotation', $this->get_setting('file_rotation')));
53 $this->log_rotation = intval(apply_filters('iwp/log_rotation', $this->get_setting('log_rotation')));
54 $this->timeout = intval(apply_filters('iwp/timeout', $this->get_setting('timeout')));
55 }
56
57 protected function get_available_encodings()
58 {
59 $output = [];
60
61 if (function_exists('mb_list_encodings')) {
62 $encodings = mb_list_encodings();
63 foreach ($encodings as $encoding) {
64 $output[$encoding] = $encoding;
65 }
66 }
67
68 return $output;
69 }
70
71 public function _default_settings()
72 {
73 return [
74 'debug' => [
75 'type' => 'bool',
76 'value' => false,
77 ],
78 'cleanup' => [
79 'type' => 'bool',
80 'value' => false
81 ],
82 'file_rotation' => [
83 'type' => 'number',
84 'value' => 5
85 ],
86 'log_rotation' => [
87 'type' => 'number',
88 'value' => -1
89 ],
90 'timeout' => [
91 'type' => 'number',
92 'value' => 30
93 ],
94 ];
95 }
96
97 public function get_settings()
98 {
99 $defaults = $this->_default_settings();
100 $settings = get_option('iwp_settings', []);
101 $output = [];
102
103 foreach ($defaults as $setting => $default) {
104 $output[$setting] = isset($settings[$setting]) ? $settings[$setting] : $default['value'];
105 }
106
107 return $output;
108 }
109
110 public function get_setting($key)
111 {
112 $defaults = $this->_default_settings();
113 $settings = get_option('iwp_settings', []);
114
115 if (!isset($defaults[$key])) {
116 return false;
117 }
118
119 return isset($settings[$key]) ? $settings[$key] : $defaults[$key]['value'];
120 }
121 }
122