PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 7.3.7
WP Popular Posts v7.3.7
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 4 months ago Block 8 months 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 8 months ago Bootstrap.php 5 years ago Cache.php 8 months ago Helper.php 8 months ago I18N.php 5 years ago Image.php 8 months ago Output.php 4 months ago Query.php 8 months ago Settings.php 4 months 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 8 months ago
Settings.php
173 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 'experimental' => false,
104 'ajax' => true,
105 'css' => true,
106 'link' => [
107 'target' => '_self'
108 ],
109 'thumbnail' => [
110 'source' => 'featured',
111 'format' => 'original',
112 'field' => '',
113 'resize' => false,
114 'default' => '',
115 'lazyload' => true
116 ],
117 'log' => [
118 'level' => 1,
119 'limit' => 0,
120 'expires_after' => 180
121 ],
122 'cache' => [
123 'active' => true,
124 'interval' => [
125 'time' => 'minute',
126 'value' => 1
127 ]
128 ],
129 'sampling' => [
130 'active' => false,
131 'rate' => 100
132 ]
133 ]
134 ]
135 ];
136
137 /**
138 * Returns plugin options.
139 *
140 * @since 4.0.0
141 * @access public
142 * @param string $option_set
143 * @return array
144 */
145 public static function get(string $option_set = '')
146 {
147 $options = self::$defaults;
148
149 if ( 'widget_options' == $option_set ) {
150 return $options['widget_options'];
151 }
152
153 $admin_options = get_option('wpp_settings_config');
154
155 if ( ! $admin_options ) {
156 $admin_options = $options['admin_options'];
157 add_option('wpp_settings_config', $admin_options);
158 }
159 else {
160 $options['admin_options'] = Helper::merge_array_r(
161 $options['admin_options'],
162 (array) $admin_options
163 );
164 }
165
166 if ( 'admin_options' == $option_set ) {
167 return $options['admin_options'];
168 }
169
170 return $options;
171 }
172 }
173