class-wordpress-popular-posts-activator.php
8 years ago
class-wordpress-popular-posts-deactivator.php
8 years ago
class-wordpress-popular-posts-helper.php
8 years ago
class-wordpress-popular-posts-i18n.php
8 years ago
class-wordpress-popular-posts-image.php
8 years ago
class-wordpress-popular-posts-loader.php
8 years ago
class-wordpress-popular-posts-output.php
8 years ago
class-wordpress-popular-posts-query.php
8 years ago
class-wordpress-popular-posts-rest-controller.php
8 years ago
class-wordpress-popular-posts-settings.php
8 years ago
class-wordpress-popular-posts-template.php
8 years ago
class-wordpress-popular-posts-translate.php
8 years ago
class-wordpress-popular-posts-widget.php
8 years ago
class-wordpress-popular-posts.php
8 years ago
widget-form.php
8 years ago
class-wordpress-popular-posts-settings.php
166 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Set / get plugin default options. |
| 5 | * |
| 6 | * @link http://cabrerahector.com |
| 7 | * @since 4.0.0 |
| 8 | * |
| 9 | * @package WordPressPopularPosts |
| 10 | * @subpackage WordPressPopularPosts/includes |
| 11 | */ |
| 12 | |
| 13 | /** |
| 14 | * Set / get plugin default options. |
| 15 | * |
| 16 | * @package WordPressPopularPosts |
| 17 | * @subpackage WordPressPopularPosts/includes |
| 18 | * @author Hector Cabrera <me@cabrerahector.com> |
| 19 | */ |
| 20 | |
| 21 | class WPP_Settings { |
| 22 | |
| 23 | /** |
| 24 | * Plugin uploads directory. |
| 25 | * |
| 26 | * @since 3.0.4 |
| 27 | * @var array |
| 28 | */ |
| 29 | static public $defaults = array( |
| 30 | 'widget_options' => array( |
| 31 | 'title' => '', |
| 32 | 'limit' => 10, |
| 33 | 'offset' => 0, |
| 34 | 'range' => 'daily', |
| 35 | 'time_unit' => 'hour', |
| 36 | 'time_quantity' => 24, |
| 37 | 'freshness' => false, |
| 38 | 'order_by' => 'views', |
| 39 | 'post_type' => 'post', |
| 40 | 'pid' => '', |
| 41 | 'author' => '', |
| 42 | 'cat' => '', |
| 43 | 'taxonomy' => 'category', |
| 44 | 'term_id' => '', |
| 45 | 'shorten_title' => array( |
| 46 | 'active' => false, |
| 47 | 'length' => 25, |
| 48 | 'words' => false |
| 49 | ), |
| 50 | 'post-excerpt' => array( |
| 51 | 'active' => false, |
| 52 | 'length' => 55, |
| 53 | 'keep_format' => false, |
| 54 | 'words' => false |
| 55 | ), |
| 56 | 'thumbnail' => array( |
| 57 | 'active' => false, |
| 58 | 'build' => 'manual', |
| 59 | 'width' => 75, |
| 60 | 'height' => 75, |
| 61 | 'crop' => true |
| 62 | ), |
| 63 | 'rating' => false, |
| 64 | 'stats_tag' => array( |
| 65 | 'comment_count' => false, |
| 66 | 'views' => true, |
| 67 | 'author' => false, |
| 68 | 'date' => array( |
| 69 | 'active' => false, |
| 70 | 'format' => 'F j, Y' |
| 71 | ), |
| 72 | 'category' => false, |
| 73 | 'taxonomy' => array( |
| 74 | 'active' => false, |
| 75 | 'name' => 'category' |
| 76 | ) |
| 77 | ), |
| 78 | 'markup' => array( |
| 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>{thumb} {title} <span class="wpp-meta post-stats">{stats}</span></li>' |
| 85 | |
| 86 | ) |
| 87 | ), |
| 88 | 'admin_options' => array( |
| 89 | 'stats' => array( |
| 90 | 'range' => 'last7days', |
| 91 | 'time_unit' => 'hour', |
| 92 | 'time_quantity' => 24, |
| 93 | 'order_by' => 'views', |
| 94 | 'limit' => 10, |
| 95 | 'post_type' => 'post,page', |
| 96 | 'freshness' => false |
| 97 | ), |
| 98 | 'tools' => array( |
| 99 | 'ajax' => false, |
| 100 | 'css' => true, |
| 101 | 'link' => array( |
| 102 | 'target' => '_self' |
| 103 | ), |
| 104 | 'thumbnail' => array( |
| 105 | 'source' => 'featured', |
| 106 | 'field' => '', |
| 107 | 'resize' => false, |
| 108 | 'default' => '' |
| 109 | ), |
| 110 | 'log' => array( |
| 111 | 'level' => 1, |
| 112 | 'limit' => 0, |
| 113 | 'expires_after' => 180 |
| 114 | ), |
| 115 | 'cache' => array( |
| 116 | 'active' => false, |
| 117 | 'interval' => array( |
| 118 | 'time' => 'hour', |
| 119 | 'value' => 1 |
| 120 | ) |
| 121 | ), |
| 122 | 'sampling' => array( |
| 123 | 'active' => false, |
| 124 | 'rate' => 100 |
| 125 | ) |
| 126 | ) |
| 127 | ) |
| 128 | ); |
| 129 | |
| 130 | /** |
| 131 | * Returns plugin options. |
| 132 | * |
| 133 | * @since 4.0.0 |
| 134 | * @access public |
| 135 | * @param string $option_set |
| 136 | * @return array |
| 137 | */ |
| 138 | public static function get( $option_set = null ){ |
| 139 | |
| 140 | $options = self::$defaults; |
| 141 | |
| 142 | if ( 'widget_options' == $option_set ) { |
| 143 | return $options[ 'widget_options' ]; |
| 144 | } |
| 145 | |
| 146 | if ( !$admin_options = get_option( 'wpp_settings_config' ) ) { |
| 147 | $admin_options = $options[ 'admin_options' ]; |
| 148 | add_option( 'wpp_settings_config', $admin_options ); |
| 149 | } |
| 150 | else { |
| 151 | $options[ 'admin_options' ] = WPP_Helper::merge_array_r( |
| 152 | $options[ 'admin_options' ], |
| 153 | (array) $admin_options |
| 154 | ); |
| 155 | } |
| 156 | |
| 157 | if ( 'admin_options' == $option_set ) { |
| 158 | return $options[ 'admin_options' ]; |
| 159 | } |
| 160 | |
| 161 | return $options; |
| 162 | |
| 163 | } |
| 164 | |
| 165 | } // End WPP_Settings class |
| 166 |