PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 7.3.3
WP Popular Posts v7.3.3
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 1 year ago Admin 1 year ago Block 1 year ago Compatibility 1 year ago Container 1 year ago Front 1 year ago Rest 1 year ago Shortcode 1 year ago Traits 1 year ago Widget 1 year ago Bootstrap.php 1 year ago Cache.php 1 year ago Helper.php 1 year ago Image.php 1 year ago Output.php 1 year ago Query.php 1 year ago Settings.php 1 year ago Themer.php 1 year ago Translate.php 1 year ago WordPressPopularPosts.php 1 year ago deprecated.php 1 year ago template-tags.php 1 year ago
Settings.php
172 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 ],
101 'tools' => [
102 'experimental' => false,
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' => 0,
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 ]
133 ]
134 ];
135
136 /**
137 * Returns plugin options.
138 *
139 * @since 4.0.0
140 * @access public
141 * @param string $option_set
142 * @return array
143 */
144 public static function get(string $option_set = '')
145 {
146 $options = self::$defaults;
147
148 if ( 'widget_options' == $option_set ) {
149 return $options['widget_options'];
150 }
151
152 $admin_options = get_option('wpp_settings_config');
153
154 if ( ! $admin_options ) {
155 $admin_options = $options['admin_options'];
156 add_option('wpp_settings_config', $admin_options);
157 }
158 else {
159 $options['admin_options'] = Helper::merge_array_r(
160 $options['admin_options'],
161 (array) $admin_options
162 );
163 }
164
165 if ( 'admin_options' == $option_set ) {
166 return $options['admin_options'];
167 }
168
169 return $options;
170 }
171 }
172