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

112 lines 3.1 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 public $is_pro;
26
27 public $rest_version;
28 public $rest_namespace;
29
30 public function __construct()
31 {
32 $this->plugin_file_path = realpath(dirname(__DIR__) . '/../../jc-importer.php');
33 $this->plugin_dir_path = plugin_dir_path($this->plugin_file_path);
34 $this->plugin_folder_name = basename($this->plugin_dir_path);
35 $this->plugin_basename = plugin_basename($this->plugin_file_path);
36 $this->plugin_domain = 'importwp';
37 $this->plugin_version = IWP_VERSION;
38 $this->is_pro = false;
39 $this->encodings = $this->get_available_encodings();
40
41 $this->view_dir = $this->plugin_dir_path . trailingslashit('views');
42
43 $this->rest_namespace = 'iwp';
44 $this->rest_version = 'v1';
45
46 $this->file_rotation = intval(apply_filters('iwp/file_rotation', $this->get_setting('file_rotation')));
47 $this->log_rotation = intval(apply_filters('iwp/log_rotation', $this->get_setting('log_rotation')));
48 $this->timeout = intval(apply_filters('iwp/timeout', $this->get_setting('timeout')));
49 }
50
51 protected function get_available_encodings()
52 {
53 $encodings = mb_list_encodings();
54 $output = [];
55 foreach ($encodings as $encoding) {
56 $output[$encoding] = $encoding;
57 }
58 return $output;
59 }
60
61 public function _default_settings()
62 {
63 return [
64 'debug' => [
65 'type' => 'bool',
66 'value' => false,
67 ],
68 'cleanup' => [
69 'type' => 'bool',
70 'value' => false
71 ],
72 'file_rotation' => [
73 'type' => 'number',
74 'value' => 5
75 ],
76 'log_rotation' => [
77 'type' => 'number',
78 'value' => -1
79 ],
80 'timeout' => [
81 'type' => 'number',
82 'value' => 30
83 ],
84 ];
85 }
86
87 public function get_settings()
88 {
89 $defaults = $this->_default_settings();
90 $settings = get_site_option('iwp_settings', []);
91 $output = [];
92
93 foreach ($defaults as $setting => $default) {
94 $output[$setting] = isset($settings[$setting]) ? $settings[$setting] : $default['value'];
95 }
96
97 return $output;
98 }
99
100 public function get_setting($key)
101 {
102 $defaults = $this->_default_settings();
103 $settings = get_site_option('iwp_settings', []);
104
105 if (!isset($defaults[$key])) {
106 return false;
107 }
108
109 return isset($settings[$key]) ? $settings[$key] : $defaults[$key]['value'];
110 }
111 }
112