admin-page.php
952 lines
| 1 | <?php |
| 2 | if ( basename($_SERVER['SCRIPT_NAME']) == basename(__FILE__) ) |
| 3 | exit('Please do not load this page directly'); |
| 4 | |
| 5 | $tabs = [ |
| 6 | 'stats' => __('Stats', 'wordpress-popular-posts'), |
| 7 | 'tools' => __('Tools', 'wordpress-popular-posts'), |
| 8 | 'params' => __('Parameters', 'wordpress-popular-posts'), |
| 9 | 'debug' => 'Debug' |
| 10 | ]; |
| 11 | |
| 12 | // Set active tab |
| 13 | if ( isset($_GET['tab'] ) && isset($tabs[$_GET['tab']] ) ) |
| 14 | $current = $_GET['tab']; |
| 15 | else |
| 16 | $current = 'stats'; |
| 17 | |
| 18 | // Update options on form submission |
| 19 | if ( isset($_POST['section']) ) { |
| 20 | |
| 21 | if ( "stats" == $_POST['section'] ) { |
| 22 | $current = 'stats'; |
| 23 | |
| 24 | if ( isset($_POST['wpp-admin-token']) && wp_verify_nonce($_POST['wpp-admin-token'], 'wpp-update-stats-options') ) { |
| 25 | $this->config['stats']['limit'] = ( \WordPressPopularPosts\Helper::is_number($_POST['stats_limit']) && $_POST['stats_limit'] > 0 ) ? $_POST['stats_limit'] : 10; |
| 26 | $this->config['stats']['post_type'] = empty($_POST['stats_type']) ? "post,page" : $_POST['stats_type']; |
| 27 | $this->config['stats']['freshness'] = empty($_POST['stats_freshness']) ? false : $_POST['stats_freshness']; |
| 28 | |
| 29 | update_option('wpp_settings_config', $this->config); |
| 30 | echo "<div class=\"notice notice-success is-dismissible\"><p><strong>" . __('Settings saved.', 'wordpress-popular-posts') . "</strong></p></div>"; |
| 31 | } |
| 32 | } |
| 33 | elseif ( "misc" == $_POST['section'] ) { |
| 34 | $current = 'tools'; |
| 35 | |
| 36 | if ( isset($_POST['wpp-admin-token'] ) && wp_verify_nonce($_POST['wpp-admin-token'], 'wpp-update-misc-options') ) { |
| 37 | $this->config['tools']['link']['target'] = $_POST['link_target']; |
| 38 | $this->config['tools']['css'] = $_POST['css']; |
| 39 | |
| 40 | update_option('wpp_settings_config', $this->config); |
| 41 | echo "<div class=\"notice notice-success is-dismissible\"><p><strong>" . __('Settings saved.', 'wordpress-popular-posts') . "</strong></p></div>"; |
| 42 | } |
| 43 | } |
| 44 | elseif ( "thumb" == $_POST['section'] ) { |
| 45 | $current = 'tools'; |
| 46 | |
| 47 | if ( isset($_POST['wpp-admin-token']) && wp_verify_nonce($_POST['wpp-admin-token'], 'wpp-update-thumbnail-options') ) { |
| 48 | if ( |
| 49 | $_POST['thumb_source'] == "custom_field" |
| 50 | && ( ! isset($_POST['thumb_field']) || empty($_POST['thumb_field']) ) |
| 51 | ) { |
| 52 | echo '<div id="wpp-message" class="error fade"><p>' . __('Please provide the name of your custom field.', 'wordpress-popular-posts') . '</p></div>'; |
| 53 | } |
| 54 | else { |
| 55 | // thumbnail settings changed, flush transients |
| 56 | if ( $this->config['tools']['cache']['active'] ) { |
| 57 | $this->flush_transients(); |
| 58 | } |
| 59 | |
| 60 | $this->config['tools']['thumbnail']['source'] = $_POST['thumb_source']; |
| 61 | $this->config['tools']['thumbnail']['field'] = ( ! empty($_POST['thumb_field']) ) ? $_POST['thumb_field'] : "wpp_thumbnail"; |
| 62 | $this->config['tools']['thumbnail']['default'] = ( ! empty($_POST['upload_thumb_src']) ) ? $_POST['upload_thumb_src'] : ""; |
| 63 | $this->config['tools']['thumbnail']['resize'] = $_POST['thumb_field_resize']; |
| 64 | $this->config['tools']['thumbnail']['lazyload'] = (bool) $_POST['thumb_lazy_load']; |
| 65 | |
| 66 | update_option('wpp_settings_config', $this->config ); |
| 67 | echo "<div class=\"notice notice-success is-dismissible\"><p><strong>" . __('Settings saved.', 'wordpress-popular-posts') . "</strong></p></div>"; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | elseif ( "data" == $_POST['section'] && current_user_can('manage_options') ) { |
| 72 | $current = 'tools'; |
| 73 | |
| 74 | if ( isset($_POST['wpp-admin-token'] ) && wp_verify_nonce($_POST['wpp-admin-token'], 'wpp-update-data-options') ) { |
| 75 | $this->config['tools']['log']['level'] = $_POST['log_option']; |
| 76 | $this->config['tools']['log']['limit'] = $_POST['log_limit']; |
| 77 | $this->config['tools']['log']['expires_after'] = ( \WordPressPopularPosts\Helper::is_number($_POST['log_expire_time']) && $_POST['log_expire_time'] > 0 ) |
| 78 | ? $_POST['log_expire_time'] |
| 79 | : 180; |
| 80 | $this->config['tools']['ajax'] = $_POST['ajax']; |
| 81 | |
| 82 | // if any of the caching settings was updated, destroy all transients created by the plugin |
| 83 | if ( |
| 84 | $this->config['tools']['cache']['active'] != $_POST['cache'] |
| 85 | || $this->config['tools']['cache']['interval']['time'] != $_POST['cache_interval_time'] |
| 86 | || $this->config['tools']['cache']['interval']['value'] != $_POST['cache_interval_value'] |
| 87 | ) { |
| 88 | $this->flush_transients(); |
| 89 | } |
| 90 | |
| 91 | $this->config['tools']['cache']['active'] = $_POST['cache']; |
| 92 | $this->config['tools']['cache']['interval']['time'] = $_POST['cache_interval_time']; |
| 93 | $this->config['tools']['cache']['interval']['value'] = ( isset($_POST['cache_interval_value']) && \WordPressPopularPosts\Helper::is_number($_POST['cache_interval_value']) && $_POST['cache_interval_value'] > 0 ) |
| 94 | ? $_POST['cache_interval_value'] |
| 95 | : 1; |
| 96 | |
| 97 | $this->config['tools']['sampling']['active'] = $_POST['sampling']; |
| 98 | $this->config['tools']['sampling']['rate'] = ( isset($_POST['sample_rate']) && \WordPressPopularPosts\Helper::is_number($_POST['sample_rate']) && $_POST['sample_rate'] > 0 ) |
| 99 | ? $_POST['sample_rate'] |
| 100 | : 100; |
| 101 | |
| 102 | update_option('wpp_settings_config', $this->config); |
| 103 | echo "<div class=\"notice notice-success is-dismissible\"><p><strong>" . __('Settings saved.', 'wordpress-popular-posts') . "</strong></p></div>"; |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | } |
| 108 | |
| 109 | $rand = md5(uniqid(rand(), true)); |
| 110 | |
| 111 | if ( ! $wpp_rand = get_option("wpp_rand") ) { |
| 112 | add_option("wpp_rand", $rand); |
| 113 | } else { |
| 114 | update_option("wpp_rand", $rand); |
| 115 | } |
| 116 | |
| 117 | ?> |
| 118 | <script type="text/javascript"> |
| 119 | // TOOLS |
| 120 | function confirm_reset_cache() { |
| 121 | if ( confirm("<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e("This operation will delete all entries from WordPress Popular Posts' cache table and cannot be undone.", 'wordpress-popular-posts'); ?> \n\n" + "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e("Do you want to continue?", 'wordpress-popular-posts'); ?>") ) { |
| 122 | jQuery.post( |
| 123 | ajaxurl, |
| 124 | { |
| 125 | action: 'wpp_clear_data', |
| 126 | token: '<?php echo get_option("wpp_rand"); ?>', |
| 127 | clear: 'cache' |
| 128 | }, function(data){ |
| 129 | var response = ""; |
| 130 | |
| 131 | switch( data ) { |
| 132 | case "1": |
| 133 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Success! The cache table has been cleared!', 'wordpress-popular-posts'); ?>"; |
| 134 | break; |
| 135 | |
| 136 | case "2": |
| 137 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Error: cache table does not exist.', 'wordpress-popular-posts'); ?>"; |
| 138 | break; |
| 139 | |
| 140 | case "3": |
| 141 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Invalid action.', 'wordpress-popular-posts'); ?>"; |
| 142 | break; |
| 143 | |
| 144 | case "4": |
| 145 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Sorry, you do not have enough permissions to do this. Please contact the site administrator for support.', 'wordpress-popular-posts'); ?>"; |
| 146 | break; |
| 147 | |
| 148 | default: |
| 149 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Invalid action.', 'wordpress-popular-posts'); ?>"; |
| 150 | break; |
| 151 | } |
| 152 | |
| 153 | alert(response); |
| 154 | } |
| 155 | ); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | function confirm_reset_all() { |
| 160 | if ( confirm("<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e("This operation will delete all stored info from WordPress Popular Posts' data tables and cannot be undone.", 'wordpress-popular-posts'); ?> \n\n" + "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e("Do you want to continue?", 'wordpress-popular-posts'); ?>")) { |
| 161 | jQuery.post( |
| 162 | ajaxurl, |
| 163 | { |
| 164 | action: 'wpp_clear_data', |
| 165 | token: '<?php echo get_option("wpp_rand"); ?>', |
| 166 | clear: 'all' |
| 167 | }, function(data){ |
| 168 | var response = ""; |
| 169 | |
| 170 | switch( data ) { |
| 171 | case "1": |
| 172 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Success! All data have been cleared!', 'wordpress-popular-posts'); ?>"; |
| 173 | break; |
| 174 | |
| 175 | case "2": |
| 176 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Error: one or both data tables are missing.', 'wordpress-popular-posts'); ?>"; |
| 177 | break; |
| 178 | |
| 179 | case "3": |
| 180 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Invalid action.', 'wordpress-popular-posts'); ?>"; |
| 181 | break; |
| 182 | |
| 183 | case "4": |
| 184 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Sorry, you do not have enough permissions to do this. Please contact the site administrator for support.', 'wordpress-popular-posts'); ?>"; |
| 185 | break; |
| 186 | |
| 187 | default: |
| 188 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Invalid action.', 'wordpress-popular-posts'); ?>"; |
| 189 | break; |
| 190 | } |
| 191 | |
| 192 | alert(response); |
| 193 | } |
| 194 | ); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | function confirm_clear_image_cache() { |
| 199 | if ( confirm("<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e("This operation will delete all cached thumbnails and cannot be undone.", 'wordpress-popular-posts'); ?> \n\n" + "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e("Do you want to continue?", 'wordpress-popular-posts'); ?>") ) { |
| 200 | jQuery.post( |
| 201 | ajaxurl, |
| 202 | { |
| 203 | action: 'wpp_clear_thumbnail', |
| 204 | token: '<?php echo get_option("wpp_rand"); ?>' |
| 205 | }, function(data){ |
| 206 | var response = ""; |
| 207 | |
| 208 | switch( data ) { |
| 209 | case "1": |
| 210 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Success! All files have been deleted!', 'wordpress-popular-posts'); ?>"; |
| 211 | break; |
| 212 | |
| 213 | case "2": |
| 214 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('The thumbnail cache is already empty!', 'wordpress-popular-posts'); ?>"; |
| 215 | break; |
| 216 | |
| 217 | case "3": |
| 218 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Invalid action.', 'wordpress-popular-posts'); ?>"; |
| 219 | break; |
| 220 | |
| 221 | case "4": |
| 222 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Sorry, you do not have enough permissions to do this. Please contact the site administrator for support.', 'wordpress-popular-posts'); ?>"; |
| 223 | break; |
| 224 | |
| 225 | default: |
| 226 | response = "<?php /*translators: Special characters (such as accents) must be replaced with Javascript Octal codes (eg. \341 is the Octal code for small a with acute accent) */ _e('Invalid action.', 'wordpress-popular-posts'); ?>"; |
| 227 | break; |
| 228 | } |
| 229 | |
| 230 | alert(response); |
| 231 | } |
| 232 | ); |
| 233 | } |
| 234 | } |
| 235 | </script> |
| 236 | |
| 237 | <nav id="wpp-menu"> |
| 238 | <ul> |
| 239 | <li><a href="#" title="<?php esc_attr_e('Menu'); ?>"><span><?php _e('Menu'); ?></span></a></li> |
| 240 | <li <?php echo ('stats' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo admin_url('options-general.php?page=wordpress-popular-posts&tab=stats'); ?>" title="<?php esc_attr_e('Stats', 'wordpress-popular-posts'); ?>"><span><?php _e('Stats', 'wordpress-popular-posts'); ?></span></a></li> |
| 241 | <li <?php echo ('tools' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo admin_url('options-general.php?page=wordpress-popular-posts&tab=tools'); ?>" title="<?php esc_attr_e('Tools', 'wordpress-popular-posts'); ?>"><span><?php _e('Tools', 'wordpress-popular-posts'); ?></span></a></li> |
| 242 | <li <?php echo ('params' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo admin_url('options-general.php?page=wordpress-popular-posts&tab=params'); ?>" title="<?php esc_attr_e('Parameters', 'wordpress-popular-posts'); ?>"><span><?php _e('Parameters', 'wordpress-popular-posts'); ?></span></a></li> |
| 243 | <li <?php echo ('debug' == $current ) ? 'class="current"' : ''; ?>><a href="<?php echo admin_url('options-general.php?page=wordpress-popular-posts&tab=debug'); ?>" title="Debug"><span>Debug</span></a></li> |
| 244 | </ul> |
| 245 | </nav> |
| 246 | |
| 247 | <div class="wpp-wrapper wpp-section-<?php echo $current; ?>"> |
| 248 | <div class="wpp-header"> |
| 249 | <h2>WordPress Popular Posts</h2> |
| 250 | <h3><?php echo $tabs[$current]; ?></h3> |
| 251 | </div> |
| 252 | |
| 253 | <?php |
| 254 | // Stats chart |
| 255 | if ( 'stats' == $current ) { |
| 256 | $chart_data = json_decode( |
| 257 | $this->get_chart_data($this->config['stats']['range'], strtoupper($this->config['stats']['time_unit']), $this->config['stats']['time_quantity']), |
| 258 | true |
| 259 | ); |
| 260 | ?> |
| 261 | |
| 262 | <a href="#" id="wpp-stats-config-btn" class="dashicons dashicons-admin-generic"></a> |
| 263 | |
| 264 | <div id="wpp-stats-config" class="wpp-lightbox"> |
| 265 | <form action="" method="post" id="wpp_stats_options" name="wpp_stats_options"> |
| 266 | <label for="stats_type"><?php _e("Post type", 'wordpress-popular-posts'); ?>:</label> |
| 267 | <input type="text" name="stats_type" value="<?php echo esc_attr($this->config['stats']['post_type']); ?>" size="15"> |
| 268 | |
| 269 | <label for="stats_limits"><?php _e("Limit", 'wordpress-popular-posts'); ?>:</label> |
| 270 | <input type="text" name="stats_limit" value="<?php echo $this->config['stats']['limit']; ?>" size="5"> |
| 271 | |
| 272 | <label for="stats_freshness"><input type="checkbox" class="checkbox" <?php echo ($this->config['stats']['freshness']) ? 'checked="checked"' : ''; ?> id="stats_freshness" name="stats_freshness"> <small><?php _e('Display only posts published within the selected Time Range', 'wordpress-popular-posts'); ?></small></label> |
| 273 | |
| 274 | <div class="clear"></div> |
| 275 | <br /><br /> |
| 276 | |
| 277 | <input type="hidden" name="section" value="stats"> |
| 278 | <button type="submit" class="button-primary action"><?php _e("Apply", 'wordpress-popular-posts'); ?></button> |
| 279 | <button class="button-secondary action right"><?php _e("Cancel"); ?></button> |
| 280 | |
| 281 | <?php wp_nonce_field('wpp-update-stats-options', 'wpp-admin-token'); ?> |
| 282 | </form> |
| 283 | </div> |
| 284 | |
| 285 | <div id="wpp-stats-range" class="wpp-lightbox"> |
| 286 | <form action="" method="post"> |
| 287 | <ul class="wpp-lightbox-tabs"> |
| 288 | <li class="active"><a href="#"><?php _e('Custom Time Range', 'wordpress-popular-posts'); ?></a></li> |
| 289 | <li><a href="#"><?php _e('Date Range', 'wordpress-popular-posts'); ?></a></li> |
| 290 | </ul> |
| 291 | |
| 292 | <div class="wpp-lightbox-tab-content wpp-lightbox-tab-content-active" id="custom-time-range"> |
| 293 | <input type="text" id="stats_range_time_quantity" name="stats_range_time_quantity" value="<?php echo $this->config['stats']['time_quantity']; ?>"> |
| 294 | |
| 295 | <select id="stats_range_time_unit" name="stats_range_time_unit"> |
| 296 | <option <?php if ($this->config['stats']['time_unit'] == "minute") { ?>selected="selected"<?php } ?> value="minute"><?php _e("Minute(s)", 'wordpress-popular-posts'); ?></option> |
| 297 | <option <?php if ($this->config['stats']['time_unit'] == "hour") { ?>selected="selected"<?php } ?> value="hour"><?php _e("Hour(s)", 'wordpress-popular-posts'); ?></option> |
| 298 | <option <?php if ($this->config['stats']['time_unit'] == "day") { ?>selected="selected"<?php } ?> value="day"><?php _e("Day(s)", 'wordpress-popular-posts'); ?></option> |
| 299 | </select> |
| 300 | </div> |
| 301 | |
| 302 | <div class="wpp-lightbox-tab-content" id="custom-date-range"> |
| 303 | <input type="text" id="stats_range_date" name="stats_range_date" value="" placeholder="<?php esc_attr_e('Select a date...', 'wordpress-popular-posts'); ?>" readonly> |
| 304 | </div> |
| 305 | |
| 306 | <div class="clear"></div> |
| 307 | <br /> |
| 308 | |
| 309 | <button type="submit" class="button-primary action"> |
| 310 | <?php _e("Apply", 'wordpress-popular-posts'); ?> |
| 311 | </button> |
| 312 | <button class="button-secondary action right"> |
| 313 | <?php _e("Cancel"); ?> |
| 314 | </button> |
| 315 | </form> |
| 316 | </div> |
| 317 | |
| 318 | <div id="wpp-chart-wrapper"> |
| 319 | <h4><?php echo $chart_data['totals']['label_summary']; ?></h4> |
| 320 | <h5><?php echo $chart_data['totals']['label_date_range']; ?></h5> |
| 321 | |
| 322 | <ul class="wpp-header-nav" id="wpp-time-ranges"> |
| 323 | <li <?php echo ('daily' == $this->config['stats']['range'] || 'today' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="today" title="<?php esc_attr_e('Today', 'wordpress-popular-posts'); ?>"><?php _e('Today', 'wordpress-popular-posts'); ?></a></li> |
| 324 | <li <?php echo ('daily' == $this->config['stats']['range'] || 'last24hours' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="last24hours" title="<?php esc_attr_e('Last 24 hours', 'wordpress-popular-posts'); ?>">24h</a></li> |
| 325 | <li <?php echo ('weekly' == $this->config['stats']['range'] || 'last7days' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="last7days" title="<?php esc_attr_e('Last 7 days', 'wordpress-popular-posts'); ?>">7d</a></li> |
| 326 | <li <?php echo ('monthly' == $this->config['stats']['range'] || 'last30days' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="last30days" title="<?php esc_attr_e('Last 30 days', 'wordpress-popular-posts'); ?>">30d</a></li> |
| 327 | <li <?php echo ('custom' == $this->config['stats']['range'] ) ? ' class="current"' : ''; ?>><a href="#" data-range="custom" title="<?php esc_attr_e('Custom', 'wordpress-popular-posts'); ?>"><?php _e('Custom', 'wordpress-popular-posts'); ?></a></li> |
| 328 | </ul> |
| 329 | |
| 330 | <div id="wpp-chart"> |
| 331 | <p><?php echo sprintf( __('Err... A nice little chart is supposed to be here, instead you are seeing this because your browser is too old. <br /> Please <a href="%s" target="_blank">get a better browser</a>.', 'wordpress-popular-posts'), 'https://browsehappy.com/'); ?></p> |
| 332 | |
| 333 | <script> |
| 334 | if ( WPPChart.canRender() ) { |
| 335 | jQuery("#wpp-chart p").remove(); |
| 336 | WPPChart.init('wpp-chart'); |
| 337 | } |
| 338 | </script> |
| 339 | </div> |
| 340 | </div> |
| 341 | <?php |
| 342 | } // End stats chart |
| 343 | ?> |
| 344 | |
| 345 | <div id="wpp-listing" class="wpp-content"<?php echo ('stats' == $current ) ? '' : ' style="display: none;"'; ?>> |
| 346 | <ul class="wpp-tabbed-nav"> |
| 347 | <li class="active"><a href="#" title="<?php esc_attr_e('Most viewed', 'wordpress-popular-posts'); ?>"><span class="wpp-icon-eye"></span><span><?php _e('Most viewed', 'wordpress-popular-posts'); ?></span></a></li> |
| 348 | <li><a href="#" title="<?php esc_attr_e('Most commented', 'wordpress-popular-posts'); ?>"><span class="wpp-icon-comment"></span><span><?php _e('Most commented', 'wordpress-popular-posts'); ?></span></a></li> |
| 349 | <li><a href="#" title="<?php esc_attr_e('Trending now', 'wordpress-popular-posts'); ?>"><span class="wpp-icon-rocket"></span><span><?php _e('Trending now', 'wordpress-popular-posts'); ?></span></a></li> |
| 350 | <li><a href="#" title="<?php esc_attr_e('Hall of Fame', 'wordpress-popular-posts'); ?>"><span class="wpp-icon-award"></span><span><?php _e('Hall of Fame', 'wordpress-popular-posts'); ?></span></a></li> |
| 351 | </ul> |
| 352 | |
| 353 | <div class="wpp-tab-content wpp-tab-content-active"> |
| 354 | <span class="spinner"></span> |
| 355 | </div> |
| 356 | |
| 357 | <div class="wpp-tab-content"> |
| 358 | <span class="spinner"></span> |
| 359 | </div> |
| 360 | |
| 361 | <div class="wpp-tab-content"> |
| 362 | <span class="spinner"></span> |
| 363 | </div> |
| 364 | |
| 365 | <div class="wpp-tab-content"> |
| 366 | <?php |
| 367 | $args = [ |
| 368 | 'range' => 'all', |
| 369 | 'post_type' => $this->config['stats']['post_type'], |
| 370 | 'order_by' => 'views', |
| 371 | 'limit' => $this->config['stats']['limit'], |
| 372 | 'stats_tag' => [ |
| 373 | 'comment_count' => 1, |
| 374 | 'views' => 1, |
| 375 | 'date' => [ |
| 376 | 'active' => 1 |
| 377 | ] |
| 378 | ] |
| 379 | ]; |
| 380 | $hof = new \WordPressPopularPosts\Query($args); |
| 381 | $posts = $hof->get_posts(); |
| 382 | |
| 383 | $this->render_list($posts, 'hof'); |
| 384 | ?> |
| 385 | </div> |
| 386 | </div> |
| 387 | |
| 388 | <!-- Start tools --> |
| 389 | <div id="wpp_tools" <?php echo ( "tools" == $current ) ? '' : ' style="display: none;"'; ?>> |
| 390 | <h3 class="wmpp-subtitle"><?php _e("Thumbnails", 'wordpress-popular-posts'); ?></h3> |
| 391 | |
| 392 | <form action="" method="post" id="wpp_thumbnail_options" name="wpp_thumbnail_options"> |
| 393 | <table class="form-table"> |
| 394 | <tbody> |
| 395 | <tr valign="top"> |
| 396 | <th scope="row"><label for="thumb_default"><?php _e("Default thumbnail", 'wordpress-popular-posts'); ?>:</label></th> |
| 397 | <td> |
| 398 | <div id="thumb-review"> |
| 399 | <img src="<?php echo ($this->config['tools']['thumbnail']['default'] ) ? str_replace(parse_url($this->config['tools']['thumbnail']['default'], PHP_URL_SCHEME) . ':', '', $this->config['tools']['thumbnail']['default']) : plugins_url() . '/wordpress-popular-posts/assets/images/no_thumb.jpg'; ?>" alt="" /> |
| 400 | </div> |
| 401 | |
| 402 | <input id="upload_thumb_button" type="button" class="button" value="<?php _e("Change thumbnail", 'wordpress-popular-posts'); ?>"> |
| 403 | <input type="hidden" id="upload_thumb_src" name="upload_thumb_src" value=""> |
| 404 | |
| 405 | <p class="description"><?php _e("This image will be displayed when no thumbnail is available", 'wordpress-popular-posts'); ?>.</p> |
| 406 | </td> |
| 407 | </tr> |
| 408 | <tr valign="top"> |
| 409 | <th scope="row"><label for="thumb_source"><?php _e("Pick image from", 'wordpress-popular-posts'); ?>:</label></th> |
| 410 | <td> |
| 411 | <select name="thumb_source" id="thumb_source"> |
| 412 | <option <?php if ($this->config['tools']['thumbnail']['source'] == "featured") { ?>selected="selected"<?php } ?> value="featured"><?php _e("Featured image", 'wordpress-popular-posts'); ?></option> |
| 413 | <option <?php if ($this->config['tools']['thumbnail']['source'] == "first_image") { ?>selected="selected"<?php } ?> value="first_image"><?php _e("First image on post", 'wordpress-popular-posts'); ?></option> |
| 414 | <option <?php if ($this->config['tools']['thumbnail']['source'] == "first_attachment") { ?>selected="selected"<?php } ?> value="first_attachment"><?php _e("First attachment", 'wordpress-popular-posts'); ?></option> |
| 415 | <option <?php if ($this->config['tools']['thumbnail']['source'] == "custom_field") { ?>selected="selected"<?php } ?> value="custom_field"><?php _e("Custom field", 'wordpress-popular-posts'); ?></option> |
| 416 | </select> |
| 417 | <br /> |
| 418 | <p class="description"><?php _e("Tell WordPress Popular Posts where it should get thumbnails from", 'wordpress-popular-posts'); ?>.</p> |
| 419 | </td> |
| 420 | </tr> |
| 421 | <tr valign="top"> |
| 422 | <th scope="row"><label for="thumb_lazy_load"><?php _e("Lazy load", 'wordpress-popular-posts'); ?>:</label> <small>[<a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#lazy-loading" target="_blank" title="<?php _e('What is this?', 'wordpress-popular-posts'); ?>">?</a>]</small></th> |
| 423 | <td> |
| 424 | <select name="thumb_lazy_load" id="thumb_lazy_load"> |
| 425 | <option <?php if ( ! $this->config['tools']['thumbnail']['lazyload'] ) { ?>selected="selected"<?php } ?> value="0"><?php _e("No", 'wordpress-popular-posts'); ?></option> |
| 426 | <option <?php if ( $this->config['tools']['thumbnail']['lazyload'] ) { ?>selected="selected"<?php } ?> value="1"><?php _e("Yes", 'wordpress-popular-posts'); ?></option> |
| 427 | </select> |
| 428 | </td> |
| 429 | </tr> |
| 430 | <tr valign="top" <?php if ($this->config['tools']['thumbnail']['source'] != "custom_field") { ?>style="display: none;"<?php } ?> id="row_custom_field"> |
| 431 | <th scope="row"><label for="thumb_field"><?php _e("Custom field name", 'wordpress-popular-posts'); ?>:</label></th> |
| 432 | <td> |
| 433 | <input type="text" id="thumb_field" name="thumb_field" value="<?php echo esc_attr($this->config['tools']['thumbnail']['field']); ?>" size="10" <?php if ($this->config['tools']['thumbnail']['source'] != "custom_field") { ?>style="display: none;"<?php } ?> /> |
| 434 | </td> |
| 435 | </tr> |
| 436 | <tr valign="top" <?php if ($this->config['tools']['thumbnail']['source'] != "custom_field") { ?>style="display: none;"<?php } ?> id="row_custom_field_resize"> |
| 437 | <th scope="row"><label for="thumb_field_resize"><?php _e("Resize image from Custom field?", 'wordpress-popular-posts'); ?>:</label></th> |
| 438 | <td> |
| 439 | <select name="thumb_field_resize" id="thumb_field_resize"> |
| 440 | <option <?php if ( !$this->config['tools']['thumbnail']['resize'] ) { ?>selected="selected"<?php } ?> value="0"><?php _e("No, use image as is", 'wordpress-popular-posts'); ?></option> |
| 441 | <option <?php if ($this->config['tools']['thumbnail']['resize'] == 1 ) { ?>selected="selected"<?php } ?> value="1"><?php _e("Yes", 'wordpress-popular-posts'); ?></option> |
| 442 | </select> |
| 443 | </td> |
| 444 | </tr> |
| 445 | <?php |
| 446 | $wp_upload_dir = wp_get_upload_dir(); |
| 447 | if ( is_dir($wp_upload_dir['basedir'] . "/" . 'wordpress-popular-posts') ) : |
| 448 | ?> |
| 449 | <tr valign="top"> |
| 450 | <th scope="row"></th> |
| 451 | <td> |
| 452 | <input type="button" name="wpp-reset-cache" id="wpp-reset-cache" class="button-secondary" value="<?php _e("Empty image cache", 'wordpress-popular-posts'); ?>" onclick="confirm_clear_image_cache()"> |
| 453 | <p class="description"><?php _e("Use this button to clear WPP's thumbnails cache", 'wordpress-popular-posts'); ?>.</p> |
| 454 | </td> |
| 455 | </tr> |
| 456 | <?php |
| 457 | endif; |
| 458 | ?> |
| 459 | <tr valign="top"> |
| 460 | <td colspan="2"> |
| 461 | <input type="hidden" name="section" value="thumb"> |
| 462 | <input type="submit" class="button-primary action" id="btn_th_ops" value="<?php _e("Apply", 'wordpress-popular-posts'); ?>" name=""> |
| 463 | </td> |
| 464 | </tr> |
| 465 | </tbody> |
| 466 | </table> |
| 467 | |
| 468 | <?php wp_nonce_field('wpp-update-thumbnail-options', 'wpp-admin-token'); ?> |
| 469 | </form> |
| 470 | <br /> |
| 471 | <p style="display: <?php echo ( current_user_can('manage_options') ) ? 'block' : 'none'; ?>; float:none; clear:both;"> </p> |
| 472 | |
| 473 | <h3 class="wmpp-subtitle" style="display: <?php echo ( current_user_can('manage_options') ) ? 'block' : 'none'; ?>"><?php _e("Data", 'wordpress-popular-posts'); ?></h3> |
| 474 | |
| 475 | <form action="" method="post" id="wpp_ajax_options" name="wpp_ajax_options" style="display: <?php echo ( current_user_can('manage_options') ) ? 'block' : 'none'; ?>"> |
| 476 | <table class="form-table"> |
| 477 | <tbody> |
| 478 | <tr valign="top"> |
| 479 | <th scope="row"><label for="log_option"><?php _e("Log views from", 'wordpress-popular-posts'); ?>:</label></th> |
| 480 | <td> |
| 481 | <select name="log_option" id="log_option"> |
| 482 | <option <?php if ($this->config['tools']['log']['level'] == 0) { ?>selected="selected"<?php } ?> value="0"><?php _e("Visitors only", 'wordpress-popular-posts'); ?></option> |
| 483 | <option <?php if ($this->config['tools']['log']['level'] == 2) { ?>selected="selected"<?php } ?> value="2"><?php _e("Logged-in users only", 'wordpress-popular-posts'); ?></option> |
| 484 | <option <?php if ($this->config['tools']['log']['level'] == 1) { ?>selected="selected"<?php } ?> value="1"><?php _e("Everyone", 'wordpress-popular-posts'); ?></option> |
| 485 | </select> |
| 486 | <br /> |
| 487 | </td> |
| 488 | </tr> |
| 489 | <tr valign="top"> |
| 490 | <th scope="row"><label for="log_limit"><?php _e("Log limit", 'wordpress-popular-posts'); ?>:</label></th> |
| 491 | <td> |
| 492 | <select name="log_limit" id="log_limit"> |
| 493 | <option <?php if ($this->config['tools']['log']['limit'] == 0) { ?>selected="selected"<?php } ?> value="0"><?php _e("Disabled", 'wordpress-popular-posts'); ?></option> |
| 494 | <option <?php if ($this->config['tools']['log']['limit'] == 1) { ?>selected="selected"<?php } ?> value="1"><?php _e("Keep data for", 'wordpress-popular-posts'); ?></option> |
| 495 | </select> |
| 496 | |
| 497 | <label for="log_expire_time"<?php echo ($this->config['tools']['log']['limit'] == 0) ? ' style="display: none;"' : ''; ?>> |
| 498 | <input type="text" id="log_expire_time" name="log_expire_time" value="<?php echo esc_attr($this->config['tools']['log']['expires_after']); ?>" size="3"> <?php _e("day(s)", 'wordpress-popular-posts'); ?> |
| 499 | </label> |
| 500 | |
| 501 | <p class="description"<?php echo ($this->config['tools']['log']['limit'] == 0) ? ' style="display: none;"' : ''; ?>><?php _e("Data older than the specified time frame will be automatically discarded", 'wordpress-popular-posts'); ?>.</p> |
| 502 | |
| 503 | <br <?php echo (1 == $this->config['tools']['log']['limit']) ? 'style="display: none;"' : ''; ?>/> |
| 504 | </td> |
| 505 | </tr> |
| 506 | <tr valign="top"> |
| 507 | <th scope="row"><label for="ajax"><?php _e("Ajaxify widget", 'wordpress-popular-posts'); ?>:</label></th> |
| 508 | <td> |
| 509 | <select name="ajax" id="ajax"> |
| 510 | <option <?php if (! $this->config['tools']['ajax']) { ?>selected="selected"<?php } ?> value="0"><?php _e("Disabled", 'wordpress-popular-posts'); ?></option> |
| 511 | <option <?php if ($this->config['tools']['ajax']) { ?>selected="selected"<?php } ?> value="1"><?php _e("Enabled", 'wordpress-popular-posts'); ?></option> |
| 512 | </select> |
| 513 | |
| 514 | <br /> |
| 515 | <p class="description"><?php _e("If you are using a caching plugin such as WP Super Cache, enabling this feature will keep the popular list from being cached by it", 'wordpress-popular-posts'); ?>.</p> |
| 516 | </td> |
| 517 | </tr> |
| 518 | <tr valign="top"> |
| 519 | <th scope="row"><label for="cache"><?php _e("Data Caching", 'wordpress-popular-posts'); ?>:</label> <small>[<a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#caching-db-queries-results" target="_blank" title="<?php _e('What is this?', 'wordpress-popular-posts'); ?>">?</a>]</small></th> |
| 520 | <td> |
| 521 | <select name="cache" id="cache"> |
| 522 | <option <?php if ( ! $this->config['tools']['cache']['active'] ) { ?>selected="selected"<?php } ?> value="0"><?php _e("Never cache", 'wordpress-popular-posts'); ?></option> |
| 523 | <option <?php if ( $this->config['tools']['cache']['active'] ) { ?>selected="selected"<?php } ?> value="1"><?php _e("Enable caching", 'wordpress-popular-posts'); ?></option> |
| 524 | </select> |
| 525 | |
| 526 | <br /> |
| 527 | <p class="description"><?php _e("WPP can cache the popular list for a specified amount of time. Recommended for large / high traffic sites", 'wordpress-popular-posts'); ?>.</p> |
| 528 | </td> |
| 529 | </tr> |
| 530 | <tr valign="top" <?php if ( ! $this->config['tools']['cache']['active'] ) { ?>style="display: none;"<?php } ?> id="cache_refresh_interval"> |
| 531 | <th scope="row"><label for="cache_interval_value"><?php _e("Refresh cache every", 'wordpress-popular-posts'); ?>:</label></th> |
| 532 | <td> |
| 533 | <input name="cache_interval_value" type="text" id="cache_interval_value" value="<?php echo ( isset($this->config['tools']['cache']['interval']['value']) ) ? (int) $this->config['tools']['cache']['interval']['value'] : 1; ?>" class="small-text"> |
| 534 | <select name="cache_interval_time" id="cache_interval_time"> |
| 535 | <option <?php if ($this->config['tools']['cache']['interval']['time'] == "minute") { ?>selected="selected"<?php } ?> value="minute"><?php _e("Minute(s)", 'wordpress-popular-posts'); ?></option> |
| 536 | <option <?php if ($this->config['tools']['cache']['interval']['time'] == "hour") { ?>selected="selected"<?php } ?> value="hour"><?php _e("Hour(s)", 'wordpress-popular-posts'); ?></option> |
| 537 | <option <?php if ($this->config['tools']['cache']['interval']['time'] == "day") { ?>selected="selected"<?php } ?> value="day"><?php _e("Day(s)", 'wordpress-popular-posts'); ?></option> |
| 538 | <option <?php if ($this->config['tools']['cache']['interval']['time'] == "week") { ?>selected="selected"<?php } ?> value="week"><?php _e("Week(s)", 'wordpress-popular-posts'); ?></option> |
| 539 | <option <?php if ($this->config['tools']['cache']['interval']['time'] == "month") { ?>selected="selected"<?php } ?> value="month"><?php _e("Month(s)", 'wordpress-popular-posts'); ?></option> |
| 540 | <option <?php if ($this->config['tools']['cache']['interval']['time'] == "year") { ?>selected="selected"<?php } ?> value="month"><?php _e("Year(s)", 'wordpress-popular-posts'); ?></option> |
| 541 | </select> |
| 542 | <br /> |
| 543 | <p class="description" style="display: none;" id="cache_too_long"><?php _e("Really? That long?", 'wordpress-popular-posts'); ?></p> |
| 544 | </td> |
| 545 | </tr> |
| 546 | <tr valign="top"> |
| 547 | <th scope="row"><label for="sampling"><?php _e("Data Sampling", 'wordpress-popular-posts'); ?>:</label> <small>[<a href="https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#data-sampling" target="_blank" title="<?php _e('What is this?', 'wordpress-popular-posts'); ?>">?</a>]</small></th> |
| 548 | <td> |
| 549 | <select name="sampling" id="sampling"> |
| 550 | <option <?php if ( !$this->config['tools']['sampling']['active'] ) { ?>selected="selected"<?php } ?> value="0"><?php _e("Disabled", 'wordpress-popular-posts'); ?></option> |
| 551 | <option <?php if ( $this->config['tools']['sampling']['active'] ) { ?>selected="selected"<?php } ?> value="1"><?php _e("Enabled", 'wordpress-popular-posts'); ?></option> |
| 552 | </select> |
| 553 | |
| 554 | <br /> |
| 555 | <p class="description"><?php echo sprintf( __('By default, WordPress Popular Posts stores in database every single visit your site receives. For small / medium sites this is generally OK, but on large / high traffic sites the constant writing to the database may have an impact on performance. With <a href="%1$s" target="_blank">data sampling</a>, WordPress Popular Posts will store only a subset of your traffic and report on the tendencies detected in that sample set (for more, <a href="%2$s" target="_blank">please read here</a>)', 'wordpress-popular-posts'), 'http://en.wikipedia.org/wiki/Sample_%28statistics%29', 'https://github.com/cabrerahector/wordpress-popular-posts/wiki/7.-Performance#data-sampling'); ?>.</p> |
| 556 | </td> |
| 557 | </tr> |
| 558 | <tr valign="top" <?php if ( ! $this->config['tools']['sampling']['active'] ) { ?>style="display: none;"<?php } ?>> |
| 559 | <th scope="row"><label for="sample_rate"><?php _e("Sample Rate", 'wordpress-popular-posts'); ?>:</label></th> |
| 560 | <td> |
| 561 | <input name="sample_rate" type="text" id="sample_rate" value="<?php echo ( isset($this->config['tools']['sampling']['rate']) ) ? (int) $this->config['tools']['sampling']['rate'] : 100; ?>" class="small-text"> |
| 562 | <br /> |
| 563 | <p class="description"><?php echo sprintf(__("A sampling rate of %d is recommended for large / high traffic sites. For lower traffic sites, you should lower the value", 'wordpress-popular-posts'), 100); ?>.</p> |
| 564 | </td> |
| 565 | </tr> |
| 566 | <tr valign="top"> |
| 567 | <td colspan="2"> |
| 568 | <input type="hidden" name="section" value="data"> |
| 569 | <input type="submit" class="button-primary action" id="btn_ajax_ops" value="<?php _e("Apply", 'wordpress-popular-posts'); ?>" name=""> |
| 570 | </td> |
| 571 | </tr> |
| 572 | </tbody> |
| 573 | </table> |
| 574 | |
| 575 | <?php wp_nonce_field('wpp-update-data-options', 'wpp-admin-token'); ?> |
| 576 | </form> |
| 577 | <br /> |
| 578 | <p style="display: block; float:none; clear: both;"> </p> |
| 579 | |
| 580 | <h3 class="wmpp-subtitle"><?php _e("Miscellaneous", 'wordpress-popular-posts'); ?></h3> |
| 581 | |
| 582 | <form action="" method="post" id="wpp_link_options" name="wpp_link_options"> |
| 583 | <table class="form-table"> |
| 584 | <tbody> |
| 585 | <tr valign="top"> |
| 586 | <th scope="row"><label for="link_target"><?php _e("Open links in", 'wordpress-popular-posts'); ?>:</label></th> |
| 587 | <td> |
| 588 | <select name="link_target" id="link_target"> |
| 589 | <option <?php if ($this->config['tools']['link']['target'] == '_self') { ?>selected="selected"<?php } ?> value="_self"><?php _e("Current window", 'wordpress-popular-posts'); ?></option> |
| 590 | <option <?php if ($this->config['tools']['link']['target'] == '_blank') { ?>selected="selected"<?php } ?> value="_blank"><?php _e("New tab/window", 'wordpress-popular-posts'); ?></option> |
| 591 | </select> |
| 592 | <br /> |
| 593 | </td> |
| 594 | </tr> |
| 595 | <tr valign="top"> |
| 596 | <th scope="row"><label for="css"><?php _e("Use plugin's stylesheet", 'wordpress-popular-posts'); ?>:</label></th> |
| 597 | <td> |
| 598 | <select name="css" id="css"> |
| 599 | <option <?php if ($this->config['tools']['css']) { ?>selected="selected"<?php } ?> value="1"><?php _e("Enabled", 'wordpress-popular-posts'); ?></option> |
| 600 | <option <?php if (!$this->config['tools']['css']) { ?>selected="selected"<?php } ?> value="0"><?php _e("Disabled", 'wordpress-popular-posts'); ?></option> |
| 601 | </select> |
| 602 | <br /> |
| 603 | <p class="description"><?php _e("By default, the plugin includes a stylesheet called wpp.css which you can use to style your popular posts listing. If you wish to use your own stylesheet or do not want it to have it included in the header section of your site, use this.", 'wordpress-popular-posts'); ?></p> |
| 604 | </td> |
| 605 | </tr> |
| 606 | <tr valign="top"> |
| 607 | <td colspan="2"> |
| 608 | <input type="hidden" name="section" value="misc"> |
| 609 | <input type="submit" class="button-primary action" value="<?php _e("Apply", 'wordpress-popular-posts'); ?>" name=""> |
| 610 | </td> |
| 611 | </tr> |
| 612 | </tbody> |
| 613 | </table> |
| 614 | |
| 615 | <?php wp_nonce_field('wpp-update-misc-options', 'wpp-admin-token'); ?> |
| 616 | </form> |
| 617 | <br /> |
| 618 | <p style="display: block; float: none; clear: both;"> </p> |
| 619 | |
| 620 | <div style="display: <?php echo ( current_user_can('manage_options') ) ? 'block' : 'none'; ?>"> |
| 621 | <br /><br /> |
| 622 | |
| 623 | <p><?php _e('WordPress Popular Posts maintains data in two separate tables: one for storing the most popular entries on a daily basis (from now on, "cache"), and another one to keep the All-time data (from now on, "historical data" or just "data"). If for some reason you need to clear the cache table, or even both historical and cache tables, please use the buttons below to do so.', 'wordpress-popular-posts') ?></p> |
| 624 | <p><input type="button" name="wpp-reset-cache" id="wpp-reset-cache" class="button-secondary" value="<?php _e("Empty cache", 'wordpress-popular-posts'); ?>" onclick="confirm_reset_cache()"> <label for="wpp-reset-cache"><small><?php _e('Use this button to manually clear entries from WPP cache only', 'wordpress-popular-posts'); ?></small></label></p> |
| 625 | <p><input type="button" name="wpp-reset-all" id="wpp-reset-all" class="button-secondary" value="<?php _e("Clear all data", 'wordpress-popular-posts'); ?>" onclick="confirm_reset_all()"> <label for="wpp-reset-all"><small><?php _e('Use this button to manually clear entries from all WPP data tables', 'wordpress-popular-posts'); ?></small></label></p> |
| 626 | </div> |
| 627 | </div> |
| 628 | <!-- End tools --> |
| 629 | |
| 630 | <!-- Start params --> |
| 631 | <div id="wpp_params" <?php echo ( "params" == $current ) ? '' : ' style="display: none;"'; ?>> |
| 632 | <div> |
| 633 | <p><?php printf( __('With the following parameters you can customize the popular posts list when using either the <a href="%1$s">wpp_get_mostpopular() template tag</a> or the <a href="%2$s">[wpp] shortcode</a>.', 'wordpress-popular-posts'), |
| 634 | 'https://github.com/cabrerahector/wordpress-popular-posts/wiki/2.-Template-tags#wpp_get_mostpopular', |
| 635 | 'https://github.com/cabrerahector/wordpress-popular-posts/wiki/1.-Using-WPP-on-posts-&-pages' |
| 636 | ); ?></p> |
| 637 | <br /> |
| 638 | |
| 639 | <div style="overflow-x: auto;"> |
| 640 | <table cellspacing="0" class="wp-list-table"> |
| 641 | <thead> |
| 642 | <tr> |
| 643 | <th class="manage-column column-title"><?php _e('Parameter', 'wordpress-popular-posts'); ?></th> |
| 644 | <th class="manage-column column-title"><?php _e('What it does ', 'wordpress-popular-posts'); ?></th> |
| 645 | <th class="manage-column column-title"><?php _e('Possible values', 'wordpress-popular-posts'); ?></th> |
| 646 | <th class="manage-column column-title"><?php _e('Defaults to', 'wordpress-popular-posts'); ?></th> |
| 647 | <th class="manage-column column-title"><?php _e('Example', 'wordpress-popular-posts'); ?></th> |
| 648 | </tr> |
| 649 | </thead> |
| 650 | <tbody> |
| 651 | <tr> |
| 652 | <td><strong>header</strong></td> |
| 653 | <td><?php _e('Sets a heading for the list', 'wordpress-popular-posts'); ?></td> |
| 654 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 655 | <td><?php _e('None', 'wordpress-popular-posts'); ?></td> |
| 656 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'header' => 'Popular Posts'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp header='Popular Posts']<br /><br /></td> |
| 657 | </tr> |
| 658 | <tr class="alternate"> |
| 659 | <td><strong>header_start</strong></td> |
| 660 | <td><?php _e('Set the opening tag for the heading of the list', 'wordpress-popular-posts'); ?></td> |
| 661 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 662 | <td><h2></td> |
| 663 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'header' => 'Popular Posts', <br /> 'header_start' => '<h3 class="title">',<br /> 'header_end' => '</h3>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp header='Popular Posts' header_start='<h3 class="title">' header_end='</h3>']<br /><br /></td> |
| 664 | </tr> |
| 665 | <tr> |
| 666 | <td><strong>header_end</strong></td> |
| 667 | <td><?php _e('Set the closing tag for the heading of the list', 'wordpress-popular-posts'); ?></td> |
| 668 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 669 | <td></h2></td> |
| 670 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'header' => 'Popular Posts', <br /> 'header_start' => '<h3 class="title">',<br /> 'header_end' => '</h3>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp header='Popular Posts' header_start='<h3 class="title">' header_end='</h3>']<br /><br /></td> |
| 671 | </tr> |
| 672 | <tr class="alternate"> |
| 673 | <td><strong>limit</strong></td> |
| 674 | <td><?php _e('Sets the maximum number of popular posts to be shown on the listing', 'wordpress-popular-posts'); ?></td> |
| 675 | <td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td> |
| 676 | <td>10</td> |
| 677 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'limit' => 5<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp limit=5]<br /><br /></td> |
| 678 | </tr> |
| 679 | <tr> |
| 680 | <td><strong>range</strong></td> |
| 681 | <td><?php _e('Tells WordPress Popular Posts to retrieve the most popular entries within the time range specified by you', 'wordpress-popular-posts'); ?></td> |
| 682 | <td>"last24hours", "last7days", "last30days", "all", "custom"</td> |
| 683 | <td>last24hours</td> |
| 684 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'range' => 'last7days'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp range='last7days']<br /><br /></td> |
| 685 | </tr> |
| 686 | <tr class="alternate"> |
| 687 | <td><strong>time_quantity</strong></td> |
| 688 | <td><?php _e('Especifies the number of time units of the custom time range', 'wordpress-popular-posts'); ?></td> |
| 689 | <td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td> |
| 690 | <td>24</td> |
| 691 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'range' => 'custom',<br /> 'time_quantity' => 1,<br /> 'time_unit' => 'hour'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp range='custom' time_quantity=1 time_unit='hour']<br /><br /></td> |
| 692 | </tr> |
| 693 | <tr> |
| 694 | <td><strong>time_unit</strong></td> |
| 695 | <td><?php _e('Especifies the time unit of the custom time range', 'wordpress-popular-posts'); ?></td> |
| 696 | <td>minute, hour, day, week, month</td> |
| 697 | <td>hour</td> |
| 698 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'range' => 'custom',<br /> 'time_quantity' => 1,<br /> 'time_unit' => 'hour'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp range='custom' time_quantity=1 time_unit='hour']<br /><br /></td> |
| 699 | </tr> |
| 700 | <tr class="alternate"> |
| 701 | <td><strong>freshness</strong></td> |
| 702 | <td><?php _e('Tells WordPress Popular Posts to retrieve the most popular entries published within the time range specified by you', 'wordpress-popular-posts'); ?></td> |
| 703 | <td>1 (true), 0 (false)</td> |
| 704 | <td>0</td> |
| 705 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'range' => 'weekly',<br /> 'freshness' => 1<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp range='last7days' freshness=1]<br /><br /></td> |
| 706 | </tr> |
| 707 | <tr> |
| 708 | <td><strong>order_by</strong></td> |
| 709 | <td><?php _e('Sets the sorting option of the popular posts', 'wordpress-popular-posts'); ?></td> |
| 710 | <td>"comments", "views", "avg" <?php _e('(for average views per day)', 'wordpress-popular-posts'); ?></td> |
| 711 | <td>views</td> |
| 712 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'order_by' => 'comments'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp order_by='comments']<br /><br /></td> |
| 713 | </tr> |
| 714 | <tr class="alternate"> |
| 715 | <td><strong>post_type</strong></td> |
| 716 | <td><?php _e('Defines the type of posts to show on the listing', 'wordpress-popular-posts'); ?></td> |
| 717 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 718 | <td>post</td> |
| 719 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'post_type' => 'post,page,your-custom-post-type'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp post_type='post,page,your-custom-post-type']<br /><br /></td> |
| 720 | </tr> |
| 721 | <tr> |
| 722 | <td><strong>pid</strong></td> |
| 723 | <td><?php _e('If set, WordPress Popular Posts will exclude the specified post(s) ID(s) form the listing.', 'wordpress-popular-posts'); ?></td> |
| 724 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 725 | <td><?php _e('None', 'wordpress-popular-posts'); ?></td> |
| 726 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'pid' => '60,25,31'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp pid='60,25,31']<br /><br /></td> |
| 727 | </tr> |
| 728 | <tr class="alternate"> |
| 729 | <td><strong>cat</strong></td> |
| 730 | <td><?php _e('If set, WordPress Popular Posts will retrieve all entries that belong to the specified category ID(s). If a minus sign is used, entries associated to the category will be excluded instead.', 'wordpress-popular-posts'); ?></td> |
| 731 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 732 | <td><?php _e('None', 'wordpress-popular-posts'); ?></td> |
| 733 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'cat' => '1,55,-74'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp cat='1,55,-74']<br /><br /></td> |
| 734 | </tr> |
| 735 | <tr> |
| 736 | <td><strong>taxonomy</strong></td> |
| 737 | <td><?php _e('If set, WordPress Popular Posts will filter posts by a given taxonomy.', 'wordpress-popular-posts'); ?></td> |
| 738 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 739 | <td><?php _e('None', 'wordpress-popular-posts'); ?></td> |
| 740 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'taxonomy' => 'post_tag',<br /> 'term_id' => '118,75,15'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><?php<br />$args = array(<br /> 'taxonomy' => 'category; post_tag',<br /> 'term_id' => '1,55,-74; 118,75,15'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp taxonomy='post_tag' term_id='118,75,15']<br /><br />[wpp taxonomy='category; post_tag' term_id='1,55,-74; 118,75,15']<br /><br /></td> |
| 741 | </tr> |
| 742 | <tr class="alternate"> |
| 743 | <td><strong>term_id</strong></td> |
| 744 | <td><?php _e('If set, WordPress Popular Posts will retrieve all entries that belong to the specified term ID(s). If a minus sign is used, entries associated to the term(s) will be excluded instead.', 'wordpress-popular-posts'); ?></td> |
| 745 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 746 | <td><?php _e('None', 'wordpress-popular-posts'); ?></td> |
| 747 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'taxonomy' => 'post_tag',<br /> 'term_id' => '118,75,15'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp taxonomy='post_tag' term_id='118,75,15']<br /><br /></td> |
| 748 | </tr> |
| 749 | <tr> |
| 750 | <td><strong>author</strong></td> |
| 751 | <td><?php _e('If set, WordPress Popular Posts will retrieve all entries created by specified author(s) ID(s).', 'wordpress-popular-posts'); ?></td> |
| 752 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 753 | <td><?php _e('None', 'wordpress-popular-posts'); ?></td> |
| 754 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'author' => '75,8,120'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp author='75,8,120']<br /><br /></td> |
| 755 | </tr> |
| 756 | <tr class="alternate"> |
| 757 | <td><strong>title_length</strong></td> |
| 758 | <td><?php _e('If set, WordPress Popular Posts will shorten each post title to "n" characters whenever possible', 'wordpress-popular-posts'); ?></td> |
| 759 | <td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td> |
| 760 | <td>25</td> |
| 761 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'title_length' => 25<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp title_length=25]<br /><br /></td> |
| 762 | </tr> |
| 763 | <tr> |
| 764 | <td><strong>title_by_words</strong></td> |
| 765 | <td><?php _e('If set to 1, WordPress Popular Posts will shorten each post title to "n" words instead of characters', 'wordpress-popular-posts'); ?></td> |
| 766 | <td>1 (true), (0) false</td> |
| 767 | <td>0</td> |
| 768 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'title_by_words' => 1,<br /> 'title_length' => 25<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp title_by_words=1 title_length=25]<br /><br /></td> |
| 769 | </tr> |
| 770 | <tr class="alternate"> |
| 771 | <td><strong>excerpt_length</strong></td> |
| 772 | <td><?php _e('If set, WordPress Popular Posts will build and include an excerpt of "n" characters long from the content of each post listed as popular', 'wordpress-popular-posts'); ?></td> |
| 773 | <td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td> |
| 774 | <td>0</td> |
| 775 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'excerpt_length' => 55,<br /> 'post_html' => '<li>{title} <span class="wpp-excerpt">{summary}</span></li>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp excerpt_length=25 post_html='<li>{title} <span class="wpp-excerpt">{summary}</span></li>']<br /><br /></td> |
| 776 | </tr> |
| 777 | <tr> |
| 778 | <td><strong>excerpt_format</strong></td> |
| 779 | <td><?php _e('If set, WordPress Popular Posts will maintaing all styling tags (strong, italic, etc) and hyperlinks found in the excerpt', 'wordpress-popular-posts'); ?></td> |
| 780 | <td>1 (true), (0) false</td> |
| 781 | <td>0</td> |
| 782 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'excerpt_format' => 1,<br /> 'excerpt_length' => 55,<br /> 'post_html' => '<li>{title} <span class="wpp-excerpt">{summary}</span></li>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp excerpt_format=1 excerpt_length=25 post_html='<li>{title} <span class="wpp-excerpt">{summary}</span></li>']<br /><br /></td> |
| 783 | </tr> |
| 784 | <tr class="alternate"> |
| 785 | <td><strong>excerpt_by_words</strong></td> |
| 786 | <td><?php _e('If set to 1, WordPress Popular Posts will shorten the excerpt to "n" words instead of characters', 'wordpress-popular-posts'); ?></td> |
| 787 | <td>1 (true), (0) false</td> |
| 788 | <td>0</td> |
| 789 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'excerpt_by_words' => 1,<br /> 'excerpt_length' => 55,<br /> 'post_html' => '<li>{title} <span class="wpp-excerpt">{summary}</span></li>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp excerpt_by_words=1 excerpt_length=55 post_html='<li>{title} <span class="wpp-excerpt">{summary}</span></li>']<br /><br /></td> |
| 790 | </tr> |
| 791 | <tr> |
| 792 | <td><strong>thumbnail_width</strong></td> |
| 793 | <td><?php _e('If set, and if your current server configuration allows it, you will be able to display thumbnails of your posts. This attribute sets the width for thumbnails', 'wordpress-popular-posts'); ?></td> |
| 794 | <td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td> |
| 795 | <td>0</td> |
| 796 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'thumbnail_width' => 30,<br /> 'thumbnail_height' => 30<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp thumbnail_width=30 thumbnail_height=30]<br /><br /></td> |
| 797 | </tr> |
| 798 | <tr class="alternate"> |
| 799 | <td><strong>thumbnail_height</strong></td> |
| 800 | <td><?php _e('If set, and if your current server configuration allows it, you will be able to display thumbnails of your posts. This attribute sets the height for thumbnails', 'wordpress-popular-posts'); ?></td> |
| 801 | <td><?php _e('Positive integer', 'wordpress-popular-posts'); ?></td> |
| 802 | <td>0</td> |
| 803 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'thumbnail_width' => 30,<br /> 'thumbnail_height' => 30<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp thumbnail_width=30 thumbnail_height=30]<br /><br /></td> |
| 804 | </tr> |
| 805 | <tr> |
| 806 | <td><strong>rating</strong></td> |
| 807 | <td><?php _e('If set, and if the WP-PostRatings plugin is installed and enabled on your blog, WordPress Popular Posts will show how your visitors are rating your entries', 'wordpress-popular-posts'); ?></td> |
| 808 | <td>1 (true), (0) false</td> |
| 809 | <td>0</td> |
| 810 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'rating' => 1,<br /> 'post_html' => '<li>{title} {rating}</li>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp rating=1 post_html='<li>{title} {rating}</li>']<br /><br /></td> |
| 811 | </tr> |
| 812 | <tr class="alternate"> |
| 813 | <td><strong>stats_comments</strong></td> |
| 814 | <td><?php _e('If set, WordPress Popular Posts will show how many comments each popular post has got during the specified time range', 'wordpress-popular-posts'); ?></td> |
| 815 | <td>1 (true), 0 (false)</td> |
| 816 | <td>0</td> |
| 817 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_comments' => 1<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_comments=1]<br /><br /></td> |
| 818 | </tr> |
| 819 | <tr> |
| 820 | <td><strong>stats_views</strong></td> |
| 821 | <td><?php _e('If set, WordPress Popular Posts will show how many views each popular post has got during the specified time range', 'wordpress-popular-posts'); ?></td> |
| 822 | <td>1 (true), (0) false</td> |
| 823 | <td>1</td> |
| 824 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_views' => 0<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_views=0]<br /><br /></td> |
| 825 | </tr> |
| 826 | <tr class="alternate"> |
| 827 | <td><strong>stats_author</strong></td> |
| 828 | <td><?php _e('If set, WordPress Popular Posts will show who published each popular post on the list', 'wordpress-popular-posts'); ?></td> |
| 829 | <td>1 (true), (0) false</td> |
| 830 | <td>0</td> |
| 831 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_author' => 1<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_author=1]<br /><br /></td> |
| 832 | </tr> |
| 833 | <tr> |
| 834 | <td><strong>stats_date</strong></td> |
| 835 | <td><?php _e('If set, WordPress Popular Posts will display the date when each popular post on the list was published', 'wordpress-popular-posts'); ?></td> |
| 836 | <td>1 (true), (0) false</td> |
| 837 | <td>0</td> |
| 838 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_date' => 1<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_date=1]<br /><br /></td> |
| 839 | </tr> |
| 840 | <tr class="alternate"> |
| 841 | <td><strong>stats_date_format</strong></td> |
| 842 | <td><?php _e('Sets the date format', 'wordpress-popular-posts'); ?></td> |
| 843 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 844 | <td>0</td> |
| 845 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_date' => 1,<br /> 'stats_date_format' => 'F j, Y'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_date=1 stats_date_format='F j, Y']<br /><br /></td> |
| 846 | </tr> |
| 847 | <tr> |
| 848 | <td><strong>stats_category</strong></td> |
| 849 | <td><?php _e('If set, WordPress Popular Posts will display the categories associated to each entry', 'wordpress-popular-posts'); ?></td> |
| 850 | <td>1 (true), (0) false</td> |
| 851 | <td>0</td> |
| 852 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_category' => 1, <br /> 'post_html' => '<li><a href="{url}">{text_title}</a> {category}</li>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_taxonomy=1 post_html='<li><a href="{url}">{text_title}</a> {category}</li>']<br /><br /></td> |
| 853 | </tr> |
| 854 | <tr class="alternate"> |
| 855 | <td><strong>stats_taxonomy</strong></td> |
| 856 | <td><?php _e('If set, WordPress Popular Posts will display the taxonomies associated to each entry', 'wordpress-popular-posts'); ?></td> |
| 857 | <td>1 (true), (0) false</td> |
| 858 | <td>0</td> |
| 859 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'stats_taxonomy' => 1, <br /> 'post_html' => '<li><a href="{url}">{text_title}</a> {taxonomy}</li>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp stats_taxonomy=1 post_html='<li><a href="{url}">{text_title}</a> {taxonomy}</li>']<br /><br /></td> |
| 860 | </tr> |
| 861 | <tr> |
| 862 | <td><strong>wpp_start</strong></td> |
| 863 | <td><?php _e('Sets the opening tag for the listing', 'wordpress-popular-posts'); ?></td> |
| 864 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 865 | <td><ul></td> |
| 866 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'wpp_start' => '<ol>',<br /> 'wpp_end' => '</ol>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp wpp_start='<ol>' wpp_end='</ol>']<br /><br /></td> |
| 867 | </tr> |
| 868 | <tr class="alternate"> |
| 869 | <td><strong>wpp_end</strong></td> |
| 870 | <td><?php _e('Sets the closing tag for the listing', 'wordpress-popular-posts'); ?></td> |
| 871 | <td><?php _e('Text string', 'wordpress-popular-posts'); ?></td> |
| 872 | <td></ul></td> |
| 873 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'wpp_start' => '<ol>',<br /> 'wpp_end' => '</ol>'<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp wpp_start='<ol>' wpp_end='</ol>']<br /><br /></td> |
| 874 | </tr> |
| 875 | <tr> |
| 876 | <td><strong>post_html</strong></td> |
| 877 | <td><?php _e('Sets the HTML structure of each post', 'wordpress-popular-posts'); ?></td> |
| 878 | <td><?php _e('Text string, custom HTML', 'wordpress-popular-posts'); ?>.<br /><br /><strong><?php _e('Available Content Tags', 'wordpress-popular-posts'); ?>:</strong> <br /><br /><em>{thumb}</em> (<?php _e('returns thumbnail linked to post/page, requires thumbnail_width & thumbnail_height', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{thumb_img}</em> (<?php _e('returns thumbnail image without linking to post/page, requires thumbnail_width & thumbnail_height', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{thumb_url}</em> (<?php _e('returns thumbnail url, requires thumbnail_width & thumbnail_height', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{title}</em> (<?php _e('returns linked post/page title', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{pid}</em> (<?php _e('returns the post/page ID', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{summary}</em> (<?php _e('returns post/page excerpt, and requires excerpt_length to be greater than 0', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{stats}</em> (<?php _e('returns the default stats tags', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{rating}</em> (<?php _e('returns post/page current rating, requires WP-PostRatings installed and enabled', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{score}</em> (<?php _e('returns post/page current rating as an integer, requires WP-PostRatings installed and enabled', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{url}</em> (<?php _e('returns the URL of the post/page', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{text_title}</em> (<?php _e('returns post/page title, no link', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{title_attr}</em> (<?php _e('similar to text_title, sanitized for use in title/alt attributes', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{author}</em> (<?php _e('returns linked author name, requires stats_author=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{category}</em> (<?php _e('returns linked category name, requires stats_category=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{taxonomy}</em> (<?php _e('returns linked taxonomy names, requires stats_taxonomy=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{views}</em> (<?php _e('returns views count only, no text', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{comments}</em> (<?php _e('returns comments count only, no text, requires stats_comments=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{date}</em> (<?php _e('returns post/page date, requires stats_date=1', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{total_items}</em> (<?php _e('outputs number of popular posts found', 'wordpress-popular-posts'); ?>)<br /><br /> <em>{item_position}</em> (<?php _e('outputs the position of the post in the listing', 'wordpress-popular-posts'); ?>)</td> |
| 879 | <td><li>{thumb} {title} <span class="wpp-meta post-stats">{stats}</span></li></td> |
| 880 | <td><strong><?php _e('With wpp_get_mostpopular():', 'wordpress-popular-posts'); ?></strong><br /><br /><?php<br />$args = array(<br /> 'post_html' => '<li>{thumb} <a href="{url}">{text_title}</a></li>',<br /> 'thumbnail_width' => 100,<br /> 'thumbnail_height' => 75<br />);<br /><br />wpp_get_mostpopular($args);<br />?><br /><br /><hr /><br /><strong><?php _e('With the [wpp] shortcode:', 'wordpress-popular-posts'); ?></strong><br /><br />[wpp thumbnail_width=100 thumbnail_height=75 post_html='<li>{thumb} <a href="{url}">{text_title}</a></li>']<br /><br /></td> |
| 881 | </tr> |
| 882 | </tbody> |
| 883 | </table> |
| 884 | </div> |
| 885 | </div> |
| 886 | </div> |
| 887 | <!-- End params --> |
| 888 | |
| 889 | <!-- Start debug --> |
| 890 | <?php |
| 891 | global $wpdb, $wp_version; |
| 892 | |
| 893 | $my_theme = wp_get_theme(); |
| 894 | $site_plugins = get_plugins(); |
| 895 | $plugin_names = []; |
| 896 | $performance_nag = get_option('wpp_performance_nag'); |
| 897 | |
| 898 | if ( ! $performance_nag ) { |
| 899 | $performance_nag = [ |
| 900 | 'status' => 0, |
| 901 | 'last_checked' => null |
| 902 | ]; |
| 903 | } |
| 904 | |
| 905 | switch($performance_nag['status']) { |
| 906 | case 0: |
| 907 | $performance_nag_status = 'Inactive'; |
| 908 | break; |
| 909 | case 1: |
| 910 | $performance_nag_status = 'Active'; |
| 911 | break; |
| 912 | case 2: |
| 913 | $performance_nag_status = 'Remind me later'; |
| 914 | break; |
| 915 | case 3: |
| 916 | $performance_nag_status = 'Dismissed'; |
| 917 | break; |
| 918 | default: |
| 919 | $performance_nag_status = 'Inactive'; |
| 920 | break; |
| 921 | } |
| 922 | |
| 923 | foreach( $site_plugins as $main_file => $plugin_meta ) : |
| 924 | if ( ! is_plugin_active($main_file) ) |
| 925 | continue; |
| 926 | $plugin_names[] = sanitize_text_field($plugin_meta['Name'] . ' ' . $plugin_meta['Version']); |
| 927 | endforeach; |
| 928 | ?> |
| 929 | <div id="wpp_debug" <?php echo ( "debug" == $current ) ? '' : ' style="display: none;"'; ?>> |
| 930 | <h3>Plugin Configuration</h3> |
| 931 | <p><strong>Performance Nag:</strong> <?php echo $performance_nag_status; ?></p> |
| 932 | <p><strong>Log Limit:</strong> <?php echo ( $this->config['tools']['log']['limit'] ) ? 'Yes, keep data for ' . $this->config['tools']['log']['expires_after'] . ' days' : 'No'; ?></p> |
| 933 | <p><strong>Log Views From:</strong> <?php echo ( 0 == $this->config['tools']['log']['level'] ) ? 'Visitors only' : ( (2 == $this->config['tools']['log']['level']) ? 'Logged-in users only' : 'Everyone' ); ?></p> |
| 934 | <p><strong>Data Caching:</strong> <?php echo ( $this->config['tools']['cache']['active'] ) ? 'Yes, ' . $this->config['tools']['cache']['interval']['value'] . ' ' . $this->config['tools']['cache']['interval']['time'] : 'No'; ?></p> |
| 935 | <p><strong>Data Sampling:</strong> <?php echo ( $this->config['tools']['sampling']['active'] ) ? 'Yes, with a rate of ' . $this->config['tools']['sampling']['rate'] : 'No'; ?></p> |
| 936 | <p><strong>External object cache:</strong> <?php echo ( wp_using_ext_object_cache() ) ? 'Yes' : 'No'; ?></p> |
| 937 | <p><strong>WPP_CACHE_VIEWS:</strong> <?php echo ( defined('WPP_CACHE_VIEWS') && WPP_CACHE_VIEWS ) ? 'Yes' : 'No'; ?></p> |
| 938 | |
| 939 | <br /> |
| 940 | |
| 941 | <h3>System Info</h3> |
| 942 | <p><strong>PHP version:</strong> <?php echo phpversion(); ?></p> |
| 943 | <p><strong>PHP extensions:</strong> <?php echo implode(', ', get_loaded_extensions()); ?></p> |
| 944 | <p><strong>Database version:</strong> <?php echo $wpdb->get_var("SELECT VERSION();"); ?></p> |
| 945 | <p><strong>InnoDB availability:</strong> <?php echo $wpdb->get_var("SELECT SUPPORT FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE = 'InnoDB';"); ?></p> |
| 946 | <p><strong>WordPress version:</strong> <?php echo $wp_version; ?></p> |
| 947 | <p><strong>Multisite:</strong> <?php echo ( function_exists('is_multisite') && is_multisite() ) ? 'Yes' : 'No'; ?></p> |
| 948 | <p><strong>Active plugins:</strong> <?php echo implode(', ', $plugin_names); ?></p> |
| 949 | <p><strong>Theme:</strong> <?php echo $my_theme->get('Name') . ' (' . $my_theme->get('Version') . ') by ' . $my_theme->get('Author'); ?></p> |
| 950 | </div> |
| 951 | <!-- End debug --> |
| 952 | </div> |