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