PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 7.0.0
WP Popular Posts v7.0.0
4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 5.0.0 5.0.1 5.0.2 5.1.0 5.2.0 5.2.1 5.2.2 5.2.3 5.2.4 5.3.0 5.3.1 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.4.0 5.4.1 5.4.2 5.5.0 5.5.1 6.0.0 6.0.1 6.0.2 6.0.3 6.0.4 6.0.5 6.1.0 6.1.1 6.1.2 6.1.3 6.1.4 6.2.0 6.2.1 6.3.0 6.3.1 6.3.2 6.3.3 6.3.4 6.4.0 6.4.1 6.4.2 7.0.0 7.0.1 7.1.0 7.2.0 7.3.0 7.3.1 7.3.2 7.3.3 7.3.4 7.3.5 7.3.6 7.3.7 7.3.8 7.4.0 trunk 2.3.7 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.5 4.0.6
wordpress-popular-posts / src / Settings.php
wordpress-popular-posts / src Last commit date
Activation 2 years ago Admin 2 years ago Block 2 years ago Container 2 years ago Front 2 years ago Rest 2 years ago Shortcode 2 years ago Traits 2 years ago Widget 2 years ago Bootstrap.php 2 years ago Cache.php 2 years ago Helper.php 2 years ago I18N.php 2 years ago Image.php 2 years ago Output.php 2 years ago Query.php 2 years ago Settings.php 2 years ago Themer.php 2 years ago Translate.php 2 years ago WordPressPopularPosts.php 2 years ago deprecated.php 2 years ago template-tags.php 2 years ago
Settings.php
171 lines
1 <?php
2 /**
3 * Set / get plugin default options.
4 *
5 * @link http://cabrerahector.com
6 * @since 4.0.0
7 *
8 * @package WordPressPopularPosts
9 */
10
11 /**
12 * Set / get plugin default options.
13 *
14 * @package WordPressPopularPosts
15 * @author Hector Cabrera <me@cabrerahector.com>
16 */
17
18 namespace WordPressPopularPosts;
19
20 class Settings {
21
22 /**
23 * Plugin uploads directory.
24 *
25 * @since 3.0.4
26 * @var array
27 */
28 private static $defaults = [
29 'widget_options' => [
30 'title' => '',
31 'limit' => 10,
32 'offset' => 0,
33 'range' => 'daily',
34 'time_unit' => 'hour',
35 'time_quantity' => 24,
36 'freshness' => false,
37 'order_by' => 'views',
38 'post_type' => 'post',
39 'pid' => '',
40 'author' => '',
41 'cat' => '',
42 'taxonomy' => 'category',
43 'term_id' => '',
44 'shorten_title' => [
45 'active' => false,
46 'length' => 25,
47 'words' => false
48 ],
49 'post-excerpt' => [
50 'active' => false,
51 'length' => 55,
52 'keep_format' => false,
53 'words' => false
54 ],
55 'thumbnail' => [
56 'active' => false,
57 'build' => 'manual',
58 'width' => 75,
59 'height' => 75,
60 'crop' => true
61 ],
62 'rating' => false,
63 'stats_tag' => [
64 'comment_count' => false,
65 'views' => true,
66 'author' => false,
67 'date' => [
68 'active' => false,
69 'format' => 'F j, Y'
70 ],
71 'category' => false,
72 'taxonomy' => [
73 'active' => false,
74 'name' => 'category'
75 ]
76 ],
77 'markup' => [
78 'custom_html' => false,
79 'title-start' => '<h2>',
80 'title-end' => '</h2>',
81 'wpp-start' => '<ul class="wpp-list">',
82 'wpp-end' => '</ul>',
83 'post-html' => '<li>{thumb} {title} <span class="wpp-meta post-stats">{stats}</span></li>'
84 ],
85 'theme' => [
86 'name' => '',
87 'applied' => false
88 ]
89 ],
90 'admin_options' => [
91 'stats' => [
92 'range' => 'last7days',
93 'time_unit' => 'hour',
94 'time_quantity' => 24,
95 'order_by' => 'views',
96 'limit' => 10,
97 'post_type' => 'post',
98 'freshness' => false
99 ],
100 'tools' => [
101 'experimental' => false,
102 'ajax' => true,
103 'css' => true,
104 'link' => [
105 'target' => '_self'
106 ],
107 'thumbnail' => [
108 'source' => 'featured',
109 'format' => 'original',
110 'field' => '',
111 'resize' => false,
112 'default' => '',
113 'lazyload' => true
114 ],
115 'log' => [
116 'level' => 1,
117 'limit' => 0,
118 'expires_after' => 180
119 ],
120 'cache' => [
121 'active' => true,
122 'interval' => [
123 'time' => 'minute',
124 'value' => 1
125 ]
126 ],
127 'sampling' => [
128 'active' => false,
129 'rate' => 100
130 ]
131 ]
132 ]
133 ];
134
135 /**
136 * Returns plugin options.
137 *
138 * @since 4.0.0
139 * @access public
140 * @param string $option_set
141 * @return array
142 */
143 public static function get(string $option_set = '')
144 {
145 $options = self::$defaults;
146
147 if ( 'widget_options' == $option_set ) {
148 return $options['widget_options'];
149 }
150
151 $admin_options = get_option('wpp_settings_config');
152
153 if ( ! $admin_options ) {
154 $admin_options = $options['admin_options'];
155 add_option('wpp_settings_config', $admin_options);
156 }
157 else {
158 $options['admin_options'] = Helper::merge_array_r(
159 $options['admin_options'],
160 (array) $admin_options
161 );
162 }
163
164 if ( 'admin_options' == $option_set ) {
165 return $options['admin_options'];
166 }
167
168 return $options;
169 }
170 }
171