PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 7.4.0
WP Popular Posts v7.4.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 8 months ago Admin 3 weeks ago Block 3 weeks ago Compatibility 8 months ago Container 8 months ago Front 1 year ago Rest 8 months ago Shortcode 1 year ago Traits 4 years ago Widget 3 weeks ago Bootstrap.php 5 years ago Cache.php 8 months ago Helper.php 3 weeks ago I18N.php 5 years ago Image.php 8 months ago Output.php 3 weeks ago Query.php 3 weeks ago Settings.php 3 weeks ago Themer.php 8 months ago Translate.php 3 years ago Upgrader.php 8 months ago WordPressPopularPosts.php 8 months ago deprecated.php 4 years ago template-tags.php 3 weeks ago
Settings.php
176 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' => '', /* Deprecated */
40 'exclude' => '',
41 'author' => '',
42 'cat' => '',
43 'taxonomy' => 'category',
44 'term_id' => '',
45 'shorten_title' => [
46 'active' => false,
47 'length' => 25,
48 'words' => false
49 ],
50 'post-excerpt' => [
51 'active' => false,
52 'length' => 55,
53 'keep_format' => false,
54 'words' => false
55 ],
56 'thumbnail' => [
57 'active' => false,
58 'build' => 'manual',
59 'width' => 75,
60 'height' => 75,
61 'crop' => true
62 ],
63 'rating' => false,
64 'stats_tag' => [
65 'comment_count' => false,
66 'views' => true,
67 'author' => false,
68 'date' => [
69 'active' => false,
70 'format' => 'F j, Y'
71 ],
72 'category' => false,
73 'taxonomy' => [
74 'active' => false,
75 'name' => 'category'
76 ]
77 ],
78 'markup' => [
79 'custom_html' => false,
80 'title-start' => '<h2>',
81 'title-end' => '</h2>',
82 'wpp-start' => '<ul class="wpp-list">',
83 'wpp-end' => '</ul>',
84 'post-html' => '<li class="{current_class}">{thumb} {title} <span class="wpp-meta post-stats">{stats}</span></li>'
85 ],
86 'theme' => [
87 'name' => '',
88 'applied' => false
89 ]
90 ],
91 'admin_options' => [
92 'stats' => [
93 'range' => 'last7days',
94 'time_unit' => 'hour',
95 'time_quantity' => 24,
96 'order_by' => 'views',
97 'limit' => 10,
98 'post_type' => 'post',
99 'freshness' => false,
100 'y_scale' => false
101 ],
102 'tools' => [
103 'ajax' => true,
104 'css' => true,
105 'link' => [
106 'target' => '_self'
107 ],
108 'thumbnail' => [
109 'source' => 'featured',
110 'format' => 'original',
111 'field' => '',
112 'resize' => false,
113 'default' => '',
114 'lazyload' => true
115 ],
116 'log' => [
117 'level' => 1,
118 'limit' => 1,
119 'expires_after' => 180
120 ],
121 'cache' => [
122 'active' => true,
123 'interval' => [
124 'time' => 'minute',
125 'value' => 1
126 ]
127 ],
128 'sampling' => [
129 'active' => false,
130 'rate' => 100
131 ],
132 'views_column' => [
133 'active' => false,
134 'post_types' => 'post'
135 ]
136 ]
137 ]
138 ];
139
140 /**
141 * Returns plugin options.
142 *
143 * @since 4.0.0
144 * @access public
145 * @param string $option_set
146 * @return array
147 */
148 public static function get(string $option_set = '')
149 {
150 $options = self::$defaults;
151
152 if ( 'widget_options' == $option_set ) {
153 return $options['widget_options'];
154 }
155
156 $admin_options = get_option('wpp_settings_config');
157
158 if ( ! $admin_options ) {
159 $admin_options = $options['admin_options'];
160 add_option('wpp_settings_config', $admin_options);
161 }
162 else {
163 $options['admin_options'] = Helper::merge_array_r(
164 $options['admin_options'],
165 (array) $admin_options
166 );
167 }
168
169 if ( 'admin_options' == $option_set ) {
170 return $options['admin_options'];
171 }
172
173 return $options;
174 }
175 }
176