PluginProbe ʕ •ᴥ•ʔ
WP Popular Posts / 5.4.0
WP Popular Posts v5.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 4 years ago Admin 4 years ago Block 4 years ago Container 4 years ago Front 4 years ago Rest 4 years ago Widget 4 years ago Bootstrap.php 4 years ago Cache.php 4 years ago Helper.php 4 years ago I18N.php 4 years ago Image.php 4 years ago Output.php 4 years ago Query.php 4 years ago Settings.php 4 years ago Themer.php 4 years ago Translate.php 4 years ago WordPressPopularPosts.php 4 years ago deprecated.php 4 years ago template-tags.php 4 years ago
Settings.php
168 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,page',
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 'field' => '',
110 'resize' => false,
111 'default' => '',
112 'lazyload' => true
113 ],
114 'log' => [
115 'level' => 1,
116 'limit' => 0,
117 'expires_after' => 180
118 ],
119 'cache' => [
120 'active' => true,
121 'interval' => [
122 'time' => 'minute',
123 'value' => 1
124 ]
125 ],
126 'sampling' => [
127 'active' => false,
128 'rate' => 100
129 ]
130 ]
131 ]
132 ];
133
134 /**
135 * Returns plugin options.
136 *
137 * @since 4.0.0
138 * @access public
139 * @param string $option_set
140 * @return array
141 */
142 public static function get($option_set = null)
143 {
144 $options = self::$defaults;
145
146 if ( 'widget_options' == $option_set ) {
147 return $options['widget_options'];
148 }
149
150 if ( ! $admin_options = get_option('wpp_settings_config') ) {
151 $admin_options = $options['admin_options'];
152 add_option('wpp_settings_config', $admin_options);
153 }
154 else {
155 $options['admin_options'] = Helper::merge_array_r(
156 $options['admin_options'],
157 (array) $admin_options
158 );
159 }
160
161 if ( 'admin_options' == $option_set ) {
162 return $options['admin_options'];
163 }
164
165 return $options;
166 }
167 }
168